'html', 'linkType' => 'none', 'show' => 'y', ); protected function _initElements() { $dataObj = new App_Slide_Admin_Obj(); $config = Qs_Application::getConfig('slide')->toArray(); $this->addElement('text', 'title', array('label' => 'Title', 'required' => true)); $type = $this->_getData('type'); $this->addElement( 'select', 'type', array( 'label' => 'Type', 'multiOptions' => $dataObj->getDSlideType4Select(), 'required' => true, 'value' => $type, 'separator' => ' ', ) ); $this->addElement( 'htmlEditor', 'html', array( 'label' => 'HTML Content', 'toolbar' => 'Basic', 'required' => (!$this->isSubmitted() || 'html' == $type), 'description' => 'Note: not all content may show inside the slider item because of its limited height.' ) ); $this->addElement( 'extendedImage', 'image', array( 'label' => 'Slide Image', 'required' => (!$this->isSubmitted() || 'image' == $type), 'resize' => $config['image']['width'] . 'x' . $config['image']['height'], 'validators' => array( array('IsImage', true), array( 'ImageSize', true, array( 'minwidth' => $config['image']['width'], 'minheight' => $config['image']['height'] ) ) ) ) ); $this->addElement( 'extendedImage', 'backgroundImage', array( 'label' => 'Background Image', 'required' => ('html' == $type), 'resize' => $config['image']['width'] . 'x' . $config['image']['height'] . $config['image']['resizeMethodAlias'] ) ); $linkType = $this->_getData('linkType'); $this->addElement( 'select', 'linkType', array( 'label' => 'Type', 'multiOptions' => array( 'none' => 'No Link', 'url' => 'URL', 'cms' => 'Site Page', 'product' => 'Product'), 'required' => true, 'value' => $linkType, 'separator' => ' ', ) ); $this->addElement( 'text', 'url', array( 'label' => 'Url', 'class' => 'text', 'validators' => array('url'), 'description' => 'Example: http://www.adaptainc.com' ) ); $this->addElement('text', 'linkText', array('label' => 'Link Text', 'class' => 'text')); $this->addElement('select', 'pageId', array('label' => 'Site Page', 'escapeLabel' => false)); $this->pageId->setMultiOptions(App_Cms_Obj::getInstance()->getPages4Select(0)); $this->addElement('select', 'productId', array('label' => 'Product\'s Page', 'escapeLabel' => false)); $productObj = new App_ECommerce_Product_Obj(); $this->productId->setMultiOptions($productObj->getProducts4Select()); $this->addDisplayGroup( array('linkType', 'url', 'pageId', 'productId', 'linkText'), 'linkTypeGroup', array('legend' => 'Link') ); $this->getDisplayGroup('linkTypeGroup')->getDecorator('HtmlTag')->setOption('class', $linkType); $this->addElement('checkbox', 'show', array('label' => 'Show on user end', 'decoration' => 'simple')); foreach (array('url', 'linkText', 'pageId', 'productId', 'image', 'backgroundImage') as $element) { $this->{$element}->getDecorator('Label')->setOption('class', 'required'); } if (in_array($linkType, array('url', 'cms', 'pageId', 'productId'))) { if (App_Slide_View::HTML_TYPE == $type) { $this->getElement('linkText')->setRequired(); } if ('url' == $linkType) { $this->getElement('url')->setRequired(); } else if ('cms' == $linkType) { $this->getElement('pageId')->setRequired(); } else if ('productId' == $linkType) { $this->getElement('productId')->setRequired(); } } } public function render(Zend_View_Interface $view = null) { /** * спочатку робиться рендер щоб ініціалізувалась форма і підчепились джаваскрипти, бо з App_Slide.updateQsForm() * робляться звернення до Qs_Form */ $content = parent::render($view); /** @var $doc Qs_Doc */ $doc = Zend_Registry::get('doc'); $doc->addScript('js/app/admin-slide.js'); $options = array('formId' => $this->getId()); $doc->addInitFunction('initAppSlide', array($options)); return $content; } }