'sorter', 'defaultIpp' => 20); protected $_formDefaults = array( 'pageType' => App_SideBlock_Obj::PAGE_ALL, 'linkType' => App_SideBlock_Obj::LINK_NODE, 'blockType' => App_SideBlock_Obj::TYPE_HTML, 'show' => 'y' ); protected function _bindListColumns(Qs_Sys_ViewController_List $list) { $list->addColumn('no', 'no', array('orderBy' => 'sorter')) ->addColumn('text', 'title', array('orderBy' => 'title', 'title' => 'Title')) ->addColumn('block_content', 'content') ->addColumn('page_list', 'pageList', array('title' => 'Show on pages')) ->addColumn( 'link_enum', 'show', array( 'title' => 'Show', 'orderBy' => 'show', 'values' => array('y' => 'Yes', 'n' => 'No'), )) ->addColumn('options', 'options'); return $this; } protected function _bindFormFields(Qs_Form $form) { $pageType = $this->_getData('pageType', $this->getFormDefaults('pageType')); $blockType = $this->_getData('blockType', $this->getFormDefaults('blockType')); $linkType = $this->_getData('linkType', $this->getFormDefaults('linkType')); $form->addElement( 'text', 'title', array( 'label' => 'Title', 'required' => true ) ); if (App_SideBlock_View::$blockTypes) { $classList = implode(' ', array_keys(App_SideBlock_View::$blockTypes)); $form->addElement( 'select', 'blockType', array( 'label' => 'Block Type', 'multiOptions' => App_SideBlock_View::$blockTypes, 'onchange' => '$("#' . $form->getAttrib("id") . '>dl:first")' . '.removeClass("' . $classList . '")' . '.addClass(this.value);', 'required' => true, ) ); } $form->addElement( 'htmlEditor', 'content', array( 'label' => 'Content', 'required' => true, 'height' => 350 ) ); $form->addElement( 'select', 'pageType', array( 'label' => 'Show on Pages', 'multiOptions' => App_SideBlock_View::$pageTypeTitles, 'onchange' => '$("#' . $form->getAttrib("id") . '>dl:first")' . '.removeClass("' . implode(' ', array_keys(App_SideBlock_View::$pageTypeTitles)) . '")' . '.addClass(this.value);' ) ); $form->addElement( 'multiCheckbox', 'idPage', array( 'columns' => 5, 'multiOptions' => $this->dataObj->getSitePages() ) ); if ($blockType !== App_SideBlock_Obj::TYPE_HTML) { $form->getElement('content')->setRequired(false); } if ($pageType == App_SideBlock_Obj::PAGE_CUSTOM) { $form->getElement('idPage')->setRequired(); } $form->addElement( 'select', 'linkType', array( 'label' => 'Link Type', 'multiOptions' => App_SideBlock_View::$linkTypeTitles, 'onchange' => '$("#' . $form->getAttrib("id") . '>dl:first")' . '.removeClass("' . implode(' ', array_keys(App_SideBlock_View::$linkTypeTitles)) . '")' . '.addClass(this.value);' ) ); $form->addElement( 'text', 'linkTitle', array( 'label' => 'Link Title', 'maxlength' => 255, 'required' => (App_SideBlock_Obj::LINK_NODE != $linkType), ) ); $form->addElement( 'select', 'linkPageId', array( 'label' => 'Site Page', 'escapeLabel' => false, 'required' => (App_SideBlock_Obj::LINK_PAGE == $linkType), 'multiOptions' => array('0' => '- Select Page -') + App_Cms_Obj::getInstance()->getPages4Select(0, 0) ) ); $form->addElement( 'text', 'linkUrl', array( 'label' => 'Url', 'required' => (App_SideBlock_Obj::LINK_URL == $linkType), 'description' => 'Example: http://www.adaptainc.com', 'maxlength' => 255, 'filters' => array('StringTrim'), 'validators' => array('Url') ) ); $form->addElement( 'checkbox', 'show', array( 'label' => 'Show on the user side', 'decoration' => 'simple', ) ); $form->getElement('linkTitle')->getDecorator('label')->setOption('class', 'required'); $form->getElement('linkPageId')->getDecorator('label')->setOption('class', 'required'); $form->getElement('linkUrl')->getDecorator('label')->setOption('class', 'required'); $form->getDecorator('HtmlTag')->setOption( 'class', 'SideBlock-form_elements '. $pageType . ' ' . $blockType . ' ' . $linkType ); $form->addFormRule(array($this, 'validateForm')); return $this; } public function validateForm($data) { $errors = array(); $blockType = Qs_Array::get($data, 'blockType'); $id = Qs_Array::get($data, 'id'); if (null !== $blockType && App_SideBlock_Obj::TYPE_HTML !== $blockType && 0 < $this->dataObj->getBlockCountByType($blockType, $id) ) { $errors['blockType'] = Qs_Array::get(App_SideBlock_View::$blockTypeTitles, $blockType, 'Block') . ' already added'; } return (empty($errors)) ? true : $errors; } }