sintonia/airtime_mvc/application/forms/AddShowStyle.php

105 lines
3.4 KiB
PHP
Raw Normal View History

<?php
require_once 'customfilters/ImageSize.php';
class Application_Form_AddShowStyle extends Zend_Form_SubForm
{
public function init()
{
// Add show background-color input
2011-01-21 19:25:12 +01:00
$this->addElement('text', 'add_show_background_color', array(
'label' => _('Background Colour:'),
'class' => 'input_text',
2011-01-21 20:58:23 +01:00
'filters' => array('StringTrim')
));
$bg = $this->getElement('add_show_background_color');
$bg->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big'
))));
$stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 6);
$bg->setValidators(array(
'Hex', $stringLengthValidator
));
// Add show color input
2011-01-21 19:25:12 +01:00
$this->addElement('text', 'add_show_color', array(
'label' => _('Text Colour:'),
'class' => 'input_text',
2011-01-21 20:58:23 +01:00
'filters' => array('StringTrim')
));
$c = $this->getElement('add_show_color');
$c->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big'
))));
$c->setValidators(array(
'Hex', $stringLengthValidator
));
// Show the current logo
$this->addElement('image', 'show_logo_current', array(
'label' => _('Current Logo:'),
));
$logo = $this->getElement('show_logo_current');
$logo->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big'
))));
// Since we need to use a Zend_Form_Element_Image proto, disable it
$logo->setAttrib('disabled','disabled');
// Add show image input
$fileCountValidator = Application_Form_Helper_ValidationTypes::overrideFileCountValidator(1);
$fileExtensionValidator = Application_Form_Helper_ValidationTypes::overrideFileExtensionValidator('jpg,png,gif');
$upload = new Zend_Form_Element_File('upload');
$upload->setLabel(_('Show Logo:'))
->setRequired(false)
->setDecorators(array('File', array('ViewScript', array(
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big',
'placement' => false
))))
2014-09-17 00:03:14 +02:00
->addValidators(array(
$fileCountValidator,
$fileExtensionValidator
))
->addFilter('ImageSize');
2014-09-17 00:03:14 +02:00
$this->addElement($upload);
// Add image preview
$this->addElement('image', 'show_logo_preview', array(
'label' => _('Logo Preview:'),
));
$preview = $this->getElement('show_logo_preview');
$preview->setDecorators(array(array('ViewScript', array(
'viewScript' => 'form/add-show-style.phtml',
'class' => 'big'
))));
$preview->setAttrib('disabled','disabled');
}
public function disable()
{
$elements = $this->getElements();
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {
$element->setAttrib('disabled','disabled');
}
}
}
}