| <?php |
| function innerHTML($el) { |
| $doc = new DOMDocument(); |
| $doc->appendChild($doc->importNode($el, TRUE)); |
| $html = trim($doc->saveHTML()); |
| $tag = $el->nodeName; |
| $html = preg_replace('@^<' . $tag . '[^>]*>|</' . $tag . '>$@', '', $html); |
| return $html; |
| } |
| function enhanceDoc($doc) { |
| $docXPath = new DomXPath($doc); |
| $titles = $docXPath->query("//*[contains(@class, 'title')]"); |
| foreach ($titles as $title) { |
| $id = $title->parentNode->getAttribute('id'); |
| if ($id != '') { |
| $link = $title->firstChild; |
| $link->setAttribute('href', '#' . $id); |
| } |
| } |
| } |
| |
| $statetVersion = basename($App->getScriptName(), '.php'); |
| |
| if(!isset($keywords) OR $keywords == '') { |
| $keywords = "eclipse, statet, news, new and noteworthy"; |
| } |
| if (!isset($theme)) { |
| $theme = "solstice"; |
| } |
| $Theme = $App->getThemeClass($theme); |
| $themeVariables = array(); |
| |
| $themeVariables['btn_cfa'] = array( |
| 'hide' => FALSE, |
| 'href' => 'https://projects.eclipse.org/projects/science.statet/', |
| 'text' => '<i class="fa fa-home"></i> StatET' |
| ); |
| |
| $Nav->addNavSeparator("StatET 4.0", ""); |
| $Nav->addCustomNav("New and Noteworthy", "/statet/news/noteworthy-4.0.php", "_self", 1); |
| $Nav->addNavSeparator("StatET", "/statet/"); |
| $Nav->addCustomNav("Mailing List: statet-users", "https://accounts.eclipse.org/mailing-list/statet-users", "_self", 3); |
| |
| $file = basename($App->getScriptName(), '.php').'.html'; |
| |
| $doc = new DOMDocument; |
| $doc->loadhtmlfile($file); |
| enhanceDoc($doc); |
| |
| $title = $doc->getElementsByTagName('title')->item(0); |
| $title = innerHTML($title); |
| |
| $body = $doc->getElementsByTagName('body')->item(0); |
| $body = innerHTML($body); |
| $html = $body; |
| $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'auto'); |
| |
| # Begin: page-specific settings. Change these. |
| $Theme->setThemeVariables($themeVariables); |
| $Theme->setPageAuthor(""); |
| $Theme->setPageKeywords($keywords); |
| $Theme->setPageTitle($title); |
| $Theme->setHtml($html); |
| |
| $Theme->setNav($Nav); |
| $Theme->setMenu($Menu); |
| |
| $App->Promotion = FALSE; |
| $App->AddExtraHtmlHeader('<link rel="stylesheet" href="download.css" type="text/css">'); |
| |
| |
| $Theme->generatePage(); |