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; }
protected static function _getElementFromXMLNode(YXMLElement $xml, Type $type) { // load element $element_type = (string) $xml->attributes()->type; $element = self::loadElement($element_type, $type->getApplication()->getPath() . '/elements'); // bind element data or set undefined if ($element !== false) { $element->loadConfig($xml); return $element; } return null; }
public function loadConfig(YXMLElement $xml) { // bind xml data foreach ($xml->attributes() as $name => $value) { $this->_config->set($name, (string) $value); } // set identifier $this->identifier = $this->_config->get('identifier'); return $this; }
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'); }