CC-3174 : Show Content Builder
adding time filled/empty row data.
This commit is contained in:
parent
7e223aebae
commit
4f5b5d8562
4 changed files with 78 additions and 28 deletions
|
@ -68,7 +68,7 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @return DateTime endDT in UTC
|
||||
*/
|
||||
private function findEndTime($p_startDT, $p_duration) {
|
||||
public static function findEndTime($p_startDT, $p_duration) {
|
||||
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
||||
|
@ -149,7 +149,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
Logging::log("adding file with id: ".$file["id"]);
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $file['cliplength']);
|
||||
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
|
@ -184,7 +184,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
Logging::log("adjusting iterm {$item->getDbId()}");
|
||||
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
|
@ -346,7 +346,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
Logging::log("adjusting item #".$item->getDbId());
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
$itemEndDT = self::findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT);
|
||||
$item->setDbEnds($itemEndDT);
|
||||
|
|
|
@ -7,6 +7,8 @@ class Application_Model_ShowBuilder {
|
|||
private $endDT;
|
||||
private $user;
|
||||
|
||||
private $contentDT;
|
||||
|
||||
private $defaultRowArray = array(
|
||||
"header" => false,
|
||||
"footer" => false,
|
||||
|
@ -15,9 +17,7 @@ class Application_Model_ShowBuilder {
|
|||
"id" => 0,
|
||||
"instance" => "",
|
||||
"starts" => "",
|
||||
"startsUnix" => null,
|
||||
"ends" => "",
|
||||
"endsUnix" => null,
|
||||
"runtime" => "",
|
||||
"title" => "",
|
||||
"creator" => "",
|
||||
|
@ -56,11 +56,45 @@ class Application_Model_ShowBuilder {
|
|||
return $runtime;
|
||||
}
|
||||
|
||||
private function makeFooterRow() {
|
||||
private function formatTimeFilled($p_sec) {
|
||||
|
||||
$formatted = "";
|
||||
$sign = ($p_sec < 0) ? "-" : "+";
|
||||
|
||||
$time = Application_Model_Playlist::secondsToPlaylistTime(abs($p_sec));
|
||||
Logging::log("time is: ".$time);
|
||||
$info = explode(":", $time);
|
||||
|
||||
$formatted .= $sign;
|
||||
|
||||
if ($info[0] > 0) {
|
||||
$formatted .= " {$info[0]}h";
|
||||
}
|
||||
|
||||
if ($info[1] > 0) {
|
||||
$formatted .= " {$info[1]}m";
|
||||
}
|
||||
|
||||
if ($info[2] > 0) {
|
||||
$sec = round($info[2], 0);
|
||||
$formatted .= " {$sec}s";
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
private function makeFooterRow($p_item) {
|
||||
|
||||
$row = $this->defaultRowArray;
|
||||
$row["footer"] = true;
|
||||
|
||||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
$contentDT = $this->contentDT;
|
||||
|
||||
$runtime = bcsub($contentDT->format("U.u"), $showEndDT->format("U.u"), 6);
|
||||
$row["runtime"] = $runtime;
|
||||
$row["fRuntime"] = $this->formatTimeFilled($runtime);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
@ -80,6 +114,8 @@ class Application_Model_ShowBuilder {
|
|||
$row["title"] = $p_item["show_name"];
|
||||
$row["instance"] = intval($p_item["si_id"]);
|
||||
|
||||
$this->contentDT = $showStartDT;
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
@ -107,6 +143,8 @@ class Application_Model_ShowBuilder {
|
|||
$row["title"] = $p_item["file_track_title"];
|
||||
$row["creator"] = $p_item["file_artist_name"];
|
||||
$row["album"] = $p_item["file_album_title"];
|
||||
|
||||
$this->contentDT = $schedEndDT;
|
||||
}
|
||||
//show is empty
|
||||
else {
|
||||
|
@ -125,14 +163,17 @@ class Application_Model_ShowBuilder {
|
|||
|
||||
$scheduled_items = Application_Model_Schedule::GetScheduleDetailItems($this->startDT->format("Y-m-d H:i:s"), $this->endDT->format("Y-m-d H:i:s"));
|
||||
|
||||
foreach ($scheduled_items as $item) {
|
||||
for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) {
|
||||
|
||||
$item = $scheduled_items[$i];
|
||||
|
||||
//make a header row.
|
||||
if ($current_id !== $item["si_id"]) {
|
||||
|
||||
//make a footer row.
|
||||
if ($current_id !== -1) {
|
||||
$display_items[] = $this->makeFooterRow();
|
||||
//pass in the previous row as it's the last row for the previous show.
|
||||
$display_items[] = $this->makeFooterRow($scheduled_items[$i-1]);
|
||||
}
|
||||
|
||||
$display_items[] = $this->makeHeaderRow($item);
|
||||
|
@ -146,7 +187,7 @@ class Application_Model_ShowBuilder {
|
|||
|
||||
//make the last footer if there were any scheduled items.
|
||||
if (count($scheduled_items) > 0) {
|
||||
$display_items[] = $this->makeFooterRow();
|
||||
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
|
||||
}
|
||||
|
||||
return $display_items;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue