Ejemplo n.º 1
0
function art_menu_style_parcer($doc, $elements, $show_sub_menus)
{
    $parentNodes_to_delete = array();
    $childNodes_to_delete = array();
    foreach ($elements as $element) {
        if (is_a($element, "DOMElement") && $element->tagName == "li") {
            $children = $element->childNodes;
            foreach ($children as $child) {
                if (is_a($child, "DOMElement") && $child->tagName == "a") {
                    $caption = $child->nodeValue;
                    if (empty($caption)) {
                        $childNodes_to_delete[] = $child;
                        $parentNodes_to_delete[] = $element;
                        break;
                    }
                    $child->nodeValue = check_plain($caption);
                } else {
                    if (!$show_sub_menus) {
                        $childNodes_to_delete[] = $child;
                    }
                }
            }
        }
    }
    art_remove_elements($childNodes_to_delete);
    art_remove_elements($parentNodes_to_delete);
    return $elements;
}
Ejemplo n.º 2
0
function art_menu_style_parcer($doc, $elements, $show_sub_menus)
{
    $parentNodes_to_delete = array();
    $childNodes_to_delete = array();
    foreach ($elements as $element) {
        if (is_a($element, "DOMElement") && $element->tagName == "li") {
            $children = $element->childNodes;
            $parent_class = $element->getAttribute("class");
            $is_parent_class_active = strpos($parent_class, "active") !== FALSE;
            foreach ($children as $child) {
                if (is_a($child, "DOMElement") && $child->tagName == "a") {
                    $caption = $child->nodeValue;
                    if (empty($caption) || $caption == 'test') {
                        $childNodes_to_delete[] = $child;
                        $parentNodes_to_delete[] = $element;
                        break;
                    }
                    $child->nodeValue = "";
                    if ($is_parent_class_active) {
                        $child->setAttribute("class", $child->getAttribute("class") . ' active');
                    }
                    $spanL = $doc->createElement("span");
                    $spanL->setAttribute("class", "l");
                    //$spanL->nodeValue = " ";
                    $child->appendChild($spanL);
                    $spanR = $doc->createElement("span");
                    $spanR->setAttribute("class", "r");
                    //$spanR->nodeValue = " ";
                    $child->appendChild($spanR);
                    $spanT = $doc->createElement("span");
                    $spanT->setAttribute("class", "t");
                    $spanT->nodeValue = check_plain($caption);
                    $child->appendChild($spanT);
                } else {
                    if (!$show_sub_menus) {
                        $childNodes_to_delete[] = $child;
                    }
                }
            }
        }
    }
    art_remove_elements($childNodes_to_delete);
    art_remove_elements($parentNodes_to_delete);
    return $elements;
}