/**
  * Tag strings constructor (it replaces arguments as @arg@ by their value)
  *
  * @param string $str The string to compose
  * @param string $tag_type The tag name to get the class mask constant
  * @param array $args The arguments as 'id' => 'replacement'
  * @return string
  * @throws \Exception if the tag mask doesn't exist in the adapter
  */
 protected function _tagComposer($str = '', $tag_type = 'default', array $args = array())
 {
     $const_name = 'mask_' . $tag_type;
     $mask = @constant(get_class($this) . '::' . $const_name);
     if (null === $mask) {
         throw new \Exception(sprintf('Unknown mask for tag type "%s" in "%s" Reporter adapter!', $tag_type, get_class($this)));
     }
     if (isset($args['attrs'])) {
         $args['attributes'] = $args['attrs'];
         unset($args['attrs']);
     }
     if (isset($args['attributes'])) {
         array_push($args, HtmlHelper::parseAttributes($args['attributes']));
         unset($args['attributes']);
     }
     if (strlen($str)) {
         array_unshift($args, $str);
         $str = vsprintf($mask, array_pad($args, substr_count($mask, '%'), ''));
     }
     return $str;
 }
 /**
  * Set the page structure
  *
  * This will store the page structure in the registry and create a DOM unique ID for
  * each one.
  *
  * @param   array $structure The page blocks to set
  * @return  self
  */
 public function setPageStructure(array $structure)
 {
     foreach ($structure as $_ref) {
         HtmlHelper::getNewId($_ref, true);
     }
     $this->registry->setEntry('page_structure', $structure);
     return $this;
 }
    $content = '<p>Test content</p>';
}
$public_sources = true;
$url_sources = "http://github.com/atelierspierrot/templatengine";
$host_sources_name = "GitHub";
$host_sources_home = "http://github.com/";
$make_navigation_list_from_content = function (array $ctt, array $attrs) {
    $str = '';
    foreach ($ctt as $var => $val) {
        if (is_array($val)) {
            $str .= '<li><a href="#">' . $var . '</a>' . $make_navigation_list_from_content($val) . '</li>';
        } else {
            $str .= '<li><a href="' . $val . '">' . $var . '</a></li>';
        }
    }
    return '<ul' . (!empty($attrs) ? HtmlHelper::parseAttributes($attrs) : '') . '>' . $str . '</ul>';
};
?>
<nav>
<?php 
if (is_array($content)) {
    ?>
    <?php 
    echo $make_navigation_list_from_content($content, array('id' => "navigation_menu", 'class' => "menu", 'role' => "navigation"));
} else {
    ?>
    <?php 
    echo $content;
}
if ($public_sources) {
    ?>
Esempio n. 4
0
 /**
  * Write minified versions of the files stack in the cache directory
  *
  * @param string $mask A mask to write each line via "sprintf()"
  * @return string The string to display fot this template object
  */
 public function writeMinified($mask = '%s')
 {
     $str = '';
     foreach ($this->cleanStack($this->getMinified(), 'file') as $entry) {
         $tag_attrs = array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $entry['file']);
         if (isset($entry['media']) && !empty($entry['media']) && $entry['media'] != 'screen') {
             $tag_attrs['media'] = $entry['media'];
         }
         $str .= sprintf($mask, Html::writeHtmlTag('link', null, $tag_attrs, true));
     }
     return $str;
 }
 /**
  * Write the Template Object strings ready for template display
  *
  * @param string $mask A mask to write each line via "sprintf()"
  * @return string The string to display fot this template object
  */
 public function write($mask = '%s')
 {
     $content = '';
     foreach ($this->get() as $entry) {
         $content .= $entry . "\n";
     }
     $str = sprintf($mask, Html::writeHtmlTag('script', $content));
     return $str;
 }
 /**
  * Returns the full HTML `script`
  *
  * @return string
  */
 public function __toHtml()
 {
     try {
         $this->parse();
         $str = \Library\Helper\Html::writeHtmlTag('script', null, array('src' => $this->transformed_data['src'], 'type' => $this->transformed_data['type']), true);
     } catch (\Exception $e) {
         $str = $e->getMessage();
     }
     return $str;
 }
 /**
  * Get a uniq DOM ID for an element
  *
  * @param string $reference A reference used to store the ID (and retrieve it - by default, a uniqid)
  * @param string|bool $base_id A string that will be used to construct the ID, if set to `true`, the reference will be used as `$base_id`)
  * @param bool $return Return/Echo flag (default is to echo result)
  * @return mixed The result of the `_echo` function (string or bool)
  * @see _echo()
  * @see Library\Helper\Html::getNewId()
  */
 function _newid($reference = null, $base_id = null, $return = false)
 {
     return _echo(Helper\Html::getNewId($reference, $base_id), $return);
 }
Esempio n. 8
0
 /**
  * Write the Template Object strings ready for template display
  *
  * @param string $mask A mask to write each line via "sprintf()"
  * @return string The string to display fot this template object
  */
 public function write($mask = '%s')
 {
     $str = '';
     foreach ($this->cleanStack($this->get()) as $entry) {
         $str .= (strlen($str) > 0 ? $this->separator : '') . $entry;
     }
     $title_str = Html::writeHtmlTag('title', strip_tags($str));
     return sprintf($mask, $title_str);
 }
Esempio n. 9
0
 /**
  * Write the Template Object strings ready for template display
  *
  * @param string $mask A mask to write each line via "sprintf()"
  * @return string The string to display fot this template object
  */
 public function write($mask = '%s')
 {
     $str = '';
     foreach ($this->cleanStack($this->get(), 'name') as $entry) {
         $tag_attrs = array();
         if (true === $entry['http-equiv']) {
             $tag_attrs['http-equiv'] = $entry['name'];
         } else {
             $tag_attrs['name'] = $entry['name'];
         }
         $tag_attrs['content'] = $entry['content'];
         $tag = Html::writeHtmlTag('meta', null, $tag_attrs, true);
         if (isset($entry['condition']) && !empty($entry['condition'])) {
             $tag = ConditionalComment::buildCondition($tag, $entry['condition']);
         }
         $str .= sprintf($mask, $tag);
     }
     return $str;
 }
 /**
  * Write minified versions of the files stack in the cache directory
  */
 public function writeMinified($mask = '%s')
 {
     $str = '';
     foreach ($this->cleanStack($this->getMinified(), 'path') as $entry) {
         $tag_attrs = array('type' => 'text/javascript', 'src' => $entry['path']);
         $str .= sprintf($mask, Html::writeHtmlTag('script', null, $tag_attrs));
     }
     return $str;
 }
Esempio n. 11
0
 /**
  * Write the Template Object strings ready for template display
  *
  * @param string $mask A mask to write each line via "sprintf()"
  * @return string The string to display fot this template object
  */
 public function write($mask = '%s')
 {
     $str = '';
     // allow multi same links
     //        foreach($this->cleanStack( $this->get(), 'rel' ) as $entry) {
     foreach ($this->get() as $entry) {
         $str .= sprintf($mask, Html::writeHtmlTag('link', null, $entry, true));
     }
     return $str;
 }