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

This commit is contained in:
Yuchen Wang 2011-11-14 00:35:27 -05:00
commit becaf7a152
12 changed files with 114 additions and 67 deletions

View File

@ -415,7 +415,7 @@ class ApiController extends Zend_Controller_Action
$show_inst->setRecordedFile($file_id);
$show_name = $show_inst->getName();
$show_genre = $show_inst->getGenre();
$show_start_time = ConvertToLocalDateTimeString($show_inst->getShowStart());
$show_start_time = ConvertToLocalDateTimeString($show_inst->getShowInstanceStart());
} catch (Exception $e){
//we've reached here probably because the show was

View File

@ -160,8 +160,10 @@ class PreferenceController extends Zend_Controller_Action
$num_of_stream = intval(Application_Model_Preference::GetNumOfStreams());
$form = new Application_Form_StreamSetting();
$form->setSetting($setting);
$form->startFrom();
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$form->setSetting($setting);
$form->startFrom();
}
for($i=1; $i<=$num_of_stream; $i++){
$subform = new Application_Form_StreamSettingSubForm();
$subform->setPrefix($i);

View File

@ -181,8 +181,8 @@ class ScheduleController extends Zend_Controller_Action
$params = '/format/json/id/#id#';
$showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowStart());
$showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowEnd());
$showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceStart());
$showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowInstanceEnd());
$menu = array();
@ -355,8 +355,8 @@ class ScheduleController extends Zend_Controller_Action
return false;
}
$start_timestamp = $show->getShowStart();
$end_timestamp = $show->getShowEnd();
$start_timestamp = $show->getShowInstanceStart();
$end_timestamp = $show->getShowInstanceEnd();
//check to make sure show doesn't overlap.
if(Application_Model_Show::getShows(new DateTime($start_timestamp, new DateTimeZone("UTC")),
@ -408,7 +408,7 @@ class ScheduleController extends Zend_Controller_Action
return false;
}
$originalShowName = $originalShow->getName();
$originalShowStart = $originalShow->getShowStart();
$originalShowStart = $originalShow->getShowInstanceStart();
$timestamp = strtotime($originalShowStart);
$this->view->additionalShowInfo =
@ -465,8 +465,8 @@ class ScheduleController extends Zend_Controller_Action
'add_show_genre' => $show->getGenre(),
'add_show_description' => $show->getDescription()));
$startsDateTime = new DateTime($showInstance->getShowStart(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($showInstance->getShowEnd(), new DateTimeZone("UTC"));
$startsDateTime = new DateTime($showInstance->getShowInstanceStart(), new DateTimeZone("UTC"));
$endsDateTime = new DateTime($showInstance->getShowInstanceEnd(), new DateTimeZone("UTC"));
$startsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
$endsDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -760,7 +760,7 @@ class ScheduleController extends Zend_Controller_Action
}
$show = new Application_Model_Show($showInstance->getShowId());
$show->cancelShow($showInstance->getShowStart());
$show->cancelShow($showInstance->getShowInstanceStart());
}
}

View File

@ -26,21 +26,21 @@ class Application_Model_Dashboard
if ($showInstance->isRecorded()){
//last item is a show instance
return array("name"=>$showInstance->getName(),
"starts"=>$showInstance->getShowStart(),
"ends"=>$showInstance->getShowEnd());
"starts"=>$showInstance->getShowInstanceStart(),
"ends"=>$showInstance->getShowInstanceEnd());
} else {
return null;
}
} else {
//return the one that started later.
if ($row[0]["starts"] >= $showInstance->getShowStart()){
if ($row[0]["starts"] >= $showInstance->getShowInstanceStart()){
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
"starts"=>$row[0]["starts"],
"ends"=>$row[0]["ends"]);
} else {
return array("name"=>$showInstance->getName(),
"starts"=>$showInstance->getShowStart(),
"ends"=>$showInstance->getShowEnd());
"starts"=>$showInstance->getShowInstanceStart(),
"ends"=>$showInstance->getShowInstanceEnd());
}
}
}
@ -75,8 +75,8 @@ class Application_Model_Dashboard
//last item is a show instance
if ($showInstance->isRecorded()){
return array("name"=>$showInstance->getName(),
"starts"=>$showInstance->getShowStart(),
"ends"=>$showInstance->getShowEnd(),
"starts"=>$showInstance->getShowInstanceStart(),
"ends"=>$showInstance->getShowInstanceEnd(),
"media_item_played"=>false,
"record"=>true);
} else {
@ -114,22 +114,22 @@ class Application_Model_Dashboard
if ($showInstance->isRecorded()){
//last item is a show instance
return array("name"=>$showInstance->getName(),
"starts"=>$showInstance->getShowStart(),
"ends"=>$showInstance->getShowEnd());
"starts"=>$showInstance->getShowInstanceStart(),
"ends"=>$showInstance->getShowInstanceEnd());
} else {
return null;
}
} else {
//return the one that starts sooner.
if ($row[0]["starts"] <= $showInstance->getShowStart()){
if ($row[0]["starts"] <= $showInstance->getShowInstanceStart()){
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
"starts"=>$row[0]["starts"],
"ends"=>$row[0]["ends"]);
} else {
return array("name"=>$showInstance->getName(),
"starts"=>$showInstance->getShowStart(),
"ends"=>$showInstance->getShowEnd());
"starts"=>$showInstance->getShowInstanceStart(),
"ends"=>$showInstance->getShowInstanceEnd());
}
}
}

View File

@ -81,8 +81,8 @@ class Application_Model_Nowplaying
$showId = $si->getShowId();
$show = new Application_Model_Show($showId);
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowStart());
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowEnd());
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceStart());
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceEnd());
//append show header row
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));

View File

@ -144,7 +144,7 @@ class Application_Model_Schedule {
global $CC_CONFIG;
$date = new Application_Model_DateHelper;
$timeNow = $date->getUtcTimestamp();
$timeNow = $date->getTimestamp();
return array("env"=>APPLICATION_ENV,
"schedulerTime"=>$timeNow,
"previous"=>Application_Model_Dashboard::GetPreviousItem($timeNow),

View File

@ -134,12 +134,17 @@ class Application_Model_Show {
}
/**
* Remove Show Instances that occur on days of the week specified
* This function is called when a repeating show is edited and the
* days that is repeats on have changed. More specifically, a day
* that the show originally repeated on has been "unchecked".
*
* Removes Show Instances that occur on days of the week specified
* by input array. For example, if array contains one value of "0",
* then all show instances that occur on Sunday are removed.
* (0 = Sunday, 1=Monday) then all show instances that occur on
* Sunday are removed.
*
* @param array p_uncheckedDays
* An array specifying which days
* An array specifying which days should be removed.
*/
public function removeUncheckedDaysInstances($p_uncheckedDays)
{
@ -307,8 +312,13 @@ class Application_Model_Show {
/**
* Deletes all future instances of the current show object
* from the show_instances table.
*
* from the show_instances table. This function is used when
* a show is being edited - in some cases, when a show is edited
* we just destroy all future show instances, and let another function
* regenerate them later on. Note that this isn't always the most
* desirable thing to do. Deleting a show instance and regenerating
* it cause any scheduled playlists within those show instances to
* be gone for good.
*/
public function deleteAllInstances(){
global $CC_DBC;
@ -327,7 +337,6 @@ class Application_Model_Show {
/**
* Deletes all future rebroadcast instances of the current
* show object from the show_instances table.
*
*/
public function deleteAllRebroadcasts(){
global $CC_DBC;
@ -346,7 +355,9 @@ class Application_Model_Show {
/**
* Deletes all show instances of current show after a
* certain date.
* certain date. Note that although not enforced, $p_date
* should never be in the past, as we never want to allow
* deletion of shows that have already occured.
*
* @param string $p_date
* The date which to delete after, if null deletes from the current timestamp.
@ -370,17 +381,16 @@ class Application_Model_Show {
$CC_DBC->query($sql);
/*
CcShowInstancesQuery::create()
->filterByDbShowId($showId)
->filterByDbStartTime($p_date, Criteria::GREATER_EQUAL)
->delete();
*/
}
/**
* Deletes all show instances of current show before a
* certain date.
* certain date.
*
* This function is used in the case where a repeating show is being
* edited and the start date of the first show has been changed more
* into the future. In this case, delete any show instances that
* exist before the new start date.
*
* @param string $p_date
* The date which to delete before
@ -494,14 +504,15 @@ class Application_Model_Show {
public function isStartDateTimeInPast(){
$date = new Application_Model_DateHelper;
$current_timestamp = $date->getTimestamp();
return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime());
return ($current_timestamp > ($this->getStartDate()." ".$this->getStartTime()));
}
/**
* Get the ID's of future instance of the current show.
*
* @return array
* A simple array containing all future instance ID's
* A simple array containing all ID's of show instance
* scheduled in the future.
*/
public function getAllFutureInstanceIds(){
global $CC_DBC;
@ -523,6 +534,13 @@ class Application_Model_Show {
return $instance_ids;
}
/* Called when a show's duration is changed (edited).
*
* @param array $p_data
* array containing the POST data about the show from the
* browser.
*
*/
private function updateDurationTime($p_data){
//need to update cc_show_instances, cc_show_days
@ -1365,7 +1383,7 @@ class Application_Model_Show {
// Convert back to local timezone
$rows = $CC_DBC->GetAll($sql);
Application_Model_Show::ConvertToLocalTimeZone($rows, array("start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
return $rows;
}
@ -1406,7 +1424,7 @@ class Application_Model_Show {
// Convert timestamps to local timezone
$rows = $CC_DBC->GetAll($sql);
Application_Model_Show::ConvertToLocalTimeZone($rows, array("start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
return $rows;
}
@ -1460,7 +1478,7 @@ class Application_Model_Show {
*/
public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) {
$timezone = date_default_timezone_get();
foreach($rows as &$row) {
foreach($columnsToConvert as $column) {
$row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]);

View File

@ -56,7 +56,7 @@ class Application_Model_ShowInstance {
* @return string in format "Y-m-d H:i:s" (PHP time notation)
* TODO: make this function return a DateTime object instead.
*/
public function getShowStart()
public function getShowInstanceStart()
{
return $this->_showInstance->getDbStarts();
}
@ -66,21 +66,21 @@ class Application_Model_ShowInstance {
* @return string in format "Y-m-d H:i:s" (PHP time notation)
* TODO: make this function return a DateTime object instead.
*/
public function getShowEnd()
public function getShowInstanceEnd()
{
return $this->_showInstance->getDbEnds();
}
public function getStartDate()
{
$showStart = $this->getShowStart();
$showStart = $this->getShowInstanceStart();
$showStartExplode = explode(" ", $showStart);
return $showStartExplode[0];
}
public function getStartTime()
{
$showStart = $this->getShowStart();
$showStart = $this->getShowInstanceStart();
$showStartExplode = explode(" ", $showStart);
return $showStartExplode[1];
@ -150,7 +150,7 @@ class Application_Model_ShowInstance {
if (!is_null($scheduleStarts)){
$scheduleStartsEpoch = strtotime($scheduleStarts);
$showStartsEpoch = strtotime($this->getShowStart());
$showStartsEpoch = strtotime($this->getShowInstanceStart());
$diff = $showStartsEpoch - $scheduleStartsEpoch;
@ -183,8 +183,8 @@ class Application_Model_ShowInstance {
$mins = abs($deltaMin%60);
$today_timestamp = time();
$starts = $this->getShowStart();
$ends = $this->getShowEnd();
$starts = $this->getShowInstanceStart();
$ends = $this->getShowInstanceEnd();
$startsDateTime = new DateTime($starts, new DateTimeZone("UTC"));
@ -247,8 +247,8 @@ class Application_Model_ShowInstance {
$mins = abs($deltaMin%60);
$today_timestamp = date("Y-m-d H:i:s");
$starts = $this->getShowStart();
$ends = $this->getShowEnd();
$starts = $this->getShowInstanceStart();
$ends = $this->getShowInstanceEnd();
if(strtotime($today_timestamp) > strtotime($starts)) {
return "can't resize a past show";
@ -303,7 +303,7 @@ class Application_Model_ShowInstance {
$lastGroupId = $this->getLastGroupId();
if (is_null($lastGroupId)) {
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), null, $plId);
$groupId = $sched->add($this->_instanceId, $this->getShowInstanceStart(), null, $plId);
}
else {
$groupId = $sched->addPlaylistAfter($this->_instanceId, $lastGroupId, $plId);
@ -323,7 +323,7 @@ class Application_Model_ShowInstance {
$lastGroupId = $this->getLastGroupId();
if (is_null($lastGroupId)) {
$groupId = $sched->add($this->_instanceId, $this->getShowStart(), $file_id);
$groupId = $sched->add($this->_instanceId, $this->getShowInstanceStart(), $file_id);
}
else {
$groupId = $sched->addFileAfter($this->_instanceId, $lastGroupId, $file_id);
@ -440,8 +440,8 @@ class Application_Model_ShowInstance {
public function getPercentScheduled()
{
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
$start_timestamp = $this->getShowInstanceStart();
$end_timestamp = $this->getShowInstanceEnd();
$time_filled = $this->getTimeScheduled();
$s_epoch = strtotime($start_timestamp);
@ -460,8 +460,8 @@ class Application_Model_ShowInstance {
{
global $CC_DBC;
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
$start_timestamp = $this->getShowInstanceStart();
$end_timestamp = $this->getShowInstanceEnd();
$sql = "SELECT TIMESTAMP '{$end_timestamp}' - TIMESTAMP '{$start_timestamp}' ";
$length = $CC_DBC->GetOne($sql);
@ -596,11 +596,11 @@ class Application_Model_ShowInstance {
}
public function getShowEndGapTime(){
$showEnd = $this->getShowEnd();
$showEnd = $this->getShowInstanceEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
if (is_null($lastItemEnd)){
$lastItemEnd = $this->getShowStart();
$lastItemEnd = $this->getShowInstanceStart();
}

View File

@ -50,6 +50,13 @@ class Application_Model_StreamSetting {
return $rows;
}
/*
* function that take all the information of stream and sets them.
* This is used by stream setting via UI.
*
* @param $data - array that contains all the data. $data is [][] which
* contains multiple stream information
*/
public static function setStreamSetting($data){
global $CC_DBC;
foreach($data as $key=>$d){
@ -76,6 +83,20 @@ class Application_Model_StreamSetting {
}
}
/*
* Sets indivisual stream setting.
*
* $data - data array. $data is [].
*/
public static function setIndivisualStreamSetting($data){
global $CC_DBC;
foreach($data as $keyname => $v){
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
$CC_DBC->query($sql);
}
}
public static function setLiquidsoapError($stream_id, $msg){
global $CC_DBC;

View File

@ -8,6 +8,7 @@
<div style="clear:both"></div>
<?php }?>
<?php echo $this->statusMsg;?>
<?php if($this->form->getElement('output_sound_device') != null){?>
<fieldset class="padded">
<legend>Hardware Audio Out</legend>
<dl class="zend_form">
@ -21,6 +22,7 @@
</dd>
</dl>
</fieldset>
<?php } ?>
<?php
for($i=1;$i<=$this->num_stream;$i++){
echo $this->form->getSubform("s".$i."_subform");

View File

@ -13,7 +13,7 @@ var currentElem;
var serverUpdateInterval = 5000;
var uiUpdateInterval = 200;
var timezoneOffset = 0;
//var timezoneOffset = 0;
//set to "development" if we are developing :). Useful to disable alerts
//when entering production mode.
@ -167,11 +167,13 @@ function updatePlaybar(){
$('#show-length').empty();
if (currentShow.length > 0){
$('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime + timezoneOffset) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime + timezoneOffset));
//$('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime + timezoneOffset) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime + timezoneOffset));
$('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime));
}
/* Column 2 update */
$('#time').text(convertDateToHHMMSS(estimatedSchedulePosixTime + timezoneOffset));
//$('#time').text(convertDateToHHMMSS(estimatedSchedulePosixTime + timezoneOffset));
$('#time').text(convertDateToHHMMSS(estimatedSchedulePosixTime));
}
function calcAdditionalData(currentItem){
@ -211,7 +213,7 @@ function parseItems(obj){
calcAdditionalShowData(obj.nextShow);
var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
timezoneOffset = parseInt(obj.timezoneOffset)*1000;
//timezoneOffset = parseInt(obj.timezoneOffset)*1000;
var date = new Date();
localRemoteTimeOffset = date.getTime() - schedulePosixTime;
}

View File

@ -30,7 +30,9 @@ function rebuildStreamURL(ele){
function restrictOggBitrate(ele, on){
var div = ele.closest("div")
if(on){
div.find("select[id$=data-bitrate]").find("option[value='48']").attr('selected','selected');
if(parseInt(div.find("select[id$=data-bitrate]").val(),10) < 48){
div.find("select[id$=data-bitrate]").find("option[value='48']").attr("selected","selected");
}
div.find("select[id$=data-bitrate]").find("option[value='24']").attr("disabled","disabled");
div.find("select[id$=data-bitrate]").find("option[value='32']").attr("disabled","disabled");
}else{