/**
  * @param array $htmlSnippets see Webforge\CMS\Navigation\NestedSetConverter::toHTMLList()
  */
 public function getHTML($locale, array $htmlSnippets = array(), NestedSetConverter $converter = NULL, \Closure $qbHook = NULL)
 {
     $that = $this;
     $htmlSnippets = array_merge(array('rootOpen' => function ($root) {
         return '<ul id="nav">';
     }, 'nodeDecorator' => function ($node) use($that, $locale) {
         $url = $that->getUrl($node, $locale);
         $html = '<li><a href="' . $url . '">';
         if ($node->getDepth() === 0 && $node->getImage() != NULL) {
             $html .= '<img src="' . \Psc\HTML\HTML::escAttr($node->getImage()) . '" alt="' . \Psc\HTML\HTML::escAttr($node->getTitle($locale)) . '" />';
         }
         $html .= \Psc\HTML\HTML::esc($node->getTitle($locale));
         $html .= '</a>';
         return $html;
     }), $htmlSnippets);
     $qb = $this->childrenQueryBuilder(NULL, $qbHook ?: $this->getDefaultQueryBuilderHook());
     $query = $qb->getQuery();
     $nodes = $query->getResult();
     $converter = $converter ?: new NestedSetConverter();
     return $converter->toHTMLList($nodes, $htmlSnippets);
 }
示例#2
0
文件: Tag.php 项目: pscheit/psc-cms
 public function htmlAttributes()
 {
     $html = NULL;
     foreach ($this->getAttributes() as $name => $value) {
         $html .= ' ' . $name . '="';
         if (array_key_exists($name, self::$glues)) {
             $value = implode(self::$glues[$name], $value);
         } elseif ($name === 'id') {
             $value = HTML::string2id($value);
         } elseif (is_array($value)) {
             throw new \Psc\Exception('Cannot connvert value (as array) for attribute: ' . $name);
         }
         $html .= HTML::escAttr((string) $value);
         $html .= '"';
     }
     return $html;
 }