當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Service::render方法代碼示例

本文整理匯總了PHP中Pimcore\Model\Document\Service::render方法的典型用法代碼示例。如果您正苦於以下問題:PHP Service::render方法的具體用法?PHP Service::render怎麽用?PHP Service::render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimcore\Model\Document\Service的用法示例。


在下文中一共展示了Service::render方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wordExportAction

 public function wordExportAction()
 {
     //error_reporting(E_ERROR);
     //ini_set("display_errors", "off");
     $id = $this->getParam("id");
     $data = \Zend_Json::decode($this->getParam("data"));
     $source = $this->getParam("source");
     $exportFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $id . ".html";
     if (!is_file($exportFile)) {
         /*file_put_contents($exportFile, '<!DOCTYPE html>' . "\n" . '<html>
               <head>
                   <style type="text/css">' . file_get_contents(PIMCORE_PATH . "/static/css/word-export.css") . '</style>
               </head>
               <body>
           ');*/
         File::put($exportFile, '<style type="text/css">' . file_get_contents(PIMCORE_PATH . "/static6/css/word-export.css") . '</style>');
     }
     foreach ($data as $el) {
         try {
             $element = Element\Service::getElementById($el["type"], $el["id"]);
             $output = "";
             // check supported types (subtypes)
             if (!in_array($element->getType(), array("page", "snippet", "email", "object"))) {
                 continue;
             }
             if ($element instanceof Element\ElementInterface) {
                 $output .= '<h1 class="element-headline">' . ucfirst($element->getType()) . " - " . $element->getFullPath() . ' (ID: ' . $element->getId() . ')</h1>';
             }
             if ($element instanceof Document\PageSnippet) {
                 if ($element instanceof Document\Page) {
                     $structuredDataEmpty = true;
                     $structuredData = '
                         <table border="1" cellspacing="0" cellpadding="5">
                             <tr>
                                 <td colspan="2"><span style="color:#cc2929;font-weight: bold;">Structured Data</span></td>
                             </tr>
                     ';
                     if ($element->getTitle()) {
                         $structuredData .= '<tr>
                                 <td><span style="color:#cc2929;">Title</span></td>
                                 <td>' . $element->getTitle() . '&nbsp;</td>
                             </tr>';
                         $structuredDataEmpty = false;
                     }
                     if ($element->getDescription()) {
                         $structuredData .= '<tr>
                                 <td><span style="color:#cc2929;">Description</span></td>
                                 <td>' . $element->getDescription() . '&nbsp;</td>
                             </tr>';
                         $structuredDataEmpty = false;
                     }
                     if ($element->getKeywords()) {
                         $structuredData .= '<tr>
                                 <td><span style="color:#cc2929;">Keywords</span></td>
                                 <td>' . $element->getKeywords() . '&nbsp;</td>
                             </tr>';
                         $structuredDataEmpty = false;
                     }
                     if ($element->getProperty("navigation_name")) {
                         $structuredData .= '<tr>
                                 <td><span style="color:#cc2929;">Navigation</span></td>
                                 <td>' . $element->getProperty("navigation_name") . '&nbsp;</td>
                             </tr>';
                         $structuredDataEmpty = false;
                     }
                     $structuredData .= '</table>';
                     if (!$structuredDataEmpty) {
                         $output .= $structuredData;
                     }
                 }
                 // we need to set the parameter "pimcore_admin" here to be able to render unpublished documents
                 $reqBak = $_REQUEST;
                 $_REQUEST["pimcore_admin"] = true;
                 $html = Document\Service::render($element, array(), false);
                 $_REQUEST = $reqBak;
                 // set the request back to original
                 $html = preg_replace("@</?(img|meta|div|section|aside|article|body|bdi|bdo|canvas|embed|footer|head|header|html)([^>]+)?>@", "", $html);
                 $html = preg_replace('/<!--(.*)-->/Uis', '', $html);
                 include_once "simple_html_dom.php";
                 $dom = str_get_html($html);
                 if ($dom) {
                     // remove containers including their contents
                     $elements = $dom->find("form,script,style,noframes,noscript,object,area,mapm,video,audio,iframe,textarea,input,select,button,");
                     if ($elements) {
                         foreach ($elements as $el) {
                             $el->outertext = "";
                         }
                     }
                     $clearText = function ($string) {
                         $string = str_replace("\r\n", "", $string);
                         $string = str_replace("\n", "", $string);
                         $string = str_replace("\r", "", $string);
                         $string = str_replace("\t", "", $string);
                         $string = preg_replace('/&[a-zA-Z0-9]+;/', '', $string);
                         // remove html entities
                         $string = preg_replace('#[ ]+#', '', $string);
                         return $string;
                     };
                     // remove empty tags (where it matters)
                     $elements = $dom->find("a, li");
//.........這裏部分代碼省略.........
開發者ID:quorak,項目名稱:pimcore,代碼行數:101,代碼來源:TranslationController.php

示例2: replacePlaceholders

 /**
  * Helper to simply replace the placeholders with their value
  *
  * @param string | Model\Document $mixed
  * @param array $params
  * @param null | Model\Document $document
  * @return string
  */
 public function replacePlaceholders($mixed, $params = [], $document = null, $enableLayoutOnPlaceholderReplacement = true)
 {
     if (is_string($mixed)) {
         $contentString = $mixed;
     } elseif ($mixed instanceof Model\Document) {
         $contentString = Model\Document\Service::render($mixed, $params, $enableLayoutOnPlaceholderReplacement);
     }
     if ($document instanceof Model\Document === false) {
         $document = null;
     }
     //detects the placeholders
     $placeholderStack = $this->detectPlaceholders($contentString, $params, $document);
     //replaces the placeholders if any were found
     if (!empty($placeholderStack)) {
         $replacedString = $this->replacePlaceholdersFromStack($placeholderStack);
         return $replacedString;
     } else {
         return $contentString;
     }
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:28,代碼來源:Placeholder.php

示例3: renderDocument

 public function renderDocument($params)
 {
     $html = Document\Service::render($this, $params, true);
     return $html;
 }
開發者ID:pimcore,項目名稱:pimcore,代碼行數:5,代碼來源:PrintAbstract.php


注:本文中的Pimcore\Model\Document\Service::render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。