<?php
class Banner_Form_Admin_Url extends Zend_Form {

	public function init() {
		$config = Banner_Module_Module::getInstance()->config;
		$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('Button', 'submit', array(
			'class' => 'button green',
			'type' => 'submit',
			'label' => 'Zapisz',
			'decorators' => array('ViewHelper')
		));

		$page = new Zend_Navigation_Page_Mvc(array('module' => 'Banner', 'controller' => 'admin_index', 'action' => 'index'));

		$this->addElement('Button', 'cancel', array(
			'class' => 'button red',
			'label' => 'Anuluj',
			'onclick' => 'window.location = \'' . $page->getHref() . '\'',
			'decorators' => array('ViewHelper')
		));
	}

}