Пример #1
0
 protected function _addItem($group, YXMLElement $item)
 {
     $id = (string) $item->attributes()->id;
     $name = (string) $item->name;
     if (!empty($name)) {
         if (empty($id)) {
             $id = JFilterOutput::stringURLSafe($name);
         }
         while ($this->_keyExists($this->_item_groups, $id)) {
             $id .= '-2';
         }
         $item->addAttribute('id', $id);
         $this->_item_groups[$group][$id] = $item;
     }
     return $this;
 }
Пример #2
0
 public static function index(YXMLElement $node, $args)
 {
     if ($node->getName() == 'ul') {
         // set ul level
         $level = $args['level'] / 2 + 1;
         $node->addAttribute('class', trim($node->attributes()->class . ' level' . $level));
         // set order/first/last for li
         $count = count($node->children());
         foreach ($node->children() as $i => $child) {
             $child->addAttribute('level', $level);
             $child->addAttribute('order', $i + 1);
             if ($i == 0) {
                 $child->addAttribute('first', 1);
             }
             if ($i == $count - 1) {
                 $child->addAttribute('last', 1);
             }
         }
     }
     if ($node->getName() == 'li') {
         // level and item order
         $css = 'level' . $node->attributes()->level;
         $css .= ' item' . $node->attributes()->order;
         // first, last and parent
         if ($node->attributes()->first) {
             $css .= ' first';
         }
         if ($node->attributes()->last) {
             $css .= ' last';
         }
         if (isset($node->ul)) {
             $css .= ' parent';
         }
         // add li css classes
         $node->addAttribute('class', trim($node->attributes()->class . ' ' . $css));
         // add a/span css classes
         if ($firstChild = $node->firstChild()) {
             $firstChild->addAttribute('class', trim($firstChild->attributes()->class . ' ' . $css));
         }
     }
     $node->removeAttribute('level')->removeAttribute('order')->removeAttribute('first')->removeAttribute('last');
 }