'image', 'linkType' => 'none', 'show' => 'y', ); public function __construct($options = array()) { parent::__construct($options); $this->_actions[] = 'hotspot'; } public function setSlideType($type) { $this->dataObj->setType($type); return $this; } protected function _bindListColumns($list) { $list->addColumn('no', 'no', array('orderBy' => 'sorter', 'attribs' => array('width' => '50'), ) ) ->addColumn( 'image', 'image', array('title' => 'Image', 'attribs' => array('width' => 250), 'imageAttribs'=> array('width' => 190) ) ) ->addColumn( 'text', 'title', array('title' => 'Title', 'orderBy' => 'title') ) ->addColumn( 'html', 'html', array('title' => 'Description') ) ->addColumn( 'link_enum', 'show', array( 'title' => 'Show', 'orderBy' => 'show', 'attribs' => array('width' => 60), 'values' => array('y' => 'Yes', 'n' => 'No'), ) ) ->addColumn( 'options', 'options', array( 'attribs' => array('width' => '200'), 'actions' => array( 'edit' => array(), 'hotspot' => array('title' => 'Manage hot spots'), 'delete' => array() ) ) ); 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('hidden', 'type', array('value' => 'html')); $form->addElement( 'extendedImage', 'image', array('label' => 'Image', 'required' => (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( 'extendedImage', 'backgroundImage', array('label' => 'Background Image', 'required' => true, 'resize' => $this->dataObj->imageWidth . 'x' . $this->dataObj->imageHeight, ) ); $form->backgroundImage->addValidator('File_IsImage'); $form->backgroundImage->getValidator('File_IsImage')->setMessage( 'Uploaded file type is wrong', Zend_Validate_File_IsImage::FALSE_TYPE ); $form->addElement( 'htmlEditor', 'html', array( 'label' => 'Slide Description', 'toolbarSet' => 'Basic', 'required' => (in_array($this->_action, array('new', 'edit')) || 'html' == $type), 'width' => $this->dataObj->htmlWidth, 'description' => "Allowed maximum {$this->dataObj->descriptionLengh} characters", ) ); $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 Link for Slide', 'class' => 'text', 'description' => 'Enter full URL. Example http://google.com', 'validators' => array('url') ) ); $form->addElement('text', 'linkText', array('label' => 'Link Text', 'class' => 'text')); 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', 'linkText'), '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?idSlide=' . $id; } Qs_Http::redirect($url); } protected function _renderMainForm($form) { $this->doc->addStylesheet('css/admin-slide.css'); $form->getDecorator('HtmlTag')->setOption('class', $form->type->getValue()); return parent::_renderMainForm($form); } public function getFormDefaults($field = false) { $this->_formDefaults['type'] = 'html'; return Qs_Array::get($this->_formDefaults, $field); } public function setFormDefaults($field, $value = null) { if (is_array($field)) { $this->_formDefaults = $field; } else if (is_string($field)) { Qs_Array::set($this->_formDefaults, $field, $value); } else { throw new Qs_ViewController_Exception('Invalid field type'); } return $this; } }