diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 20e6c8a69..d13cd678d 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -14,6 +14,7 @@ class PreferenceController extends Zend_Controller_Action ->addActionContext('is-import-in-progress', 'json') ->addActionContext('change-stream-setting', 'json') ->addActionContext('get-liquidsoap-status', 'json') + ->addActionContext('set-source-connection-url', 'json') ->initContext(); } @@ -335,6 +336,19 @@ class PreferenceController extends Zend_Controller_Action } die(json_encode($out)); } + + public function setSourceConnectionUrlAction(){ + $request = $this->getRequest(); + $type = $request->getParam("type", null); + $url = urldecode($request->getParam("url", null)); + + if($type == 'masterdj'){ + Application_Model_Preference::SetMasterDJSourceConnectionURL($url); + }elseif($type == 'livedj'){ + Application_Model_Preference::SetLiveDJSourceConnectionURL($url); + } + die(); + } } diff --git a/airtime_mvc/application/forms/AddShowLiveStream.php b/airtime_mvc/application/forms/AddShowLiveStream.php index 56d6bd4b2..44e6e4087 100644 --- a/airtime_mvc/application/forms/AddShowLiveStream.php +++ b/airtime_mvc/application/forms/AddShowLiveStream.php @@ -47,13 +47,8 @@ class Application_Form_AddShowLiveStream extends Zend_Form_SubForm ->setDecorators(array('ViewHelper')); $this->addElement($custom_password); - // hardcoded for now - $liquidsoap_host = 'localhost'; - $liquidsoap_port = "8080"; - $liquidsoap_mount_point = "test"; - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>"http://$liquidsoap_host:$liquidsoap_port/$liquidsoap_mount_point")) + array('ViewScript', array('viewScript' => 'form/add-show-live-stream.phtml', "connection_url"=>Application_Model_Preference::GetLiveDJSourceConnectionURL())) )); } } \ No newline at end of file diff --git a/airtime_mvc/application/forms/LiveStreamingPreferences.php b/airtime_mvc/application/forms/LiveStreamingPreferences.php index 721e7af07..235d75786 100644 --- a/airtime_mvc/application/forms/LiveStreamingPreferences.php +++ b/airtime_mvc/application/forms/LiveStreamingPreferences.php @@ -5,10 +5,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm public function init() { - $this->setDecorators(array( - array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml')) - )); - //Master username $master_username = new Zend_Form_Element_Text('master_username'); $master_username->setAttrib('autocomplete', 'off') @@ -31,37 +27,51 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm $this->addElement($master_password); //liquidsoap harbor.input port - $port = new Zend_Form_Element_Text('master_harbor_input_port'); - $port->setLabel("Master DJ Port") - ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamPort()) + $m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort(); + $master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port'); + $master_dj_port->setLabel("Master DJ Port") + ->setValue($m_port) ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); - $this->addElement($port); + $this->addElement($master_dj_port); - $mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); - $mount->setLabel("Master DJ Mount Point") - ->setValue(Application_Model_StreamSetting::GetMasterLiveSteamMountPoint()) + $m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint(); + $master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); + $master_dj_mount->setLabel("Master DJ Mount Point") + ->setValue($m_mount) ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - $this->addElement($mount); + $this->addElement($master_dj_mount); //liquidsoap harbor.input port - $port = new Zend_Form_Element_Text('dj_harbor_input_port'); - $port->setLabel("DJ Port") - ->setValue(Application_Model_StreamSetting::GetDJLiveSteamPort()) + $l_port = Application_Model_StreamSetting::GetDJLiveSteamPort(); + $live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port'); + $live_dj_port->setLabel("DJ Port") + ->setValue($l_port) ->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999)))) ->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>'Only numbers are allowed.'))) ->setDecorators(array('ViewHelper')); - $this->addElement($port); + $this->addElement($live_dj_port); - $mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point'); - $mount->setLabel("DJ Mount Point") - ->setValue(Application_Model_StreamSetting::GetDJLiveSteamMountPoint()) + $l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint(); + $live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point'); + $live_dj_mount->setLabel("DJ Mount Point") + ->setValue($l_mount) ->setValidators(array( array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered')))) ->setDecorators(array('ViewHelper')); - $this->addElement($mount); + $this->addElement($live_dj_mount); + + $master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL(); + $live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL(); + + $master_dj_connection_url = ($master_dj_connection_url == "")?("http://".$_SERVER['SERVER_NAME'].":".$m_port."/".$m_mount):$master_dj_connection_url; + $live_dj_connection_url = ($live_dj_connection_url == "")?"http://".$_SERVER['SERVER_NAME'].":".$l_port."/".$l_mount:$live_dj_connection_url; + + $this->setDecorators(array( + array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url,)) + )); } } \ No newline at end of file diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 38b220aac..ce6a61d13 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -740,6 +740,22 @@ class Application_Model_Preference return "on"; } } + + public static function SetMasterDJSourceConnectionURL($value){ + self::SetValue("master_dj_source_connection_url", $value, false); + } + + public static function GetMasterDJSourceConnectionURL(){ + return self::GetValue("master_dj_source_connection_url"); + } + + public static function SetLiveDJSourceConnectionURL($value){ + self::SetValue("live_dj_source_connection_url", $value, false); + } + + public static function GetLiveDJSourceConnectionURL(){ + return self::GetValue("live_dj_source_connection_url"); + } /* User specific preferences end */ } diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 59a1adc54..bc0fe6f06 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -133,7 +133,6 @@ class Application_Model_StreamSetting { if(!isset($exists["dj_live_stream_mp"])){ $rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string")); } - Logging::log(print_r($rows, true)); return $rows; } diff --git a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php index 12bf8537d..2a8366aa0 100644 --- a/airtime_mvc/application/views/helpers/SourceSwitchStatus.php +++ b/airtime_mvc/application/views/helpers/SourceSwitchStatus.php @@ -3,7 +3,6 @@ class Airtime_View_Helper_SourceSwitchStatus extends Zend_View_Helper_Abstract{ public function SourceSwitchStatus(){ $status = array("live_dj"=>Application_Model_Preference::GetSourceSwitchStatus("live_dj"), "master_dj"=>Application_Model_Preference::GetSourceSwitchStatus("master_dj")); - Logging::log(print_r($status,true)); return $status; } } \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml index b62ff41fe..b94c4e2e0 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_livestream.phtml @@ -57,6 +57,14 @@ +