diff --git a/application/controllers/LibraryController.php b/application/controllers/LibraryController.php index 9011dc1ae..df805861d 100644 --- a/application/controllers/LibraryController.php +++ b/application/controllers/LibraryController.php @@ -4,6 +4,7 @@ class LibraryController extends Zend_Controller_Action { protected $pl_sess = null; + protected $search_sess = null; public function init() { @@ -20,6 +21,7 @@ class LibraryController extends Zend_Controller_Action ->initContext(); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); + $this->search_sess = new Zend_Session_Namespace("search"); } public function indexAction() @@ -28,6 +30,9 @@ class LibraryController extends Zend_Controller_Action $this->_helper->layout->setLayout('library'); + unset($this->search_sess->md); + unset($this->search_sess->order); + $this->_helper->actionStack('context-menu', 'library'); $this->_helper->actionStack('contents', 'library'); $this->_helper->actionStack('index', 'sideplaylist'); @@ -82,14 +87,17 @@ class LibraryController extends Zend_Controller_Action public function contentsAction() { - $this->_helper->viewRenderer->setResponseSegment('library'); - $this->view->headScript()->appendFile('/js/campcaster/library/library.js','text/javascript'); - $query["category"] = $this->_getParam('ob', "dc:creator"); - $query["order"] = $this->_getParam('order', "asc"); - - $this->view->files = StoredFile::getFiles($query); + $this->_helper->viewRenderer->setResponseSegment('library'); + + $order["category"] = $this->_getParam('ob', "dc:creator"); + $order["order"] = $this->_getParam('order', "asc"); + + $this->search_sess->order = $order; + $md = isset($this->search_sess->md) ? $this->search_sess->md : array(); + + $this->view->files = StoredFile::searchFiles($md, $order); } public function searchAction() diff --git a/application/controllers/SearchController.php b/application/controllers/SearchController.php index 5d8e21b3d..c4554f8f7 100644 --- a/application/controllers/SearchController.php +++ b/application/controllers/SearchController.php @@ -4,6 +4,7 @@ class SearchController extends Zend_Controller_Action { protected $form; + protected $search_sess = null; public function init() { @@ -18,6 +19,7 @@ class SearchController extends Zend_Controller_Action ->initContext(); $this->form = new Application_Form_AdvancedSearch(); + $this->search_sess = new Zend_Session_Namespace("search"); } public function indexAction() @@ -46,6 +48,10 @@ class SearchController extends Zend_Controller_Action // Form has not been submitted - displayed using layouts if (!$request->isPost()) { + + unset($this->search_sess->md); + unset($this->search_sess->order); + $sub = new Application_Form_AdvancedSearchRow(1); $form->addSubForm($sub, 'row_1'); $form->getSubForm('row_1')->removeDecorator('DtDdWrapper'); @@ -62,11 +68,12 @@ class SearchController extends Zend_Controller_Action return; } - // form was submitted, send back strings to json response. - //$this->view->form = $form->__toString(); + // form was submitted, send back strings to json response. + $info = $form->getValues(); + $this->search_sess->md = $info; + $order = isset($this->search_sess->order) ? $this->search_sess->order : NULL; - $info = $form->getValues(); - $this->view->files = StoredFile::searchFiles($info); + $this->view->files = StoredFile::searchFiles($info, $order); $this->view->results = $this->view->render('library/update.phtml'); unset($this->view->files); } diff --git a/application/models/StoredFile.php b/application/models/StoredFile.php index 7c17b6fd0..31e47aa59 100644 --- a/application/models/StoredFile.php +++ b/application/models/StoredFile.php @@ -1726,22 +1726,7 @@ class StoredFile { return $CC_CONFIG['accessDir']."/$p_token.$p_ext"; } - - public static function getFiles($query=NULL) - { - global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping; - - $sql = "SELECT * FROM ".$CC_CONFIG['filesTable']; - - if(!is_null($query)) { - $ob = " ORDER BY ".$g_metadata_xml_to_db_mapping[$query["category"]]; - $sql = $sql . $ob . " " .$query["order"]; - } - - return $CC_DBC->getAll($sql); - } - - public static function searchFiles($md) + public static function searchFiles($md, $order=NULL) { global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping; @@ -1776,8 +1761,15 @@ class StoredFile { } } - $where = " WHERE ". join(" AND ", $cond); - $sql = $sql . $where; + if(count($cond) > 0) { + $where = " WHERE ". join(" AND ", $cond); + $sql = $sql . $where; + } + + if(!is_null($order)) { + $ob = " ORDER BY ".$g_metadata_xml_to_db_mapping[$order["category"]]; + $sql = $sql . $ob . " " .$order["order"]; + } //echo $sql; return $CC_DBC->getAll($sql); diff --git a/application/views/scripts/playlist/close.phtml b/application/views/scripts/playlist/close.phtml new file mode 100644 index 000000000..421ba5dd4 --- /dev/null +++ b/application/views/scripts/playlist/close.phtml @@ -0,0 +1 @@ +

View script for controller Playlist and script/action name close
\ No newline at end of file diff --git a/public/js/campcaster/library/library.js b/public/js/campcaster/library/library.js index 343b0f720..c1dad5e53 100644 --- a/public/js/campcaster/library/library.js +++ b/public/js/campcaster/library/library.js @@ -22,6 +22,7 @@ function setLibraryContents(data){ } function setUpLibrary() { + $("#library_display tr:first-child span.title").data({'ob': 'dc:title', 'order' : 'asc'}); $("#library_display tr:first-child span.artist").data({'ob': 'dc:creator', 'order' : 'desc'}); $("#library_display tr:first-child span.album").data({'ob': 'dc:source', 'order' : 'asc'}); @@ -33,11 +34,6 @@ function setUpLibrary() { ob = $(this).data('ob'), order = $(this).data('order'); - //append orderby category to url. - url = url + "/ob/" + ob; - //append asc or desc order. - url = url + "/order/" + order; - //toggle order for next click. if(order === 'asc') { $(this).data('order', 'desc'); @@ -46,7 +42,7 @@ function setUpLibrary() { $(this).data('order', 'asc'); } - $.post(url, setLibraryContents); + $.post(url, {ob: ob, order: order}, setLibraryContents); }); $("#library_display tr:not(:first-child)") diff --git a/public/js/campcaster/onready/library.js b/public/js/campcaster/onready/library.js new file mode 100644 index 000000000..045656421 --- /dev/null +++ b/public/js/campcaster/onready/library.js @@ -0,0 +1,6 @@ +$(document).ready(function() { + + setUpLibrary(); + setUpSPL(); + +}); diff --git a/public/js/campcaster/onready/search.js b/public/js/campcaster/onready/search.js new file mode 100644 index 000000000..cfd22d817 --- /dev/null +++ b/public/js/campcaster/onready/search.js @@ -0,0 +1,7 @@ +$(document).ready(function() { + + setUpLibrary(); + setUpSearch(); + setUpSPL(); + +});