本文整理汇总了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() . ' </td>
</tr>';
$structuredDataEmpty = false;
}
if ($element->getDescription()) {
$structuredData .= '<tr>
<td><span style="color:#cc2929;">Description</span></td>
<td>' . $element->getDescription() . ' </td>
</tr>';
$structuredDataEmpty = false;
}
if ($element->getKeywords()) {
$structuredData .= '<tr>
<td><span style="color:#cc2929;">Keywords</span></td>
<td>' . $element->getKeywords() . ' </td>
</tr>';
$structuredDataEmpty = false;
}
if ($element->getProperty("navigation_name")) {
$structuredData .= '<tr>
<td><span style="color:#cc2929;">Navigation</span></td>
<td>' . $element->getProperty("navigation_name") . ' </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");
//.........这里部分代码省略.........
示例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;
}
}
示例3: renderDocument
public function renderDocument($params)
{
$html = Document\Service::render($this, $params, true);
return $html;
}