当前位置: 首页>>代码示例>>PHP>>正文


PHP simple_html_dom::__toString方法代码示例

本文整理汇总了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');
 }
开发者ID:Edke,项目名称:PdfResponse,代码行数:50,代码来源:PdfResponse.php

示例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;
}
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:18,代码来源:form.php

示例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);
 }
开发者ID:jkuchar,项目名称:pdfresponse,代码行数:76,代码来源:PDFResponse.php

示例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();
 }
开发者ID:ralfeus,项目名称:moomi-daeri.com,代码行数:24,代码来源:import.php


注:本文中的simple_html_dom::__toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。