'All Pages', App_SideBlock_Obj::PAGE_CUSTOM => 'Custom Pages' ); public static $linkTypeTitles = array( App_SideBlock_Obj::LINK_NODE => 'None', App_SideBlock_Obj::LINK_URL => 'Url', App_SideBlock_Obj::LINK_PAGE => 'Site Page', ); public static $blockTypeTitles = array( App_SideBlock_Obj::TYPE_HTML => 'Html' ); /** * Additional block handlers should implement App_SideBlock_Item_Interface * @var array Type Title => Class Name */ public static $blockTypes = array( 'html' => 'HTML', 'App_News_View' => 'News', 'App_Form_Contact_View' => 'Contact Form' ); protected $_actions = array('list'); protected $_listOptions = array('defaultOrderBy' => 'sorter', 'isDisabledLimit' => true); protected $_externalItems = array(); public function exec() { $this->dataObj->setIdPage($this->doc->getOption('id')); return parent::exec(); } protected function _addListItem(Qs_Sys_ViewController_List $list = null, $template = 'list.tpl', $returnItem = false) { if (null == $list) { $list = $this->list; } $item = $list->toArray(); $item = $this->_prepareExternalItems($item); $item['tpl'] = $this->getTemplate($template); if ($returnItem) { return (empty($item['list'])) ? null : $item; } if (!empty($item['list'])) { $this->doc->addItem($item, 'LEFT_ITEMS'); } return $this; } public function setIdPage($id) { $this->dataObj->setIdPage($id); return $this; } public function getItem() { $item = $this->_addListItem(null, 'list.tpl', true); return $item; } protected function _prepareExternalItems($item) { foreach ($item['list'] as &$block) { $blockType = $block['blockType']; if (App_SideBlock_Obj::TYPE_HTML !== $blockType && array_key_exists($blockType, App_SideBlock_View::$blockTypes) ) { $block['externalItem'] = $this->_getExternalItem($blockType); } } return $item; } protected function _getExternalItem($blockType) { if (!isset($this->_externalItems[$blockType])) { /** @var $view Qs_ViewController */ $view = new $blockType(); $view->setDoc($this->doc); $item = $view->getSideBlockItem(); $this->_externalItems[$blockType] = new Qs_Doc_Item($item); } return $this->_externalItems[$blockType]; } }