SAAS-876 - Initial commit

This commit is contained in:
Duncan Sommerville 2015-07-03 13:32:41 -04:00
parent e3101e90b2
commit 457230ba07
9 changed files with 125 additions and 99 deletions

View file

@ -7,7 +7,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
{
$CC_CONFIG = Config::getConfig();
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
@ -103,7 +102,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($showSourceMount);
// demo only code
if (!$isStreamConfigable) {
if ($isDemo) {
$elements = $this->getElements();
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {

View file

@ -16,6 +16,10 @@ class Application_Form_StreamSetting extends Zend_Form
public function startFrom()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'preference/stream-setting.phtml'))
));
$setting = $this->setting;
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
@ -55,6 +59,13 @@ class Application_Form_StreamSetting extends Zend_Form
->setAttribs(array('style' => "border: 0; color: #f6931f; font-weight: bold;"))
->setDecorators(array('ViewHelper'));
$this->addElement($replay_gain);
$custom = Application_Model_Preference::getUsingCustomStreamSettings();
$customSettings = new Zend_Form_Element_Radio('customStreamSettings');
$customSettings->setLabel(_('Stream Settings:'));
$customSettings->setMultiOptions(array(_("Default"), _("Use Custom")));
$customSettings->setValue(!empty($custom) ? $custom : 0);
$this->addElement($customSettings);
}
public function isValid($data)

View file

@ -42,7 +42,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
$this->setIsArray(true);
$this->setElementsBelongTo($prefix."_data");
$disable_all = Application_Model_Preference::GetEnableStreamConf() == "false";
$disable_all = !Application_Model_Preference::getUsingCustomStreamSettings();
$enable = new Zend_Form_Element_Checkbox('enable');
$enable->setLabel(_('Enabled:'))
@ -221,10 +221,10 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
$adminPass->setAttrib('alt', 'regular_text');
$this->addElement($adminPass);
$liquidsopa_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
$liquidsoap_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsopa_error_msg))
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsoap_error_msg))
));
}
@ -232,23 +232,25 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
{
$f_data = $data['s'.$this->prefix."_data"];
$isValid = parent::isValid($f_data);
if ($f_data['enable'] == 1) {
if ($f_data['host'] == '') {
$element = $this->getElement("host");
$element->addError(_("Server cannot be empty."));
$isValid = false;
}
if ($f_data['port'] == '') {
$element = $this->getElement("port");
$element->addError(_("Port cannot be empty."));
$isValid = false;
}
if ($f_data['output'] == 'icecast') {
if ($f_data['mount'] == '') {
$element = $this->getElement("mount");
$element->addError(_("Mount cannot be empty with Icecast server."));
if ($f_data) {
if ($f_data['enable'] == 1) {
if ($f_data['host'] == '') {
$element = $this->getElement("host");
$element->addError(_("Server cannot be empty."));
$isValid = false;
}
if ($f_data['port'] == '') {
$element = $this->getElement("port");
$element->addError(_("Port cannot be empty."));
$isValid = false;
}
if ($f_data['output'] == 'icecast') {
if ($f_data['mount'] == '') {
$element = $this->getElement("mount");
$element->addError(_("Mount cannot be empty with Icecast server."));
$isValid = false;
}
}
}
}