<?php
class Banner_Form_Admin_Crop extends Zend_Form {

	public function init() {
		$this->setAttrib('class', 'no-ajax');
		$id = Zend_Controller_Front::getInstance()->getRequest()->getParam('id');
		$page = new Zend_Navigation_Page_Mvc(array('module' => 'Banner', 'controller' => 'admin_index', 'action' => 'crop', 'params' => array('id' => !$id ? '' : $id)));

		$config = Banner_Module_Module::getInstance()->config;

		$this->setAction($page->getHref());
		$this->setAttrib('id', 'coords');

		$this->addElement('Hidden', 'src', array('id' => 'src'));
		$this->getElement('src')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'position', array('id' => 'position', 'value' => 0));
		$this->getElement('position')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'x1', array('value' => 0));
		$this->getElement('x1')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'y1', array('value' => 0));
		$this->getElement('y1')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'x2', array('value' => 0));
		$this->getElement('x2')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'y2', array('value' => 0));
		$this->getElement('y2')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'w', array('value' => 0,
//			'validators' => array(new Zend_Validate_Between(array('min' => $config->imageThumbs->slide->width, 'max' => $config->imageThumbs->slide->width)))
		));
		$this->getElement('w')->clearDecorators()
			->addDecorators(array('ViewHelper'));

		$this->addElement('Hidden', 'h', array('value' => 0,
//			'validators' => array(new Zend_Validate_Between(array('min' => $config->imageThumbs->slide->height, 'max' => $config->imageThumbs->slide->height)))
		));
		$this->getElement('h')->clearDecorators()->addDecorators(array('ViewHelper'));

		$this->addElement('Button', 'crop', array(
			'class' => 'button',
			'type' => 'submit',
			'label' => 'Przytnij i 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 white',
			'label' => 'Anuluj',
			'onclick' => 'window.location = \'' . $page->getHref() . '\'',
			'decorators' => array('ViewHelper')
		));
	}

}
