2011-01-21 00:30:53 +01:00
|
|
|
<?php
|
|
|
|
|
2014-09-13 00:05:24 +02:00
|
|
|
require_once 'customfilters/ImageSize.php';
|
|
|
|
|
2011-01-21 00:30:53 +01:00
|
|
|
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(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Background Colour:'),
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 20:58:23 +01:00
|
|
|
'filters' => array('StringTrim')
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
|
|
|
|
2011-01-31 03:42:53 +01:00
|
|
|
$bg = $this->getElement('add_show_background_color');
|
|
|
|
|
|
|
|
$bg->setDecorators(array(array('ViewScript', array(
|
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
|
|
|
'class' => 'big'
|
|
|
|
))));
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2013-01-14 20:13:32 +01:00
|
|
|
$stringLengthValidator = Application_Form_Helper_ValidationTypes::overrideStringLengthValidator(6, 6);
|
2012-05-07 14:48:33 +02:00
|
|
|
$bg->setValidators(array(
|
2013-01-14 20:13:32 +01:00
|
|
|
'Hex', $stringLengthValidator
|
2012-05-07 14:48:33 +02:00
|
|
|
));
|
2011-01-31 03:42:53 +01:00
|
|
|
|
2014-09-13 00:05:24 +02:00
|
|
|
// Add show color input
|
2011-01-21 19:25:12 +01:00
|
|
|
$this->addElement('text', 'add_show_color', array(
|
2012-11-15 16:59:06 +01:00
|
|
|
'label' => _('Text Colour:'),
|
2011-01-28 23:37:31 +01:00
|
|
|
'class' => 'input_text',
|
2011-01-21 20:58:23 +01:00
|
|
|
'filters' => array('StringTrim')
|
2011-01-21 00:30:53 +01:00
|
|
|
));
|
2011-01-31 03:42:53 +01:00
|
|
|
|
|
|
|
$c = $this->getElement('add_show_color');
|
|
|
|
|
|
|
|
$c->setDecorators(array(array('ViewScript', array(
|
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
|
|
|
'class' => 'big'
|
|
|
|
))));
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
$c->setValidators(array(
|
2013-01-14 20:13:32 +01:00
|
|
|
'Hex', $stringLengthValidator
|
2012-05-07 14:48:33 +02:00
|
|
|
));
|
2014-09-13 00:05:24 +02:00
|
|
|
|
2014-09-18 01:48:17 +02:00
|
|
|
// 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');
|
|
|
|
|
2014-09-13 00:05:24 +02:00
|
|
|
// 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');
|
|
|
|
|
2014-09-18 01:48:17 +02:00
|
|
|
$upload->setLabel(_('Show Logo:'))
|
2014-09-13 00:05:24 +02:00
|
|
|
->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
|
|
|
|
))
|
2014-09-13 00:05:24 +02:00
|
|
|
->addFilter('ImageSize');
|
2014-09-17 00:03:14 +02:00
|
|
|
|
2014-09-13 00:05:24 +02:00
|
|
|
$this->addElement($upload);
|
2014-09-18 01:48:17 +02:00
|
|
|
|
|
|
|
// 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');
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function disable()
|
|
|
|
{
|
2012-03-30 21:11:24 +02:00
|
|
|
$elements = $this->getElements();
|
2012-08-29 05:04:55 +02:00
|
|
|
foreach ($elements as $element) {
|
|
|
|
if ($element->getType() != 'Zend_Form_Element_Hidden') {
|
2012-04-05 22:01:27 +02:00
|
|
|
$element->setAttrib('disabled','disabled');
|
2012-03-30 21:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
|
|
|
|
}
|