1) { $dSlash .= array_shift($dList) . '/'; if (!is_dir($dSlash)) mkdir($dSlash); } if (!is_file($f)) continue; if (substr($f,-4) <> 'html') { /* * An image or something else, copy unmodified */ copy ($f,$r); continue; } $prepend = str_repeat('../',$depth); $doc = new DOMDocument(); @$doc->loadHTMLFile($f); /* * Remove Page Tools Group */ $xpath = new DOMXPath($doc); /* * Remove Top Menu Tools Group, and add a link to the ADOdb site */ $nodes = $xpath->query("//div[@class='tools group']"); foreach($nodes as $node) { $pn = $node->parentNode; $pn->removeChild($node); $newChild = $doc->createElement('div',''); $newDiv = $pn->appendChild($newChild); $newDiv->setAttribute('style','text-align:right'); $newChild = $doc->createElement('a','ADOdb Web Site'); $newA = $newDiv->appendChild($newChild); $newA->setAttribute('href','https://adodb.org'); } /* * Remove Trace */ $nodes = $xpath->query("//div[@class='breadcrumbs']"); foreach($nodes as $node) { $node->parentNode->removeChild($node); } /* * Remove Side Menu Tools Group */ $nodes = $xpath->query("//div[@id='dokuwiki__pagetools']"); foreach($nodes as $node) { $node->parentNode->removeChild($node); } /* * Fix main links */ $nodes = $xpath->query("//a[@class='wikilink1']"); foreach($nodes as $node) { $n = $node->getAttribute('title'); $p = $prepend . str_replace(':','/',$n) . '.html'; $node->setAttribute('href', $p); } /* * Fix In Page links */ $nodes = $xpath->query("//a[@class='wikilink2']"); foreach($nodes as $node) { $n = $node->getAttribute('title'); $p = $prepend . str_replace(':','/',$n) . '.html'; $node->setAttribute('href', $p); } /* * Make Graphic point to first page. This will break if the image size * ever changes. */ $corePage = $prepend . '/index.html'; $nodes = $xpath->query("//img[@width='176']"); foreach($nodes as $node) { $node->parentNode->setAttribute('href', $corePage); } /* * Change title of page */ $nodes = $xpath->query("//title"); foreach($nodes as $node) { $docTitle = implode(':',$titleList); $docTitle = str_replace('.html','',$docTitle); $pn = $node->parentNode; $pn->removeChild($node); $newChild = $doc->createElement('title',$docTitle); $pn->appendChild($newChild); } $doc->saveHTMLFile($r); echo $r, "\n"; } /* * Now remove the original index and replace it with the hardcopy documentation one */ unlink ('documentation/index.html'); rename('documentation/adodb_index.html','documentation/index.html'); /* * We could add in an auto zip and upload here, but this is a good place to * stop and check the output */