', $empty_str, $output); } else { $output = preg_replace('~(]*>)([^<]*)()~', '$1$2$3', $output); } return $output; } function nuvemdario_menu_xml_parcer($content, $show_sub_menus, $menu_class) { $parent_id = $menu_class . '-id'; $doc = nuvemdario_xml_document_creator($content, $parent_id); if ($doc === FALSE) { return $content; // An error occurred while reading XML content } $parent = $doc->documentElement; $elements = $parent->childNodes; $ul_elements = $doc->getElementsByTagName("ul"); $ul_element = NULL; foreach($ul_elements as $ul_element) { // First ul element with css-class b2-hmenu or b2-vmenu if (($ul_element->getAttribute('class') == "b2-vmenu") || ($ul_element->getAttribute('class') == "b2-hmenu")) break; continue; } if ($ul_element == NULL) return $content; $ul_children = nuvemdario_menu_style_parcer($doc, $ul_element->childNodes, $show_sub_menus); $parent->appendChild($ul_element); while ($ul_element->previousSibling) $parent->removeChild($ul_element->previousSibling); return html_entity_decode($doc->saveHTML(), ENT_NOQUOTES, "UTF-8"); } function nuvemdario_xml_document_creator($content, $parent_id) { $old_error_handler = set_error_handler('nuvemdario_handle_xml_error'); $dom = new DOMDocument(); /* Support Block Edit Link module */ $doc_content = <<< XML ]>
$content
XML; $dom->loadXml($doc_content); restore_error_handler(); return $dom; } function nuvemdario_handle_xml_error($errno, $errstr, $errfile, $errline) { if ($errno==E_WARNING && (substr_count($errstr,"DOMDocument::loadXML()")>0)) return false; // An error occurred while reading XML content else return true; // Successful } function nuvemdario_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; } } } } nuvemdario_remove_elements($childNodes_to_delete); nuvemdario_remove_elements($parentNodes_to_delete); return $elements; } function nuvemdario_remove_elements($elements_to_delete) { if (!isset($elements_to_delete)) return; foreach($elements_to_delete as $element) { if ($element != null) { $element->parentNode->removeChild($element); } } } function nuvemdario_node_worker($node) { $links_output = nuvemdario_links_woker($node->links); $terms_output = nuvemdario_terms_worker($node->taxonomy); $output = $links_output; if (!empty($links_output) && !empty($terms_output)) { $output .= ' | '; } $output .= $terms_output; return $output; } /* * Split out taxonomy terms by vocabulary. * * @param $terms * An object providing all relevant information for displaying terms: * * @ingroup themeable */ function nuvemdario_terms_worker($terms) { $result = ''; $terms = get_terms_D7($content); if (!empty($terms)) { ob_start();?> ' . render($terms) . ''; } return $result; } /** * Return a themed set of links. * * @param $links * A keyed array of links to be themed. * @param $attributes * A keyed array of attributes * @return * A string containing an unordered list of links. */ function nuvemdario_links_woker($links, $attributes = array('class' => 'links')) { $output = ''; if (!empty($links)) { $output = ''; $num_links = count($links); $index = 0; foreach ($links as $key => $link) { $class = $key; if (strpos ($class, "read_more") !== FALSE) { continue; } // Automatically add a class to each link and also to each LI if (isset($link['attributes']) && isset($link['attributes']['class'])) { $link['attributes']['class'] .= ' ' . $key; } else { $link['attributes']['class'] = $key; } // Add first and last classes to the list of links to help out themers. $extra_class = ''; if ($index == 1) { $extra_class .= 'first '; } if ($index == $num_links) { $extra_class .= 'last '; } $link_output = nuvemdario_get_html_link_output($link); if (!empty($class)) { if (strpos ($key, "comment") !== FALSE) { if ($index > 0 && !empty($link_output) && !empty($output)) { $output .= ' | '; } ob_start();?> 0 && !empty($link_output) && !empty($output)) { $output .= ' | '; } ob_start();?> $link['language'], 'attributes'=>$link['attributes'], 'query'=>$link['query'], 'fragment'=>$link['fragment'], 'absolute'=>FALSE, 'html'=>$html)); } } else if ($link['title']) { if (!$html) { $link['title'] = check_plain($link['title']); } $output = $link['title']; } return $output; } function nuvemdario_content_replace($content) { $first_time_str = '
$output
EOT; } else { $output = $content; } return $output; } function nuvemdario_placeholders_output($var1, $var2, $var3) { $output = ''; if (!empty($var1) && !empty($var2) && !empty($var3)) { $output .= <<< EOT
$var1 $var2 $var3
EOT; } else if (!empty($var1) && !empty($var2)) { $output .= <<< EOT
$var1 $var2
EOT; } else if (!empty($var2) && !empty($var3)) { $output .= <<< EOT
$var2 $var3
EOT; } else if (!empty($var1) && !empty($var3)) { $output .= <<< EOT
$var1 $var3
EOT; } else { if (!empty($var1)) { $output .= <<< EOT
$var1
EOT; } if (!empty($var2)) { $output .= <<< EOT
$var2
EOT; } if (!empty($var3)) { $output .= <<< EOT
$var3
EOT; } } return $output; } function nuvemdario_get_sidebar($sidebar, $vnavigation, $class) { $result = 'b2-layout-cell '; if (empty($sidebar) && empty($vnavigation)) { $result .= 'b2-content'; } else { $result .= $class; } $output = '
'.render($vnavigation) . render($sidebar).'
'; return $output; } function nuvemdario_get_content_cell_style($left, $vnav_left, $right, $vnav_right, $content) { return 'b2-layout-cell b2-content'; } function nuvemdario_submitted_worker($date, $author) { $output = ''; if ($date != '') { ob_start();?> ' . $title . ''; else $output = $title; return $output; } function nuvemdario_vmenu_output($subject, $content) { if (empty($content)) return; $output = nuvemdario_menu_worker($content, true, 'b2-vmenu'); $bvm = "
\r\n
\r\n"; $bvmt = "
\r\n
\r\n
\r\n

"; $evmt = "

\r\n
\r\n"; $bvmc = "
\r\n
\r\n
\r\n"; $evmc = "\r\n
\r\n
\r\n
\r\n
\r\n"; $evm = "\r\n
\r\n
\r\n
\r\n"; echo $bvm; if ('' != $bvmt && '' != $evmt && !empty($subject)) { echo $bvmt; echo $subject; echo $evmt; } echo $bvmc; echo $output; echo $evmc; echo $evm; }