From 4d8f28f3fd6692635c707eb44a85994192debb1c Mon Sep 17 00:00:00 2001 From: naomiaro Date: Wed, 12 Jan 2011 17:52:57 -0500 Subject: [PATCH 1/6] show content returning info in a useful way --- application/models/Shows.php | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/application/models/Shows.php b/application/models/Shows.php index 857d7f6bf..c1fe42c1d 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -285,9 +285,41 @@ class Show { LEFT JOIN cc_files AS f ON f.id = s.file_id LEFT JOIN cc_playlist AS p ON p.id = s.playlist_id ) - WHERE ss.show_day = '{$timeinfo[0]}' AND ss.show_id = '{$this->_showId}'"; + WHERE ss.show_day = '{$timeinfo[0]}' AND ss.show_id = '{$this->_showId}' ORDER BY starts"; - return $CC_DBC->GetAll($sql); + $res = $CC_DBC->GetAll($sql); + + if(count($res) <= 0) { + return $res; + } + + $items = array(); + $currGroupId = -1; + $pl_counter = -1; + $f_counter = -1; + foreach ($res as $row) { + if($currGroupId != $row["group_id"]){ + $currGroupId = $row["group_id"]; + $pl_counter = $pl_counter + 1; + $f_counter = -1; + + $items[$pl_counter]["pl_name"] = $row["name"]; + $items[$pl_counter]["pl_creator"] = $row["creator"]; + $items[$pl_counter]["pl_description"] = $row["description"]; + + $sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'"; + $length = $CC_DBC->GetOne($sql); + + $items[$pl_counter]["pl_length"] = $length; + } + $f_counter = $f_counter + 1; + + $items[$pl_counter][$f_counter]["f_name"] = $row["track_title"]; + $items[$pl_counter][$f_counter]["f_artist"] = $row["artist_name"]; + $items[$pl_counter][$f_counter]["f_length"] = $row["length"]; + } + + return $items; } public function clearShow($day) { From ad869e0f7fd21f2e3e48c8fcffaed16b1bfa5bad Mon Sep 17 00:00:00 2001 From: naomiaro Date: Wed, 12 Jan 2011 19:40:05 -0500 Subject: [PATCH 2/6] will display in the UI what is scheduled in a show when you add things. --- .../controllers/ScheduleController.php | 3 +++ application/models/Shows.php | 11 +++++---- .../schedule/scheduled-content-partial.phtml | 2 -- .../scripts/schedule/scheduled-content.phtml | 24 +++++++++++++++++++ public/js/airtime/schedule/schedule.js | 8 +++---- 5 files changed, 37 insertions(+), 11 deletions(-) delete mode 100644 application/views/scripts/schedule/scheduled-content-partial.phtml create mode 100644 application/views/scripts/schedule/scheduled-content.phtml diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 8500453f3..827351760 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -156,6 +156,9 @@ class ScheduleController extends Zend_Controller_Action $show->scheduleShow($start, array($plId)); $this->view->showContent = $show->getShowContent($start); + $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); + + unset($this->view->showContent); } else { diff --git a/application/models/Shows.php b/application/models/Shows.php index c1fe42c1d..24a93ebff 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -305,18 +305,19 @@ class Show { $items[$pl_counter]["pl_name"] = $row["name"]; $items[$pl_counter]["pl_creator"] = $row["creator"]; - $items[$pl_counter]["pl_description"] = $row["description"]; + $items[$pl_counter]["pl_description"] = $row["description"]; + $items[$pl_counter]["pl_group"] = $row["group_id"]; - $sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'"; + $sql = "SELECT SUM(clip_length) FROM cc_schedule WHERE group_id = '{$currGroupId}'"; $length = $CC_DBC->GetOne($sql); $items[$pl_counter]["pl_length"] = $length; } $f_counter = $f_counter + 1; - $items[$pl_counter][$f_counter]["f_name"] = $row["track_title"]; - $items[$pl_counter][$f_counter]["f_artist"] = $row["artist_name"]; - $items[$pl_counter][$f_counter]["f_length"] = $row["length"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_name"] = $row["track_title"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_artist"] = $row["artist_name"]; + $items[$pl_counter]["pl_content"][$f_counter]["f_length"] = $row["length"]; } return $items; diff --git a/application/views/scripts/schedule/scheduled-content-partial.phtml b/application/views/scripts/schedule/scheduled-content-partial.phtml deleted file mode 100644 index 6e2d847d7..000000000 --- a/application/views/scripts/schedule/scheduled-content-partial.phtml +++ /dev/null @@ -1,2 +0,0 @@ -

First header

-
First content
diff --git a/application/views/scripts/schedule/scheduled-content.phtml b/application/views/scripts/schedule/scheduled-content.phtml new file mode 100644 index 000000000..7e82b36ea --- /dev/null +++ b/application/views/scripts/schedule/scheduled-content.phtml @@ -0,0 +1,24 @@ +showContent) > 0) : ?> + showContent as $pl) : ?> +
  • " class="ui-widget-content"> +

    +
    + + +
    +
    +
    +

    +
    + +
    + + +
    +
    + +
    +
  • + + + diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index 5a1d327d2..eb47d9169 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -194,14 +194,14 @@ function makeScheduleDialog(dialog, show) { url = '/Schedule/schedule-show/format/json'; - //$("#schedule_playlist_chosen") - // .append(ui.helper); - - $.post(url, {plId: pl_id, start: start_date, end: end_date, showId: show.id}, function(json){ var x; + + $("#schedule_playlist_chosen") + .empty() + .append(json.chosen); }); } From 0ffa232b6d2f8916bd037ee1481c5ae126797c83 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Thu, 13 Jan 2011 16:24:10 -0500 Subject: [PATCH 3/6] schedule show finds playlists available and returns show content better --- .../controllers/ScheduleController.php | 38 +++++++++---------- application/models/Shows.php | 2 +- public/js/airtime/schedule/schedule.js | 28 ++++++-------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 827351760..d941e958b 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -141,35 +141,33 @@ class ScheduleController extends Zend_Controller_Action public function scheduleShowAction() { $request = $this->getRequest(); - + + $start = $this->_getParam('start'); + $end = $this->_getParam('end'); + $showId = $this->_getParam('showId'); + $day = $this->_getParam('day'); + + $userInfo = Zend_Auth::getInstance()->getStorage()->read(); + + $user = new User($userInfo->id, $userInfo->type); + $show = new Show($user, $showId); + if($request->isPost()) { $plId = $this->_getParam('plId'); - $start = $this->_getParam('start'); - $end = $this->_getParam('end'); - $showId = $this->_getParam('showId'); - $userInfo = Zend_Auth::getInstance()->getStorage()->read(); - - $user = new User($userInfo->id, $userInfo->type); - $show = new Show($user, $showId); $show->scheduleShow($start, array($plId)); - - $this->view->showContent = $show->getShowContent($start); - $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); - - unset($this->view->showContent); - } - else { - $length = $this->_getParam('length'); + $this->view->playlists = $show->searchPlaylistsForShow($day); + $this->view->showContent = $show->getShowContent($start); - $this->view->playlists = Playlist::searchPlaylists($length); - $this->view->dialog = $this->view->render('schedule/schedule-show.phtml'); + $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); + $this->view->dialog = $this->view->render('schedule/schedule-show.phtml'); - unset($this->view->playlists); - } + unset($this->view->showContent); + unset($this->view->playlists); + } public function clearShowAction() diff --git a/application/models/Shows.php b/application/models/Shows.php index 24a93ebff..80ab2f43e 100644 --- a/application/models/Shows.php +++ b/application/models/Shows.php @@ -515,7 +515,7 @@ class Show { return $event; } - public function searchPlaylistsForShow($day, $search){ + public function searchPlaylistsForShow($day, $search=null){ global $CC_DBC; $sql = "SELECT * FROM cc_show_days WHERE show_id = '{$this->_showId}' AND day = '{$day}'"; diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index eb47d9169..d0cdd2025 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -185,9 +185,10 @@ function makeScheduleDialog(dialog, show) { dialog.find("#schedule_playlist_chosen") .droppable({ drop: function(event, ui) { - var li, pl_id, url, start_date, end_date; + var li, pl_id, url, start_date, end_date, day; pl_id = $(ui.helper).attr("id").split("_").pop(); + day = show.start.getDay(); start_date = makeTimeStamp(show.start); end_date = makeTimeStamp(show.end); @@ -195,7 +196,7 @@ function makeScheduleDialog(dialog, show) { url = '/Schedule/schedule-show/format/json'; $.post(url, - {plId: pl_id, start: start_date, end: end_date, showId: show.id}, + {plId: pl_id, start: start_date, end: end_date, showId: show.id, day: day}, function(json){ var x; @@ -208,13 +209,17 @@ function makeScheduleDialog(dialog, show) { }); } -function openScheduleDialog(show, time) { - var url; +function openScheduleDialog(show) { + var url, start_date, end_date, day; url = '/Schedule/schedule-show/format/json'; + day = show.start.getDay(); + + start_date = makeTimeStamp(show.start); + end_date = makeTimeStamp(show.end); $.get(url, - {length: time}, + {day: day, start: start_date, end: end_date, showId: show.id}, function(json){ var dialog = $(json.dialog); @@ -250,17 +255,8 @@ function eventMenu(action, el, pos) { }); } else if (method === 'schedule-show') { - var length, h, m, s, time; - - length = event.end.getTime() - event.start.getTime(); - - h = Math.floor(length / (1000*60*60)); - m = (length % (1000*60*60)) / (1000*60); - s = ((length % (1000*60*60)) % (1000*60)) / 1000; - - time = h+":"+m+":"+s; - - openScheduleDialog(event, time); + + openScheduleDialog(event); } else if (method === 'clear-show') { start_date = makeTimeStamp(event.start); From a8f24952bd4a381d44e3d61870488cdf28ffc3ee Mon Sep 17 00:00:00 2001 From: naomiaro Date: Thu, 13 Jan 2011 18:01:15 -0500 Subject: [PATCH 4/6] updates the playlists that can be chosen for the show. --- application/controllers/ScheduleController.php | 1 + application/views/scripts/schedule/find-playlists.phtml | 5 +++++ public/js/airtime/schedule/schedule.js | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index d941e958b..32c83a70b 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -162,6 +162,7 @@ class ScheduleController extends Zend_Controller_Action $this->view->playlists = $show->searchPlaylistsForShow($day); $this->view->showContent = $show->getShowContent($start); + $this->view->choice = $this->view->render('schedule/find-playlists.phtml'); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); $this->view->dialog = $this->view->render('schedule/schedule-show.phtml'); diff --git a/application/views/scripts/schedule/find-playlists.phtml b/application/views/scripts/schedule/find-playlists.phtml index e69de29bb..f5d6626cf 100644 --- a/application/views/scripts/schedule/find-playlists.phtml +++ b/application/views/scripts/schedule/find-playlists.phtml @@ -0,0 +1,5 @@ +playlists) > 0) { + echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); + } +?> diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index d0cdd2025..6531abe89 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -200,6 +200,14 @@ function makeScheduleDialog(dialog, show) { function(json){ var x; + $("#schedule_playlist_choice") + .empty() + .append(json.choice) + .find('li') + .draggable({ + helper: 'clone' + }); + $("#schedule_playlist_chosen") .empty() .append(json.chosen); From f312ea0d608d5248d70942c57b1e2567135656ad Mon Sep 17 00:00:00 2001 From: naomiaro Date: Thu, 13 Jan 2011 18:27:44 -0500 Subject: [PATCH 5/6] show will open dialog properly showing scheduled content if there is any --- .../controllers/ScheduleController.php | 7 ++++- .../schedule/find-playlists.ajax.phtml | 3 +++ .../scripts/schedule/find-playlists.phtml | 3 +++ .../scripts/schedule/schedule-show.phtml | 8 ++---- .../scripts/schedule/scheduled-content.phtml | 2 ++ public/js/airtime/schedule/schedule.js | 27 ++++++++++++------- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/application/controllers/ScheduleController.php b/application/controllers/ScheduleController.php index 32c83a70b..fadbdb161 100644 --- a/application/controllers/ScheduleController.php +++ b/application/controllers/ScheduleController.php @@ -146,6 +146,11 @@ class ScheduleController extends Zend_Controller_Action $end = $this->_getParam('end'); $showId = $this->_getParam('showId'); $day = $this->_getParam('day'); + $search = $this->_getParam('search', null); + + if($search == "") { + $search = null; + } $userInfo = Zend_Auth::getInstance()->getStorage()->read(); @@ -159,7 +164,7 @@ class ScheduleController extends Zend_Controller_Action $show->scheduleShow($start, array($plId)); } - $this->view->playlists = $show->searchPlaylistsForShow($day); + $this->view->playlists = $show->searchPlaylistsForShow($day, $search); $this->view->showContent = $show->getShowContent($start); $this->view->choice = $this->view->render('schedule/find-playlists.phtml'); diff --git a/application/views/scripts/schedule/find-playlists.ajax.phtml b/application/views/scripts/schedule/find-playlists.ajax.phtml index f5d6626cf..185ce5f98 100644 --- a/application/views/scripts/schedule/find-playlists.ajax.phtml +++ b/application/views/scripts/schedule/find-playlists.ajax.phtml @@ -2,4 +2,7 @@ if(count($this->playlists) > 0) { echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); } + else { + echo "No Playlists Fit Duration"; + } ?> diff --git a/application/views/scripts/schedule/find-playlists.phtml b/application/views/scripts/schedule/find-playlists.phtml index f5d6626cf..185ce5f98 100644 --- a/application/views/scripts/schedule/find-playlists.phtml +++ b/application/views/scripts/schedule/find-playlists.phtml @@ -2,4 +2,7 @@ if(count($this->playlists) > 0) { echo $this->partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); } + else { + echo "No Playlists Fit Duration"; + } ?> diff --git a/application/views/scripts/schedule/schedule-show.phtml b/application/views/scripts/schedule/schedule-show.phtml index eee852c11..bc315759c 100644 --- a/application/views/scripts/schedule/schedule-show.phtml +++ b/application/views/scripts/schedule/schedule-show.phtml @@ -1,9 +1,5 @@
    -
      -partialLoop('schedule/find-playlists-partial.phtml', $this->playlists); -?> -
    -
      No Playlists
    +
      +
        diff --git a/application/views/scripts/schedule/scheduled-content.phtml b/application/views/scripts/schedule/scheduled-content.phtml index 7e82b36ea..910a2ad65 100644 --- a/application/views/scripts/schedule/scheduled-content.phtml +++ b/application/views/scripts/schedule/scheduled-content.phtml @@ -20,5 +20,7 @@ + +
      • No Playlists
      • diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index 6531abe89..5a1b8b713 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -159,7 +159,7 @@ function openShowDialog() { }); } -function makeScheduleDialog(dialog, show) { +function makeScheduleDialog(dialog, json, show) { dialog.find("#schedule_playlist_search").keyup(function(){ var url, string, day; @@ -172,20 +172,29 @@ function makeScheduleDialog(dialog, show) { $("#schedule_playlist_choice") .empty() - .append(html); + .append(html) + .find('li') + .draggable({ + helper: 'clone' + }); }); }); - dialog.find('#schedule_playlist_choice li') - .draggable({ - helper: 'clone' - }); + dialog.find('#schedule_playlist_choice') + .append(json.choice) + .find('li') + .draggable({ + helper: 'clone' + }); dialog.find("#schedule_playlist_chosen") + .append(json.chosen) .droppable({ drop: function(event, ui) { - var li, pl_id, url, start_date, end_date, day; + var li, pl_id, url, start_date, end_date, day, search; + + search = $("#schedule_playlist_search").val(); pl_id = $(ui.helper).attr("id").split("_").pop(); day = show.start.getDay(); @@ -196,7 +205,7 @@ function makeScheduleDialog(dialog, show) { url = '/Schedule/schedule-show/format/json'; $.post(url, - {plId: pl_id, start: start_date, end: end_date, showId: show.id, day: day}, + {plId: pl_id, start: start_date, end: end_date, showId: show.id, day: day, search: search}, function(json){ var x; @@ -231,7 +240,7 @@ function openScheduleDialog(show) { function(json){ var dialog = $(json.dialog); - makeScheduleDialog(dialog, show); + makeScheduleDialog(dialog, json, show); dialog.dialog({ autoOpen: false, From a4fb54cd018a9413a8002b4fbeb21b689fc30c82 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Thu, 13 Jan 2011 23:44:36 -0500 Subject: [PATCH 6/6] show and hide file content of scheduled items. --- .../scripts/schedule/schedule-show.phtml | 6 +++--- .../scripts/schedule/scheduled-content.phtml | 21 +++++++++---------- public/js/airtime/schedule/schedule.js | 11 +++++++++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/application/views/scripts/schedule/schedule-show.phtml b/application/views/scripts/schedule/schedule-show.phtml index bc315759c..b854df484 100644 --- a/application/views/scripts/schedule/schedule-show.phtml +++ b/application/views/scripts/schedule/schedule-show.phtml @@ -1,5 +1,5 @@
        - -
          -
            + +
              +
                diff --git a/application/views/scripts/schedule/scheduled-content.phtml b/application/views/scripts/schedule/scheduled-content.phtml index 910a2ad65..980ab27ea 100644 --- a/application/views/scripts/schedule/scheduled-content.phtml +++ b/application/views/scripts/schedule/scheduled-content.phtml @@ -1,15 +1,12 @@ showContent) > 0) : ?> showContent as $pl) : ?> -
              • " class="ui-widget-content"> -

                -
                - - -
                -
                -
                -

                -
                +
              • "> +
                + + +
                +
              • -
              • No Playlists
              • +

                Empty

                +
                No Playlists
                diff --git a/public/js/airtime/schedule/schedule.js b/public/js/airtime/schedule/schedule.js index 5a1b8b713..f50cd6aca 100644 --- a/public/js/airtime/schedule/schedule.js +++ b/public/js/airtime/schedule/schedule.js @@ -219,11 +219,20 @@ function makeScheduleDialog(dialog, json, show) { $("#schedule_playlist_chosen") .empty() - .append(json.chosen); + .append(json.chosen) + .find("li") + .click(function(){ + $(this).find(".group_list").toggle(); + }); }); } }); + + dialog.find("#schedule_playlist_chosen li") + .click(function(){ + $(this).find(".group_list").toggle(); + }); } function openScheduleDialog(show) {