search maintains state
This commit is contained in:
parent
b1a4cb5bd4
commit
e768539ea8
7 changed files with 51 additions and 34 deletions
|
@ -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->_helper->viewRenderer->setResponseSegment('library');
|
||||
|
||||
$this->view->files = StoredFile::getFiles($query);
|
||||
$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()
|
||||
|
|
|
@ -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');
|
||||
|
@ -63,10 +69,11 @@ class SearchController extends Zend_Controller_Action
|
|||
}
|
||||
|
||||
// form was submitted, send back strings to json response.
|
||||
//$this->view->form = $form->__toString();
|
||||
|
||||
$info = $form->getValues();
|
||||
$this->view->files = StoredFile::searchFiles($info);
|
||||
$this->search_sess->md = $info;
|
||||
$order = isset($this->search_sess->order) ? $this->search_sess->order : NULL;
|
||||
|
||||
$this->view->files = StoredFile::searchFiles($info, $order);
|
||||
$this->view->results = $this->view->render('library/update.phtml');
|
||||
unset($this->view->files);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
1
application/views/scripts/playlist/close.phtml
Normal file
1
application/views/scripts/playlist/close.phtml
Normal file
|
@ -0,0 +1 @@
|
|||
<br /><br /><center>View script for controller <b>Playlist</b> and script/action name <b>close</b></center>
|
|
@ -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)")
|
||||
|
|
6
public/js/campcaster/onready/library.js
Normal file
6
public/js/campcaster/onready/library.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
setUpLibrary();
|
||||
setUpSPL();
|
||||
|
||||
});
|
7
public/js/campcaster/onready/search.js
Normal file
7
public/js/campcaster/onready/search.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
setUpLibrary();
|
||||
setUpSearch();
|
||||
setUpSPL();
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue