<?php
class Banner_Form_Admin_Add extends Zend_Form {

	public function init() {
		$config = Banner_Module_Module::getInstance()->config;
		$view = new Zend_View();

		$this->setAction('#add_slide');
		$this->setAttrib('id', 'add_slide');
		$this->setAttrib('class', 'uniform');
		$this->setAttrib('class', 'no-ajax');
		
		if($config->slogan){
			$slogan = new Zend_Form_Element_Text('slogan', array(
			    'label' => 'Slogan',
			    'validators' => array(new Zend_Validate_StringLength(0,120))
			    ));
			$slogan->addFilter('StringTrim')->addFilter('StripTags');
			$this->addElement($slogan);
		}
		
		if($config->url){
			$url = new Zend_Form_Element_Text('url', array(
			    'label' => 'Link. Przykładowa postać: http://www.eppearance.pl/',
			    'validators' => array(new Eppe_Validate_Url())
			));
			$slogan->addFilter('StringTrim');
			$this->addElement($url);
		}
		
		if($config->alt){
			$alt = new Zend_Form_Element_Text('alt', array(
			    'label' => 'Alt zdjęcia',
			    'validators' => array(new Zend_Validate_StringLength(0,240))
			    ));
			$alt->addFilter('StringTrim')->addFilter('StripTags');
			$this->addElement($alt);
		}
		
		$this->addElement('File', 'slide', array(
			'label' => 'Obrazek',
			'id' => 'upload',
			'description' => $view->translate("Formaty .jpg, .gif. Rozmiar nie mniejszy niż %1\$s x %2\$s px.", $config->imageThumbs->slide->width, $config->imageThumbs->slide->height),
			'required' => true,
			'validators' => array(
				new Zend_Validate_File_Extension(array('extension' => 'jpg,jpeg,gif')),
				new Zend_Validate_File_Count(array('max' => 1)),
				new Zend_Validate_File_ImageSize(array('minheight' => $config->imageThumbs->slide->height, 'minwidth' => $config->imageThumbs->slide->width))
			)
			)
		);

		$this->addElement('Hidden', 'form', array('value' => 'add_slide'));
		$this->getElement('form')->clearDecorators()
			->addDecorators(array('ViewHelper'));
		
		$this->addElement('Button', 'execute', array(
			'class' => 'button',
			'type' => 'submit',
			'label' => 'Zapisz',
			'decorators' => array('ViewHelper')
		));
	}

}
