_mode) { $this->_mode = 'edit'; } return $this->_mode; } public function setMode($mode) { $this->_mode = $mode; } public function setViewController($viewController) { $this->_viewController = $viewController; } public function getViewController() { return $this->_viewController; } public function setLanguage($language) { $this->_language = $language; return $this; } public function setDoc($doc) { $this->_doc = $doc; return $this; } public function getLanguage() { return $this->_language; } public function isDefaultLanguage() { return $this->_language === Qs_Constant::get('DEFAULT_LANGUAGE'); } public function init() { parent::init(); $this->setLegend('Meta'); $this->addElement('hidden', 'id'); if ($this->isDefaultLanguage()) { //$this->addElement('select', 'idParent', array('label' => 'Parent Page', 'escapeLabel' => false)); $this->addElement('hidden', 'idParent'); $this->addElement( 'text', 'alias', array('label' => 'Alias', 'required' => true, 'description' => 'Allowed characters: a-z, A-Z, 0-9, "-", "_", "."') ); $this->alias->addValidator( 'Regex', false, array('pattern' => '/^[-_a-zA-Z0-9\.]+$/', 'messages' => array( Zend_Validate_Regex::NOT_MATCH => 'You have used unallowed symbols. Please note: ' . 'the allowed ones are a -z, A-Z, 0-9, "-", "_", "."')) ); $this->_addOptionCheckbox('showInSiteMap', 'Show in Sitemap'); $this->_addOptionCheckbox('showInMenu', 'Show in Menu'); if ($this->_doc->getAuth()->getSuMode()) { $this->addElement('select', 'handler', array('label' => 'Handler', 'required' => true)); $this->_addOptionCheckbox('allowDelete', 'Allow delete'); $this->_addOptionCheckbox('isSecure', 'Secure page'); $this->_addOptionCheckbox('isIndexing', 'Include this page in search results'); $this->_addOptionCheckbox('final', 'Final page'); $this->_addOptionCheckbox('system', 'System (hidden in admin end)'); $this->addElement('select', 'bodyTemplate', array('label' => 'Body Template')); } else { $this->addElement('hidden', 'handler'); } } if (!empty($this->_optionsElements)) { $this->addDisplayGroup( $this->_optionsElements, 'optionsGroup', array( 'legend' => 'Options', ) ); $this->optionsGroup->removeDecorator('HtmlTag'); } $this->addElement('text', 'title', array('label' => 'Title', 'required' => true)); $this->addElement('text', 'header', array('label' => 'Header')); $this->addElement('text', 'menuTitle', array('label' => 'Menu Title')); $this->addElement('textarea', 'introduction', array('label' => 'Page Introduction', 'attribs' => array('rows' => 5))); $this->addElement('textarea', 'keywords', array('label' => 'Keywords', 'attribs' => array('rows' => 2))); $this->addElement('textarea', 'description', array('label' => 'Description', 'attribs' => array('rows' => 2))); $this->addElement('button', 'save', array('label' => 'Save', 'decorators' => array('ViewHelper', 'HtmlTag'))); $this->addElement('button', 'cancel', array('label' => 'Cancel', 'decorators' => array('ViewHelper', 'HtmlTag'))); $this->addElement('button', 'edit', array('label' => 'Edit', 'decorators' => array('ViewHelper', 'HtmlTag'))); $this->addDisplayGroup( array('save', 'cancel', 'edit'), 'meta_toolbar', array( 'decorators' => array( 'FormElements', array( 'decorator' => 'HtmlTag', 'options' => array('tag' => 'dd', 'class' => 'meta_toolbar') ) ) ) ); } protected function _addOptionCheckbox($name, $label) { $this->addElement( 'checkbox', $name, array( 'label' => $label, 'checkedValue' => 'y', 'uncheckedValue' => 'n', 'decorators' => array( array('decorator' => 'ViewHelper', 'options' => array('separator' => '
')), array('decorator' => 'Label', 'options' => array('placement' => 'APPEND')) ) ) ); if (empty($this->_optionsElements)) { $this->$name->getDecorator('ViewHelper')->setOption('separator', null); } $this->_optionsElements[] = $name; } public function beforeRender() { $mode = $this->getMode(); switch ($mode) { case 'view': $this->getDecorator('HtmlTag')->setOption('class', 'meta view_mode'); break; default: break; } } public function render(Zend_View_Interface $view = null) { $this->beforeRender(); return parent::render($view); } public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('FormElements') ->addDecorator('HtmlTag', array('tag' => 'dl')) ->addDecorator('Fieldset'); } } public function addElement($element, $name = null, $options = null) { $hiddenFields = $this->_viewController->getConfig('hiddenFields'); if (is_array($hiddenFields) && in_array($name, $hiddenFields)) { return $this; } parent::addElement($element, $name, $options); } }