2011-08-15 22:10:46 +02:00
|
|
|
<?php
|
|
|
|
|
2011-08-18 19:53:12 +02:00
|
|
|
class Application_Form_StreamSetting extends Zend_Form
|
2011-08-15 22:10:46 +02:00
|
|
|
{
|
2011-08-18 19:53:12 +02:00
|
|
|
private $setting;
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2011-08-15 22:10:46 +02:00
|
|
|
public function init()
|
|
|
|
{
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2011-08-18 19:53:12 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function setSetting($setting)
|
|
|
|
{
|
2011-08-18 19:53:12 +02:00
|
|
|
$this->setting = $setting;
|
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function startFrom()
|
|
|
|
{
|
2015-07-03 19:32:41 +02:00
|
|
|
$this->setDecorators(array(
|
|
|
|
array('ViewScript', array('viewScript' => 'preference/stream-setting.phtml'))
|
|
|
|
));
|
|
|
|
|
2011-08-18 19:53:12 +02:00
|
|
|
$setting = $this->setting;
|
2012-07-11 00:55:44 +02:00
|
|
|
|
2017-02-27 17:47:26 +01:00
|
|
|
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
|
|
|
|
$output_sound_device->setLabel(_('Hardware Audio Output:'))
|
|
|
|
->setRequired(false)
|
|
|
|
->setValue(($setting['output_sound_device'] == "true")?1:0)
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($output_sound_device);
|
|
|
|
|
|
|
|
$output_sound_device_type = new Zend_Form_Element_Select('output_sound_device_type');
|
|
|
|
$output_sound_device_type->setLabel(_('Output Type'))
|
|
|
|
->setMultiOptions(array(
|
|
|
|
"ALSA"=>_("ALSA"),
|
|
|
|
"AO"=>_("AO"),
|
|
|
|
"OSS"=>_("OSS"),
|
|
|
|
"Portaudio"=>_("Portaudio"),
|
|
|
|
"Pulseaudio"=>_("Pulseaudio"),
|
|
|
|
"Jack"=>_("Jack")))
|
|
|
|
->setValue(isset($setting['output_sound_device_type'])?$setting['output_sound_device_type']:0)
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($output_sound_device_type);
|
|
|
|
|
2011-11-23 23:03:30 +01:00
|
|
|
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
|
2012-11-15 16:59:06 +01:00
|
|
|
$icecast_vorbis_metadata->setLabel(_('Icecast Vorbis Metadata'))
|
2011-11-23 23:03:30 +01:00
|
|
|
->setRequired(false)
|
|
|
|
->setValue(($setting['icecast_vorbis_metadata'] == "true")?1:0)
|
|
|
|
->setDecorators(array('ViewHelper'));
|
2012-08-29 05:04:55 +02:00
|
|
|
if (Application_Model_Preference::GetEnableStreamConf() == "false") {
|
2011-11-23 23:03:30 +01:00
|
|
|
$icecast_vorbis_metadata->setAttrib("readonly", true);
|
2011-09-02 22:13:30 +02:00
|
|
|
}
|
2011-11-23 23:03:30 +01:00
|
|
|
$this->addElement($icecast_vorbis_metadata);
|
2011-12-13 12:10:25 +01:00
|
|
|
|
|
|
|
$stream_format = new Zend_Form_Element_Radio('streamFormat');
|
2012-11-15 16:59:06 +01:00
|
|
|
$stream_format->setLabel(_('Stream Label:'));
|
|
|
|
$stream_format->setMultiOptions(array(_("Artist - Title"),
|
|
|
|
_("Show - Artist - Title"),
|
|
|
|
_("Station name - Show name")));
|
2011-12-13 12:10:25 +01:00
|
|
|
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
|
|
|
|
$stream_format->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($stream_format);
|
2012-12-28 04:58:41 +01:00
|
|
|
|
2013-01-08 00:14:57 +01:00
|
|
|
$offAirMeta = new Zend_Form_Element_Text('offAirMeta');
|
2013-01-11 19:17:08 +01:00
|
|
|
$offAirMeta->setLabel(_('Off Air Metadata'))
|
2013-01-08 00:14:57 +01:00
|
|
|
->setValue(Application_Model_StreamSetting::getOffAirMeta())
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($offAirMeta);
|
|
|
|
|
2013-01-10 19:49:41 +01:00
|
|
|
$enable_replay_gain = new Zend_Form_Element_Checkbox("enableReplayGain");
|
|
|
|
$enable_replay_gain->setLabel(_("Enable Replay Gain"))
|
|
|
|
->setValue(Application_Model_Preference::GetEnableReplayGain())
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($enable_replay_gain);
|
|
|
|
|
2012-12-28 04:58:41 +01:00
|
|
|
$replay_gain = new Zend_Form_Element_Hidden("replayGainModifier");
|
|
|
|
$replay_gain->setLabel(_("Replay Gain Modifier"))
|
|
|
|
->setValue(Application_Model_Preference::getReplayGainModifier())
|
|
|
|
->setAttribs(array('style' => "border: 0; color: #f6931f; font-weight: bold;"))
|
|
|
|
->setDecorators(array('ViewHelper'));
|
|
|
|
$this->addElement($replay_gain);
|
2015-07-03 19:32:41 +02:00
|
|
|
|
|
|
|
$custom = Application_Model_Preference::getUsingCustomStreamSettings();
|
|
|
|
$customSettings = new Zend_Form_Element_Radio('customStreamSettings');
|
2015-07-08 22:04:09 +02:00
|
|
|
$customSettings->setLabel(_('Streaming Server:'));
|
2017-03-10 20:35:09 +01:00
|
|
|
$customSettings->setMultiOptions(array(_("Default Streaming"), _("Custom / 3rd Party Streaming")));
|
2015-07-03 19:32:41 +02:00
|
|
|
$customSettings->setValue(!empty($custom) ? $custom : 0);
|
|
|
|
$this->addElement($customSettings);
|
2011-08-18 19:53:12 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-08-29 05:04:55 +02:00
|
|
|
public function isValid($data)
|
|
|
|
{
|
|
|
|
if (isset($data['output_sound_device'])) {
|
2012-01-13 22:56:02 +01:00
|
|
|
$d = array();
|
|
|
|
$d["output_sound_device"] = $data['output_sound_device'];
|
|
|
|
$d["icecast_vorbis_metadata"] = $data['icecast_vorbis_metadata'];
|
2012-08-29 05:04:55 +02:00
|
|
|
if (isset($data['output_sound_device_type'])) {
|
2012-01-13 22:56:02 +01:00
|
|
|
$d["output_sound_device_type"] = $data['output_sound_device_type'];
|
|
|
|
}
|
|
|
|
$d["streamFormat"] = $data['streamFormat'];
|
|
|
|
$this->populate($d);
|
2011-12-21 23:30:42 +01:00
|
|
|
}
|
2012-02-21 23:58:05 +01:00
|
|
|
$isValid = parent::isValid($data);
|
2012-08-29 05:04:55 +02:00
|
|
|
|
2012-02-21 23:58:05 +01:00
|
|
|
return $isValid;
|
2011-08-15 22:10:46 +02:00
|
|
|
}
|
|
|
|
}
|