search uses pagination

This commit is contained in:
naomiaro 2011-01-03 11:47:21 -05:00
parent c24a152eba
commit 75cd410ba4
9 changed files with 136 additions and 64 deletions

View file

@ -33,8 +33,7 @@ class LibraryController extends Zend_Controller_Action
$this->_helper->layout->setLayout('library');
unset($this->search_sess->md);
unset($this->search_sess->order);
$this->_helper->actionStack('contents', 'library');
$this->_helper->actionStack('index', 'sideplaylist');
}
@ -59,7 +58,7 @@ class LibraryController extends Zend_Controller_Action
}
$menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'),
'title' => 'Info');
'title' => 'Edit Metadata');
}
else if($type === "pl") {
@ -124,13 +123,40 @@ class LibraryController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('library');
$order["category"] = $this->_getParam('ob', "dc:creator");
$order["order"] = $this->_getParam('order', "asc");
$cat = $this->_getParam('ob', null);
$or = $this->_getParam('order', null);
$page = $this->_getParam('page', null);
if(!is_null($cat) && !is_null($or)) {
$order["category"] = $cat;
$order["order"] = $or;
$this->search_sess->order = $order;
}
else if(isset($this->search_sess->order)){
$order = $this->search_sess->order;
}
else{
$order = null;
}
if (isset($this->search_sess->page)) {
$last_page = $this->search_sess->page;
}
else{
$last_page = null;
}
$currpage = isset($page) ? $page : $last_page;
$this->search_sess->page = $currpage;
$this->search_sess->order = $order;
$md = isset($this->search_sess->md) ? $this->search_sess->md : array();
$this->view->files = StoredFile::searchFiles($md, $order);
$count = StoredFile::searchFiles($md, $order, true);
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Null($count));
$paginator->setCurrentPageNumber($currpage);
$this->view->paginator = $paginator;
$this->view->files = StoredFile::searchFiles($md, $order, false, $paginator->getCurrentPageNumber(), $paginator->getItemCountPerPage());
}
public function editFileMdAction()

View file

@ -15,7 +15,6 @@ class SearchController extends Zend_Controller_Action
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('newfield', 'html')
->addActionContext('display', 'json')
->initContext();
$this->form = new Application_Form_AdvancedSearch();
@ -30,8 +29,8 @@ class SearchController extends Zend_Controller_Action
$this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
$this->_helper->actionStack('display', 'search');
$this->_helper->actionStack('contents', 'library');
$this->_helper->actionStack('display', 'search');
$this->_helper->actionStack('index', 'sideplaylist');
}
@ -46,18 +45,15 @@ class SearchController extends Zend_Controller_Action
$this->form = new Application_Form_AdvancedSearch();
$form = $this->form;
$this->view->form = $form;
// 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');
$this->view->form = $form;
return;
}
@ -65,24 +61,15 @@ class SearchController extends Zend_Controller_Action
$form->preValidation($request->getPost());
if (!$form->isValid($request->getPost())) {
$this->view->form = $form->__toString();
return;
}
// form was submitted, send back strings to json response.
// valid form was submitted set as search criteria.
$info = $form->getValues();
$this->search_sess->md = $info;
$order = isset($this->search_sess->order) ? $this->search_sess->order : NULL;
$this->view->files = StoredFile::searchFiles($info, $order);
if (count($this->view->files) > 0) {
$this->view->results = $this->view->render('library/update.phtml');
}
else {
$this->view->results = "<tr>No Results</tr>";
}
unset($this->view->files);
//make sure to start on first page of new results.
unset($this->search_sess->page);
}
public function newfieldAction()