Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
a9d125bc4d
|
@ -238,6 +238,7 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$show_filter = intval($request->getParam("showFilter", 0));
|
||||
$my_shows = intval($request->getParam("myShows", 0));
|
||||
$timestamp = intval($request->getParam("timestamp", -1));
|
||||
$instances = $request->getParam("instances", array());
|
||||
|
||||
$startsDT = DateTime::createFromFormat("U", $starts_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.
|
||||
// -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;
|
||||
}
|
||||
else {
|
||||
|
@ -275,7 +276,9 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
||||
$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;
|
||||
|
||||
$end = microtime(true);
|
||||
|
|
|
@ -11,12 +11,6 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
|
|||
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
|
||||
$startDate = new Zend_Form_Element_Text('sb_date_start');
|
||||
$startDate->class = 'input_text';
|
||||
|
|
|
@ -19,6 +19,8 @@ class Application_Model_ShowBuilder {
|
|||
private $contentDT;
|
||||
private $epoch_now;
|
||||
private $currentShow;
|
||||
|
||||
private $showInstances = array();
|
||||
|
||||
private $defaultRowArray = array(
|
||||
"header" => false,
|
||||
|
@ -311,11 +313,13 @@ class Application_Model_ShowBuilder {
|
|||
* @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;
|
||||
$shows = Application_Model_Show::getShows($this->startDT, $this->endDT);
|
||||
$currentInstances = array();
|
||||
|
||||
foreach ($shows as $show) {
|
||||
$currentInstances[] = $show["instance_id"];
|
||||
|
||||
if (isset($show["last_scheduled"])) {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -392,6 +397,10 @@ class Application_Model_ShowBuilder {
|
|||
if (isset($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.
|
||||
|
@ -399,6 +408,6 @@ class Application_Model_ShowBuilder {
|
|||
$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">
|
||||
<?php echo $this->element->getElement('sb_timestamp') ?>
|
||||
<?php echo $this->element->getElement('sb_date_start') ?>
|
||||
<?php echo $this->element->getElement('sb_time_start') ?>
|
||||
<?php echo $this->element->getElement('sb_date_end') ?>
|
||||
|
|
|
@ -19,31 +19,35 @@ var AIRTIME = (function(AIRTIME){
|
|||
}
|
||||
|
||||
mod.timeout = undefined;
|
||||
mod.timestamp = -1;
|
||||
mod.showInstances = [];
|
||||
|
||||
mod.resetTimestamp = function() {
|
||||
var timestamp = $("#sb_timestamp");
|
||||
//reset timestamp value since input values could have changed.
|
||||
timestamp.val(-1);
|
||||
|
||||
mod.timestamp = -1;
|
||||
};
|
||||
|
||||
mod.setTimestamp = function(timestamp) {
|
||||
$("#sb_timestamp").val(timestamp);
|
||||
|
||||
mod.timestamp = timestamp;
|
||||
};
|
||||
|
||||
mod.getTimestamp = function() {
|
||||
var timestamp = $("#sb_timestamp"),
|
||||
val;
|
||||
|
||||
//if the timestamp field is on the page return it, or give the default of -1
|
||||
//to ensure a page refresh.
|
||||
if (timestamp.length === 1) {
|
||||
val = timestamp.val();
|
||||
if (mod.timestamp !== undefined) {
|
||||
return mod.timestamp;
|
||||
}
|
||||
else {
|
||||
val = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return val;
|
||||
};
|
||||
|
||||
mod.setShowInstances = function(showInstances) {
|
||||
mod.showInstances = showInstances;
|
||||
};
|
||||
|
||||
mod.getShowInstances = function() {
|
||||
return mod.showInstances;
|
||||
};
|
||||
|
||||
mod.getSelectedData = function() {
|
||||
|
@ -117,6 +121,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
mod.fnServerData = function ( sSource, aoData, fnCallback ) {
|
||||
|
||||
aoData.push( { name: "timestamp", value: AIRTIME.showbuilder.getTimestamp()} );
|
||||
aoData.push( { name: "instances", value: AIRTIME.showbuilder.getShowInstances()} );
|
||||
aoData.push( { name: "format", value: "json"} );
|
||||
|
||||
if (mod.fnServerData.hasOwnProperty("start")) {
|
||||
|
@ -130,16 +135,17 @@ var AIRTIME = (function(AIRTIME){
|
|||
aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
|
||||
}
|
||||
|
||||
$.ajax( {
|
||||
$.ajax({
|
||||
"dataType": "json",
|
||||
"type": "POST",
|
||||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": function(json) {
|
||||
AIRTIME.showbuilder.setTimestamp(json.timestamp);
|
||||
AIRTIME.showbuilder.setShowInstances(json.instances);
|
||||
fnCallback(json);
|
||||
}
|
||||
} );
|
||||
});
|
||||
};
|
||||
|
||||
mod.builderDataTable = function() {
|
||||
|
|
|
@ -218,6 +218,7 @@ AIRTIME = (function(AIRTIME) {
|
|||
data["start"] = start;
|
||||
data["end"] = end;
|
||||
data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
|
||||
data["instances"] = AIRTIME.showbuilder.getShowInstances();
|
||||
|
||||
if (fn.hasOwnProperty("ops")) {
|
||||
data["myShows"] = fn.ops.myShows;
|
||||
|
|
Loading…
Reference in New Issue