'image', 'show' => 'y', 'type' => 'image', ); public function setSlideType($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' => 250), '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(), 'delete' => array() ) ) ); return $this; } protected function _bindFormFields($form) { $form->addElement('text', 'title', array('label' => 'Title', 'required' => true)); $type = $this->_getData('type', $this->getFormDefaults('type')); if ('edit' == $this->_action) { $form->addElement('hidden','type'); } else { $form->addElement( 'select', 'type', array( 'label' => 'Type', 'multiOptions' => $this->dataObj->getDSlideType4Select(), 'required' => true, 'separator' => ' ', 'onchange' => "$('dl:first', this.form).attr('class', this.value);", ) ); } $form->addElement( 'htmlEditor', 'html', array( 'label' => 'HTML Content', 'toolbarSet' => 'Basic', 'required' => ('html' == $type), 'width' => 395, 'height' => 200, 'description' => "Allowed maximum {$this->dataObj->descriptionLengh} characters", ) ); $form->addElement( 'extendedImage', 'image', array('label' => 'Banner Image', 'required' => ('image' == $type), 'description' => 'Required Image Size is ' . $this->dataObj->smallImageWidth . 'x' . $this->dataObj->smallImageHeight . ' px', ) ); $form->addElement( 'extendedImage', 'backgroundImage', array('label' => 'Background Image', 'required' => ('html' == $type), 'description' => 'Required Image Size is ' . $this->dataObj->imageWidth . 'x' . $this->dataObj->imageHeight . ' px', ) ); $form->addElement( 'text', 'url', array( 'label' => 'Url', 'required' => ('image' == $type) ? false : true, 'class' => 'text', 'description' => 'Example: http://www.google.com', 'validators' => array('url') ) ); // $form->url->getDecorator('label')->setOption('class', 'required'); $form->addElement( 'checkbox', 'show', array('label' => 'Show', 'decoration' => 'simple') ); $form->backgroundImage->getDecorator('label')->setOption('class', 'required'); $form->image->addValidator('File_IsImage'); $form->image->getValidator('File_IsImage')->setMessage( 'Uploaded file type is wrong', Zend_Validate_File_IsImage::FALSE_TYPE ); $validatorMessages = array( Zend_Validate_File_ImageSize::WIDTH_TOO_BIG => "Maximum allowed width for image '%value%'" . " should be '%maxwidth%' but '%width%' detected", Zend_Validate_File_ImageSize::WIDTH_TOO_SMALL => "Minimum expected width for image '%value%'" . " should be '%minwidth%' but '%width%' detected", Zend_Validate_File_ImageSize::HEIGHT_TOO_BIG => "Maximum allowed height for image '%value%' " . "should be '%maxheight%' but '%height%' detected", Zend_Validate_File_ImageSize::HEIGHT_TOO_SMALL => "Minimum expected height for image '%value%'" . " should be '%minheight%' but '%height%' detected", //Zend_Validate_File_ImageSize::NOT_DETECTED => "The size of image '%value%' could not be detected", Zend_Validate_File_ImageSize::NOT_DETECTED => "", Zend_Validate_File_ImageSize::NOT_READABLE => "File '%value%' can not be read", ); $form->backgroundImage->addValidator( 'File_ImageSize', false, array( 'minheight' => $this->dataObj->imageHeight, 'minwidth' => $this->dataObj->imageWidth, 'maxheight' => $this->dataObj->imageHeight, 'maxwidth' => $this->dataObj->imageWidth, 'messages' => $validatorMessages ) ); $form->image->addValidator( 'File_ImageSize', false, array( 'minheight' => $this->dataObj->smallImageHeight, 'minwidth' => $this->dataObj->smallImageWidth, 'maxheight' => $this->dataObj->smallImageHeight, 'maxwidth' => $this->dataObj->smallImageWidth, 'messages' => $validatorMessages ) ); $form->addFormRule(array($this, 'validateFrom')); return $this; } public function validateFrom($data) { $errors = array(); $type = (empty($data['type'])) ? $this->getFormDefaults('type') : $data['type']; if (!empty($data['html'])) { $length = strlen(strip_tags($data['html'])); if ($length > $this->dataObj->descriptionLengh) { $errors['html'] = "Description is too large. You entered {$length} characters"; } } return (empty($errors)) ? true : $errors; } protected function _renderMainForm($form) { $this->doc->addStylesheet('css/admin-slide.css'); $form->getDecorator('HtmlTag')->setOption('class', $form->type->getValue()); return parent::_renderMainForm($form); } }