_messageTemplates[self::MSG_SELECT_PAGE] = 'Please select one of the pages in the "Search" dropdown ' . 'above to reorder its %itemsName%.'; return parent::_init(); } protected function _initAction() { parent::_initAction(); if ('reorder' === $this->_action || 'updateOrder' === $this->_action) { if (($idPage = Qs_Request::getGetValue('idPage'))) { $this->_getDataObj()->addFilter(array('idPage' => (int) $idPage)); } else { $this->_doc->display404(); } } return $this; } protected function _addListItem() { if (($idPage = $this->_getDataObj()->getFilter('idPage'))) { $this->_getList()->setOption('orderBy', 'sorter'); } $this->_doc->addScript('js/jquery.toggleItems.js') ->addReadyFunction('$("div.pageList").toggleItems'); return parent::_addListItem(); } protected function _getDefaultLinks() { $links = parent::_getDefaultLinks(); $this->_prepareReorderLink($links); return $links; } protected function _prepareReorderLink(array &$links) { $links['reorder'] = array('title' => 'Reorder ' . $this->getConfig('itemsName')); if (($idPage = $this->_getDataObj()->getFilter('idPage'))) { $links['reorder']['url'] = $this->url(array( 'action' => 'reorder', 'idPage' => (int) $idPage )); } else { $msg = htmlentities($this->_createMessage(self::MSG_SELECT_PAGE)); $links['reorder']['attribs'] = array( 'class' => 'warning', 'onclick' => "alert('{$msg}'); return false;" ); $links['reorder']['url'] = '#'; } return $links; } protected function _getReorderForm(array $options = array()) { $form = parent::_getReorderForm($options); if (($idPage = $this->_getDataObj()->getFilter('idPage'))) { $form->setAction($this->url(array('action' => 'updateOrder', 'idPage' => $idPage))); } return $form; } protected function _initFromForm(Qs_Form $form) { $data = $form->getValues(); if ('html' != $data['blockType']) { $data['content'] = ''; } switch ($data['linkType']) { case 'url': $data['linkPageId'] = ''; break; case 'page': $data['linkUrl'] = ''; break; default: $data['linkUrl'] = ''; $data['linkPageId'] = ''; $data['linkTitle'] = ''; break; } $this->_getDataObj()->initFromForm($data); return $this; } }