From 1c6d7725ca731401b8d391290776223d1693d800 Mon Sep 17 00:00:00 2001 From: Jamie Connor Date: Wed, 18 Sep 2013 17:35:32 +1200 Subject: [PATCH] Modified weekInfo from ApiController to display current week and next, changed widget to display extra days. --- .../application/controllers/ApiController.php | 52 ++++++++----------- widgets/js/jquery.showinfo.js | 4 +- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a44926146..f96865e17 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -299,7 +299,7 @@ class ApiController extends Zend_Controller_Action } } - public function weekInfoAction() + public function weekInfoAction() { if (Application_Model_Preference::GetAllow3rdPartyApi()) { // disable the view and the layout @@ -311,39 +311,29 @@ class ApiController extends Zend_Controller_Action $utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart); $dow = array("monday", "tuesday", "wednesday", "thursday", "friday", - "saturday", "sunday"); + "saturday", "sunday", "nextmonday", "nexttuesday", "nextwednesday", + "nextthursday", "nextfriday", "nextsaturday", "nextsunday"); $result = array(); - - $request = $this->getRequest(); - $days = $request->getParam('days'); - if (empty($days)) {$days = 7;} - - for ($i=0; $i<$days; $i++) { - $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); - $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd); - $utcDayStart = $utcDayEnd; + for ($i=0; $i<14; $i++) { + $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); + $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd); + $utcDayStart = $utcDayEnd; - Application_Model_Show::convertToLocalTimeZone($shows, - array("starts", "ends", "start_timestamp", - "end_timestamp")); - - if ($days==7) { //return with day of week index - standard - $result[$dow[$i]] = $shows; - } - else{ //return with number index - days has been specified - $result[$i] = $shows; - } - - } - // XSS exploit prevention - for ($i=0; $i<$days; $i++) { - foreach ($result[$i] as &$show) { - $show["name"] = htmlspecialchars($show["name"]); - $show["url"] = htmlspecialchars($show["url"]); - } - } - + Application_Model_Show::convertToLocalTimeZone($shows, + array("starts", "ends", "start_timestamp", + "end_timestamp")); + + $result[$dow[$i]] = $shows; + } + + // XSS exploit prevention + foreach ($dow as $d) { + foreach ($result[$d] as &$show) { + $show["name"] = htmlspecialchars($show["name"]); + $show["url"] = htmlspecialchars($show["url"]); + } + } //used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; diff --git a/widgets/js/jquery.showinfo.js b/widgets/js/jquery.showinfo.js index eab3f3d8b..c3cf6db94 100644 --- a/widgets/js/jquery.showinfo.js +++ b/widgets/js/jquery.showinfo.js @@ -238,7 +238,7 @@ var defaults = { sourceDomain: "http://localhost/", //where to get show status from updatePeriod: 600, - dowText: {monday:"Monday", tuesday:"Tuesday", wednesday:"Wednesday", thursday:"Thursday", friday:"Friday", saturday:"Saturday", sunday:"Sunday"}, + dowText:{monday:"Monday", tuesday:"Tuesday", wednesday:"Wednesday",thursday:"Thursday", friday:"Friday", saturday:"Saturday",sunday:"Sunday", nextmonday:"Next Monday", nexttuesday:"Next Tuesday",nextwednesday:"Next Wednesday", nextthursday:"Next Thursday",nextfriday:"Next Friday", nextsaturday:"Next Saturday", nextsunday:"NextSunday"}, miscText: {time:"Time", programName:"Program Name", details:"Details", readMore:"Read More"} }; options = $.extend(true, defaults, options); @@ -250,7 +250,7 @@ obj.attr("class", "ui-tabs"); - var dow = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]; + var dow = ["monday", "tuesday", "wednesday", "thursday", "friday","saturday", "sunday", "nextmonday", "nexttuesday", "nextwednesday","nextthursday", "nextfriday", "nextsaturday", "nextsunday"]; var date = new Date(); //subtract 1 because javascript date function returns