'image', 'linkType' => 'none', 'show' => 'y', ); protected function _initElements() { $dataObj = new App_Slide_Admin_Obj(); $config = Qs_Application::getConfig('slide')->toArray(); $type = $this->_getData('type'); $maxTitleLength = 'html' == $type ? $config['maxTextTitleLength'] : $config['maxImageTitleLength']; $descriptionTitle = "Text space is limited to " . $maxTitleLength . " characters. Characters above the limit won't be shown on the user end."; $this->addElement( 'text', 'title', array( 'label' => 'Title', 'required' => true, 'description' => $descriptionTitle ) ); $this->addElement( 'select', 'type', array( 'label' => 'Type', 'multiOptions' => $dataObj->getDSlideType4Select(), 'required' => true, 'value' => $type, 'separator' => ' ', ) ); $this->addElement( 'textarea', 'html', array( 'label' => 'Text', 'rows' => 3, 'required' => (!$this->isSubmitted() || 'html' == $type), 'width' => 520, 'description' => 'Only first two entered text rows will be shown on the user end' ) ); $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' => 'html' == $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'] ) ) ) ) ); if (($validator = $this->getElement('backgroundImage')->getValidator('File_Upload'))) { /** @var Zend_Validate_File_Upload $validator */ $validator->setMessage('Background Image was not uploaded', Zend_Validate_File_Upload::NO_FILE); } $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', '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(array('' => '- Select Page -') + App_Cms_Obj::getInstance()->getPages4Select(0)); $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')); $this->addElement('checkbox', 'isPwx', array('label' => 'Show on PWX 2016', 'decoration' => 'simple')); foreach (array('url', 'linkText', 'pageId', 'image', 'backgroundImage') 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; } }