Modified weekInfo from ApiController to display current week and next, changed widget to display extra days.

This commit is contained in:
Jamie Connor 2013-09-18 17:35:32 +12:00
parent f7f2cdc51c
commit 1c6d7725ca
2 changed files with 23 additions and 33 deletions

View File

@ -299,7 +299,7 @@ class ApiController extends Zend_Controller_Action
} }
} }
public function weekInfoAction() public function weekInfoAction()
{ {
if (Application_Model_Preference::GetAllow3rdPartyApi()) { if (Application_Model_Preference::GetAllow3rdPartyApi()) {
// disable the view and the layout // disable the view and the layout
@ -311,39 +311,29 @@ class ApiController extends Zend_Controller_Action
$utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart); $utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart);
$dow = array("monday", "tuesday", "wednesday", "thursday", "friday", $dow = array("monday", "tuesday", "wednesday", "thursday", "friday",
"saturday", "sunday"); "saturday", "sunday", "nextmonday", "nexttuesday", "nextwednesday",
"nextthursday", "nextfriday", "nextsaturday", "nextsunday");
$result = array(); $result = array();
for ($i=0; $i<14; $i++) {
$request = $this->getRequest(); $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
$days = $request->getParam('days'); $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
if (empty($days)) {$days = 7;} $utcDayStart = $utcDayEnd;
for ($i=0; $i<$days; $i++) {
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
$shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
$utcDayStart = $utcDayEnd;
Application_Model_Show::convertToLocalTimeZone($shows, Application_Model_Show::convertToLocalTimeZone($shows,
array("starts", "ends", "start_timestamp", array("starts", "ends", "start_timestamp",
"end_timestamp")); "end_timestamp"));
if ($days==7) { //return with day of week index - standard $result[$dow[$i]] = $shows;
$result[$dow[$i]] = $shows; }
}
else{ //return with number index - days has been specified // XSS exploit prevention
$result[$i] = $shows; foreach ($dow as $d) {
} foreach ($result[$d] as &$show) {
$show["name"] = htmlspecialchars($show["name"]);
} $show["url"] = htmlspecialchars($show["url"]);
// XSS exploit prevention }
for ($i=0; $i<$days; $i++) { }
foreach ($result[$i] 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. //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; $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;

View File

@ -238,7 +238,7 @@
var defaults = { var defaults = {
sourceDomain: "http://localhost/", //where to get show status from sourceDomain: "http://localhost/", //where to get show status from
updatePeriod: 600, 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"} miscText: {time:"Time", programName:"Program Name", details:"Details", readMore:"Read More"}
}; };
options = $.extend(true, defaults, options); options = $.extend(true, defaults, options);
@ -250,7 +250,7 @@
obj.attr("class", "ui-tabs"); 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(); var date = new Date();
//subtract 1 because javascript date function returns //subtract 1 because javascript date function returns