From 9854834b2618d31b1b5eeeed671ac62099f40a8e Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 6 Jan 2011 16:20:51 -0500 Subject: [PATCH] adding fields to allow for multiple playlists scheduled in a show --- application/controllers/LibraryController.php | 6 +---- application/models/StoredFile.php | 9 +++++-- .../views/scripts/library/contents.phtml | 1 + .../scripts/library/libraryTablePartial.phtml | 1 + build/schema.xml | 2 ++ build/sql/triggers.sql | 24 +++++++++++++++++++ public/js/airtime/library/library.js | 1 + 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/application/controllers/LibraryController.php b/application/controllers/LibraryController.php index 99e3d7ec3..da98fae22 100644 --- a/application/controllers/LibraryController.php +++ b/application/controllers/LibraryController.php @@ -37,10 +37,6 @@ class LibraryController extends Zend_Controller_Action unset($this->search_sess->page); unset($this->search_sess->md); - - //if ($this->getRequest()->isGet()) { - // unset($this->search_sess->quick); - //} $this->_helper->actionStack('contents', 'library'); $this->_helper->actionStack('quick-search', 'library'); @@ -218,7 +214,7 @@ class LibraryController extends Zend_Controller_Action $search = $this->_getParam('search', null); $this->search_sess->quick_string = $search; - $categories = array("dc:title", "dc:creator", "dc:source"); + $categories = array("dc:title", "dc:creator", "dc:source", "ls:type"); $keywords = explode(" ", $search); $md = array(); diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php index 490d19c93..d35a55800 100644 --- a/application/models/StoredFile.php +++ b/application/models/StoredFile.php @@ -6,6 +6,7 @@ require_once("Schedule.php"); global $g_metadata_xml_to_db_mapping; $g_metadata_xml_to_db_mapping = array( + "ls:type" => "ftype", "dc:format" => "format", "ls:bitrate" => "bit_rate", "ls:samplerate" => "sample_rate", @@ -1763,6 +1764,10 @@ class StoredFile { if($key === "dc:title"){ $plSelect .= "name AS ".$val.", "; $fileSelect .= $val.", "; + } + else if ($key === "ls:type"){ + $plSelect .= "'playlist' AS ".$val.", "; + $fileSelect .= $val.", "; } else if ($key === "dc:creator"){ $plSelect .= "creator AS ".$val.", "; @@ -1789,13 +1794,13 @@ class StoredFile { $selector = "SELECT *"; } - $from = " FROM ((".$plSelect."PL.id, 'playlist' AS ftype + $from = " FROM ((".$plSelect."PL.id FROM ".$CC_CONFIG["playListTable"]." AS PL LEFT JOIN ".$CC_CONFIG['playListTimeView']." PLT ON PL.id = PLT.id) UNION - (".$fileSelect."id, ftype FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS "; + (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS "; $sql = $selector." ".$from; diff --git a/application/views/scripts/library/contents.phtml b/application/views/scripts/library/contents.phtml index 1ea505484..526bd37b8 100644 --- a/application/views/scripts/library/contents.phtml +++ b/application/views/scripts/library/contents.phtml @@ -8,6 +8,7 @@ Album Track Length + Type partialLoop('library/libraryTablePartial.phtml', $this->files); diff --git a/application/views/scripts/library/libraryTablePartial.phtml b/application/views/scripts/library/libraryTablePartial.phtml index 52074462d..7f8502fbe 100644 --- a/application/views/scripts/library/libraryTablePartial.phtml +++ b/application/views/scripts/library/libraryTablePartial.phtml @@ -5,4 +5,5 @@ album_title ?> track_number ?> length ?> + ftype ?> diff --git a/build/schema.xml b/build/schema.xml index 599b679e4..720e7126a 100644 --- a/build/schema.xml +++ b/build/schema.xml @@ -153,6 +153,8 @@ + + diff --git a/build/sql/triggers.sql b/build/sql/triggers.sql index c059ffe80..a190be622 100644 --- a/build/sql/triggers.sql +++ b/build/sql/triggers.sql @@ -21,3 +21,27 @@ CREATE FUNCTION calculate_position() RETURNS trigger AS CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents FOR EACH ROW EXECUTE PROCEDURE calculate_position(); + +---------------------------------------------------------------------------------- +--show_content() +---------------------------------------------------------------------------------- +DROP FUNCTION show_content() CASCADE; + +CREATE FUNCTION show_content() RETURNS trigger AS + ' + BEGIN + IF(TG_OP=''INSERT'') THEN + UPDATE cc_show_schedule SET position = (position + 1) + WHERE (id = new.id AND position >= new.position AND id != new.id); + END IF; + IF(TG_OP=''DELETE'') THEN + UPDATE cc_show_schedule SET position = (position - 1) + WHERE (id = old.id AND position > old.position); + END IF; + RETURN NULL; + END; + ' + LANGUAGE 'plpgsql'; + +CREATE TRIGGER show_content AFTER INSERT OR DELETE ON cc_show_schedule +FOR EACH ROW EXECUTE PROCEDURE show_content(); diff --git a/public/js/airtime/library/library.js b/public/js/airtime/library/library.js index 258278022..12ea190d5 100644 --- a/public/js/airtime/library/library.js +++ b/public/js/airtime/library/library.js @@ -66,6 +66,7 @@ function setUpLibrary() { $("#library_display tr:first-child span.album").data({'ob': 'dc:source', 'order' : 'asc'}); $("#library_display tr:first-child span.track").data({'ob': 'ls:track_num', 'order' : 'asc'}); $("#library_display tr:first-child span.length").data({'ob': 'dcterms:extent', 'order' : 'asc'}); + $("#library_display tr:first-child span.type").data({'ob': 'dcterms:extent', 'order' : 'asc'}); $("#library_display tr:first-child span").click(function(){ var url = "/Library/contents/format/html",