From e8d7b591277ff5e195640673f45b9151e5780b94 Mon Sep 17 00:00:00 2001 From: mkonecny Date: Tue, 25 Jan 2011 15:25:24 -0500 Subject: [PATCH 1/6] -datagrid now highlights current song playing --- application/models/Nowplaying.php | 15 +++--- application/models/Schedule.php | 7 +-- .../views/scripts/nowplaying/index.phtml | 53 +++++++++++++++---- public/js/playlist/playlist.js | 8 +++ 4 files changed, 64 insertions(+), 19 deletions(-) diff --git a/application/models/Nowplaying.php b/application/models/Nowplaying.php index 0dbb3933e..759bbb0d7 100644 --- a/application/models/Nowplaying.php +++ b/application/models/Nowplaying.php @@ -9,7 +9,8 @@ class Application_Model_Nowplaying $current = Schedule::GetCurrentlyPlaying($timeNow); $next = Schedule::GetNextItems($timeNow, 10); - $columnHeaders = array(array("sTitle"=>"Date"), + $columnHeaders = array(array("sTitle"=>"type", "bVisible"=>false), + array("sTitle"=>"Date"), array("sTitle"=>"Start"), array("sTitle"=>"End"), array("sTitle"=>"Duration"), @@ -21,19 +22,19 @@ class Application_Model_Nowplaying $rows = array(); foreach ($previous as $item){ - array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], - $item["album_title"], "x" , "y")); + array_push($rows, array("p", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], + $item["album_title"], "x" , $item["playlistname"])); } foreach ($current as $item){ - array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], - $item["album_title"], "x" , "y")); + array_push($rows, array("c", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], + $item["album_title"], "x" , $item["playlistname"])); } foreach ($next as $item){ - array_push($rows, array($item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], - $item["album_title"], "x" , "y")); + array_push($rows, array("n", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"], + $item["album_title"], "x" , $item["playlistname"])); } return array("columnHeaders"=>$columnHeaders, "rows"=>$rows); diff --git a/application/models/Schedule.php b/application/models/Schedule.php index 6adae79bf..52d72337f 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -479,9 +479,10 @@ class Schedule { public static function GetPreviousItems($timeNow, $prevCount = 1){ global $CC_CONFIG, $CC_DBC; - $sql = "SELECT * FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft" + $sql = "SELECT *, pt.name as playlistname FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" ." WHERE (st.ends < TIMESTAMP '$timeNow')" ." AND (st.file_id = ft.id)" + ." AND (st.playlist_id = pt.id)" ." ORDER BY st.starts DESC" ." LIMIT $prevCount"; $rows = $CC_DBC->GetAll($sql); @@ -491,7 +492,7 @@ class Schedule { public static function GetCurrentlyPlaying($timeNow){ global $CC_CONFIG, $CC_DBC; - $sql = "SELECT *, pt.name as playlistName FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" + $sql = "SELECT *, pt.name as playlistname FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" ." WHERE (st.starts < TIMESTAMP '$timeNow')" ." AND (st.ends > TIMESTAMP '$timeNow')" ." AND (st.playlist_id = pt.id)" @@ -502,7 +503,7 @@ class Schedule { public static function GetNextItems($timeNow, $nextCount = 1) { global $CC_CONFIG, $CC_DBC; - $sql = "SELECT *, pt.name as playlistName FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" + $sql = "SELECT *, pt.name as playlistname FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt" ." WHERE (st.starts > TIMESTAMP '$timeNow')" ." AND (st.file_id = ft.id)" ." AND (st.playlist_id = pt.id)" diff --git a/application/views/scripts/nowplaying/index.phtml b/application/views/scripts/nowplaying/index.phtml index 049701146..7ca964c38 100644 --- a/application/views/scripts/nowplaying/index.phtml +++ b/application/views/scripts/nowplaying/index.phtml @@ -1,6 +1,10 @@