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()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
// Add show background-color input
|
|
|
|
$this->addElement('text', 'add_show_background_color', [
|
|
|
|
'label' => _('Background Colour:'),
|
|
|
|
'class' => 'input_text',
|
|
|
|
'filters' => ['StringTrim'],
|
|
|
|
]);
|
2011-01-21 00:30:53 +01:00
|
|
|
|
2011-01-31 03:42:53 +01:00
|
|
|
$bg = $this->getElement('add_show_background_color');
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$bg->setDecorators([['ViewScript', [
|
2011-01-31 03:42:53 +01:00
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
2021-10-11 16:10:47 +02:00
|
|
|
'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);
|
2021-10-11 16:10:47 +02:00
|
|
|
$bg->setValidators([
|
|
|
|
'Hex', $stringLengthValidator,
|
|
|
|
]);
|
2011-01-31 03:42:53 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// Add show color input
|
|
|
|
$this->addElement('text', 'add_show_color', [
|
|
|
|
'label' => _('Text Colour:'),
|
|
|
|
'class' => 'input_text',
|
|
|
|
'filters' => ['StringTrim'],
|
|
|
|
]);
|
2011-01-31 03:42:53 +01:00
|
|
|
|
|
|
|
$c = $this->getElement('add_show_color');
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$c->setDecorators([['ViewScript', [
|
2011-01-31 03:42:53 +01:00
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
2021-10-11 16:10:47 +02:00
|
|
|
'class' => 'big',
|
|
|
|
]]]);
|
|
|
|
|
|
|
|
$c->setValidators([
|
|
|
|
'Hex', $stringLengthValidator,
|
|
|
|
]);
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2014-09-18 01:48:17 +02:00
|
|
|
// Show the current logo
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('image', 'add_show_logo_current', [
|
|
|
|
'label' => _('Current Logo:'),
|
|
|
|
]);
|
|
|
|
|
2014-09-19 18:55:47 +02:00
|
|
|
$logo = $this->getElement('add_show_logo_current');
|
2021-10-11 16:10:47 +02:00
|
|
|
$logo->setDecorators([
|
|
|
|
['ViewScript', [
|
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
|
|
|
'class' => 'big',
|
|
|
|
]],
|
|
|
|
]);
|
2014-09-18 01:48:17 +02:00
|
|
|
// Since we need to use a Zend_Form_Element_Image proto, disable it
|
2021-10-11 16:10:47 +02:00
|
|
|
$logo->setAttrib('disabled', 'disabled');
|
|
|
|
|
2014-09-18 22:38:18 +02:00
|
|
|
// Button to remove the current logo
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('button', 'add_show_logo_current_remove', [
|
|
|
|
'label' => '<span class="ui-button-text">' . _('Remove') . '</span>',
|
|
|
|
'class' => 'ui-button ui-state-default ui-button-text-only',
|
|
|
|
'escape' => false,
|
|
|
|
]);
|
|
|
|
|
2014-09-18 22:38:18 +02:00
|
|
|
// Add show image input
|
|
|
|
$upload = new Zend_Form_Element_File('add_show_logo');
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-09-18 01:48:17 +02:00
|
|
|
$upload->setLabel(_('Show Logo:'))
|
2021-10-11 16:10:47 +02:00
|
|
|
->setRequired(false)
|
|
|
|
->setDecorators(['File', ['ViewScript', [
|
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
|
|
|
'class' => 'big',
|
|
|
|
'placement' => false,
|
|
|
|
]]])
|
|
|
|
->addValidator('Count', false, 1)
|
|
|
|
->addValidator('Extension', false, 'jpg,jpeg,png,gif')
|
2022-01-23 19:15:55 +01:00
|
|
|
->addFilter('ImageSize');
|
2015-03-02 22:00:11 +01:00
|
|
|
|
2014-09-13 00:05:24 +02:00
|
|
|
$this->addElement($upload);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2014-09-18 01:48:17 +02:00
|
|
|
// Add image preview
|
2021-10-11 16:10:47 +02:00
|
|
|
$this->addElement('image', 'add_show_logo_preview', [
|
|
|
|
'label' => _('Logo Preview:'),
|
|
|
|
]);
|
|
|
|
|
2014-09-19 18:55:47 +02:00
|
|
|
$preview = $this->getElement('add_show_logo_preview');
|
2021-10-11 16:10:47 +02:00
|
|
|
$preview->setDecorators([['ViewScript', [
|
|
|
|
'viewScript' => 'form/add-show-style.phtml',
|
|
|
|
'class' => 'big',
|
|
|
|
]]]);
|
|
|
|
$preview->setAttrib('disabled', 'disabled');
|
2015-03-02 22:00:11 +01:00
|
|
|
|
|
|
|
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
|
|
|
|
$csrf_element = new Zend_Form_Element_Hidden('csrf');
|
|
|
|
$csrf_element->setValue($csrf_namespace->authtoken)
|
|
|
|
->setRequired('true')
|
|
|
|
->removeDecorator('HtmlTag')
|
2022-01-23 19:15:55 +01:00
|
|
|
->removeDecorator('Label');
|
2015-03-02 22:00:11 +01:00
|
|
|
$this->addElement($csrf_element);
|
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) {
|
2022-07-07 20:01:15 +02:00
|
|
|
if (
|
|
|
|
$element->getType() != 'Zend_Form_Element_Hidden'
|
2015-06-26 20:23:45 +02:00
|
|
|
// We should still be able to remove the show logo
|
2022-07-07 20:01:15 +02:00
|
|
|
&& $element->getName() != 'add_show_logo_current_remove'
|
|
|
|
) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$element->setAttrib('disabled', 'disabled');
|
2012-03-30 21:11:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public function hideShowLogo()
|
|
|
|
{
|
2015-06-26 20:23:45 +02:00
|
|
|
$this->removeElement('add_show_logo');
|
|
|
|
$this->removeElement('add_show_logo_preview');
|
|
|
|
}
|
2011-01-21 00:30:53 +01:00
|
|
|
}
|