Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
martin 2011-09-29 18:19:08 -04:00
commit 421f543f99
8 changed files with 73 additions and 73 deletions

View File

@ -76,10 +76,10 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetStationWebSite($values["StationWebSite"]); Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
Application_Model_Preference::SetPublicise($values["Publicise"]); Application_Model_Preference::SetPublicise($values["Publicise"]);
$form->Logo->receive(); $form->Logo->receive();
$imagePath = $form->Logo->getFileName(); $imagePath = $form->Logo->getFileName();
Application_Model_Preference::SetStationCountry($values["Country"]); Application_Model_Preference::SetStationCountry($values["Country"]);
Application_Model_Preference::SetStationCity($values["City"]); Application_Model_Preference::SetStationCity($values["City"]);
Application_Model_Preference::SetStationDescription($values["Description"]); Application_Model_Preference::SetStationDescription($values["Description"]);
@ -103,36 +103,36 @@ class PreferenceController extends Zend_Controller_Action
$this->view->form = $form; $this->view->form = $form;
//$form->render($this->view); //$form->render($this->view);
} }
public function directoryConfigAction() public function directoryConfigAction()
{ {
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){ if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$request = $this->getRequest(); $request = $this->getRequest();
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/serverbrowse/serverbrowser.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/serverbrowse/serverbrowser.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/musicdirs.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/musicdirs.js','text/javascript');
$watched_dirs_pref = new Application_Form_WatchedDirPreferences(); $watched_dirs_pref = new Application_Form_WatchedDirPreferences();
$this->view->form = $watched_dirs_pref; $this->view->form = $watched_dirs_pref;
} }
} }
public function streamSettingAction() public function streamSettingAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js','text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js','text/javascript');
// get current settings // get current settings
$temp = Application_Model_StreamSetting::getStreamSetting(); $temp = Application_Model_StreamSetting::getStreamSetting();
$setting = array(); $setting = array();
foreach ($temp as $t){ foreach ($temp as $t){
$setting[$t['keyname']] = $t['value']; $setting[$t['keyname']] = $t['value'];
} }
// get predefined type and bitrate from pref table // get predefined type and bitrate from pref table
$temp_types = Application_Model_Preference::GetStreamType(); $temp_types = Application_Model_Preference::GetStreamType();
$stream_types = array(); $stream_types = array();
@ -144,7 +144,7 @@ class PreferenceController extends Zend_Controller_Action
} }
$stream_types[trim($type)] = $temp; $stream_types[trim($type)] = $temp;
} }
$temp_bitrate = Application_Model_Preference::GetStreamBitrate(); $temp_bitrate = Application_Model_Preference::GetStreamBitrate();
$max_bitrate = intval(Application_Model_Preference::GetMaxBitrate()); $max_bitrate = intval(Application_Model_Preference::GetMaxBitrate());
$stream_bitrates = array(); $stream_bitrates = array();
@ -153,7 +153,7 @@ class PreferenceController extends Zend_Controller_Action
$stream_bitrates[trim($type)] = strtoupper(trim($type))." Kbit/s"; $stream_bitrates[trim($type)] = strtoupper(trim($type))." Kbit/s";
} }
} }
$num_of_stream = intval(Application_Model_Preference::GetNumOfStreams()); $num_of_stream = intval(Application_Model_Preference::GetNumOfStreams());
$form = new Application_Form_StreamSetting(); $form = new Application_Form_StreamSetting();
$form->setSetting($setting); $form->setSetting($setting);
@ -193,7 +193,7 @@ class PreferenceController extends Zend_Controller_Action
} }
} }
$this->view->num_stream = $num_of_stream; $this->view->num_stream = $num_of_stream;
$this->view->disable_stream_conf = Application_Model_Preference::GetDisableStreamConf(); $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
$this->view->form = $form; $this->view->form = $form;
} }
@ -273,7 +273,7 @@ class PreferenceController extends Zend_Controller_Action
$watched_dirs_form = new Application_Form_WatchedDirPreferences(); $watched_dirs_form = new Application_Form_WatchedDirPreferences();
$this->view->subform = $watched_dirs_form->render(); $this->view->subform = $watched_dirs_form->render();
} }
public function isImportInProgressAction(){ public function isImportInProgressAction(){
$now = time(); $now = time();
$res = false; $res = false;

View File

@ -3,29 +3,29 @@
class Application_Form_StreamSetting extends Zend_Form class Application_Form_StreamSetting extends Zend_Form
{ {
private $setting; private $setting;
public function init() public function init()
{ {
} }
public function setSetting($setting){ public function setSetting($setting){
$this->setting = $setting; $this->setting = $setting;
} }
public function startFrom(){ public function startFrom() {
$setting = $this->setting; $setting = $this->setting;
$output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device'); $output_sound_device = new Zend_Form_Element_Checkbox('output_sound_device');
$output_sound_device->setLabel('Enabled') $output_sound_device->setLabel('Enabled')
->setRequired(false) ->setRequired(false)
->setValue(($setting['output_sound_device'] == "true")?1:0) ->setValue(($setting['output_sound_device'] == "true")?1:0)
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
if(Application_Model_Preference::GetDisableStreamConf() == "true"){ if (Application_Model_Preference::GetEnableStreamConf() == "false"){
$output_sound_device->setAttrib("readonly", true); $output_sound_device->setAttrib("readonly", true);
} }
$this->addElement($output_sound_device); $this->addElement($output_sound_device);
} }
public function isValid($data){ public function isValid($data){
$this->populate(array("output_sound_device"=>$data)); $this->populate(array("output_sound_device"=>$data));
return true; return true;

View File

@ -4,43 +4,43 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
private $setting; private $setting;
private $stream_types; private $stream_types;
private $stream_bitrates; private $stream_bitrates;
public function init() public function init()
{ {
} }
public function setPrefix($prefix){ public function setPrefix($prefix){
$this->prefix = $prefix; $this->prefix = $prefix;
} }
public function setSetting($setting){ public function setSetting($setting){
$this->setting = $setting; $this->setting = $setting;
} }
public function setStreamTypes($stream_types){ public function setStreamTypes($stream_types){
$this->stream_types = $stream_types; $this->stream_types = $stream_types;
} }
public function setStreamBitrates($stream_bitrates){ public function setStreamBitrates($stream_bitrates){
$this->stream_bitrates = $stream_bitrates; $this->stream_bitrates = $stream_bitrates;
} }
public function startForm(){ public function startForm(){
$prefix = "s".$this->prefix; $prefix = "s".$this->prefix;
$stream_number = $this->prefix; $stream_number = $this->prefix;
$setting = $this->setting; $setting = $this->setting;
$stream_types = $this->stream_types; $stream_types = $this->stream_types;
$stream_bitrates = $this->stream_bitrates; $stream_bitrates = $this->stream_bitrates;
$this->setIsArray(true); $this->setIsArray(true);
$this->setElementsBelongTo($prefix."_data"); $this->setElementsBelongTo($prefix."_data");
$disable_all = false; $disable_all = false;
if(Application_Model_Preference::GetDisableStreamConf() == "true"){ if(Application_Model_Preference::GetEnableStreamConf() == "false"){
$disable_all = true; $disable_all = true;
} }
$enable = new Zend_Form_Element_Checkbox('enable'); $enable = new Zend_Form_Element_Checkbox('enable');
$enable->setLabel('Enabled:') $enable->setLabel('Enabled:')
->setValue($setting[$prefix.'_output'] != 'disabled'?1:0) ->setValue($setting[$prefix.'_output'] != 'disabled'?1:0)
@ -49,7 +49,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$enable->setAttrib("disabled", "disabled"); $enable->setAttrib("disabled", "disabled");
} }
$this->addElement($enable); $this->addElement($enable);
$type = new Zend_Form_Element_Select('type'); $type = new Zend_Form_Element_Select('type');
$type->setLabel("Stream Type:") $type->setLabel("Stream Type:")
->setMultiOptions($stream_types) ->setMultiOptions($stream_types)
@ -59,7 +59,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$type->setAttrib("disabled", "disabled"); $type->setAttrib("disabled", "disabled");
} }
$this->addElement($type); $this->addElement($type);
$bitrate = new Zend_Form_Element_Select('bitrate'); $bitrate = new Zend_Form_Element_Select('bitrate');
$bitrate->setLabel("Bit Rate:") $bitrate->setLabel("Bit Rate:")
->setMultiOptions($stream_bitrates) ->setMultiOptions($stream_bitrates)
@ -70,7 +70,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
} }
$this->addElement($type); $this->addElement($type);
$this->addElement($bitrate); $this->addElement($bitrate);
$output = new Zend_Form_Element_Select('output'); $output = new Zend_Form_Element_Select('output');
$output->setLabel("Service Type:") $output->setLabel("Service Type:")
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"Shoutcast")) ->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"Shoutcast"))
@ -80,7 +80,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$output->setAttrib("disabled", "disabled"); $output->setAttrib("disabled", "disabled");
} }
$this->addElement($output); $this->addElement($output);
$host = new Zend_Form_Element_Text('host'); $host = new Zend_Form_Element_Text('host');
$host->setLabel("Server") $host->setLabel("Server")
->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"") ->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"")
@ -89,7 +89,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$host->setAttrib("disabled", "disabled"); $host->setAttrib("disabled", "disabled");
} }
$this->addElement($host); $this->addElement($host);
$port = new Zend_Form_Element_Text('port'); $port = new Zend_Form_Element_Text('port');
$port->setLabel("Port") $port->setLabel("Port")
->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"") ->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"")
@ -100,7 +100,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$port->setAttrib("disabled", "disabled"); $port->setAttrib("disabled", "disabled");
} }
$this->addElement($port); $this->addElement($port);
$pass = new Zend_Form_Element_Text('pass'); $pass = new Zend_Form_Element_Text('pass');
$pass->setLabel("Password") $pass->setLabel("Password")
->setValue(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"") ->setValue(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"")
@ -109,7 +109,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$pass->setAttrib("disabled", "disabled"); $pass->setAttrib("disabled", "disabled");
} }
$this->addElement($pass); $this->addElement($pass);
$genre = new Zend_Form_Element_Text('genre'); $genre = new Zend_Form_Element_Text('genre');
$genre->setLabel("Genre") $genre->setLabel("Genre")
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"") ->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
@ -118,7 +118,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$genre->setAttrib("disabled", "disabled"); $genre->setAttrib("disabled", "disabled");
} }
$this->addElement($genre); $this->addElement($genre);
$url = new Zend_Form_Element_Text('url'); $url = new Zend_Form_Element_Text('url');
$url->setLabel("URL") $url->setLabel("URL")
->setValue(isset($setting[$prefix.'_url'])?$setting[$prefix.'_url']:"") ->setValue(isset($setting[$prefix.'_url'])?$setting[$prefix.'_url']:"")
@ -127,7 +127,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$url->setAttrib("disabled", "disabled"); $url->setAttrib("disabled", "disabled");
} }
$this->addElement($url); $this->addElement($url);
$description = new Zend_Form_Element_Text('description'); $description = new Zend_Form_Element_Text('description');
$description->setLabel("Name/Description") $description->setLabel("Name/Description")
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"") ->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
@ -136,7 +136,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$description->setAttrib("disabled", "disabled"); $description->setAttrib("disabled", "disabled");
} }
$this->addElement($description); $this->addElement($description);
$mount = new Zend_Form_Element_Text('mount'); $mount = new Zend_Form_Element_Text('mount');
$mount->setLabel("Mount Point") $mount->setLabel("Mount Point")
->setValue(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"") ->setValue(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"")
@ -145,7 +145,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$mount->setAttrib("disabled", "disabled"); $mount->setAttrib("disabled", "disabled");
} }
$this->addElement($mount); $this->addElement($mount);
$user = new Zend_Form_Element_Text('user'); $user = new Zend_Form_Element_Text('user');
$user->setLabel("Username") $user->setLabel("Username")
->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"") ->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"")
@ -154,12 +154,12 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$user->setAttrib("disabled", "disabled"); $user->setAttrib("disabled", "disabled");
} }
$this->addElement($user); $this->addElement($user);
$this->setDecorators(array( $this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number)) array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number))
)); ));
} }
public function isValid ($data){ public function isValid ($data){
$isValid = parent::isValid($data); $isValid = parent::isValid($data);
if($data['enable'] == 1){ if($data['enable'] == 1){

View File

@ -259,13 +259,13 @@ class Application_Model_Preference
public static function GetStationDescription(){ public static function GetStationDescription(){
return self::GetValue("description"); return self::GetValue("description");
} }
public static function SetTimezone($timezone){ public static function SetTimezone($timezone){
self::SetValue("timezone", $timezone); self::SetValue("timezone", $timezone);
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
$md = array("timezone" => $timezone); $md = array("timezone" => $timezone);
} }
public static function GetTimezone(){ public static function GetTimezone(){
return self::GetValue("timezone"); return self::GetValue("timezone");
} }
@ -328,11 +328,11 @@ class Application_Model_Preference
$url = $systemInfoArray["AIRTIME_VERSION_URL"]; $url = $systemInfoArray["AIRTIME_VERSION_URL"];
$index = strpos($url,'/api/'); $index = strpos($url,'/api/');
$url = substr($url, 0, $index); $url = substr($url, 0, $index);
$headerInfo = get_headers(trim($url),1); $headerInfo = get_headers(trim($url),1);
$outputArray['WEB_SERVER'] = $headerInfo['Server'][0]; $outputArray['WEB_SERVER'] = $headerInfo['Server'][0];
} }
$outputArray['NUM_OF_USERS'] = Application_Model_User::getUserCount(); $outputArray['NUM_OF_USERS'] = Application_Model_User::getUserCount();
$outputArray['NUM_OF_SONGS'] = Application_Model_StoredFile::getFileCount(); $outputArray['NUM_OF_SONGS'] = Application_Model_StoredFile::getFileCount();
$outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount(); $outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount();
@ -365,74 +365,74 @@ class Application_Model_Preference
public static function GetRemindMeDate(){ public static function GetRemindMeDate(){
return self::GetValue("remindme"); return self::GetValue("remindme");
} }
public static function SetImportTimestamp(){ public static function SetImportTimestamp(){
$now = time(); $now = time();
if(self::GetImportTimestamp()+5 < $now){ if(self::GetImportTimestamp()+5 < $now){
self::SetValue("import_timestamp", $now); self::SetValue("import_timestamp", $now);
} }
} }
public static function GetImportTimestamp(){ public static function GetImportTimestamp(){
return self::GetValue("import_timestamp"); return self::GetValue("import_timestamp");
} }
public static function GetStreamType(){ public static function GetStreamType(){
$st = self::GetValue("stream_type"); $st = self::GetValue("stream_type");
return explode(',', $st); return explode(',', $st);
} }
public static function GetStreamBitrate(){ public static function GetStreamBitrate(){
$sb = self::GetValue("stream_bitrate"); $sb = self::GetValue("stream_bitrate");
return explode(',', $sb); return explode(',', $sb);
} }
public static function SetPrivacyPolicyCheck($flag){ public static function SetPrivacyPolicyCheck($flag){
self::SetValue("privacy_policy", $flag); self::SetValue("privacy_policy", $flag);
} }
public static function GetPrivacyPolicyCheck(){ public static function GetPrivacyPolicyCheck(){
return self::GetValue("privacy_policy"); return self::GetValue("privacy_policy");
} }
public static function SetNumOfStreams($num){ public static function SetNumOfStreams($num){
self::SetValue("num_of_streams", intval($num)); self::SetValue("num_of_streams", intval($num));
} }
public static function GetNumOfStreams(){ public static function GetNumOfStreams(){
return self::GetValue("num_of_streams"); return self::GetValue("num_of_streams");
} }
public static function SetMaxBitrate($bitrate){ public static function SetMaxBitrate($bitrate){
self::SetValue("max_bitrate", intval($bitrate)); self::SetValue("max_bitrate", intval($bitrate));
} }
public static function GetMaxBitrate(){ public static function GetMaxBitrate(){
return self::GetValue("max_bitrate"); return self::GetValue("max_bitrate");
} }
public static function SetPlanLevel($plan){ public static function SetPlanLevel($plan){
self::SetValue("plan_level", $plan); self::SetValue("plan_level", $plan);
} }
public static function GetPlanLevel(){ public static function GetPlanLevel(){
return self::GetValue("plan_level"); return self::GetValue("plan_level");
} }
public static function SetTrialEndingDate($date){ public static function SetTrialEndingDate($date){
self::SetValue("trial_end_date", $date); self::SetValue("trial_end_date", $date);
} }
public static function GetTrialEndingDate(){ public static function GetTrialEndingDate(){
return self::GetValue("trial_end_date"); return self::GetValue("trial_end_date");
} }
public static function SetDisableStreamConf($bool){ public static function SetEnableStreamConf($bool){
self::SetValue("disable_stream_conf", $bool); self::SetValue("enable_stream_conf", $bool);
} }
public static function GetDisableStreamConf(){ public static function GetEnableStreamConf(){
return self::GetValue("disable_stream_conf"); return self::GetValue("enable_stream_conf");
} }
public static function GetAirtimeVersion(){ public static function GetAirtimeVersion(){

View File

@ -958,7 +958,7 @@ class Application_Model_StoredFile {
$this->setSoundCloudErrorCode($code); $this->setSoundCloudErrorCode($code);
$this->setSoundCloudErrorMsg($msg); $this->setSoundCloudErrorMsg($msg);
// setting sc id to -3 which indicates error // setting sc id to -3 which indicates error
$this->setSoundCloudFileId(-3); $this->setSoundCloudFileId(SOUNDCLOUD_ERROR);
if(!in_array($code, array(0, 100))) { if(!in_array($code, array(0, 100))) {
break; break;
} }

View File

@ -1,6 +1,6 @@
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong stream-config"> <div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong stream-config">
<h2 style="float:left">Stream Settings</h2> <h2 style="float:left">Stream Settings</h2>
<?php if($this->disable_stream_conf != "true"){?> <?php if($this->enable_stream_conf == "true"){?>
<form method="post" action="/Preference/stream-setting" enctype="application/x-www-form-urlencoded"> <form method="post" action="/Preference/stream-setting" enctype="application/x-www-form-urlencoded">
<div class="button-bar bottom" id="submit-element" style="float:right"> <div class="button-bar bottom" id="submit-element" style="float:right">
<input type="submit" class="ui-button ui-state-default right-floated" value="Save" id="Save" name="Save" /> <input type="submit" class="ui-button ui-state-default right-floated" value="Save" id="Save" name="Save" />
@ -22,11 +22,11 @@
</dl> </dl>
</fieldset> </fieldset>
<?php <?php
for($i=1;$i<=$this->num_stream;$i++){ for($i=1;$i<=$this->num_stream;$i++){
echo $this->form->getSubform("s".$i."_subform"); echo $this->form->getSubform("s".$i."_subform");
} }
?> ?>
<?php if($this->disable_stream_conf != "true"){?> <?php if($this->enable_stream_conf == "true"){?>
<div class="button-bar bottom" id="submit-element"> <div class="button-bar bottom" id="submit-element">
<input type="submit" class="ui-button ui-state-default right-floated" value="Save" id="Save" name="Save" /> <input type="submit" class="ui-button ui-state-default right-floated" value="Save" id="Save" name="Save" />
</div> </div>