Massive simplification of the GeneralPreferences dialog
* The purpose of this was so that we can use Zend_Form_Element decorators, which I need.
This commit is contained in:
parent
9e90e8af63
commit
c4d3a8fa62
6 changed files with 99 additions and 185 deletions
|
@ -17,6 +17,7 @@ require_once "Database.php";
|
|||
require_once "Timezone.php";
|
||||
require_once "Auth.php";
|
||||
require_once __DIR__.'/forms/helpers/ValidationTypes.php';
|
||||
require_once __DIR__.'/forms/helpers/CustomDecorators.php';
|
||||
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
|
||||
|
||||
require_once (APPLICATION_PATH."/logging/Logging.php");
|
||||
|
|
|
@ -5,6 +5,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
|
||||
public function init()
|
||||
{
|
||||
$maxLens = Application_Model_Show::getMaxLengths();
|
||||
|
||||
$notEmptyValidator = Application_Form_Helper_ValidationTypes::overrideNotEmptyValidator();
|
||||
$rangeValidator = Application_Form_Helper_ValidationTypes::overrideBetweenValidator(0, 59.9);
|
||||
|
@ -22,12 +23,18 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
'required' => false,
|
||||
'filters' => array('StringTrim'),
|
||||
'value' => Application_Model_Preference::GetStationName(),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
//Default station fade in
|
||||
// Station description
|
||||
$stationDescription = new Zend_Form_Element_Textarea("stationDescription");
|
||||
$stationDescription->setLabel(_('Station Description'));
|
||||
$stationDescription->setValue(Application_Model_Preference::GetStationDescription());
|
||||
$stationDescription->setRequired(false);
|
||||
$stationDescription->setValidators(array(array('StringLength', false, array(0, $maxLens['description']))));
|
||||
$stationDescription->setAttrib('rows', 4);
|
||||
$this->addElement($stationDescription);
|
||||
|
||||
//Default station crossfade duration
|
||||
$this->addElement('text', 'stationDefaultCrossfadeDuration', array(
|
||||
'class' => 'input_text',
|
||||
'label' => _('Default Crossfade Duration (s):'),
|
||||
|
@ -39,9 +46,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(),
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
//Default station fade in
|
||||
|
@ -56,9 +60,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'value' => $defaultFadeIn,
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
//Default station fade out
|
||||
|
@ -73,25 +74,31 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'value' => $defaultFadeOut,
|
||||
'decorators' => array(
|
||||
'ViewHelper'
|
||||
)
|
||||
));
|
||||
|
||||
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
|
||||
$third_party_api->setLabel(
|
||||
sprintf(_('Allow Remote Websites To Access "Schedule" Info?%s (Enable this to make front-end widgets work.)'), '<br>'));
|
||||
$third_party_api->setMultiOptions(array(_("Disabled"),
|
||||
_("Enabled")));
|
||||
$third_party_api->setLabel(_('Public Airtime API'));
|
||||
$third_party_api->setDescription(_('Required for embeddable schedule widget.'));
|
||||
$third_party_api->setMultiOptions(array(
|
||||
_("Disabled"),
|
||||
_("Enabled"),
|
||||
));
|
||||
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
|
||||
$third_party_api->setDecorators(array('ViewHelper'));
|
||||
$third_party_api->setDescription(_('Enabling this feature will allow Airtime to provide schedule data
|
||||
to external widgets that can be embedded in your website. Enable this
|
||||
feature to reveal the embeddable code.'));
|
||||
$third_party_api->setSeparator(' '); //No <br> between radio buttons
|
||||
//$third_party_api->addDecorator(new Zend_Form_Decorator_Label(array('tag' => 'dd', 'class' => 'radio-inline-list')));
|
||||
$third_party_api->addDecorator('HtmlTag', array('tag' => 'dd',
|
||||
'id'=>"thirdPartyApi-element",
|
||||
'class' => 'radio-inline-list',
|
||||
));
|
||||
$this->addElement($third_party_api);
|
||||
|
||||
$locale = new Zend_Form_Element_Select("locale");
|
||||
$locale->setLabel(_("Default Interface Language"));
|
||||
$locale->setLabel(_("Default Language"));
|
||||
$locale->setMultiOptions(Application_Model_Locale::getLocales());
|
||||
$locale->setValue(Application_Model_Preference::GetDefaultLocale());
|
||||
$locale->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($locale);
|
||||
|
||||
/* Form Element for setting the Timezone */
|
||||
|
@ -99,7 +106,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$timezone->setLabel(_("Station Timezone"));
|
||||
$timezone->setMultiOptions(Application_Common_Timezone::getTimezones());
|
||||
$timezone->setValue(Application_Model_Preference::GetDefaultTimezone());
|
||||
$timezone->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($timezone);
|
||||
|
||||
/* Form Element for setting which day is the start of the week */
|
||||
|
@ -107,7 +113,6 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$week_start_day->setLabel(_("Week Starts On"));
|
||||
$week_start_day->setMultiOptions($this->getWeekStartDays());
|
||||
$week_start_day->setValue(Application_Model_Preference::GetWeekStartDay());
|
||||
$week_start_day->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($week_start_day);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
|
|
@ -1,138 +1,23 @@
|
|||
<fieldset class="padded">
|
||||
<dl class="zend_form">
|
||||
<dt id="stationName-label" class="block-display">
|
||||
<label class="required" for="stationName"><?php echo $this->element->getElement('stationName')->getLabel() ?>:
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="stationName-element" class="block-display">
|
||||
<?php echo $this->element->getElement('stationName') ?>
|
||||
<?php if($this->element->getElement('stationName')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('stationName')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="stationDefaultFadeIn-label" class="block-display">
|
||||
<label class="optional" for="stationDefaultFadeIn"><?php echo $this->element->getElement('stationDefaultFadeIn')->getLabel() ?></label>
|
||||
</dt>
|
||||
<dd id="stationDefaultFadeIn-element" class="block-display">
|
||||
<?php echo $this->element->getElement('stationDefaultFadeIn') ?>
|
||||
<?php if($this->element->getElement('stationDefaultFadeIn')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('stationDefaultFadeIn')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="stationDefaultFadeOut-label" class="block-display">
|
||||
<label class="optional" for="stationDefaultFadeOut"><?php echo $this->element->getElement('stationDefaultFadeOut')->getLabel() ?></label>
|
||||
</dt>
|
||||
<dd id="stationDefaultFadeOut-element" class="block-display">
|
||||
<?php echo $this->element->getElement('stationDefaultFadeOut') ?>
|
||||
<?php if($this->element->getElement('stationDefaultFadeOut')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('stationDefaultFadeOut')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="stationDefaultCrossfadeDuration-label" class="block-display">
|
||||
<label class="optional" for="stationDefaultCrossfadeDuration"><?php echo $this->element->getElement('stationDefaultCrossfadeDuration')->getLabel() ?></label>
|
||||
</dt>
|
||||
<dd id="stationDefaultCrossfadeDuration-element" class="block-display">
|
||||
<?php echo $this->element->getElement('stationDefaultCrossfadeDuration') ?>
|
||||
<?php if($this->element->getElement('stationDefaultCrossfadeDuration')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('stationDefaultCrossfadeDuration')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="thirdPartyApi-label" class="block-display">
|
||||
<label class="optional"><?php echo $this->element->getElement('thirdPartyApi')->getLabel() ?></label>
|
||||
</dt>
|
||||
<dd id="thirdPartyApi-element" class="block-display radio-inline-list">
|
||||
<?php $i=0;
|
||||
$value = $this->element->getElement('thirdPartyApi')->getValue();
|
||||
?>
|
||||
<?php foreach ($this->element->getElement('thirdPartyApi')->getMultiOptions() as $radio) : ?>
|
||||
<label for="thirdPartyApi-<?php echo $i ?>">
|
||||
<input type="radio" value="<?php echo $i ?>" id="thirdPartyApi-<?php echo $i ?>" name="thirdPartyApi" <?php if($i == $value){echo 'checked="checked"';}?>>
|
||||
<?php echo $radio ?>
|
||||
</input>
|
||||
</label>
|
||||
<?php $i = $i + 1; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if($this->element->getElement('thirdPartyApi')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('thirdPartyApi')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
|
||||
<dt id="locale-label" class="block-display">
|
||||
<label class="required" for="locale"><?php echo $this->element->getElement('locale')->getLabel() ?>:
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="locale-element" class="block-display">
|
||||
<?php echo $this->element->getElement('locale') ?>
|
||||
<?php if($this->element->getElement('locale')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('locale')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php echo $this->element->getElement('stationName')->render() ?>
|
||||
|
||||
<dt id="timezone-label" class="block-display">
|
||||
<label class="required" for="timezone"><?php echo $this->element->getElement('timezone')->getLabel() ?>:
|
||||
<span class="info-text-small"><?php _("(Required)") ?></span>
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="timezone-element" class="block-display">
|
||||
<?php echo $this->element->getElement('timezone') ?>
|
||||
<?php if($this->element->getElement('timezone')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('timezone')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php echo $this->element->getElement('stationDescription')->render() ?>
|
||||
|
||||
<!-- Week Start Day option -->
|
||||
<dt id="weekStartDay-label" class="block-display">
|
||||
<label class="required" for="timezone"><?php echo $this->element->getElement('weekStartDay')->getLabel() ?>:
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="weekStartDay-element" class="block-display">
|
||||
<?php $i=0;
|
||||
$value = $this->element->getElement('weekStartDay')->getValue();
|
||||
?>
|
||||
<select id="weekStartDay" name="weekStartDay">
|
||||
<?php foreach ($this->element->getElement('weekStartDay')->getMultiOptions() as $option) : ?>
|
||||
<option value="<?php echo $i ?>" <?php if($i == $value){echo 'selected="selected"';}?> >
|
||||
<?php echo $option ?>
|
||||
</option>
|
||||
<?php $i = $i + 1; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php echo $this->element->getElement('locale')->render() ?>
|
||||
|
||||
<?php echo $this->element->getElement('timezone')->render() ?>
|
||||
|
||||
<?php echo $this->element->getElement('weekStartDay')->render() ?>
|
||||
|
||||
<?php echo $this->element->getElement('stationDefaultFadeIn')->render() ?>
|
||||
|
||||
<?php echo $this->element->getElement('stationDefaultFadeOut')->render() ?>
|
||||
|
||||
<?php echo $this->element->getElement('stationDefaultCrossfadeDuration')->render() ?>
|
||||
|
||||
<?php echo $this->element->getElement('thirdPartyApi')->render() ?>
|
||||
|
||||
<?php if($this->element->getElement('weekStartDay')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('weekStartDay')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
|
|
@ -13,7 +13,7 @@ html, body {
|
|||
}
|
||||
|
||||
#login-page {
|
||||
background: #1f1f1f url(images/login_page_bg.png) no-repeat center 0;`
|
||||
background: #1f1f1f url(images/login_page_bg.png) no-repeat center 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height:100%;
|
||||
|
@ -1002,6 +1002,27 @@ input[type="checkbox"] {
|
|||
display:block;
|
||||
}
|
||||
|
||||
#pref_form dt, #pref_form dd,
|
||||
#pref_form textarea {
|
||||
display:block;
|
||||
float:none;
|
||||
margin-left:0;
|
||||
padding-left:0;
|
||||
width: 100%;
|
||||
}
|
||||
#pref_form textarea {
|
||||
width: 98.5%;
|
||||
}
|
||||
#pref_form select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#pref_form p.description {
|
||||
color: #3b3b3b;
|
||||
font-size: 12px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
dt.block-display, dd.block-display {
|
||||
display:block;
|
||||
float:none;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue