Example #1
0
 /**
  * @param DOMDocument $doc
  * @param             $path
  * @return mixed
  * @throws F4h_TicketConverter_Exception_File_Write
  */
 protected function _save(DOMDocument $doc, $path)
 {
     try {
         $doc->saveHTMLFile($path);
     } catch (Exception $e) {
         throw new F4h_TicketConverter_Exception_File_Write();
     }
     return $path;
 }
 public function usableInSaveHTMLFile()
 {
     $out = new MemoryOutputStream();
     // Create DOM and save it to stream
     $dom = new \DOMDocument();
     $dom->appendChild($dom->createElement('html'))->appendChild($dom->createElement('head'))->appendChild($dom->createElement('title', 'übercoder'));
     $dom->saveHTMLFile(Streams::writeableUri($out));
     // Check file contents
     $this->assertEquals('<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>&uuml;bercoder</title></head></html>', trim($out->getBytes()));
 }
Example #3
0
 public function saveTo($fname)
 {
     $status = false;
     if ($this->on_save()) {
         if ($this->is_html) {
             $this->doc->saveHTMLFile($fname);
         } else {
             $this->doc->save($fname);
         }
         $this->filename = $fname;
         $this->processPath();
         $status = true;
     }
     return $status;
 }
Example #4
0
 /**
  * Start rendering
  *
  * @param  \notifyy\Collection $oNotifier
  *
  * @return $this
  */
 public function render(\notifyy\Collection $oNotifier)
 {
     foreach ($this->_aRevisions as $oRevision) {
         $aDiffs = $oRevision->aDiffs;
         $this->_iCount = count($aDiffs);
         if ($this->_iCount > 0) {
             $oContainer = $this->_addContainer($oRevision);
             foreach ($aDiffs as $aDiff) {
                 $this->_addDiff($oContainer, $aDiff, $oRevision);
             }
         }
     }
     $sFile = getcwd() . DIRECTORY_SEPARATOR . 'Mergy_diff_' . time() . '.html';
     $this->_oHtml->saveHTMLFile($sFile);
     $oNotifier->notify(\notifyy\Notifyable::INFO, $sFile);
     return $this;
 }
function loadRecordHTML($recHMLFilename, $styleFilename)
{
    global $recID, $outputFilename;
    $recHmlDoc = new DOMDocument();
    $recHmlDoc->load($recHMLFilename);
    $recHmlDoc->xinclude();
    if (!$styleFilename) {
        return $recHmlDoc->saveHTMLFile($outputFilename);
    }
    $xslDoc = DOMDocument::load($styleFilename);
    $xslProc = new XSLTProcessor();
    $xslProc->importStylesheet($xslDoc);
    // set up common parameters for stylesheets.
    //	$xslProc->setParameter('','hbaseURL',HEURIST_BASE_URL);
    //	$xslProc->setParameter('','dbName',HEURIST_DBNAME);
    //	$xslProc->setParameter('','dbID',HEURIST_DBID);
    $xslProc->setParameter('', 'standalone', '1');
    $xslProc->transformToURI($recHmlDoc, $outputFilename);
}
function get_from_menu_css_tags()
{
    $dom = new DOMDocument();
    @$dom->loadHTMLFile("lib/props");
    $css = new stdClass();
    $dom = $dom->getElementsByTagName('a');
    foreach ($dom as $line) {
        $name = $line->nodeValue;
        $css->all[] = $name;
        if (substr_count($name, "-") > 1) {
            $css->stat["black"][] = $name;
            continue;
        }
        $link = $line->getAttribute("href");
        $support = new DOMDocument();
        if (file_exists(CACHE . $link)) {
            $support->loadHTMLFile(CACHE . $link);
        } else {
            $support->loadHTMLFile(W3C . $link);
            if (!empty($support)) {
                $support->saveHTMLFile(CACHE . $link);
            }
        }
        foreach ($support->getElementsByTagName("table") as $table) {
            if ($table->getAttribute("class") == "browserref notranslate") {
                if ($table->getElementsByTagName("tr")->length > 2) {
                    //var_dump($name); // skip tags which have more than one row for versions.
                    continue;
                }
                $depr = substr_count(strtolower($table->nodeValue), "not supported");
                $r = $depr < 1 ? "ok" : "black";
                $css->stat[$r][] = $name;
                if ($r == "black") {
                    $css->stat["count"][$depr][] = $name;
                }
            }
        }
    }
    return $css;
}
Example #7
0
 /**
  * Wrapper to DOMDocument::saveHTMLfile with exception handling
  *
  * @param string $filename filename to save to
  * @param integer $options Options bitmask (@see DOMDocument::saveHTMLFile)
  *
  * @throws fDOMException
  *
  * @return integer bytes saved
  */
 public function saveHTMLFile($filename, $options = NULL)
 {
     $tmp = parent::saveHTMLFile($filename, $options);
     if (!$tmp) {
         throw new fDOMException("Saving HTML to file '{$filename}' failed", fDOMException::SaveError);
     }
     return $tmp;
 }
Example #8
0
<?php

// removes data-edit id's (but preserves data-edit attr's)
$FILES_TO_PREP = array('index');
for ($i = 0; $i < count($FILES_TO_PREP); $i++) {
    $name = $FILES_TO_PREP[$i];
    echo $name;
    $dom = new DOMDocument();
    $dom->loadHTMLFile($name . '.php');
    //backup
    $dom->saveHTMLFile('_' . $name . '-' . time() . '.php.bak');
    // Add data-edits to
    $xpath = new DOMXPath($dom);
    $pDivs = $xpath->query("//*[@data-edit]");
    foreach ($pDivs as $div) {
        // add
        $div->setAttribute('data-edit', NULL);
        // remove
        // $div->parentNode->removeAttribute('data-edit');
    }
    $dom->saveHTMLFile($name . '.php');
    echo " &#x2714;<br />";
}
Example #9
0
    die("\nERROR - Input directory missing or incorrect \n\n");
}
if (!is_dir($outputDir)) {
    die("\nERROR - Output directory missing or incorrect \n\n");
}
echo "\n";
while (($filename = readdir($dh)) !== false) {
    if (substr($filename, -5) == '.html') {
        echo "Processing: " . $filename . "\n";
        $inputFilePath = $inputDir . $filename;
        $outputFilePath = $outputDir . $filename;
        $doc = new DOMDocument();
        $doc->loadHTMLFile($inputFilePath);
        $elements = $doc->getElementsByTagName('*');
        $existingIDs = array();
        foreach ($elements as $element) {
            $elementID = $element->getAttribute("id");
            if (in_array($elementID, $existingIDs) || $elementID == '') {
                $nodePath = $element->getNodePath();
                // Note: change this line to change ID structure
                $newID = chr(97 + mt_rand(0, 25)) . substr(md5($nodePath), 0, 14);
                echo "\tAdding ID " . $newID . " to element: " . $nodePath . "\n";
                $element->setAttribute("id", $newID);
                $elementID = $newID;
            }
            $existingIDs[] = $elementID;
        }
        $doc->saveHTMLFile($outputFilePath);
    }
}
echo "\n";
Example #10
0
<?php

// step 2
// removes data-edit attributes and sets text values to be the new edits
$FILES_TO_PREP = array('index');
$dbDir = 'db/';
$archiveDir = 'db/archive/';
for ($i = 0; $i < count($FILES_TO_PREP); $i++) {
    $name = $FILES_TO_PREP[$i];
    echo $name;
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    $dom->formatOutput = true;
    $dom->loadHTMLFile($name . '.php');
    $dom->saveHTMLFile('bak/' . $name . '.bak.php');
    //backup
    // $dom->saveHTMLFile('_' . $name . '.php.bak');
    // Add data-edits to
    $xpath = new DOMXPath($dom);
    $pDivs = $xpath->query("//*[@data-edit]");
    foreach ($pDivs as $div) {
        // loading
        $id = $div->getAttribute('data-edit');
        $stuff = unserialize(file_get_contents($dbDir . $id));
        if ($stuff !== '') {
            $div->nodeValue = urldecode($stuff['data']);
            // $div->nodeValue = urldecode($stuff['data']);
            // if (copy($dbDir . $id, $archiveDir . $id . "_" . time())) {
            // unlink($dbDir . $id);
            // }
            $div->removeAttribute('data-edit');
 public function buildAndSaveOutputSource()
 {
     $this->setSourceContent();
     $sourceContent = $this->getSourceContent();
     if (strlen($sourceContent) < 1) {
         throw new EmailDesignerException('Source is empty. No data to edit.');
     }
     $this->renderStylesheet();
     $doc = new DOMDocument('1.0', 'UTF-8');
     $doc->formatOutput = true;
     $doc->loadHTML($sourceContent);
     foreach ($doc->getElementsByTagName('*') as $tag) {
         if ($tag->hasAttribute('class')) {
             $stylesArray = [];
             $classes = $tag->getAttribute('class');
             $classes = explode(' ', $classes);
             $classes = array_filter($classes);
             foreach ($classes as $class) {
                 $styles = str_replace('  ', '', $this->getStyles()['.' . $class]);
                 $styles = explode(';', $styles);
                 $stylesArray = array_merge($stylesArray, $styles);
             }
             $tag->setAttribute('style', implode(';', $stylesArray));
         }
     }
     $doc->saveHTMLFile($this->outPutFileLocation . '.' . $this->outPutFileName);
 }
    $title = $doc->getElementsByTagName("title");
    if ($title->length > 0) {
        $title->item(0)->textContent = "saved_schedule_data";
    }
    $datetimes = $doc->getElementsByTagName('tr');
    file_put_contents($logfile, "\nData extracted:\n", FILE_APPEND);
    foreach ($datetimes as $tr) {
        //for ($i = 1; $i <= count($datetimes); $i++) {
        //file_put_contents($logfile, "\nLine:\n".$tr->c14n(), FILE_APPEND);
        /*$current_doctor_id 		= $tr->childNodes[1]->textContent;
        		$current_date 			= $tr->childNodes[3]->textContent;
        		$current_doctor_name 	= $tr->childNodes[10]->textContent;
        		$current_time 			= $tr->childNodes[2]->textContent;*/
        $current_doctor_id = $tr->childNodes[2]->textContent;
        $current_date = $tr->childNodes[6]->textContent;
        $current_doctor_name = $tr->childNodes[20]->textContent;
        $current_time = $tr->childNodes[4]->textContent;
        //file_put_contents($logfile, "search: ".$date." : ".$doctor_id." : ".$doctor_name." : ".$time."\n", FILE_APPEND);
        //file_put_contents($logfile, "line: ".$current_date." : ".$current_doctor_id." : ".$current_doctor_name." : ".$current_time."\n", FILE_APPEND);
        if ($date == $current_date && $time == $current_time && $doctor_id == $current_doctor_id) {
            file_put_contents($logfile, "Found line: " . $current_date . " : " . $current_doctor_name . " : " . $current_doctor_id . " : " . $current_time . "\n", FILE_APPEND);
            if ($tr->childNodes[12]->textContent == "1") {
                $tr->childNodes[12]->textContent = $patient_name;
            } else {
                header("HTTP/1.0 403 Forbidden");
                die("ќшибка блокировки: это врем¤ уже зан¤л другой пациент.");
            }
        }
    }
    $doc->saveHTMLFile("data/SCHEDULE_DATA.html");
}
 /**
  * ___render___
  *
  * @method ___render___
  * @param {string} $content
  */
 protected function ___render___($content)
 {
     if ($content && is_string($content)) {
         if ($this->functions_for_render && (is_array($this->functions_for_render) || $this->functions_for_render instanceof ArrayObject)) {
             $before = $this->cache_read === true ? array() : array_filter((array) $this->functions_for_render, create_function('$v', 'return $v[\'after_cache\'] !== true;'));
             $after = array_filter((array) $this->functions_for_render, create_function('$v', 'return $v[\'after_cache\'] === true;'));
         } else {
             $before = $after = array();
         }
         if (0 < count($before) || 0 < count($after)) {
             $doc = new DOMDocument();
             $doc->loadHTML($content);
             //before cache
             foreach ($before as $fn) {
                 call_user_func($fn, $dom);
             }
             if ($this->cache_file && !$this->cache_read) {
                 $doc->saveHTMLFile($this->cache_file);
             }
             //after cache
             foreach ($before as $fn) {
                 call_user_func($fn, $dom);
             }
             $content = $doc->saveHTML();
         } else {
             if ($this->cache_file) {
                 file_put_contents($this->cache_file, $content);
             }
         }
     }
     echo $content;
 }
<?php

DOMDocument::saveHTMLFile();
Example #15
0
ini_set('max_execution_time', '3600');
$CurrentUser = Authentication::Authenticate();
if (!$CurrentUser->hasPermission(RIGHT_IMPORT_XML)) {
    $e = new Error(RIGHTS_ERR_USERNOTALLOWED);
    Error::AddError($e);
    HTMLstuff::RefererRedirect();
}
HTMLstuff::RefererRegister($_SERVER['REQUEST_URI']);
if (array_key_exists('hidAction', $_POST) && $_POST['hidAction'] == 'UploadXML') {
    $f = $_FILES['fileXML'];
    if ($f['error'] === UPLOAD_ERR_OK) {
        $d = new DOMDocument();
        if (@$d->load(realpath($f['tmp_name'])) === TRUE) {
            if (@$d->schemaValidate(realpath('./candydolldb.xsd')) === TRUE) {
                $tempFilename = sprintf('cache/%1$s.xml', Utils::UUID());
                $d->saveHTMLFile($tempFilename);
                header('location:setup_data.php?file=' . urlencode($tempFilename));
                exit;
            } else {
                $e = new XMLerror(XML_ERR_SCHEMA_VALID);
                Error::AddError($e);
            }
        } else {
            $e = new XMLerror(XML_ERR_XML_VALID);
            Error::AddError($e);
        }
    } else {
        $e = new UploadError($f['error']);
        Error::AddError($e);
    }
}
function saveTransformOutput($recHMLFilename, $styleFilename, $outputFilename = null)
{
    global $outputURI;
    $recHmlDoc = new DOMDocument();
    if (preg_match("/http/", $recHMLFilename)) {
        $suc = $recHmlDoc->loadXML(loadRemoteFile($recHMLFilename));
    } else {
        $suc = $recHmlDoc->load($recHMLFilename);
    }
    if (!$suc) {
        returnXMLErrorMsgPage("Unable to load file {$recHMLFilename}");
    }
    $recHmlDoc->xinclude();
    //todo write code here to squash xincludes down to some limit.
    if (!$styleFilename) {
        if (!$outputFilename) {
            returnXMLErrorMsgPage("No transform filename or outputFilename provided for {$recHMLFilename}");
        }
        if (is_logged_in()) {
            $cntByte = $recHmlDoc->saveHTMLFile($outputFilename);
        }
        if ($cntByte > 0) {
            returnXMLSuccessMsgPage("Successfully wrote {$cntByte} bytes of untransformed file {$recHMLFilename} to {$outputFilename}");
        } else {
            returnXMLErrorMsgPage("Unable to output untransformed file {$recHMLFilename} to {$outputFilename}");
        }
    } else {
        $xslDoc = new DOMDocument();
        if (preg_match("/http/", $styleFilename)) {
            $suc = $xslDoc->loadXML(loadRemoteFile($styleFilename));
        } else {
            $suc = $xslDoc->load($styleFilename);
        }
        if (!$suc) {
            returnXMLErrorMsgPage("Unable to load XSLT transform file {$styleFilename}");
        }
    }
    $xslProc = new XSLTProcessor();
    $xslProc->importStylesheet($xslDoc);
    // set up common parameters for stylesheets.
    $xslProc->setParameter('', 'hbaseURL', HEURIST_BASE_URL);
    $xslProc->setParameter('', 'dbName', HEURIST_DBNAME);
    $xslProc->setParameter('', 'dbID', HEURIST_DBID);
    $xslProc->setParameter('', 'transform', $styleFilename);
    $xslProc->setParameter('', 'standalone', '1');
    if ($outputFilename && is_logged_in()) {
        $cntByte = $xslProc->transformToURI($recHmlDoc, $outputFilename);
        if ($cntByte > 0) {
            returnXMLSuccessMsgPage("Successfully wrote {$cntByte} bytes of {$recHMLFilename} transformed by  {$styleFilename} to {$outputFilename}" . ($outputURI ? " <a href=\"{$outputURI}\" target=\"_blank\">{$outputURI}</a>" : "Unable to determine URI for {$outputFilename} because is does not match website path!"));
        } else {
            returnXMLErrorMsgPage("Unable to  transform and/or output file {$recHMLFilename} transformed by  {$styleFilename} to {$outputFilename}");
        }
    } else {
        $doc = $xslProc->transformToDoc($recHmlDoc);
        //		echo $xslProc->transformToXML($recHmlDoc);
        echo $doc->saveHTML();
    }
}
 private function improveHTML($output_dir, $inline_img = TRUE)
 {
     $html = file_get_contents($this->file);
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $tags = $doc->getElementsByTagName('img');
     if ($tags->length == 0) {
         return FALSE;
     }
     foreach ($tags as $tag) {
         if ($tag->getAttribute('src') != "") {
             preg_match("#\\w*?.(jpg|png|gif)#is", $tag->getAttribute('src'), $filename);
             if (file_exists($output_dir . '/' . $filename[0])) {
                 if ($inline_img) {
                     $imgData = base64_encode(file_get_contents($output_dir . '/' . $filename[0]));
                     $src = 'data: ' . mime_content_type($output_dir . '/' . $filename[0]) . ';base64,' . $imgData;
                 } else {
                     $src = $filename[0];
                 }
                 $tag->setAttribute('src', $src);
             }
         }
     }
     $doc->saveHTMLFile($this->file);
 }
    //  $editTopicLinkQuery = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' edittopiclink ')]";
    $editTopicLinkQuery = ".//x:a[@class='edittopiclink']";
    $editLinks = $xpath->query($editTopicLinkQuery, $clicknode);
    $clickableQuery = ".//*[contains(concat(' ', normalize-space(@class), ' '), ' clickable ')]";
    $clickables = $xpath->query($clickableQuery, $clicknode);
    $clickablecount = $clickablecount + $clickables->length;
    $linkcount = $linkcount + $editLinks->length;
    if ($clickables->length == 1) {
        if ($editLinks->length == 1) {
            /*
            // This code clones the lower link when there is a clickable
                 $newEditLink = $editLinks->item(0)->cloneNode(false);
                 $clickwrapper = $clicknode->insertBefore($newEditLink, $clickables->item(0));
                 $clickwrapper->appendChild($clickables->item(0));
            */
            // This code moves the lower link when there is a clickable
            $clickwrapper = $clicknode->insertBefore($editLinks->item(0), $clickables->item(0));
            //Remove the existing text from the link
            $clickwrapper->nodeValue = "";
            echo $clickwrapper->nodeValue;
            $clickwrapper->appendChild($clickables->item(0));
        }
    }
}
echo "clicknodes:", $clicknodes->length, "\n";
echo "clickables:", $clickablecount, "\n";
echo "links:", $linkcount;
$doc->saveHTMLFile($argv[2]);
?>

    }
}
$csss = explode("}", file_get_contents("test.css"));
$css = array();
unset($csss[0]);
foreach ($csss as $item) {
    if (exec("echo '{$item}' | grep content -o") != "") {
        $item = str_replace([".fa-", ':before', '{content:"', '"}', '"'], "", $item);
        $css[] = $item;
    }
}
foreach ($css as $item) {
    if ($item != "") {
        $a = explode('\\f', $item);
        foreach (explode(",", $a[0]) as $ga) {
            if (!isset($c["f" . $a[1]])) {
                echo "[FAIL] nothing matches {$ga}";
            } else {
                $g = $c["f" . $a[1]]->cloneNode(true);
                $g->setAttribute("id", $ga);
                $defs->appendChild($g);
            }
        }
    }
}
echo "[DONE] saved as fa.html\n";
foreach (array("test.css") as $f) {
    unlink($f);
}
$res->saveHTMLFile("./fa.html");
<?php

$filename = dirname(__FILE__) . "/DOMDocument_saveHTMLFile_formatOutput" . time() . ".html";
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$root = $doc->createElement('html');
$root = $doc->appendChild($root);
$head = $doc->createElement('head');
$head = $root->appendChild($head);
$title = $doc->createElement('title');
$title = $head->appendChild($title);
$text = $doc->createTextNode('This is the title');
$text = $title->appendChild($text);
$bytes = $doc->saveHTMLFile($filename);
var_dump($bytes);
echo file_get_contents($filename);
unlink($filename);
Example #21
0
     }
 }
 // if the count elements found in the source is equal to the element->count given us by the element count found by jquery
 // that means we can savely edit the element. ( i.e. javascript or snipets have  not added simmular elements.
 if ($count == $element->count) {
     $count = 0;
     $bSaveTemplate = false;
     $newElement = false;
     foreach ($elements as $key => $_element) {
         $string1 = preg_replace('|[^A-Za-z0-9]|', '', $_element->nodeValue);
         $string2 = preg_replace('|[^A-Za-z0-9]|', '', $element->innerText);
         if (strtolower($string1) == strtolower($string2)) {
             if ($element->index == $count) {
                 // Add an id to the element, and save the page.
                 $_element->setAttribute('id', $_POST['id']);
                 $dom->saveHTMLFile($reqDetails->fullPath);
                 // Save the modified element to the tag db
                 $_element->nodeValue = htmlentities(base64_decode($_POST['innerHTML']));
                 $newElement = $dom->saveHTML($_element);
                 $newElement = html_entity_decode($newElement);
                 $ret = setTag($session, $pdo, $memcache, $_POST['id'], $session->language, $session->country, $session->continent, $session->request->request, $newElement);
                 $json->id = $_POST['id'];
                 $json->element = $element;
                 if (!empty($innerHTML)) {
                     $json->innerHTML = $_POST['innerHTML'];
                     // this is still base64 encoded
                 }
                 if (!empty($_POST['attributes'])) {
                     $json->attributes = $_POST['attributes'];
                     // this is still base64(json_encode) encoded
                 }
 public static function run($r)
 {
     $pdf = new pts_pdf_template(pts_title(false), 'Test Client Documentation');
     $html_doc = new pts_html_template(pts_title(false), 'Test Client Documentation');
     $pdf->AddPage();
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38, 'PNG', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(120);
     $pdf->WriteStatement('www.phoronix-test-suite.com', 'C', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(15);
     $pdf->WriteBigHeaderCenter(pts_title(true));
     $pdf->WriteHeaderCenter('User Manual');
     //$pdf->WriteText($result_file->get_description());
     $pts_options = pts_documentation::client_commands_array();
     // Write the test options HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'User Options');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'The following options are currently supported by the Phoronix Test Suite client. A list of available options can also be found by running ');
     $em = $dom->createElement('em', 'phoronix-test-suite help.');
     $p->appendChild($em);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $body->appendChild($p);
     foreach ($pts_options as $section => &$contents) {
         if (empty($contents)) {
             continue;
         }
         $header = $dom->createElement('h1', $section);
         $body->appendChild($header);
         sort($contents);
         foreach ($contents as &$option) {
             $sub_header = $dom->createElement('h3', $option[0]);
             $em = $dom->CreateElement('em', '  ' . implode(' ', $option[1]));
             $sub_header->appendChild($em);
             $body->appendChild($sub_header);
             $p = $dom->createElement('p', $option[2]);
             $body->appendChild($p);
         }
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/00_user_options.html');
     // Write the module options HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'Module Options');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'The following list is the modules included with the Phoronix Test Suite that are intended to extend the functionality of pts-core. Some of these options have commands that can be run directly in a similiar manner to the other Phoronix Test Suite user commands. Some modules are just meant to be loaded directly by adding the module name to the LoadModules tag in ~/.phoronix-test-suite/user-config.xml or via the PTS_MODULES environmental variable. A list of available modules is also available by running ');
     $em = $dom->createElement('em', 'phoronix-test-suite list-modules.');
     $p->appendChild($em);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $body->appendChild($p);
     foreach (pts_module_manager::available_modules(true) as $module) {
         pts_module_manager::load_module($module);
         $header = $dom->createElement('h2', pts_module_manager::module_call($module, 'module_name'));
         $body->appendChild($header);
         $desc = $dom->createElement('p', pts_module_manager::module_call($module, 'module_description'));
         $body->appendChild($desc);
         $all_options = pts_module_manager::module_call($module, 'user_commands');
         if (count($all_options) > 0) {
             //	$sub_header = $dom->createElement('h3', 'Module Commands');
             //	$body->appendChild($sub_header);
             foreach ($all_options as $key => $option) {
                 $p = $dom->createElement('p', 'phoronix-test-suite ' . $module . '.' . str_replace('_', '-', $key));
                 $body->appendChild($p);
             }
         }
         $vars = pts_module_manager::module_call($module, 'module_environmental_variables');
         if (is_array($vars) && count($vars) > 0) {
             $p = $dom->createElement('p', 'This module utilizes the following environmental variables: ' . implode(', ', $vars) . '.');
             $body->appendChild($p);
         }
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/00_zmodule_options.html');
     // Write the external dependencies HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'External Dependencies');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'The Phoronix Test Suite has a feature known as &quot;External Dependencies&quot; where the Phoronix Test Suite can attempt to automatically install some of the test-specific dependencies on supported distributions. If running on a distribution where there is currently no External Dependencies profile, the needed package name(s) are listed for manual installation.');
     $body->appendChild($p);
     $p = $dom->createElement('p', 'Below are a list of the operating systems that currently have external dependencies support within the Phoronix Test Suite for the automatic installation of needed test files.');
     $body->appendChild($p);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $exdep_generic_parser = new pts_exdep_generic_parser();
     $vendors = array_merge($exdep_generic_parser->get_vendor_aliases_formatted(), $exdep_generic_parser->get_vendors_list_formatted());
     sort($vendors);
     $ul = $dom->createElement('ul');
     $p->appendChild($ul);
     foreach ($vendors as $vendor) {
         $li = $dom->createElement('li', $vendor);
         $p->appendChild($li);
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/02_external_dependencies.html');
     // Write the virtual suites HTML
     $dom = new DOMDocument();
     $html = $dom->createElement('html');
     $dom->appendChild($html);
     $head = $dom->createElement('head');
     $title = $dom->createElement('title', 'Virtual Test Suites');
     $head->appendChild($title);
     $html->appendChild($head);
     $body = $dom->createElement('body');
     $html->appendChild($body);
     $p = $dom->createElement('p', 'Virtual test suites are not like a traditional test suite defined by the XML suite specification. Virtual test suites are dynamically generated in real-time by the Phoronix Test Suite client based upon the specified test critera. Virtual test suites can automatically consist of all test profiles that are compatible with a particular operating system or test profiles that meet other critera. When running a virtual suite, the OpenBenchmarking.org repository of the test profiles to use for generating the dynamic suite must be prefixed. ');
     $body->appendChild($p);
     $p = $dom->createElement('p', 'Virtual test suites can be installed and run just like a normal XML test suite and shares nearly all of the same capabilities. However, when running a virtual suite, the user will be prompted to input any user-configuration options for needed test profiles just as they would need to do if running the test individually. When running a virtual suite, the user also has the ability to select individual tests within the suite to run or to run all of the contained test profiles. Virtual test suites are also only supported for an OpenBenchmarking.org repository if there is no test profile or test suite of the same name in the repository. Below is a list of common virtual test suites for the main Phoronix Test Suite repository, but the dynamic list of available virtual test suites based upon the enabled repositories is available by running ');
     $em = $dom->createElement('em', 'phoronix-test-suite list-available-virtual-suites.');
     $p->appendChild($em);
     $phr = $dom->createElement('hr');
     $p->appendChild($phr);
     $body->appendChild($p);
     foreach (pts_virtual_test_suite::available_virtual_suites() as $virtual_suite) {
         $sub_header = $dom->createElement('h3', $virtual_suite->get_title());
         $em = $dom->CreateElement('em', '  ' . $virtual_suite->get_identifier());
         $sub_header->appendChild($em);
         $body->appendChild($sub_header);
         $p = $dom->createElement('p', $virtual_suite->get_description());
         $body->appendChild($p);
     }
     $dom->saveHTMLFile(PTS_PATH . 'documentation/stubs/55_virtual_suites.html');
     // Load the HTML documentation
     foreach (pts_file_io::glob(PTS_PATH . 'documentation/stubs/*_*.html') as $html_file) {
         $pdf->html_to_pdf($html_file);
         $html_doc->html_to_html($html_file);
     }
     if (!is_writable(PTS_PATH . 'documentation/')) {
         echo PHP_EOL . 'Not writable: ' . PTS_PATH . 'documentation/';
     } else {
         $pdf_file = PTS_PATH . 'documentation/phoronix-test-suite.pdf';
         $pdf->Output($pdf_file);
         $html_doc->Output(PTS_PATH . 'documentation/phoronix-test-suite.html');
         echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL . PHP_EOL;
         // Also re-generate the man page
         $man_page = '.TH phoronix-test-suite 1  "www.phoronix-test-suite.com" "' . PTS_VERSION . '"' . PHP_EOL . '.SH NAME' . PHP_EOL;
         $man_page .= 'phoronix-test-suite \\- The Phoronix Test Suite is an extensible open-source platform for performing testing and performance evaluation.' . PHP_EOL;
         $man_page .= '.SH SYNOPSIS' . PHP_EOL . '.B phoronix-test-suite [options]' . PHP_EOL . '.br' . PHP_EOL . '.B phoronix-test-suite benchmark [test | suite]' . PHP_EOL;
         $man_page .= '.SH DESCRIPTION' . PHP_EOL . pts_documentation::basic_description() . PHP_EOL;
         $man_page .= '.SH OPTIONS' . PHP_EOL . '.TP' . PHP_EOL;
         foreach ($pts_options as $section => &$contents) {
             if (empty($contents)) {
                 continue;
             }
             $man_page .= '.SH ' . strtoupper($section) . PHP_EOL;
             sort($contents);
             foreach ($contents as &$option) {
                 $man_page .= '.B ' . trim($option[0] . ' ' . (!empty($option[1]) && is_array($option[1]) ? implode(' ', $option[1]) : null)) . PHP_EOL . $option[2] . PHP_EOL . '.TP' . PHP_EOL;
             }
         }
         $man_page .= '.SH SEE ALSO' . PHP_EOL . '.B Websites:' . PHP_EOL . '.br' . PHP_EOL . 'http://www.phoronix-test-suite.com/' . PHP_EOL . '.br' . PHP_EOL . 'http://commercial.phoronix-test-suite.com/' . PHP_EOL . '.br' . PHP_EOL . 'http://www.openbenchmarking.org/' . PHP_EOL . '.br' . PHP_EOL . 'http://www.phoronix.com/' . PHP_EOL . '.br' . PHP_EOL . 'http://www.phoronix.com/forums/' . PHP_EOL;
         $man_page .= '.SH AUTHORS' . PHP_EOL . 'Copyright 2008 - ' . date('Y') . ' by Phoronix Media, Michael Larabel.' . PHP_EOL . '.TP' . PHP_EOL;
         file_put_contents(PTS_PATH . 'documentation/man-pages/phoronix-test-suite.1', $man_page);
     }
     // simple README
     $readme = '# Phoronix Test Suite ' . PTS_VERSION . PHP_EOL . 'http://www.phoronix-test-suite.com/' . PHP_EOL . PHP_EOL;
     $readme .= pts_documentation::basic_description() . PHP_EOL . PHP_EOL;
     $readme .= pts_file_io::file_get_contents(PTS_PATH . 'documentation/stubs/readme-basics.txt') . PHP_EOL . PHP_EOL;
     $readme = wordwrap($readme, 80, PHP_EOL);
     file_put_contents(PTS_PATH . 'README.md', $readme);
     // Phoromatic Documentation
     $pdf = new pts_pdf_template(pts_title(false), 'Phoromatic Documentation');
     $html_doc = new pts_html_template(pts_title(false), 'Phoromatic Documentation');
     $pdf->AddPage();
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/pts-308x160.png', 69, 85, 73, 38, 'PNG', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(120);
     $pdf->WriteStatement('www.phoronix-test-suite.com', 'C', 'http://www.phoronix-test-suite.com/');
     $pdf->Ln(15);
     $pdf->Image(PTS_CORE_STATIC_PATH . 'images/phoromatic-390x56.png', 55, 250, 0, 0, 'PNG', 'http://www.phoronix-test-suite.com/');
     //$pdf->Image(PTS_CORE_STATIC_PATH . 'images/phoromatic-390x56.png', 69, 85, 73, 38, 'PNG', 'http://www.phoromatic.com/');
     $pdf->WriteBigHeaderCenter(pts_title(true));
     $pdf->WriteHeaderCenter('Phoromatic User Manual');
     $pdf->html_to_pdf(PTS_PATH . 'documentation/phoromatic.html');
     $pdf_file = PTS_PATH . 'documentation/phoromatic.pdf';
     $pdf->Output($pdf_file);
     echo PHP_EOL . 'Saved To: ' . $pdf_file . PHP_EOL . PHP_EOL;
 }
Example #23
0
$dom = $dom->getElementsByTagName('a');
foreach ($dom as $line) {
    $name = $line->nodeValue;
    if (substr_count($name, "-") > 1) {
        $css->long[] = $name;
        continue;
    }
    $link = $line->getAttribute("href");
    $css->links[$name] = $link;
    $support = new DOMDocument();
    if (file_exists(CACHE . $link)) {
        $support->loadHTMLFile(CACHE . $link);
    } else {
        $support->loadHTMLFile(W3C . $link);
        if (!empty($support)) {
            $support->saveHTMLFile(CACHE . $link);
        }
    }
    foreach ($support->getElementsByTagName("table") as $table) {
        if ($table->getAttribute("class") == "browserref notranslate") {
            $depr = 0;
            if ($table->getElementsByTagName("tr")->length > 2) {
                //var_dump($name); // skip tags which have more than one row for versions.
                continue;
            }
            foreach ($table->getElementsByTagName("td") as $col) {
                if ($col->nodeValue === "Not supported") {
                    $depr++;
                }
            }
            if ($depr < 3) {
Example #24
0
 /**
  * Wrapper to DOMDocument::saveHTMLfile with exception handling
  *
  * @param string $filename filename to save to
  * @param integer $options Options bitmask (@see DOMDocument::saveHTMLFile)
  *
  * @throws fDOMException
  *
  * @return integer bytes saved
  */
 public function saveHTMLFile($filename, $options = NULL)
 {
     $tmp = parent::saveHTMLFile($filename, $options);
     if (!$tmp) {
         throw new fDOMException('saving to HTML file failed', fDOMException::SaveError);
     }
     return $tmp;
 }
Example #25
0
     * 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
*/
<?php

DOMDocument::saveHTMLFile('foo');
Example #27
0
});
xml_set_object($parser, $anObject);
// allow to use the parser as an object and so to set the handlers as methods
xml_parse_into_struct($parser, $xmlStr, $valueArr, $indexArr);
// parse an XML string into two parallel arrays (values and indexes))
// DOM
// requires libxml2 extension and expat library
$doc = new DOMDocument();
$doc->load("file.xml");
$doc->save("file2.xml");
// save a XML file
$str = $doc->saveXML();
// save a XML string
$html = $doc->saveHTML();
// save a HTML string
$doc->saveHTMLFile("file.html");
// save a HTML file
$xpath = new DOMXPath($doc);
$elements = $xpath->query("//*[@id]");
// get a list of documents with an id
foreach ($elements as $element) {
    echo $element->nodeName . PHP_EOL;
    $nodes = $element->childNodes;
    foreach ($nodes as $node) {
        echo $node->nodeValue . PHP_EOL;
    }
}
/*
Method          Description
createElement   Creates a node element that can be appended with the appendChild method of the node class
createElementNS As with createElement but supports documents with namespaces