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()) {
// 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;

View File

@ -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