本文整理汇总了PHP中simple_html_dom::__toString方法的典型用法代码示例。如果您正苦于以下问题:PHP simple_html_dom::__toString方法的具体用法?PHP simple_html_dom::__toString怎么用?PHP simple_html_dom::__toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simple_html_dom
的用法示例。
在下文中一共展示了simple_html_dom::__toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Sends response to output.
* @return void
*/
function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse)
{
if ($this->source instanceof ITemplate) {
$this->source->pdfResponse = $this;
$this->source->mPDF = $this->getMPDF();
$html = $this->source->__toString();
} else {
$html = $this->source;
}
// Fix: $html can't be empty (mPDF generates Fatal error)
if (empty($html)) {
$html = "<html><body></body></html>";
}
$mpdf = $this->getMPDF();
$mpdf->biDirectional = $this->multiLanguage;
$mpdf->SetAuthor($this->documentAuthor);
$mpdf->SetTitle($this->documentTitle);
$mpdf->SetDisplayMode($this->displayZoom, $this->displayLayout);
$mpdf->showImageErrors = true;
// @see: http://mpdf1.com/manual/index.php?tid=121&searchstring=writeHTML
if ($this->ignoreStylesInHTMLDocument) {
// copied from mPDF -> removes comments
$html = preg_replace('/<!--mpdf/i', '', $html);
$html = preg_replace('/mpdf-->/i', '', $html);
$html = preg_replace('/<\\!\\-\\-.*?\\-\\->/s', '', $html);
// deletes all <style> tags
$parsedHtml = new simple_html_dom($html);
foreach ($parsedHtml->find("style") as $el) {
$el->outertext = "";
}
$html = $parsedHtml->__toString();
$mode = 2;
// If <body> tags are found, all html outside these tags are discarded, and the rest is parsed as content for the document. If no <body> tags are found, all html is parsed as content. Prior to mPDF 4.2 the default CSS was not parsed when using mode #2
} else {
$mode = 0;
// Parse all: HTML + CSS
}
// Add content
$mpdf->WriteHTML($html, $mode);
// Add styles
if (!empty($this->styles)) {
$mpdf->WriteHTML($this->styles, 1);
}
$this->onBeforeComplete($mpdf);
$mpdf->Output(\Nette\Utils\Strings::webalize($this->documentTitle), 'I');
}
示例2: form_parser
function form_parser($buffer)
{
global $wp_version;
if (is_admin() && $wp_version >= '3.3') {
$html = new simple_html_dom();
$html->load($buffer);
if ($textareas = $html->find('textarea[class=theEditor]')) {
foreach ($textareas as $textarea) {
ob_start();
wp_editor($textarea->innertext, $textarea->id);
$editor = ob_get_clean();
$textarea->outertext = $editor;
}
}
return $html->__toString();
}
return $buffer;
}
示例3: send
/**
* Sends response to output.
* @return void
*/
public function send(IRequest $httpRequest, IResponse $httpResponse)
{
// Throws exception if sources can not be processed
$html = $this->getSource();
// Fix: $html can't be empty (mPDF generates Fatal error)
if (empty($html)) {
$html = "<html><body></body></html>";
}
$mpdf = $this->getMPDF();
$mpdf->biDirectional = $this->multiLanguage;
$mpdf->SetAuthor($this->documentAuthor);
$mpdf->SetTitle($this->documentTitle);
$mpdf->SetDisplayMode($this->displayZoom, $this->displayLayout);
// @see: http://mpdf1.com/manual/index.php?tid=121&searchstring=writeHTML
if ($this->ignoreStylesInHTMLDocument) {
// copied from mPDF -> removes comments
$html = preg_replace('/<!--mpdf/i', '', $html);
$html = preg_replace('/mpdf-->/i', '', $html);
$html = preg_replace('/<\\!\\-\\-.*?\\-\\->/s', '', $html);
// deletes all <style> tags
$parsedHtml = new simple_html_dom($html);
foreach ($parsedHtml->find("style") as $el) {
$el->outertext = "";
}
$html = $parsedHtml->__toString();
$mode = 2;
// If <body> tags are found, all html outside these tags are discarded, and the rest is parsed as content for the document. If no <body> tags are found, all html is parsed as content. Prior to mPDF 4.2 the default CSS was not parsed when using mode #2
} else {
$mode = 0;
// Parse all: HTML + CSS
}
if (class_exists('\\simple_html_dom', true)) {
// Support for base64 encoded images - workaround
$parsedHtml = new \simple_html_dom($html);
$i = 1000;
foreach ($parsedHtml->find("img") as $element) {
$boundary1 = "data:";
$pos1 = strlen($boundary1);
if (!substr($element->src, 0, $pos1) == $boundary1) {
continue;
}
$pos2 = strpos($element->src, ";", $pos1);
if ($pos2 === false) {
continue;
}
$mime = substr($element->src, $pos1, $pos2 - $pos1);
$boundary = "base64,";
$base64 = substr($element->src, $pos2 + strlen($boundary) + 1);
$data = base64_decode($base64);
if ($data === false) {
continue;
}
$propertyName = "base64Image" . $i;
$mpdf->{$propertyName} = $data;
$element->src = "var:" . $propertyName;
$i++;
}
$html = $parsedHtml->__toString();
}
$this->onBeforeWrite($mpdf);
// Add content
$mpdf->WriteHTML($html, $mode);
// Add styles
if (!empty($this->styles)) {
$mpdf->WriteHTML($this->styles, 1);
}
$this->onBeforeComplete($mpdf);
if (!$this->outputName) {
$this->outputName = Strings::webalize($this->documentTitle) . ".pdf";
}
$mpdf->Output($this->outputName, $this->outputDestination);
}
示例4: updateDescriptionImages
/**
* @param int $id
* @param string $description
* @return string
* @throws Exception
*/
private function updateDescriptionImages($id, $description)
{
/** @var ModelToolImage $modelToolImage */
$modelToolImage = $this->load->model('tool/image');
/// Download images in image description
$html = new \simple_html_dom($description);
$descriptionImages = $html->find('img');
foreach ($descriptionImages as $image) {
try {
$image->attr['src'] = HTTP_IMAGE . $modelToolImage->download($image->attr['src']);
} catch (Exception $e) {
$error = "Couldn't download an image '" . $image->attr['src'] . "'' for product {$id}. Original image will be used instead";
$this->getLogger()->write($error);
$this->data['notifications']['error'] .= "{$error}<br />";
}
}
return $html->__toString();
}