_groupTitle = (string) $groupTitle; return $this; } public function getGroupTitle() { return $this->_groupTitle; } public function getData() { /** @var $itemObj App_Cms_Item_HtmlBlock_Obj */ $itemObj = App_Cms_Obj::getInstance()->getItemObject($this->getOption('type')); if ($this->_doc->isPagePreviewMode()) { $itemObj->setDraftPrefix('Draft'); } $itemObj->setLanguage(Qs_Constant::get('CURRENT_LANGUAGE')); $itemObj->setPrimaryKey($this->getOption('number')); $itemObj->initData(); $data = $itemObj->getData(); if (!isset($data['content']) && Qs_Constant::get('CURRENT_LANGUAGE') != Qs_Constant::get('DEFAULT_LANGUAGE')) { $itemObj->setLanguage(Qs_Constant::get('DEFAULT_LANGUAGE')) ->setPrimaryKey($this->getOption('number')) ->clearData() ->initData(); $data = $itemObj->getData(); } return $data; } public function exec() { $data = $this->getData(); if (!isset($data['content'])) { return false; } if (null !== ($placeholdersSource = $this->getConfig('placeholders'))) { if ($this->_doc->hasModulePlaceholders($placeholdersSource)) { $this->applyModulePlaceholders($data['content'], $this->_doc->getModulePlaceholders($placeholdersSource)); } else { $this->applySourcePlaceholders($data['content'], $this->getSourcePlaceholders($placeholdersSource)); } } $data['tpl'] = $this->getTemplate('view.tpl'); $this->_addItem($data); return $this; } /** * @param $placeholdersSource * @return array */ public function getSourcePlaceholders($placeholdersSource) { $separator = (false !== strpos($placeholdersSource, '\\')) ? '\\' : '_'; $placeholderSourceObj = 'App' . $separator . $placeholdersSource . 'Obj'; $placeholdersData = []; if (class_exists($placeholderSourceObj)) { /** @var Qs_Db_Obj $placeholderObj */ $placeholderObj = new $placeholderSourceObj(); if ($this->_doc->isPagePreviewMode()) { if (method_exists($placeholderObj, 'getPlaceholdersPreviewData')) { $placeholdersData = $placeholderObj->getPlaceholdersPreviewData(); } } else { $placeholdersData = $placeholderObj->getPlaceholdersData(); } } return $placeholdersData; } public function applyModulePlaceholders(&$content, array $placeholders) { if ($placeholders) { $content = Html::template($content, $placeholders); $content = Qs_String::fill($content, $placeholders); } return $this; } public function applySourcePlaceholders(&$content, array $placeholders) { if ($placeholders) { $content = str_replace(array_keys($placeholders), array_values($placeholders), $content); } return $this; } }