CC-1990: Widget to display schedule and "Now Playing" on any website

-update to API controller to support new widget
This commit is contained in:
martin 2011-03-28 16:29:50 -04:00
parent ab5a6bc1c5
commit 2aa0cd22c6
2 changed files with 40 additions and 2 deletions

View File

@ -104,8 +104,6 @@ class ApiController extends Zend_Controller_Action
}
public function liveInfoAction(){
global $CC_CONFIG;
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
@ -126,6 +124,22 @@ class ApiController extends Zend_Controller_Action
echo $_GET['callback'].'('.json_encode($result).')';
}
public function weekInfoAction(){
// disable the view and the layout
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
$result = array();
for ($i=0; $i<7; $i++){
$result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i);
}
header("Content-type: text/javascript");
echo $_GET['callback'].'('.json_encode($result).')';
}
public function scheduleAction()
{
global $CC_CONFIG;

View File

@ -935,4 +935,28 @@ class Show_DAL {
return $CC_DBC->GetAll($sql);
}
public static function GetShowsByDayOfWeek($day){
//DOW FROM TIMESTAMP
//The day of the week (0 - 6; Sunday is 0) (for timestamp values only)
//SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
//Result: 5
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT"
." si.starts as show_starts,"
." si.ends as show_ends,"
." s.name as show_name,"
." s.url as url"
." FROM $CC_CONFIG[showInstances] si"
." LEFT JOIN $CC_CONFIG[showTable] s"
." ON si.show_id = s.id"
." WHERE EXTRACT(DOW FROM si.starts) = $day"
." AND EXTRACT(WEEK FROM si.starts) = EXTRACT(WEEK FROM localtimestamp)";
//echo $sql;
return $CC_DBC->GetAll($sql);
}
}