ACC SHELL
<?php
class TF_Form extends Zend_Form
{
private $_messages = array('isEmpty' => 'Tato položka je povinná.' , 'notInt' => 'Hodnota "%value%" není platná pro tuto položku. ' ,
'notBetween' => 'Hodnota "%value%" není v povoleném rozsahu (%min% - %max%). ' , 'notSame' => 'Tato položka neodpovídá.');
private $_translate = null;
public $formDecorators = array('formElements' , array('htmlTag' , array('tag' => 'div' , 'class' => 'group')) ,
array('Form' , array('class' => 'nice')));
public $elementDecorators = array('viewHelper' , array('Errors' , array('placement' => 'append')) ,
array('Description' , array('placement' => 'append' , 'tag' => 'div' , 'class' => 'description')) ,
array('Label' , array('placement' => 'preppend')) , array('htmlTag' , array('tag' => 'div' , 'class' => 'element')));
public $checkboxDecorators = array(
'viewHelper' ,
array(
'Errors' ,
array(
'placement' => 'append'
)
),
array(
'Description' ,
array(
'placement' => 'append' ,
'tag' => 'div' ,
'class' => 'description'
)
),
array(
'Label',
array(
'placement' => 'preppend'
)
),
array(
array('cleaner'=>'htmlTag'),
array(
'tag' => 'div',
'class' => 'cleaner',
'placement' => 'append',
)
),
array(
'htmlTag',
array(
'tag' => 'div',
'class' => 'element checkbox'
)
)
);
public $multiDecorators = array(array('viewHelper',array('class'=>'multiElement')) ,
array('Description' , array('placement' => 'append' , 'tag' => 'div' , 'class' => 'description')) ,
array(array('elementGroup' => 'htmlTag') , array('tag' => 'div' , 'class' => 'elementGroup')) ,
array('Errors' , array('placement' => 'append')) , array('Label' , array('placement' => 'preppend')) ,
array(array('element' => 'htmlTag') , array('tag' => 'div' , 'class' => 'element')));
public $buttonDecorators = array('viewHelper' , array('htmlTag' , array('tag' => 'div' , 'class' => 'element button')));
public $groupDecorators = array('formElements' , array('Description',array('placement' => 'prepend')), 'Fieldset' , array('htmlTag' , array('tag' => 'div' , 'class' => 'group')));
/**
*
*@param mixed $options
*@return void
*/
public function __construct ($options = null)
{
parent::__construct($options);
if (is_readable('./application/language/forms/validation/cs.php')) {
$translationData = include ('./application/language/forms/validation/cs.php');
$this->_translate = new Zend_Translate('array', $translationData, 'en');
} else {
TF_Debug::logAlert(
'Nelze najít soubor s překladem, používá se interní seznam! Nahrajte soubor s překladem do složky /languages/forms/validation/cs.php');
$this->_translate = new Zend_Translate('array', $this->_messages, 'en');
}
$this->setTranslator($this->_translate);
$this->setDefaultDecorators();
$this->addElementPrefixPath('TF_Form_Element_', 'TF/Form/Element/');
}
/**
* setDefaultDecorators
*/
private function setDefaultDecorators ()
{
$this->setDecorators(array());
$this->setDecorators($this->formDecorators);
} /* of setDefaultDecorators -------------------------------------*/
/**
* setElementDefaultDecorators
*/
public function setElementDefaultDecorators ()
{
foreach ($this->getSubForms() as $sf) {
$sf->setElementDefaultDecorators();
}
foreach ($this->getElements() as $el) {
//echo '|'.$el->getName().' is '.$el->helper;
switch ($el->helper) {
case 'formSubmit':
case 'formReset':
$el->setDecorators($this->buttonDecorators);
break;
case 'formMultiCheckbox':
case 'formMultiSelect':
case 'formRadio':
$el->setDecorators($this->multiDecorators);
break;
case 'formCheckbox':
$el->setDecorators($this->checkboxDecorators);
break;
default:
$el->setDecorators($this->elementDecorators);
break;
}
}
foreach ($this->getDisplayGroups() as $group) {
$group->setDecorators($this->groupDecorators);
}
} /* of setElementDefaultDecorators -------------------------------------*/
/**
* Load the default decorators
*/
public function loadDefaultDecorators ()
{
if ($this->loadDefaultDecoratorsIsDisabled()) {
return;
}
$decorators = $this->getDecorators();
if (empty($decorators)) {
$this->setDecorators($this->formDecorators);
}
}
/**
* setMessages
*/
public function setMessages (array $messages)
{
$this->_messages = $messages;
} /* of setMessages -------------------------------------*/
}
ACC SHELL 2018