本文整理汇总了PHP中XMLParser::getTargetsForTemplateBlocks方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::getTargetsForTemplateBlocks方法的具体用法?PHP XMLParser::getTargetsForTemplateBlocks怎么用?PHP XMLParser::getTargetsForTemplateBlocks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::getTargetsForTemplateBlocks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
private function getContent($backend = false)
{
$templateFile = SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'website' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $this->pageDocument->getTemplate() . '.xml';
if (!is_file($templateFile)) {
$templateFile = SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'website' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $this->pageDocument->getTemplate() . '.xml';
}
$tags = XMLParser::getXMLdataValues($templateFile, true, true);
$targets = XMLParser::getTargetsForTemplateBlocks($tags);
$content = '';
$processContent = false;
$freeCnt = 0;
if ($backend) {
$freeContentStr = 'free content...';
$richTextStr = 'Click here to edit richtext content...';
} else {
$freeContentStr = '';
}
// CREATING PREDEFINED RICHTEXT FIELDS
if ($this->pageDocument->getContent() === null) {
$richtextCnt = 0;
$richrextBoxes = '';
foreach ($tags as $tag) {
if ($tag['tag'] == 'LAYOUT' && $tag['type'] == 'open') {
$processContent = true;
continue;
}
if ($tag['tag'] == 'LAYOUT' && $tag['type'] == 'close') {
$processContent = false;
continue;
}
if ($processContent) {
if ($tag['type'] == 'complete') {
if (array_key_exists("attributes", $tag) && array_key_exists('ID', $tag['attributes']) && isset($targets[$tag['attributes']['ID']])) {
$templateType = $targets[$tag['attributes']['ID']]['type'];
if ($templateType == 'richtext') {
$richtextCnt++;
$richrextBoxes .= '<block id="richtext' . $richtextCnt . '" target="' . $tag['attributes']["ID"] . '" action="richtext"><![CDATA[<p></p>Click here to edit richtext content...<p></p>]]></block>';
}
}
}
}
}
if ($richrextBoxes) {
$richrextBoxes = '<?xml version="1.0" encoding="UTF-8"?><blocks>' . $richrextBoxes . '</blocks>';
}
$this->pageDocument->setContent($richrextBoxes);
$this->pageDocument->save();
}
foreach ($tags as $tag) {
if ($tag['tag'] == 'LAYOUT' && $tag['type'] == 'open') {
$processContent = true;
continue;
}
if ($tag['tag'] == 'LAYOUT' && $tag['type'] == 'close') {
$processContent = false;
continue;
}
if ($processContent) {
if ($tag['type'] == 'open') {
$content .= str_repeat(chr(9), $tag['level'] - 3) . '<' . $tag['tag'];
if (array_key_exists('attributes', $tag)) {
foreach ($tag['attributes'] as $key => $val) {
$content .= ' ' . strtolower($key) . '="' . $val . '"';
}
}
$content .= '>' . chr(10);
}
if ($tag['type'] == 'complete') {
$content .= str_repeat(chr(9), $tag['level'] - 3) . '<' . $tag['tag'];
if (array_key_exists("attributes", $tag)) {
foreach ($tag['attributes'] as $key => $val) {
$content .= ' ' . strtolower($key) . '="' . $val . '"';
}
}
$content .= '>' . chr(10);
//content here
if (array_key_exists("attributes", $tag) && array_key_exists('ID', $tag['attributes']) && isset($targets[$tag['attributes']['ID']])) {
if ($targets[$tag['attributes']['ID']]['type'] != 'free' && $targets[$tag['attributes']['ID']]['type'] != 'richtext') {
$component = explode('/', $targets[$tag['attributes']['ID']]['type']);
// check if defined BLOCK exists ---> checking if "execute<BlockName>" method exist in <module> class
$controler = $this->getController();
if ($controler->actionExists($component[0], $component[1])) {
// render block params
if (isset($targets[$tag['attributes']['ID']]['parameters'])) {
$arr = array();
$parameters = explode(' ', $targets[$tag['attributes']['ID']]['parameters']);
foreach ($parameters as $parameter) {
$param = explode('=', $parameter);
$arr[$param[0]] = $param[1];
}
$this->getRequest()->setParameter('params', $arr);
}
$content .= $this->getPresentationFor($component[0], $component[1]);
} else {
$content .= "<br>Block '" . $component[0] . "/" . $component[1] . "' doesn't exist!<br>";
}
} else {
$freeCnt++;
$blobData = $this->pageDocument->getContent();
if (!empty($blobData)) {
//.........这里部分代码省略.........