blob: aca885d07ed4396c78cb0e90b64b1bc7709fef9b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?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);
}
}
}
if(!isset($keywords) OR $keywords == '') {
$keywords = "eclipse, statet, news, new and noteworthy";
}
if (!isset($theme)) {
$theme = "solstice";
}
$Theme = $App->getThemeClass($theme);
$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->setPageAuthor("");
$Theme->setPageKeywords($keywords);
$Theme->setPageTitle($title);
$Theme->setHtml($html);
if (isset($Nav)) {
$Theme->setNav($Nav);
}
if (isset($Menu)) {
$Theme->setMenu($Menu);
}
$right_nav = FALSE;
$App->Promotion = FALSE;
$App->AddExtraHtmlHeader('<link rel="stylesheet" href="noteworthy.css" type="text/css">');
$Theme->generatePage();
|