/** * 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; }
$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) { ?>
/** * Build an HTML attribute string * * @param string $var The name of the attribute * @param string $val The value of the attribute * @return string A string representing the attribute/value couple ready to write as HTML attribute */ function _attribute($var, $val) { return Helper\Html::parseAttributes(array($var => $val)); }