Пример #1
0
 public static function isManifest(YXMLElement $xml)
 {
     return $xml->getName() == 'application';
 }
Пример #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');
 }