From 044081ef1367f3dad11e45cf3b04542201e962eb Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 2 Apr 2014 15:54:38 -0400 Subject: [PATCH] CC-5766 : Fix Show Contents action on calendar show contents are now just for past shows. takes information from the playout history. --- .../controllers/AudiopreviewController.php | 91 +------------------ .../controllers/PlayouthistoryController.php | 7 +- .../controllers/ScheduleController.php | 44 +++------ .../application/models/ShowInstance.php | 8 -- .../application/services/CalendarService.php | 44 ++++----- .../application/services/HistoryService.php | 7 +- .../schedule/show-content-dialog.phtml | 40 ++++++++ 7 files changed, 83 insertions(+), 158 deletions(-) diff --git a/airtime_mvc/application/controllers/AudiopreviewController.php b/airtime_mvc/application/controllers/AudiopreviewController.php index 5fa21c7b3..c95273474 100644 --- a/airtime_mvc/application/controllers/AudiopreviewController.php +++ b/airtime_mvc/application/controllers/AudiopreviewController.php @@ -7,8 +7,7 @@ class AudiopreviewController extends Zend_Controller_Action public function init() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); - $ajaxContext->addActionContext('show-preview', 'json') - ->addActionContext('media-preview', 'json') + $ajaxContext->addActionContext('media-preview', 'json') ->initContext(); } @@ -21,92 +20,4 @@ class AudiopreviewController extends Zend_Controller_Action $this->view->playlist = $jPlayerMaker->getJPlayerPlaylist(); } - - /** - * Simply sets up the view to play the required show track. - * Gets the parameters from the request and sets them to the view. - */ - public function showPreviewAction() - { - $CC_CONFIG = Config::getConfig(); - - $showID = $this->_getParam('showID'); - $showIndex = $this->_getParam('showIndex'); - - $baseUrl = Application_Common_OsPath::getBaseDir(); - - $this->view->headScript()->appendFile($baseUrl.'js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headLink()->appendStylesheet($baseUrl.'js/jplayer/skin/jplayer.airtime.audio.preview.css?'.$CC_CONFIG['airtime_version']); - $this->_helper->layout->setLayout('audioPlayer'); - - $logo = Application_Model_Preference::GetStationLogo(); - if ($logo) { - $this->view->logo = "data:image/png;base64,$logo"; - } else { - $this->view->logo = $baseUrl."css/images/airtime_logo_jp.png"; - } - - $this->view->showID = $showID; - $this->view->showIndex = $showIndex; - - $this->_helper->viewRenderer->setRender('audio-preview'); - } - - /** - *Function will load and return the contents of the requested show. - */ - public function getShowAction() - { - $baseUrl = Application_Common_OsPath::getBaseDir(); - // disable the view and the layout - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $showID = $this->_getParam('showID'); - - if (!isset($showID)) { - return; - } - - $showInstance = new Application_Model_ShowInstance($showID); - $result = array(); - $position = 0; - foreach ($showInstance->getShowListContent() as $track) { - - $elementMap = array( - 'element_title' => isset($track['track_title']) ? $track['track_title'] : "", - 'element_artist' => isset($track['creator']) ? $track['creator'] : "", - 'element_position' => $position, - 'element_id' => ++$position, - 'mime' => isset($track['mime'])?$track['mime']:"" - ); - - $elementMap['type'] = $track['type']; - if ($track['type'] == 0) { - $mime = $track['mime']; - if (strtolower($mime) === 'audio/mp3') { - $elementMap['element_mp3'] = $track['item_id']; - } elseif (strtolower($mime) === 'audio/ogg') { - $elementMap['element_oga'] = $track['item_id']; - } elseif (strtolower($mime) === 'audio/mp4') { - $elementMap['element_m4a'] = $track['item_id']; - } elseif (strtolower($mime) === 'audio/wav') { - $elementMap['element_wav'] = $track['item_id']; - } elseif (strtolower($mime) === 'audio/x-flac') { - $elementMap['element_flac'] = $track['item_id']; - } else { - throw new Exception("Unknown file type: $mime"); - } - - $elementMap['uri'] = $baseUrl."api/get-media/file/".$track['item_id']; - } else { - $elementMap['uri'] = $track['filepath']; - } - $result[] = $elementMap; - } - - $this->_helper->json($result); - - } } diff --git a/airtime_mvc/application/controllers/PlayouthistoryController.php b/airtime_mvc/application/controllers/PlayouthistoryController.php index baf65944b..80ad9e92e 100644 --- a/airtime_mvc/application/controllers/PlayouthistoryController.php +++ b/airtime_mvc/application/controllers/PlayouthistoryController.php @@ -146,10 +146,13 @@ class PlayouthistoryController extends Zend_Controller_Action list($startsDT, $endsDT) = $this->getStartEnd(); + $limit = intval($params["iDisplayLength"]); + $offset = intval($params["iDisplayStart"]); + $historyService = new Application_Service_HistoryService(); - $r = $historyService->getPlayedItemData($startsDT, $endsDT, $params, $instance); + $r = $historyService->getPlayedItemData($startsDT, $endsDT, $instance, $offset, $limit); - $this->view->sEcho = $r["sEcho"]; + $this->view->sEcho = intval($params["sEcho"]); $this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"]; $this->view->iTotalRecords = $r["iTotalRecords"]; $this->view->history = $r["history"]; diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 8c6ba4366..45f7be457 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -26,7 +26,6 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('cancel-current-show', 'json') ->addActionContext('get-form', 'json') ->addActionContext('upload-to-sound-cloud', 'json') - ->addActionContext('content-context-menu', 'json') ->addActionContext('set-time-scale', 'json') ->addActionContext('set-time-interval', 'json') ->addActionContext('edit-repeating-show-instance', 'json') @@ -350,13 +349,22 @@ class ScheduleController extends Zend_Controller_Action $originalDateTime->format("l, F jS"), $originalDateTime->format("G:i")); } - //$this->view->showLength = $show->getShowLength(); - //$this->view->timeFilled = $show->getTimeScheduled(); - //$this->view->percentFilled = $show->getPercentScheduled(); - //$this->view->showContent = $show->getShowListContent(); + + $historyService = new Application_Service_HistoryService(); + $columns = $historyService->getDatatablesLogSheetColumns(); + $contents = $historyService->getPlayedItemData(null, null, $showInstanceId); + + //remove the checkbox column. + array_shift($columns); + + $this->view->itemColumns = $columns; + $this->view->itemContents = $contents; + $this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml'); $this->view->showTitle = htmlspecialchars($show->getName()); - //unset($this->view->showContent); + + unset($this->view->columns); + unset($this->view->contents); } public function populateRepeatingShowInstanceFormAction() @@ -601,30 +609,6 @@ class ScheduleController extends Zend_Controller_Action } } - public function contentContextMenuAction() - { - $id = $this->_getParam('id'); - - $params = '/format/json/id/#id#/'; - - $paramsPop = str_replace('#id#', $id, $params); - - // added for downlaod - $id = $this->_getParam('id'); - - $file_id = $this->_getParam('id', null); - $file = Application_Model_StoredFile::RecallById($file_id); - - $baseUrl = $this->getRequest()->getBaseUrl(); - $url = $file->getRelativeFileUrl($baseUrl).'download/true'; - $menu = array(); - $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), - 'title' => _('Download')); - - //returns format jjmenu is looking for. - $this->_helper->json->sendJson($menu); - } - /** * Sets the user specific preference for which time scale to use in Calendar. * This is only being used by schedule.js at the moment. diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index 76bf1ce2e..1bc4922e6 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -533,14 +533,6 @@ SQL; return $isFilled; } - //TODO get rid of this - public function getShowListContent() - { - $con = Propel::getConnection(); - - return $results; - } - public function getLastAudioItemEnd() { $con = Propel::getConnection(); diff --git a/airtime_mvc/application/services/CalendarService.php b/airtime_mvc/application/services/CalendarService.php index b0727cba9..a9b223bd0 100644 --- a/airtime_mvc/application/services/CalendarService.php +++ b/airtime_mvc/application/services/CalendarService.php @@ -46,19 +46,21 @@ class Application_Service_CalendarService if ($now > $end) { if ($this->ccShowInstance->isRecorded()) { - $ccFile = $this->ccShowInstance->getCcFiles(); - if (!isset($ccFile)) { + $media = $this->ccShowInstance->getMediaItem(); + if (!isset($media)) { $menu["error when recording"] = array ( "name" => _("Record file doesn't exist"), "icon" => "error"); - }else { + } + else { $menu["view_recorded"] = array( "name" => _("View Recorded File Metadata"), "icon" => "overview", - "url" => $baseUrl."library/edit-file-md/id/".$ccFile->getDbId()); + "url" => $baseUrl."library/edit-file-md/id/".$media->getId()); } //recorded show can be uploaded to soundcloud + //TODO fix this to work with new media items. if (Application_Model_Preference::GetUploadToSoundcloudOption()) { $scid = $ccFile->getDbSoundcloudId(); @@ -74,13 +76,15 @@ class Application_Service_CalendarService "name"=> $text, "icon" => "soundcloud"); } - } else { + } + else { $menu["content"] = array( "name"=> _("Show Content"), "icon" => "overview", "url" => $baseUrl."schedule/show-content-dialog"); } - } else { + } + else { // Show content can be modified from the calendar if: // the user is admin or hosting the show, // the show is not recorded @@ -96,7 +100,8 @@ class Application_Service_CalendarService "icon" => "add-remove-content", "url" => $baseUrl."showbuilder/builder-dialog/"); //if the show is linked and it's not currently playing the user can add/remove content - } elseif ($showIsLinked && $currentShowId != $this->ccShow->getDbId()) { + } + elseif ($showIsLinked && $currentShowId != $this->ccShow->getDbId()) { $menu["schedule"] = array( "name"=> _("Add / Remove Content"), @@ -115,16 +120,6 @@ class Application_Service_CalendarService "url" => $baseUrl."schedule/clear-show"); } - //"Show Content" should be a menu item at all times except when - //the show is recorded - if (!$this->ccShowInstance->isRecorded()) { - - $menu["content"] = array( - "name"=> _("Show Content"), - "icon" => "overview", - "url" => $baseUrl."schedule/show-content-dialog"); - } - //show is currently playing and user is admin if ($start <= $now && $now < $end && $isAdminOrPM) { @@ -132,7 +127,8 @@ class Application_Service_CalendarService $menu["cancel_recorded"] = array( "name"=> _("Cancel Current Show"), "icon" => "delete"); - } else { + } + else { $menu["cancel"] = array( "name"=> _("Cancel Current Show"), "icon" => "delete"); @@ -154,7 +150,8 @@ class Application_Service_CalendarService "name" => _("Edit This Instance"), "icon" => "edit", "url" => $baseUrl."Schedule/populate-repeating-show-instance-form"); - } else { + } + else { $menu["edit"] = array( "name" => _("Edit"), "icon" => "edit", @@ -170,7 +167,8 @@ class Application_Service_CalendarService "icon" => "edit", "url" => $baseUrl."Schedule/populate-repeating-show-instance-form"); } - } else { + } + else { $menu["edit"] = array( "name"=> _("Edit Show"), "icon" => "edit", @@ -198,12 +196,14 @@ class Application_Service_CalendarService "name"=> _("Delete This Instance and All Following"), "icon" => "delete", "url" => $baseUrl."schedule/delete-show"); - } elseif ($populateInstance) { + } + elseif ($populateInstance) { $menu["del"] = array( "name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."schedule/delete-show-instance"); - } else { + } + else { $menu["del"] = array( "name"=> _("Delete"), "icon" => "delete", diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 6376a1710..6e9cc0ebe 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -72,14 +72,10 @@ class Application_Service_HistoryService } //opts is from datatables. - public function getPlayedItemData($startDT, $endDT, $opts, $instanceId=null) + public function getPlayedItemData($startDT, $endDT, $instanceId=null, $offset = 0, $limit = -1) { $this->con->beginTransaction(); - //LIMIT OFFSET statements - $limit = intval($opts["iDisplayLength"]); - $offset = intval($opts["iDisplayStart"]); - $query = CcPlayoutHistoryQuery::create() ->_if(isset($instanceId)) ->filterByDbInstanceId($instanceId) @@ -143,7 +139,6 @@ class Application_Service_HistoryService } return array( - "sEcho" => intval($opts["sEcho"]), "iTotalDisplayRecords" => intval($totalCount), "iTotalRecords" => intval($totalCount), "history" => $datatables diff --git a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml index ee13b8526..570ffd342 100644 --- a/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml +++ b/airtime_mvc/application/views/scripts/schedule/show-content-dialog.phtml @@ -1,3 +1,43 @@
additionalShowInfo; ?>
+ + + + + itemColumns as $column): ?> + + + + + + itemContents["history"]); $i++): ?> + itemContents["history"][$i]; + $trclass = $i&1 ? "even" : "odd"; + ?> + + itemColumns as $column): ?> + + + + + +
+ +