'image', '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) ) ); $this->addElement( 'extendedImage', 'image', array( 'label' => 'Slide Image', 'required' => (!$this->isSubmitted() || 'image' == $type), 'resize' => $config['image']['width'] . 'x' . $config['image']['height'] . $config['image']['resizeMethodAlias'], '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' => false, 'resize' => $config['image']['width'] . 'x' . $config['image']['height'] . $config['image']['resizeMethodAlias'], 'validators' => array( array('IsImage', true), array( 'ImageSize', true, array( 'minwidth' => $config['image']['width'], 'minheight' => $config['image']['height'] ) ) ) ) ); $linkType = $this->_getData('linkType'); $this->addElement( 'select', 'linkType', array( 'label' => 'Type', 'multiOptions' => array('none' => 'No Link', 'url' => 'URL', 'cms' => 'Site Page'), 'required' => true, 'value' => $linkType, 'separator' => ' ', ) ); $this->addElement( 'text', 'url', array( 'label' => 'Url', 'class' => 'text', 'description' => 'Example: http://www.adaptainc.com' ) ); if ($linkType == 'url') { $this->getElement('url')->addValidator('url'); } $this->addElement('text', 'linkText', array('label' => 'Link Text', 'class' => 'text')); $this->addElement('select', 'pageId', array('label' => 'Site Page', 'escapeLabel' => false)); $this->pageId->setMultiOptions(array('' => '- Select Page -') + App_Cms_Obj::getInstance()->getPages4Select()); $this->addDisplayGroup( array('linkType', 'url', 'pageId', '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', 'image') as $element) { $this->{$element}->getDecorator('Label')->setOption('class', 'required'); } if (in_array($linkType, array('url', 'cms'))) { 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(); } } } 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; } }