'image', 'linkType' => 'none', 'show' => 'y', ); public function __construct($options = array()) { parent::__construct($options); //$this->_actions[] = 'hotspot'; } public function setBannerType($type) { $this->dataObj->setType($type); return $this; } protected function _bindListColumns($list) { $list->addColumn('no', 'no', array('orderBy' => 'sorter')) //->addColumn( // 'text', // 'typeTitle', // array('title' => 'Type', 'orderBy' => 'type', 'attribs' => array('width' => 100, 'align' => 'center')) //) ->addColumn( 'image', 'image', array( 'title' => 'Banner/Background Image', 'attribs' => array('width' => 200), 'imageAttribs' => array('width' => 190, 'height' => 90), ) ) ->addColumn('text', 'title', array('title' => 'Title', 'orderBy' => 'title')) ->addColumn( 'link_enum', 'show', array( 'title' => 'Show', 'orderBy' => 'show', 'attribs' => array('width' => 60), 'values' => array('y' => 'Yes', 'n' => 'No'), ) ) ->addColumn( 'options', 'options', array( 'actions' => array( 'edit' => array(), //'hotspot' => array('title' => 'Manage hot spots'), 'delete' => array() ), 'attribs' => array('width' => 80), ) ); return $this; } protected function _bindFormFields($form) { $form->addElement('text', 'title', array('label' => 'Title', 'required' => true)); /*$type = $this->_getData('type', $this->getFormDefaults('type')); $form->addElement( 'select', 'type', array( 'label' => 'Type', 'multiOptions' => $this->dataObj->getDBannerType4Select(), 'required' => true, 'value' => $type, 'separator' => ' ', 'onchange' => "$('dl:first', this.form).attr('class', this.value);", ) );*/ $form->addElement( 'extendedImage', 'image', array('label' => 'Banner Image', 'required' => true, //(in_array($this->_action, array('new', 'edit')) || 'image' == $type), 'resize' => $this->dataObj->imageWidth . 'x' . $this->dataObj->imageHeight, ) ); $form->image->addValidator('File_IsImage'); $form->image->getValidator('File_IsImage')->setMessage( 'Uploaded file type is wrong', Zend_Validate_File_IsImage::FALSE_TYPE ); $form->addElement( 'htmlEditor', 'html', array('label' => 'Description', 'required' => true, //(in_array($this->_action, array('new', 'edit')) || 'html' == $type), 'ToolbarSet' => 'Basic', 'width' => $this->dataObj->htmlWidth, 'description' => "Allowed maximum {$this->dataObj->descriptionLengh} characters", ) ); /*$form->addElement( 'extendedImage', 'backgroundImage', array('label' => 'Background Image', 'required' => false, 'resize' => $this->dataObj->imageWidth . 'x' . $this->dataObj->imageHeight, ) );*/ /*$linkType = $this->_getData('linkType', $this->getFormDefaults('linkType')); $form->addElement( 'select', 'linkType', array( 'label' => 'Type', 'multiOptions' => array('none' => 'No Link', 'url' => 'URL', 'cms' => 'Site Page'), 'required' => true, 'value' => $linkType, 'separator' => ' ', 'onchange' => "$('#fieldset-linkTypeGroup>dl:first').attr('class', this.value);", ) ); $form->addElement('text', 'url', array('label' => 'Url', 'class' => 'text', 'validators' => array('url'))); $form->url->setDescription('Example: http://www.google.com'); if ($linkType == 'url') { $form->url->setRequired(); } $form->addElement('select', 'idPage', array('label' => 'Site Page', 'escapeLabel' => false)); $form->idPage->setMultiOptions(App_Cms_Obj::getInstance()->getParent4Select(0)); $form->addDisplayGroup( array('linkType', 'url', 'idPage'), 'linkTypeGroup', array('legend' => 'Link') ); $form->linkTypeGroup->getDecorator('HtmlTag')->setOption('class', $linkType);*/ $form->addElement('checkbox', 'show', array('label' => 'Show', 'decoration' => 'simple')); $form->addFormRule(array($this, 'validateFrom')); return $this; } public function validateFrom($data) { $errors = array(); if (!empty($data['html'])) { $length = strlen(strip_tags($data['html'])); if ($length > $this->dataObj->descriptionLengh) { $errors['html'] = "Description is to large. You entered {$length} characters"; } } return (empty($errors)) ? true : $errors; } protected function _doHotspot() { $id = (int) $_REQUEST['id']; $url = BASE_URL . '/' . CURRENT_PAGE; if ($id) { $url .= '/hotspot?idBanner=' . $id; } Qs_Http::redirect($url); } protected function _renderMainForm($form) { $this->doc->addStylesheet('css/admin-banner.css'); //$form->getDecorator('HtmlTag')->setOption('class', $form->type->getValue()); return parent::_renderMainForm($form); } }