From afe6ca7002a59403269aa6837efc30f4d4a44525 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Tue, 25 Aug 2015 11:46:20 -0400 Subject: [PATCH] Cosmetic updates --- .../application/layouts/scripts/layout.phtml | 2 +- .../layouts/scripts/showbuilder.phtml | 6 +- airtime_mvc/application/models/Scheduler.php | 59 ++++++++----------- .../views/scripts/partialviews/header.phtml | 2 +- .../scripts/showbuilder/builderDialog.phtml | 4 +- .../public/js/airtime/library/library.js | 16 ++--- .../public/js/airtime/showbuilder/builder.js | 2 +- 7 files changed, 40 insertions(+), 51 deletions(-) diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index 3ce114865..be6b38087 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -76,7 +76,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
-
+
diff --git a/airtime_mvc/application/layouts/scripts/showbuilder.phtml b/airtime_mvc/application/layouts/scripts/showbuilder.phtml index d90e6579e..631510d65 100644 --- a/airtime_mvc/application/layouts/scripts/showbuilder.phtml +++ b/airtime_mvc/application/layouts/scripts/showbuilder.phtml @@ -61,9 +61,9 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 03b87f5e7..29991e893 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -412,6 +412,8 @@ class Application_Model_Scheduler private function findNextStartTime($DT, $instanceId) { + // TODO: there is at least one case where this function creates a filler block with + // an incorrect length; should keep an eye on it $sEpoch = $DT->format("U.u"); $nEpoch = $this->epochNow; @@ -450,73 +452,58 @@ class Application_Model_Scheduler private function calculateCrossfades($instanceId) { Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$instanceId); - - $sql = "SELECT * FROM cc_show_instances ". - "WHERE id = {$instanceId}"; - $instance = Application_Common_Database::prepareAndExecute( - $sql, array(), Application_Common_Database::SINGLE); + $instance = CcShowInstancesQuery::create()->findPk($instanceId); if (is_null($instance)) { throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!")); } - $itemStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC")); - $itemEndDT = null; - - $schedule_sql = "SELECT * FROM cc_schedule ". - "WHERE instance_id = {$instanceId} ". - "ORDER BY starts"; - $schedule = Application_Common_Database::prepareAndExecute($schedule_sql); + $schedule = CcScheduleQuery::create() + ->filterByDbInstanceId($instanceId) + ->orderByDbStarts() + ->find($this->con); + $itemStartDT = $instance->getDbStarts(null); foreach ($schedule as $item) { - $itemEndDT = $this->findEndTime($itemStartDT, $item["clip_length"]); - - $update_sql = "UPDATE cc_schedule SET ". - "starts = '{$itemStartDT->format(DEFAULT_MICROTIME_FORMAT)}', ". - "ends = '{$itemEndDT->format(DEFAULT_MICROTIME_FORMAT)}' ". - "WHERE id = {$item["id"]}"; - Application_Common_Database::prepareAndExecute( - $update_sql, array(), Application_Common_Database::EXECUTE); - + $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); + Logging::info($itemEndDT); + $item->setDbStarts($itemStartDT) + ->setDbEnds($itemEndDT) + ->save($this->con); $itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration); } } /* * @param int $showInstance - * @param array $exclude - * ids of sched items to remove from the calulation. - * This function squeezes all items of a show together so that - * there are no gaps between them. - */ + * @param array $exclude + * ids of sched items to remove from the calculation. + * This function squeezes all items of a show together so that + * there are no gaps between them. + */ public function removeGaps($showInstance, $exclude=null) { Logging::info("removing gaps from show instance #".$showInstance); - $instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con); + $instance = CcShowInstancesQuery::create()->findPk($showInstance, $this->con); if (is_null($instance)) { throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!")); } - $itemStartDT = $instance->getDbStarts(null); - $schedule = CcScheduleQuery::create() ->filterByDbInstanceId($showInstance) ->filterByDbId($exclude, Criteria::NOT_IN) ->orderByDbStarts() ->find($this->con); + $itemStartDT = $instance->getDbStarts(null); foreach ($schedule as $item) { - $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); - $item->setDbStarts($itemStartDT) - ->setDbEnds($itemEndDT); - - $itemStartDT = $itemEndDT; + ->setDbEnds($itemEndDT) + ->save($this->con); + $itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration); } - - $schedule->save($this->con); } /** diff --git a/airtime_mvc/application/views/scripts/partialviews/header.phtml b/airtime_mvc/application/views/scripts/partialviews/header.phtml index 4d4cf4dab..8ca2a74d2 100644 --- a/airtime_mvc/application/views/scripts/partialviews/header.phtml +++ b/airtime_mvc/application/views/scripts/partialviews/header.phtml @@ -57,7 +57,7 @@
  1. - baseUrl . "user/edit-user"?>>escape($this->loggedInAs()); ?> + baseUrl . "/user/edit-user"?>>escape($this->loggedInAs()); ?> | baseUrl . "/login/logout"?>>
diff --git a/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml b/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml index 5e66553de..b97c2ba17 100644 --- a/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml +++ b/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml @@ -4,8 +4,8 @@
diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index b2d49d8d1..3b3104f59 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -403,6 +403,7 @@ var AIRTIME = (function(AIRTIME) { //Re-enable the delete button AIRTIME.button.enableButton("btn-group #sb-trash", false); }); + mod.selectNone(); }; mod.fnDeleteSelectedItems = function() { @@ -432,13 +433,14 @@ var AIRTIME = (function(AIRTIME) { // close the object (playlist/block/webstream) // on the right side if it was just deleted // from the library - if (closeObj) { - $.post(baseUrl+"playlist/close-playlist", - {"format": "json", "type": currentObjType}, - function(json) { - $("#editor_pane_wrapper").empty().append(json.html); - }); - } + + //if (closeObj) { + // $.post(baseUrl+"playlist/close-playlist", + // {"format": "json", "type": currentObjType}, + // function(json) { + // $("#editor_pane_wrapper").empty().append(json.html); + // }); + //} } }; diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index fcb5724d4..97fcea3ad 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -342,9 +342,9 @@ var AIRTIME = (function(AIRTIME){ }; mod.fnRemove = function(aItems) { - mod.disableUI(); if (confirm($.i18n._("Delete selected item(s)?"))) { + mod.selectNone(); $.post( baseUrl+"showbuilder/schedule-remove", {"items": aItems, "format": "json"}, mod.fnItemCallback