本文整理汇总了PHP中DOMDocument::saveHTMLFile方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMDocument::saveHTMLFile方法的具体用法?PHP DOMDocument::saveHTMLFile怎么用?PHP DOMDocument::saveHTMLFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMDocument
的用法示例。
在下文中一共展示了DOMDocument::saveHTMLFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _save
/**
* @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;
}
示例2: usableInSaveHTMLFile
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>übercoder</title></head></html>', trim($out->getBytes()));
}
示例3: saveTo
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;
}
示例4: render
/**
* 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;
}
示例5: loadRecordHTML
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);
}
示例6: get_from_menu_css_tags
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;
}
示例7: saveHTMLFile
/**
* 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;
}
示例8: array
<?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 " ✔<br />";
}
示例9: die
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";
示例10: array
<?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');
示例11: buildAndSaveOutputSource
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);
}
示例12: foreach
$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");
}
示例13: ___render___
/**
* ___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;
}
示例14:
<?php
DOMDocument::saveHTMLFile();
示例15: Error
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);
}
}