getRestAlias())) { $language = Qs_Constant::get('CURRENT_LANGUAGE'); } $this->dataObj->setLanguage($language); $this->dataObj->idParent = intval(Qs_Request::getRequestValue('idParent')); if ($this->doc->getAuth()->getSuMode()) { $this->dataObj->setSuMode(); } else { $this->dataObj->addFilter(array('system' => 'n')); } $this->dataObj->setRedirection($this->getConfig('hasRedirection', false)); return $this; } public function getConfig($field = false, $default = null) { if (null === $this->_config) { $this->_config = Zend_Registry::get('config')->app->cms->toArray(); if ($this->doc->getAuth()->getSuMode()) { $this->_config['mode'] = 'advanced'; } $modeConfig = $this->_config['modes'][$this->_config['mode']]; unset($this->_config['modes']); $this->_config = array_merge($this->_config, $modeConfig); } return Qs_Array::get($this->_config, $field, $default); } protected function _doNew() { if (!$this->dataObj->isDefaultLanguage()) { Qs_Http::redirect(Qs_Request::getFinalUrl()); } $defaults = array('meta' => array(), 'options' => array()); if (isset($_REQUEST['idParent'])) { $defaults['meta']['idParent'] = intval($_REQUEST['idParent']); } if (true === $this->getConfig('additionalPages') && !$this->doc->getAuth()->getSuMode()) { if (!isset($_REQUEST['idParent']) || 0 == $_REQUEST['idParent']) { $defaults['options']['isAdditional'] = array( 'name' => 'isAdditional', 'show' => 'n', 'value' => 'y', ); $defaults['options']['showInMenu'] = array( 'name' => 'showInMenu', 'show' => 'n', 'value' => 'n', ); if (Qs_Version::compareVersion('2.3.0') <= 0) { $defaults['options']['showInFooter'] = array( 'name' => 'showInFooter', 'show' => 'n', 'value' => 'n', ); } } else { $options = $this->dataObj->getMetaOptions(intval($_REQUEST['idParent']), false, true); if (is_array($options['isAdditional'])) { $defaults['options']['isAdditional'] = $options['isAdditional']; if ('y' == $options['isAdditional']['value']) { $defaults['options']['showInMenu'] = array( 'name' => 'showInMenu', 'show' => 'n', 'value' => 'n', ); } } } } $id = $this->dataObj->insertDefaultPage($defaults); Qs_Http::redirect($this->url(array('action' => 'edit', 'id' => $id))); } protected function _doEdit() { if (!$this->dataObj->draftExists()) { try { $this->dataObj->createDraft(); } catch (App_Cms_Exception $e) { $this->_doc->displayError($e->getMessage()); return $this; } } if (!$this->dataObj->draftPageOptionExists()) { try { $this->dataObj->createPageOptionDraft(); } catch (App_Cms_Exception $e) { $this->_doc->displayError($e->getMessage()); return $this; } } $data = $this->dataObj->getDraftFromDb($this->dataObj->getPrimaryKey()); if (empty($data)) { $this->_setBackError('Invalid Page ID'); $this->_doBack(); } $form = $this->_getEditForm(); if (!empty($data['meta']['alias']) && !empty($data['meta']['title'])) { $form->meta->setMode('view'); } $form->setDefaults($data); $this->_renderMainForm($form); return $this; } protected function _getBaseForm() { $form = parent::_getBaseForm(); $form->setAjaxValidation(false); return $form; } protected function _getMetaSubForm() { $idPage = (int) Qs_Request::getRequestValue('id', $this->dataObj->getPrimaryKey()); $meta = new App_Cms_Form_SubForm_Meta(array( 'language' => $this->dataObj->getLanguage(), 'doc' => $this->_doc, 'viewController' => $this, 'metaOptions' => $this->dataObj->getDraftMetaOptions($idPage), 'isCustomOptions' => $this->dataObj->isCustomOptions(), 'isRedirectFields' => $this->dataObj->isRedirectFields(), )); if ($meta->idParent) { if ($meta->idParent instanceOf Zend_Form_Element_Select) { $meta->idParent->setMultiOptions(array(0 => 'Root') + (array)$this->dataObj->getParent4Select()); } $aliasUniqueValidator = new Qs_Validate_Unique($this->dataObj->table, 'alias', $this->dataObj->getPrimaryKey()); $aliasUniqueValidator->setWhere('idParent = ' . (int) $this->dataObj->idParent); $aliasUniqueValidator->setMessage('Alias must be unique', 'notUnique'); $meta->alias->addValidator($aliasUniqueValidator, true); $meta->addElementPrefixPath('App_Cms_Validate', 'App/Cms/Validate', 'validate'); if (Qs_Request::isXmlHttpRequest()) { $idParent = $this->_getData('idParent'); } else { $idParent = $this->_getData('meta[idParent]'); } $parentAlias = Qs_SiteMap::findFirst(array('id' => $idParent), null, null, 'fullAlias'); $meta->alias->addValidator('XmlAliasUnique', true, array('parentAlias' => $parentAlias)); } if ($meta->handler && $meta->handler instanceof Zend_Form_Element_Select) { $meta->handler->setMultiOptions($this->dataObj->getDPageHandler4Select()); } if ($meta->bodyTemplate) { if (Qs_Request::isXmlHttpRequest()) { $handler = $this->_getData('handler'); } else { $handler = $this->_getData('meta[handler]'); } $meta->bodyTemplate->setMultiOptions($this->getBodyTemplate4Select($handler)); } if (null !== ($element = $meta->getElement('redirectPageId'))) { /** @var Zend_Form_Element_Select $element */ $element->addMultiOptions($this->dataObj->getPages4Select()); } return $meta; } public function getBodyTemplate4Select($handler = 'site') { $handlerClass = 'App_Doc_' . ucfirst($handler); $handlerFile = BASE_PATH . '/App/Doc/' . ucfirst($handler) . '.php'; if (!file_exists($handlerFile)) { throw new App_Cms_Exception('Handler file not found: ' . $handlerFile); } $handlerObj = new $handlerClass(array('authentication' => false)); $paths = $handlerObj->getTemplatePath(); unset($handlerObj); $files = array(); foreach ($paths as $path) { $dir = BASE_PATH . '/tpl/' . $path . '/Body'; if (file_exists($dir) && is_dir($dir)) { $pattern = $dir . '/*.tpl'; $_files = glob($pattern); $files = array_merge($files, $_files); } $dir = BASE_PATH . '/tpl/_sys/' . $path . '/Body'; if (file_exists($dir) && is_dir($dir)) { $pattern = $dir . '/*.tpl'; $_files = glob($pattern); $files = array_merge($files, $_files); } } $templates = array(); foreach ($files as $file) { $templates[basename($file)] = basename($file); } return $templates; } protected function _bindItems(Qs_Form $form) { $data = $this->dataObj->getDraftData(); $itemGroupNames = $this->dataObj->getItemGroupNames(); foreach ($itemGroupNames as $groupName => $groupTitle) { if (!isset($data[$groupName])) { continue; } $pageItems = $data[$groupName]; $this->_filterItems($pageItems); if (empty($pageItems)) { continue; } $decoratorFieldset = array('decorator' => 'Fieldset', 'options' => array('class' => 'cms_item_group')); $options = array('decorators' => array('FormElements', $decoratorFieldset)); $items = new Qs_Form_SubForm($options); $items->setLegend($groupTitle); foreach ($pageItems as $index => $item) { $itemSubForm = $this->_getItemSubForm($item); $items->addSubForm($itemSubForm, $index); } $form->addSubForm($items, $groupName); } return $this; } protected function _filterItems(&$items) { $filter = $this->getConfig('item[filter]'); if (empty($filter)) { return false; } foreach ($items as $index => $data) { foreach ($filter as $field => $value) { if (!array_key_exists($field, $data)) { unset($items[$index]); continue; } if (is_array($value)) { if (!in_array($data[$field], $value)) { unset($items[$index]); continue; } } else { if ($data[$field] != $value) { unset($items[$index]); continue; } } } } return $this; } protected function _getItemView($item) { if (!array_key_exists($item['id'], $this->_itemView)) { $class = 'App_' . $item['type'] . 'View'; $file = BASE_PATH . '/' . str_replace('_', '/', $class) . '.php'; if (file_exists($file)) { $itemObj = new $class($item); $itemObj->setDoc($this->doc); $this->_itemView[$item['id']] = $itemObj; } else { $this->_itemView[$item['id']] = null; } } return $this->_itemView[$item['id']]; } protected function _getItemSubForm($item) { $type = rtrim($item['type'], '_'); $file = Qs_Constant::get('BASE_PATH') . '/App/Cms/Form/SubForm/Item' . $type . '.php'; $class = 'App_Cms_Form_SubForm_Item' . $type; $options = array( 'groupName' => $item['groupName'], 'itemId' => $item['id'], 'type' => $item['type'], 'legend' => $this->dataObj->getItemTypeTitle($item['type']) ); if (file_exists($file)) { $itemSubForm = new $class($options); } else { $itemSubForm = new App_Cms_Form_SubForm_Item($options); } $itemSubForm->setMode('view'); $itemObj = $this->_getItemView($item); if (null !== $itemObj && $itemObj->hasConfigForm()) { $configForm = new Qs_Form_SubForm(); $configForm->getDecorator('DtDdWrapper')->setDdAttrib('class', 'noMargin item_config'); $configForm->setLegend('Config'); $configForm->setAttrib('id', $item['groupName'] . '-i' . $item['id'] . '-config'); $itemObj->fillConfigForm($configForm); $itemSubForm->addElement('html', 'view'); $itemSubForm->addSubForm($configForm, 'config'); } return $itemSubForm; } protected function _bindFormFields(Qs_Form $form) { $languages = $this->dataObj->getLanguages(); if (count($languages) > 1) { $decorators = array('ViewHelper'); $elements = array(); foreach ($languages as $language) { $elements[] = $language['name']; $options = array( 'value' => $language['shortTitle'], 'decorators' => $decorators ); if ($language['name'] == $this->dataObj->getLanguage()) { $options['class'] = 'current'; $options['disabled'] = 'disabled'; } $options['id'] = 'lng-' . $language['name']; $form->addElement('button', $language['name'], $options); } $form->addDisplayGroup($elements, 'languageGroup', array('disableLoadDefaultDecorators' => true)); $form->languageGroup->addDecorator('FormElements') ->addDecorator('Fieldset'); } $meta = $this->_getMetaSubForm(); $form->addSubForm($meta, 'meta'); $this->_bindItems($form); if (Qs_Version::compareVersion('2.3.0') >= 0) { $config = $this->getConfig(); if ($config['hasHeaderImage'] && !in_array($this->dataObj->getPrimaryKey(), App_Cms_Obj::getImageHeaderExcludePageIds()) ) { $resize = $config['headerImageWidth'] . 'x' . $config['headerImageHeight'] . Qs_ImageFs::getResizeMethodAlias($config['headerImageResizeMethod']); $form->addElement( 'extendedImage', 'headerImage', array( 'label' => 'Header Image', 'resize' => $resize, 'required' => (bool) $config['headerImageIsRequired'], ) ); } } return $this; } protected function _getEditForm() { $form = $this->_getBaseForm(); $this->_bindFormFields($form); $this->_bindFormButtons($form); $form->addElement('hidden', 'action', array('value' => 'publish', 'decorators' => array('ViewHelper'))); $form->getDecorator('HtmlTag')->setOption('tag', 'div'); return $form; } protected function _bindFormButtons(Qs_Form $form) { $url = $this->url(array('action' => 'cancel', 'id' => $this->dataObj->getPrimaryKey())); $form->setCancelUrl($url); $form->addElement('submit', 'btnSubmit', array( 'label' => 'Publish', 'attribs' => array('class' => 'btn'), 'decorators' => array('ViewHelper') ) ); $form->btnSubmit->getDecorator('ViewHelper')->setAdditionalHtmlAfterElement('  '); $form->addElement('button', 'btnCancel', array( 'label' => 'Cancel All Changes', 'attribs' => array( 'class' => 'btn', 'onclick' => "if (confirm('{$this->getCancelMessage()}')) " . "document.location = '" . htmlspecialchars($form->getCancelUrl()) . "';" ), 'decorators' => array('ViewHelper') ) ); $form->addDisplayGroup(array('btnSubmit', 'btnCancel'), 'submitGroup', array( 'decorators' => array( 'FormElements', array('decorator' => 'HtmlTag'), 'Fieldset' ) ) ); return $this; } protected function _getFilteredHtmlBlockViewContent($content) { if (empty($content)) { return $content; } $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); $dom = new Zend_Dom_Query(); $dom->setDocumentHtml($content); $results = $dom->query('form'); foreach ($results as $tag) { foreach (array('action', 'autocomplete', 'enctype', 'method', 'name', 'target') as $attribute) { $tag->removeAttribute($attribute); } } $document = new DOMDocument(); $body = $results->getDocument()->documentElement->firstChild; for ($i = 0; $i < $body->childNodes->length; $i++) { $document->appendChild($document->importNode($body->childNodes->item($i), true)); } $content = $document->saveHtml(); $content = str_replace(array(''), array(''), $content); return $content; } protected function _renderMainForm(Qs_Form $form) { $options = array('id_form' => $form->getId()); $itemGroups = $this->dataObj->getItemGroupNames(); foreach ($itemGroups as $groupName => $groupTitle) { if ($itemSubGroup = $form->getSubForm($groupName)) { // init block options (view forms) foreach ($itemSubGroup as $index => $itemForm) { if (($configForm = $itemForm->getSubForm('config'))) { $configVeiwForm = clone $configForm; $configVeiwForm->getDecorator('DtDdWrapper')->setDdAttrib('class', 'noMargin item_config_view'); $item = $this->dataObj->getDraftData("{$groupName}[{$index}]"); $itemObj = $this->_getItemView($item); $html = $itemObj->renderConfigForm($configVeiwForm); $itemForm->view->setValue($html); } } // end of init block options (view forms) // replace form tag to div tag in all html blocks foreach ($itemSubGroup->getSubforms() as $itemSubForm) { if (! ($itemSubForm instanceof App_Cms_Form_SubForm_ItemHtmlBlock)) { continue; } $content = $this->_getFilteredHtmlBlockViewContent($itemSubForm->data->content->getValue()); $itemSubForm->data->content->setValue($content); } // end replace form tag to div tag in all html blocks $order = $itemSubGroup->getElementsOrder(); $order = array_keys($order); foreach ($order as $k => &$v) { $v = intval(str_replace('i', '', $v)); } $options['order_' . $groupName] = $order; } } $options['meta'] = array(); $options['metaMode'] = $form->meta->getMode(); $options['items'] = $this->_getItems($form); $options['config'] = $this->getConfig(); $options['su'] = $this->doc->getAuth()->getSuMode(); $options['languages'] = $this->dataObj->getLanguageNames(); $this->doc->addInitFunction('initCmsForm', array($options)); $this->doc->addScript('js/jquery.scrollTo.js'); $this->doc->addScript('js/lib/form.js'); $this->doc->addScript('js/lib/cms.js'); $this->doc->addScript('js/fckeditor/fckeditor.js'); $this->doc->addScript('js/jquery-ui.js'); $this->doc->addStylesheet('css/jquery-ui.css'); return parent::_renderMainForm($form); } protected function _getItemActions($item, Qs_Form $form) { $actions = array(); if (($form->{$item['groupName']} && $form->{$item['groupName']}->{'i' . $item['id']} && $form->{$item['groupName']}->{'i' . $item['id']}->config) || $this->doc->getAuth()->getSuMode() || $item['type'] == 'HtmlBlock_' ) { $actions[] = 'edit'; $actions[] = 'save'; $actions[] = 'cancel'; } $actions[] = 'moveUp'; $actions[] = 'moveDown'; if ($this->doc->getAuth()->getSuMode() || ($this->getConfig('item[allowDelete]') && $item['allowDelete'] == 'y') ) { $actions[] = 'delete'; } return $actions; } protected function _getItems(Qs_Form $form) { if (empty($this->_items)) { $this->_items = array(); $_items = $this->dataObj->getItemsList($this->dataObj->getPrimaryKey(), true); $_item = array_fill_keys(array('id', 'type', 'groupName', 'allowDelete'), ''); foreach ($_items as $data) { $item = array_intersect_key($data, $_item); if (!$form->{$item['groupName']} || !$form->{$item['groupName']}->{'i' . $item['id']}) { continue; } $item['actions'] = $this->_getItemActions($data, $form); $item['mode'] = $form->{$item['groupName']}->{'i' . $item['id']}->getMode(); $this->_items[] = $item; } } return $this->_items; } protected function _doUpdateMetaAjax() { $meta = $this->_getMetaSubForm(); $result = array(); if ($meta->validate()) { $data = $meta->getValues(true); $this->dataObj->updateDraftMeta($data); } else { $result['errors'] = $meta->getMessages(null, true); } $this->_displayJson($result); } protected function _doUpdateItemAjax() { $item = Qs_Request::getPost(); unset($item['action']); $item['id'] = $item['idItem']; $itemSubForm = $this->_getItemSubForm($item); $result = array('isValid' => true); if ($configForm = $itemSubForm->getSubForm('config')) { $configVeiwForm = clone $configForm; $configVeiwForm->getDecorator('DtDdWrapper')->setDdAttrib('class', 'noMargin item_config_view'); $result = $this->_getValidateResult($configVeiwForm); if (!$result['isValid']) { $this->_displayJson($result); } else { $result['viewHtml'] = $this->_getItemView($item)->renderConfigForm($configVeiwForm); } } if ($itemSubForm instanceof App_Cms_Form_SubForm_ItemHtmlBlock) { $result['contentViewHtml'] = $this->_getFilteredHtmlBlockViewContent(Qs_Array::get($item, 'data[content]')); } $this->dataObj->updateDraftItem($item['idItem'], $item['type'], $item); $this->_displayJson($result); } protected function _doLoadDialogItemTypeAjax() { $item = array(); $item['typeOptions'] = $this->dataObj->getDItemType4Select(); $item['groupNameOptions'] = $this->dataObj->getItemGroupNames(); $this->_doc->assign('item', new Qs_Doc_Item($item)); $this->_doc->setLayoutTemplate($this->getTemplate('Dialog/item-type.tpl')); echo $this->_doc->fetch(); exit; } protected function _doAddItemAjax() { $id = (int)Qs_Request::getPostValue('id'); $groupName = Qs_Request::getPostValue('groupName'); $renderGroup = (bool)Qs_Request::getPostValue('renderGroup'); $type = Qs_Request::getPostValue('type'); $itemData = array('idPage' => $id, 'type' => $type); if (!($itemData['idGroup'] = $this->dataObj->getGroupIdByName($groupName))) { $itemData['idGroup'] = 1; } $idItem = $this->dataObj->insertDraftItem($itemData); $data = $this->dataObj->getDraftItem($idItem); $this->dataObj->initDraftData(); $form = $this->_getEditForm(); $result = array('idItem' => $idItem); $result['actions'] = $this->_getItemActions($data, $form); if (in_array('edit', $result['actions'])) { $result['mode'] = 'edit'; } $this->doc->clearScripts(); $this->doc->clearStylesheets(); $this->doc->clearInlineScripts(); $this->doc->clearInitFunctions(); if ($renderGroup) { if ($subFormItemsGroup = $form->getSubForm($groupName)) { $subFormItemsGroup->setView(Qs_View::getInstance()); $result['html'] = $subFormItemsGroup->render(); } } else { if (isset($form->$groupName) && isset($form->$groupName->{"i{$idItem}"})) { $subFormItem = $form->$groupName->{"i{$idItem}"}; } else { $subFormItem = $this->_getItemSubForm(array('type' => $type, 'groupName' => $groupName, 'id' => $idItem)); } $subFormItem->setDefaults($data); $subFormItem->setAttrib('id', 'i' . $idItem); $subFormItem->setElementsBelongTo($groupName . '[i' . $idItem . ']'); $subFormItem->setView(Qs_View::getInstance()); $result['html'] = $subFormItem->render(); } $result['javascript'] = $this->_getItemJavaScript(); $this->_displayJson($result); } protected function _getItemJavaScript() { $script = ''; $head = $this->doc->getTemplateVariable('head'); foreach($head['link'] as $file) { $script .= "\$.getCSS('{$file['href']}');\n"; } if (!empty($head['script'])) { $script .= "\$.ajaxSetup({async: false});\n"; foreach ($head['script'] as $file) { $script .= "\$.getScript('{$file['src']}');\n"; } $script .= "\$.ajaxSetup({async: true});\n"; } foreach ($head['inlineScript'] as $inlineScript) { $script .= "{$inlineScript}\n"; } foreach ($head['initFunctions'] as $function) { $script .= "{$function['name']}.apply(this, {$function['encodedParams']});\n"; } return $script; } protected function _doDeleteItemAjax() { $idItem = (int)Qs_Request::getPostValue('idItem'); $this->dataObj->deleteDraftItem($idItem); die('{}'); } protected function _doReorderItemsAjax() { $id = (int)Qs_Request::getPostValue('id'); $groupName = Qs_Request::getPostValue('groupName'); $order = Qs_Request::getPostValue('order'); $this->dataObj->reorderDraftItemsGroup($order); asort($order); $result = array( 'groupName' => $groupName, 'order' => array_keys($order) ); $this->_displayJson($result); } public function getCancelMessage() { return $this->_cancelMessage; } public function setCancelMessage($message) { $this->_cancelMessage = $message; return $this; } protected function _handleFiles(Qs_Form $form) { $data = array(); foreach ($this->dataObj->getFileFields() as $fieldName) { if (($value = $form->getValue($fieldName))) { $data[$fieldName] = $value; } else if (Qs_Request::getPostValue($fieldName . '[del]') == 'on') { $data[$fieldName] = null; $adapter = new Qs_File_Transfer_Adapter_Db(); $adapter->delete(Qs_Request::getPostValue($fieldName . '[oldFile]')); unset($adapter); } } if (!empty($data)) { $this->dataObj->updateDraftMeta($data); } return $this; } protected function _doPublish() { $this->dataObj->setPrimaryKey(Qs_Request::getRequestValue('meta[id]')); $this->dataObj->initDraftData(); $data = $this->dataObj->getData(); if (empty($data)) { $this->_setBackError('The page draft you edited has been already published. ' . 'You changes are not applied. ' . 'Try again.'); $this->_doBack(); } $post = Qs_Request::getPost(); unset($post['meta'], $post['ITEMS']); // мета та айтеми зберігаються аяксьм і при публікуванні вже збережені $data = array_merge($data, $post); $this->dataObj->setPrimaryKey($data['meta']['id']); $this->dataObj->idParent = (int) $data['meta']['idParent']; $form = $this->_getEditForm(); if ($form->validate($data)) { $this->_handleFiles($form); $this->dataObj->publish(); $this->dataObj->deleteDraft(); $this->_doBack(); } else { $messages = $form->getMessages(); if (array_key_exists('meta', $messages)) { $form->meta->setMode('edit'); } else { $form->meta->setMode('view'); } foreach ($messages as $groupName => $groupItems) { if ($groupName == 'meta') { continue; } if (!$form->{$groupName}) { continue; } $items = array_keys($groupItems); foreach ($items as $item) { if (!$form->{$groupName}->{$item}) { continue; } $form->{$groupName}->{$item}->setMode('edit'); } } $this->_renderMainForm($form); } return $this; } protected function _doCancel() { $this->dataObj->deleteDraft(); $meta = $this->dataObj->getMeta($this->dataObj->getPrimaryKey()); if (null == $meta['alias']) { $this->dataObj->delete(); } $this->_doBack(); } protected function _doDelete() { $this->dataObj->deleteDraft(); $this->dataObj->delete(); $this->_setBackMessage($this->dataObj->itemName.' has been deleted'); $this->_doBack(); } protected function _doShowSiteMap() { $this->_addLinksItem(); $item = array(); $options = array(); if (true === $this->getConfig('additionalPages')) { $item['additionalPages'] = true; $options = array('select' => $this->dataObj->getAdditionalSelect4SiteMap()); } $item['siteMap'] = $this->dataObj->getSiteMap($options); App_Sitemap_Virtual::prepare($item['siteMap']); $item['siteMapPagesCount'] = $this->dataObj->getSiteMapPageCount($item['siteMap']); $item['tpl'] = $this->getTemplate('sitemap.tpl'); $this->_addItem($item); return $this; } protected function _getReorderForm(array $options = array()) { $form = $this->_getBaseForm(); $form->setAjaxValidation(false); if (true === $this->getConfig('additionalPages') && isset($_REQUEST['isAdditional'])) { $isAdditional = true; } else { $isAdditional = false; } $options = $this->dataObj->getReorderOptions( $this->getReorderValueColumn(), $this->getReorderTitleColumn(), $isAdditional ); $form->addElement('select', 'order', array( 'helper' => 'formOrderSelect', 'label' => 'Reorder ' . $this->dataObj->itemsName, 'class' => 'order_select', 'size' => 10, 'multiple' => true, 'multiOptions' => $options ) ); $form->addElement('hidden', 'action', array('value' => 'updateOrder')); $form->addElement('hidden', 'idParent', array('value' => $this->dataObj->idParent)); parent::_bindFormButtons($form); return $form; } protected function _getDefaultLinks() { $links = array(); if ($this->getConfig('allowAddTopLevelPage') || $this->doc->getAuth()->getSuMode()) { $links['new'] = 'Add top-level ' . $this->dataObj->itemName; } if ($this->getConfig('allowReorderTopLevelPages') || $this->doc->getAuth()->getSuMode()) { $links['reorder'] = 'Reorder top-level ' . $this->dataObj->itemsName; } return $links; } protected function _addGoogleAnalyticsLinkItem() { $url = Zend_Registry::get('config')->app->cms->analytics->url; $code = App_Settings_Obj::get('analyticsCode'); if (!empty($code) && !empty($url)) { $idContainer = $this->_getIdContainer(); $idContainer .= '-google-analytics'; $links = array( array( 'title' => 'Launch Google Analytics', 'attribs' => array('target' => '_blank'), 'url' => $url, ) ); parent::_addLinksItem($idContainer, $links); } return $this; } protected function _addLinksItem($idContainer = null, array $links = null) { parent::_addLinksItem($idContainer, $links); if (Qs_Version::compareVersion('2.2.0') <= 0) { $this->_addGoogleAnalyticsLinkItem(); } return $this; } protected function _doCheckContentTranslation() { $this->_addLinks(array('back' => 'Show Site Map')); $item = array( 'links' => $this->_getLinks(), 'siteMap' => $this->dataObj->getNotTranslatedPages(), 'languages' => Qs_Array::exclude(Qs_Db_Language::getList(), DEFAULT_LANGUAGE), 'tpl' => $this->getTemplate('ContentTranslation/sitemap.tpl') ); $item['siteMapPagesCount'] = $this->dataObj->getSiteMapPageCount($item['siteMap']); $this->_addItem($item); return $this; } protected function _getData($field = false, $default = null, $method = 'POST') { if ($_SERVER['REQUEST_METHOD'] == strtoupper($method)) { if (false === $field) { return $_POST; } return Qs_Request::getPostValue($field, $default); } $key = $this->dataObj->getPrimaryKey(); if (empty($key)) { return $default; } return $this->dataObj->getDraftData($field); } protected function _doGetBodyTemplatesAjax() { $handler = Qs_Request::getRequestValue('handler'); $options = $this->getBodyTemplate4Select($handler); $this->_displayJson(array('options' => $options)); } protected function _doGetHtmlBlockContentAjax() { $idItem = Qs_Request::getRequestValue('idItem'); $item = $this->dataObj->getDraftItem($idItem); die(Qs_Array::get($item, 'data[content]')); } }