/usr/share/phoronix-test-suite/pts-core/objects/pts_html_template.php is in phoronix-test-suite 4.8.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | <?php
/*
Phoronix Test Suite
URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
Copyright (C) 2011, Phoronix Media
Copyright (C) 2011, Michael Larabel
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class pts_html_template
{
private $dom;
private $dom_body;
private $section_list;
public function __construct($Title = '', $SubTitle = '')
{
$this->dom = new DOMDocument();
$html = $this->dom->createElement('html');
$this->dom->appendChild($html);
$head = $this->dom->createElement('head');
$title = $this->dom->createElement('title', $Title . ($SubTitle != null ? ' - ' . $SubTitle : null));
$head->appendChild($title);
$html->appendChild($head);
$this->dom_body = $this->dom->createElement('body');
$html->appendChild($this->dom_body);
$p = $this->dom->createElement('h1', 'Phoronix Test Suite');
$this->dom_body->appendChild($p);
$p = $this->dom->createElement('hr');
$p->setAttribute('style', 'height: 50px; border: 0;');
$this->dom_body->appendChild($p);
$this->section_list = $this->dom->createElement('ol');
$this->dom_body->appendChild($this->section_list);
}
public function html_to_html($html)
{
$dom = new DOMDocument();
if(is_file($html))
{
$dom->loadHTMLFile($html);
}
else
{
$dom->loadHTML($html);
}
$section_title = $dom->getElementsByTagName('html')->item(0)->getElementsByTagName('head')->item(0)->nodeValue;
$section_li_a = $this->dom->createElement('a', $section_title);
$section_li_a->setAttribute('href', '#' . str_replace(' ', null, $section_title));
$section_li = $this->dom->createElement('li');
$section_li->appendChild($section_li_a);
$this->section_list->appendChild($section_li);
$p = $this->dom->createElement('hr');
$p->setAttribute('style', 'height: 50px; border: 0;');
$this->dom_body->appendChild($p);
$p = $this->dom->createElement('a');
$p->setAttribute('name', str_replace(' ', null, $section_title));
$this->dom_body->appendChild($p);
$p = $this->dom->createElement('h1', $section_title);
$this->dom_body->appendChild($p);
// TODO: the below code is known to emit a fatal error right now since the nodes are different, need to copy/merge nodes between docs
foreach($dom->getElementsByTagName('html')->item(0)->getElementsByTagName('body')->item(0)->childNodes as $node)
{
$n = $this->dom->importNode($node, true);
$this->dom_body->appendChild($n);
}
}
public function Output($File)
{
$p = $this->dom->createElement('p', 'Copyright © 2008 - ' . date('Y') . ' by Phoronix Media.');
$p->setAttribute('style', 'padding-top: 30px; text-align: center;');
$this->dom_body->appendChild($p);
return $this->dom->saveHTMLFile($File);
}
}
?>
|