starting advanced search

This commit is contained in:
naomiaro 2011-02-09 22:37:18 -05:00
parent 918f4ec96d
commit 59ef9ee6a0
7 changed files with 59 additions and 61 deletions

View File

@ -4,14 +4,10 @@ class LibraryController extends Zend_Controller_Action
{
protected $pl_sess = null;
protected $search_sess = null;
public function init()
{
if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('login/index');
}
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('contents', 'json')
->addActionContext('delete', 'json')
@ -30,12 +26,21 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile('/js/datatables/js/jquery.dataTables.js','text/javascript');
$this->view->headScript()->appendFile('/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/library/library.js','text/javascript');
$this->view->headScript()->appendFile('/js/airtime/library/advancedsearch.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/media_library.css');
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
$this->_helper->layout->setLayout('library');
$this->_helper->viewRenderer->setResponseSegment('library');
$form = new Application_Form_AdvancedSearch();
$form->addGroup(1, 1);
$this->search_sess->next_group = 2;
$this->search_sess->next_row[1] = 2;
$this->view->form = $form;
$this->view->md = $this->search_sess->md;
$this->_helper->actionStack('index', 'playlist');
}

View File

@ -28,14 +28,11 @@ class SearchController extends Zend_Controller_Action
public function init()
{
if(!Zend_Auth::getInstance()->hasIdentity())
{
$this->_redirect('login/index');
}
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('newfield', 'json')
->addActionContext('newgroup', 'json')
->addActionContext('index', 'json')
->addActionContext('display', 'json')
->initContext();
$this->search_sess = new Zend_Session_Namespace("search");
@ -43,54 +40,24 @@ class SearchController extends Zend_Controller_Action
public function indexAction()
{
$this->_helper->layout->setLayout('search');
$data = $this->_getParam('data');
$form = new Application_Form_AdvancedSearch();
// Form has been submitted
$form->preValidation($data);
//if (!$form->isValid($data)) {
//$this->view->form = $form->__toString();
//return;
//}
$this->view->headScript()->appendFile('/js/contextmenu/jjmenu.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
$this->_helper->actionStack('contents', 'library');
$this->_helper->actionStack('display', 'search');
$this->_helper->actionStack('index', 'playlist');
// valid form was submitted set as search criteria.
$this->search_sess->md = $data;
}
public function displayAction()
{
$this->view->headScript()->appendFile('/js/airtime/library/advancedsearch.js','text/javascript');
$this->view->headLink()->appendStylesheet('/css/library_search.css');
$this->_helper->viewRenderer->setResponseSegment('search');
$request = $this->getRequest();
$form = new Application_Form_AdvancedSearch();
$this->view->form = $form;
// Form has not been submitted - displayed using layouts
if (!$request->isPost()) {
$form->addGroup(1, 1);
$this->search_sess->next_group = 2;
$this->search_sess->next_row[1] = 2;
return;
}
$this->view->md = $request->getPost();
// Form has been submitted
$form->preValidation($request->getPost());
if (!$form->isValid($request->getPost())) {
return;
}
// valid form was submitted set as search criteria.
$this->view->md = $form->getValues();
$this->search_sess->md = $form->getValues();
//make sure to start on first page of new results.
unset($this->search_sess->page);
}
public function newfieldAction()
@ -113,8 +80,6 @@ class SearchController extends Zend_Controller_Action
$this->search_sess->next_group = $group_id + 1;
$this->search_sess->next_row[$group_id] = 2;
}
}

View File

@ -14,7 +14,7 @@ class Application_Form_AdvancedSearch extends Zend_Form
$this->getElement('search_add_group')->removeDecorator('DtDdWrapper');
// Add the submit button
$this->addElement('submit', 'search_submit', array(
$this->addElement('button', 'search_submit', array(
'ignore' => true,
'label' => 'Submit',
'order' => '-1'

View File

@ -11,6 +11,14 @@ class Application_Form_AdvancedSearchGroup extends Zend_Form_SubForm
'order' => '-2'
));
$this->getElement('search_add_row')->removeDecorator('DtDdWrapper');
// Add the add button
$this->addElement('button', 'search_remove_group', array(
'ignore' => true,
'label' => 'Remove',
'order' => '-1'
));
$this->getElement('search_remove_group')->removeDecorator('DtDdWrapper');
}
public function addRow($row_id, $data=null) {

View File

@ -19,5 +19,8 @@
</table>
</div>
<div id="advancedSearch">
Some Text
<div id="search">
<?php echo $this->form; ?>
</div>
<div><?php echo var_dump($this->md); ?></div>
</div>

View File

@ -1,6 +1,5 @@
<?php
$this->form->setAction($this->url());
echo $this->form;
echo var_dump($this->md);
?>

View File

@ -3,7 +3,7 @@ function addRemove(el) {
id = $(el).attr("id").split("_").pop();
span = $('<span id="search_remove_'+id+'">Remove</span>').click(function(){
span = $('<a href="#" id="search_remove_'+id+'" class="ui-button ui-button-icon-only ui-widget ui-state-default"><span class="ui-icon ui-icon-closethick"></span><span class="ui-button-text">Remove</span></a>').click(function(){
$(this).parent().parent().remove();
});
@ -20,27 +20,45 @@ function ajaxAddRow() {
$.post(url, {group: group_id}, function(json) {
var newRow = $(json.html).find("#fieldset-row_"+json.row);
addRemove(newRow);
$("#fieldset-group_"+group_id+" dl:first").append(newRow);
});
}
function removeGroup() {
$(this).parent().parent().remove();
}
function ajaxAddGroup() {
var url = '/Search/newgroup/format/json';
$.post(url, function(json) {
$(".zend_form").append(json.html);
$('[id$="search_add_row"]').click(ajaxAddRow);
var group = $(json.html);
addRemove(group);
group.find('[id$="search_add_row"]').click(ajaxAddRow);
group.find('[id$="search_remove_group"]').click(removeGroup);
$(".zend_form").append(group);
});
}
function advancedSearchSubmit() {
var data = $("#advancedSearch form").serializeArray();
$.post("/Search/index", {format: "json", data: data}, function(json){
var x;
});
}
$(document).ready(function() {
$("#search_add_group").click(ajaxAddGroup);
$("#search_submit").click(advancedSearchSubmit);
$('[id$="search_add_row"]').click(ajaxAddRow);
$('[id$="search_remove_group"]').click(removeGroup);
$('[id^="fieldset-row_"]').each(function(i, el){
addRemove(el);