Example #1
0
 function html_substr2PHP4($content, $conf)
 {
     // The approximate length you want the concatenated text to be
     $minimum_length = $conf['minLength'] ? $conf['minLength'] : 200;
     // The variation in how long the text can be
     // in this example text length will be between 200-10=190 characters
     // and the character where the last tag ends
     // $length_offset = $conf['lengthOffset'] ? $conf['lengthOffset'] : 10;
     $replaceString = $conf['replaceString'] ? $conf['replaceString'] : '...';
     // Reset tag counter & quote checker
     $doc = domxml_xmltree('<body>' . $content . '</body>');
     $body = $doc->get_elements_by_tagname('body');
     $length = 0;
     $content = $this->getContentAsStringPHP4($body[0], $length, $minimum_length, $replaceString);
     return $content;
 }
Example #2
0
$self = $path_parts['basename'];
$nav = load('navigation.php');
preg_match_all('/(<a.*?href="(.*?)">(.*?)<\\/a>)/si', $nav, $as);
for ($i = 0; $i < sizeof($as[0]); $i++) {
    if ($as[2][$i] == $self) {
        $found = $as[0][$i];
        $foundname = $as[3][$i];
        $foundlink = $as[2][$i];
        break;
    }
}
if ($found) {
    $nav = str_replace($found, '<strong class="' . str_replace('.php', '', $foundlink) . '">' . $foundname . '</strong>', $nav);
}
if (!isset($_GET['ajax'])) {
    $htmldoc = domxml_xmltree($nav);
    $ul = $htmldoc->document_element();
    $uls = $htmldoc->get_elements_by_tagname("ul");
    foreach ($uls as $i) {
        $mother = $i->parent_node();
        if ($mother->node_name() == 'li') {
            if (sizeof($mother->get_elements_by_tagname("strong")) == 0) {
                $mother->remove_child($i);
            }
        }
    }
    $nav = $htmldoc->html_dump_mem();
}
function load($filelocation)
{
    if (file_exists($filelocation)) {