CC-3522 : Now Playing Screen-> Periodical message pops up
This commit is contained in:
parent
b5bf5e9598
commit
b5863d3d7a
|
@ -238,6 +238,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
$show_filter = intval($request->getParam("showFilter", 0));
|
$show_filter = intval($request->getParam("showFilter", 0));
|
||||||
$my_shows = intval($request->getParam("myShows", 0));
|
$my_shows = intval($request->getParam("myShows", 0));
|
||||||
$timestamp = intval($request->getParam("timestamp", -1));
|
$timestamp = intval($request->getParam("timestamp", -1));
|
||||||
|
$instances = $request->getParam("instances", array());
|
||||||
|
|
||||||
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
||||||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
||||||
|
@ -247,7 +248,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
|
|
||||||
//only send the schedule back if updates have been made.
|
//only send the schedule back if updates have been made.
|
||||||
// -1 default will always call the schedule to be sent back if no timestamp is defined.
|
// -1 default will always call the schedule to be sent back if no timestamp is defined.
|
||||||
if ($showBuilder->hasBeenUpdatedSince($timestamp)) {
|
if ($showBuilder->hasBeenUpdatedSince($timestamp, $instances)) {
|
||||||
$this->view->update = true;
|
$this->view->update = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -275,7 +276,9 @@ class ShowbuilderController extends Zend_Controller_Action
|
||||||
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
||||||
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
||||||
|
|
||||||
$this->view->schedule = $showBuilder->GetItems();
|
$data = $showBuilder->GetItems();
|
||||||
|
$this->view->schedule = $data["schedule"];
|
||||||
|
$this->view->instances = $data["showInstances"];
|
||||||
$this->view->timestamp = $current_time;
|
$this->view->timestamp = $current_time;
|
||||||
|
|
||||||
$end = microtime(true);
|
$end = microtime(true);
|
||||||
|
|
|
@ -11,12 +11,6 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
||||||
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))
|
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))
|
||||||
));
|
));
|
||||||
|
|
||||||
//set value to -1 originally to ensure we grab the schedule on first call.
|
|
||||||
$timestamp = new Zend_Form_Element_Hidden('sb_timestamp');
|
|
||||||
$timestamp->setValue(-1)
|
|
||||||
->setDecorators(array('ViewHelper'));
|
|
||||||
$this->addElement($timestamp);
|
|
||||||
|
|
||||||
// Add start date element
|
// Add start date element
|
||||||
$startDate = new Zend_Form_Element_Text('sb_date_start');
|
$startDate = new Zend_Form_Element_Text('sb_date_start');
|
||||||
$startDate->class = 'input_text';
|
$startDate->class = 'input_text';
|
||||||
|
|
|
@ -19,6 +19,8 @@ class Application_Model_ShowBuilder {
|
||||||
private $contentDT;
|
private $contentDT;
|
||||||
private $epoch_now;
|
private $epoch_now;
|
||||||
private $currentShow;
|
private $currentShow;
|
||||||
|
|
||||||
|
private $showInstances = array();
|
||||||
|
|
||||||
private $defaultRowArray = array(
|
private $defaultRowArray = array(
|
||||||
"header" => false,
|
"header" => false,
|
||||||
|
@ -311,11 +313,13 @@ class Application_Model_ShowBuilder {
|
||||||
* @return boolean whether the schedule in the show builder's range has been updated.
|
* @return boolean whether the schedule in the show builder's range has been updated.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function hasBeenUpdatedSince($timestamp) {
|
public function hasBeenUpdatedSince($timestamp, $instances) {
|
||||||
$outdated = false;
|
$outdated = false;
|
||||||
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
||||||
|
$currentInstances = array();
|
||||||
|
|
||||||
foreach ($shows as $show) {
|
foreach ($shows as $show) {
|
||||||
|
$currentInstances[] = $show["instance_id"];
|
||||||
|
|
||||||
if (isset($show["last_scheduled"])) {
|
if (isset($show["last_scheduled"])) {
|
||||||
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
|
$dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC"));
|
||||||
|
@ -331,7 +335,8 @@ class Application_Model_ShowBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($shows) == 0) {
|
//see if the displayed show instances have changed. (deleted, empty schedule etc)
|
||||||
|
if ($outdated === false && count($instances) !== count($currentInstances)) {
|
||||||
$outdated = true;
|
$outdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +397,10 @@ class Application_Model_ShowBuilder {
|
||||||
if (isset($row)) {
|
if (isset($row)) {
|
||||||
$display_items[] = $row;
|
$display_items[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($current_id !== -1 && !in_array($current_id, $this->showInstances)) {
|
||||||
|
$this->showInstances[] = $current_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//make the last footer if there were any scheduled items.
|
//make the last footer if there were any scheduled items.
|
||||||
|
@ -399,6 +408,6 @@ class Application_Model_ShowBuilder {
|
||||||
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
|
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $display_items;
|
return array("schedule" => $display_items, "showInstances" => $this->showInstances);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<div class="sb-timerange">
|
<div class="sb-timerange">
|
||||||
<?php echo $this->element->getElement('sb_timestamp') ?>
|
|
||||||
<?php echo $this->element->getElement('sb_date_start') ?>
|
<?php echo $this->element->getElement('sb_date_start') ?>
|
||||||
<?php echo $this->element->getElement('sb_time_start') ?>
|
<?php echo $this->element->getElement('sb_time_start') ?>
|
||||||
<?php echo $this->element->getElement('sb_date_end') ?>
|
<?php echo $this->element->getElement('sb_date_end') ?>
|
||||||
|
|
|
@ -19,31 +19,35 @@ var AIRTIME = (function(AIRTIME){
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.timeout = undefined;
|
mod.timeout = undefined;
|
||||||
|
mod.timestamp = -1;
|
||||||
|
mod.showInstances = [];
|
||||||
|
|
||||||
mod.resetTimestamp = function() {
|
mod.resetTimestamp = function() {
|
||||||
var timestamp = $("#sb_timestamp");
|
|
||||||
//reset timestamp value since input values could have changed.
|
mod.timestamp = -1;
|
||||||
timestamp.val(-1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.setTimestamp = function(timestamp) {
|
mod.setTimestamp = function(timestamp) {
|
||||||
$("#sb_timestamp").val(timestamp);
|
|
||||||
|
mod.timestamp = timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.getTimestamp = function() {
|
mod.getTimestamp = function() {
|
||||||
var timestamp = $("#sb_timestamp"),
|
|
||||||
val;
|
|
||||||
|
|
||||||
//if the timestamp field is on the page return it, or give the default of -1
|
if (mod.timestamp !== undefined) {
|
||||||
//to ensure a page refresh.
|
return mod.timestamp;
|
||||||
if (timestamp.length === 1) {
|
|
||||||
val = timestamp.val();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return val;
|
|
||||||
|
mod.setShowInstances = function(showInstances) {
|
||||||
|
mod.showInstances = showInstances;
|
||||||
|
};
|
||||||
|
|
||||||
|
mod.getShowInstances = function() {
|
||||||
|
return mod.showInstances;
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.getSelectedData = function() {
|
mod.getSelectedData = function() {
|
||||||
|
@ -117,6 +121,7 @@ var AIRTIME = (function(AIRTIME){
|
||||||
mod.fnServerData = function ( sSource, aoData, fnCallback ) {
|
mod.fnServerData = function ( sSource, aoData, fnCallback ) {
|
||||||
|
|
||||||
aoData.push( { name: "timestamp", value: AIRTIME.showbuilder.getTimestamp()} );
|
aoData.push( { name: "timestamp", value: AIRTIME.showbuilder.getTimestamp()} );
|
||||||
|
aoData.push( { name: "instances", value: AIRTIME.showbuilder.getShowInstances()} );
|
||||||
aoData.push( { name: "format", value: "json"} );
|
aoData.push( { name: "format", value: "json"} );
|
||||||
|
|
||||||
if (mod.fnServerData.hasOwnProperty("start")) {
|
if (mod.fnServerData.hasOwnProperty("start")) {
|
||||||
|
@ -130,16 +135,17 @@ var AIRTIME = (function(AIRTIME){
|
||||||
aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
|
aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax( {
|
$.ajax({
|
||||||
"dataType": "json",
|
"dataType": "json",
|
||||||
"type": "POST",
|
"type": "POST",
|
||||||
"url": sSource,
|
"url": sSource,
|
||||||
"data": aoData,
|
"data": aoData,
|
||||||
"success": function(json) {
|
"success": function(json) {
|
||||||
AIRTIME.showbuilder.setTimestamp(json.timestamp);
|
AIRTIME.showbuilder.setTimestamp(json.timestamp);
|
||||||
|
AIRTIME.showbuilder.setShowInstances(json.instances);
|
||||||
fnCallback(json);
|
fnCallback(json);
|
||||||
}
|
}
|
||||||
} );
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
mod.builderDataTable = function() {
|
mod.builderDataTable = function() {
|
||||||
|
|
|
@ -218,6 +218,7 @@ AIRTIME = (function(AIRTIME) {
|
||||||
data["start"] = start;
|
data["start"] = start;
|
||||||
data["end"] = end;
|
data["end"] = end;
|
||||||
data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
|
data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
|
||||||
|
data["instances"] = AIRTIME.showbuilder.getShowInstances();
|
||||||
|
|
||||||
if (fn.hasOwnProperty("ops")) {
|
if (fn.hasOwnProperty("ops")) {
|
||||||
data["myShows"] = fn.ops.myShows;
|
data["myShows"] = fn.ops.myShows;
|
||||||
|
|
Loading…
Reference in New Issue