From 9249bf8cd03f859a792ca1b915950a2fbbd2a432 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 10:55:42 -0400 Subject: [PATCH 1/4] Big formatting changes. --- .../application/models/ShowBuilder.php | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/airtime_mvc/application/models/ShowBuilder.php b/airtime_mvc/application/models/ShowBuilder.php index 869e3f2d8..cdd7b14c1 100644 --- a/airtime_mvc/application/models/ShowBuilder.php +++ b/airtime_mvc/application/models/ShowBuilder.php @@ -179,7 +179,7 @@ class Application_Model_ShowBuilder $showStartDT = new DateTime($p_item["si_starts"], new DateTimeZone("UTC")); $showStartDT->setTimezone(new DateTimeZone($this->timezone)); $startsEpoch = floatval($showStartDT->format("U.u")); - $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); + $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); $showEndDT->setTimezone(new DateTimeZone($this->timezone)); $endsEpoch = floatval($showEndDT->format("U.u")); @@ -188,8 +188,8 @@ class Application_Model_ShowBuilder $row["rebroadcast"] = true; $parentInstance = CcShowInstancesQuery::create()->findPk($p_item["parent_show"]); - $name = $parentInstance->getCcShow()->getDbName(); - $dt = $parentInstance->getDbStarts(null); + $name = $parentInstance->getCcShow()->getDbName(); + $dt = $parentInstance->getDbStarts(null); $dt->setTimezone(new DateTimeZone($this->timezone)); $time = $dt->format("Y-m-d H:i"); @@ -198,8 +198,6 @@ class Application_Model_ShowBuilder $row["record"] = true; if (Application_Model_Preference::GetUploadToSoundcloudOption()) { - Logging::info('$p_item contains:'); - Logging::info($p_item); $file = Application_Model_StoredFile::Recall( $p_item['si_file_id']); if (isset($file)) { @@ -242,9 +240,11 @@ class Application_Model_ShowBuilder if (isset($p_item["sched_starts"])) { - $schedStartDT = new DateTime($p_item["sched_starts"], new DateTimeZone("UTC")); + $schedStartDT = new DateTime($p_item["sched_starts"], + new DateTimeZone("UTC")); $schedStartDT->setTimezone(new DateTimeZone($this->timezone)); - $schedEndDT = new DateTime($p_item["sched_ends"], new DateTimeZone("UTC")); + $schedEndDT = new DateTime($p_item["sched_ends"], + new DateTimeZone("UTC")); $schedEndDT->setTimezone(new DateTimeZone($this->timezone)); $showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC")); @@ -350,7 +350,8 @@ class Application_Model_ShowBuilder /* * @param int $timestamp Unix timestamp in seconds. * - * @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, $instances) @@ -374,23 +375,26 @@ class Application_Model_ShowBuilder $currentInstances[] = $show["instance_id"]; if (isset($show["last_scheduled"])) { - $dt = new DateTime($show["last_scheduled"], new DateTimeZone("UTC")); + $dt = new DateTime($show["last_scheduled"], + new DateTimeZone("UTC")); } else { - $dt = new DateTime($show["created"], new DateTimeZone("UTC")); + $dt = new DateTime($show["created"], + new DateTimeZone("UTC")); } //check if any of the shows have a more recent timestamp. $showTimeStamp = intval($dt->format("U")); if ($timestamp < $showTimeStamp) { - Logging::debug("timestamp is {$timestamp} show timestamp is {$showTimeStamp}"); $outdated = true; break; } } } - //see if the displayed show instances have changed. (deleted, empty schedule etc) - if ($outdated === false && count($instances) !== count($currentInstances)) { + //see if the displayed show instances have changed. (deleted, + //empty schedule etc) + if ($outdated === false && count($instances) + !== count($currentInstances)) { Logging::debug("show instances have changed."); $outdated = true; } @@ -411,14 +415,17 @@ class Application_Model_ShowBuilder $shows[] = $this->opts["showFilter"]; } - $scheduled_items = Application_Model_Schedule::GetScheduleDetailItems($this->startDT->format("Y-m-d H:i:s"), $this->endDT->format("Y-m-d H:i:s"), $shows); + $scheduled_items = Application_Model_Schedule::GetScheduleDetailItems( + $this->startDT->format("Y-m-d H:i:s"), $this->endDT->format( + "Y-m-d H:i:s"), $shows); for ($i = 0, $rows = count($scheduled_items); $i < $rows; $i++) { $item = $scheduled_items[$i]; //don't send back data for filler rows. - if (isset($item["playout_status"]) && $item["playout_status"] < 0) { + if (isset($item["playout_status"]) && + $item["playout_status"] < 0) { continue; } @@ -427,8 +434,10 @@ class Application_Model_ShowBuilder //make a footer row. if ($current_id !== -1) { - //pass in the previous row as it's the last row for the previous show. - $display_items[] = $this->makeFooterRow($scheduled_items[$i-1]); + // 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); @@ -445,7 +454,8 @@ class Application_Model_ShowBuilder $display_items[] = $row; } - if ($current_id !== -1 && !in_array($current_id, $this->showInstances)) { + if ($current_id !== -1 && + !in_array($current_id, $this->showInstances)) { $this->showInstances[] = $current_id; } } From d90559fdf8c01394b71d9395ead176a1824e1ce7 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:02:41 -0400 Subject: [PATCH 2/4] Cleaned up ShowbuilderController --- .../controllers/ShowbuilderController.php | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index 413afbb70..fedebf7e2 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -229,35 +229,32 @@ class ShowbuilderController extends Zend_Controller_Action public function checkBuilderFeedAction() { - $request = $this->getRequest(); + $request = $this->getRequest(); $current_time = time(); $starts_epoch = $request->getParam("start", $current_time); //default ends is 24 hours after starts. - $ends_epoch = $request->getParam("end", $current_time + (60*60*24)); + $ends_epoch = $request->getParam("end", $current_time + (60*60*24)); $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()); + $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")); + $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); - $opts = array("myShows" => $my_shows, "showFilter" => $show_filter); + $opts = array("myShows" => $my_shows, "showFilter" => $show_filter); $showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts); //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, $instances)) { - $this->view->update = true; - } else { - $this->view->update = false; - } + $this->view->update = $showBuilder->hasBeenUpdatedSince( + $timestamp, $instances); } public function builderFeedAction() { - $request = $this->getRequest(); + $request = $this->getRequest(); $current_time = time(); $starts_epoch = $request->getParam("start", $current_time); From 2e0e0849c5655252005841623a5feea721d2c0f8 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:03:34 -0400 Subject: [PATCH 3/4] More clean up --- .../application/controllers/ShowbuilderController.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php index fedebf7e2..23c3fd55b 100644 --- a/airtime_mvc/application/controllers/ShowbuilderController.php +++ b/airtime_mvc/application/controllers/ShowbuilderController.php @@ -259,12 +259,12 @@ class ShowbuilderController extends Zend_Controller_Action $starts_epoch = $request->getParam("start", $current_time); //default ends is 24 hours after starts. - $ends_epoch = $request->getParam("end", $current_time + (60*60*24)); + $ends_epoch = $request->getParam("end", $current_time + (60*60*24)); $show_filter = intval($request->getParam("showFilter", 0)); - $my_shows = intval($request->getParam("myShows", 0)); + $my_shows = intval($request->getParam("myShows", 0)); $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")); $opts = array("myShows" => $my_shows, "showFilter" => $show_filter); $showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts); @@ -287,13 +287,9 @@ class ShowbuilderController extends Zend_Controller_Action } catch (OutDatedScheduleException $e) { $this->view->error = $e->getMessage(); Logging::info($e->getMessage()); - Logging::info("{$e->getFile()}"); - Logging::info("{$e->getLine()}"); } catch (Exception $e) { $this->view->error = $e->getMessage(); Logging::info($e->getMessage()); - Logging::info("{$e->getFile()}"); - Logging::info("{$e->getLine()}"); } } From 49e1b29bc973ff3c8bb54a83ca02e9acc96c9c5c Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 18 Sep 2012 11:04:33 -0400 Subject: [PATCH 4/4] Removed instances of getLine and getFile --- airtime_mvc/application/controllers/ScheduleController.php | 2 -- airtime_mvc/application/models/ShowInstance.php | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 41e1b5125..d78ae2719 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -872,8 +872,6 @@ class ScheduleController extends Zend_Controller_Action } catch (Exception $e) { $this->view->error = $e->getMessage(); Logging::info($e->getMessage()); - Logging::info("{$e->getFile()}"); - Logging::info("{$e->getLine()}"); } } } diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index f88a1d63a..f782ae076 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -590,9 +590,7 @@ SQL; $rebroad = new Application_Model_ShowInstance($rebroadcast->getDbId()); $rebroad->addFileToShow($file_id, false); } catch (Exception $e) { - Logging::info("{$e->getFile()}"); - Logging::info("{$e->getLine()}"); - Logging::info("{$e->getMessage()}"); + Logging::info($e->getMessage()); } } }