starting advanced search
This commit is contained in:
parent
918f4ec96d
commit
59ef9ee6a0
|
@ -4,14 +4,10 @@ class LibraryController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $pl_sess = null;
|
protected $pl_sess = null;
|
||||||
|
protected $search_sess = null;
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if(!Zend_Auth::getInstance()->hasIdentity())
|
|
||||||
{
|
|
||||||
$this->_redirect('login/index');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext->addActionContext('contents', 'json')
|
$ajaxContext->addActionContext('contents', 'json')
|
||||||
->addActionContext('delete', '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/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/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/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/media_library.css');
|
||||||
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
|
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
|
||||||
|
|
||||||
$this->_helper->layout->setLayout('library');
|
$this->_helper->layout->setLayout('library');
|
||||||
$this->_helper->viewRenderer->setResponseSegment('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');
|
$this->_helper->actionStack('index', 'playlist');
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,11 @@ class SearchController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
if(!Zend_Auth::getInstance()->hasIdentity())
|
|
||||||
{
|
|
||||||
$this->_redirect('login/index');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
$ajaxContext->addActionContext('newfield', 'json')
|
$ajaxContext->addActionContext('newfield', 'json')
|
||||||
->addActionContext('newgroup', 'json')
|
->addActionContext('newgroup', 'json')
|
||||||
|
->addActionContext('index', 'json')
|
||||||
|
->addActionContext('display', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
|
|
||||||
$this->search_sess = new Zend_Session_Namespace("search");
|
$this->search_sess = new Zend_Session_Namespace("search");
|
||||||
|
@ -43,54 +40,24 @@ class SearchController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function indexAction()
|
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');
|
// valid form was submitted set as search criteria.
|
||||||
$this->view->headLink()->appendStylesheet('/css/contextmenu.css');
|
$this->search_sess->md = $data;
|
||||||
|
|
||||||
$this->_helper->actionStack('contents', 'library');
|
|
||||||
$this->_helper->actionStack('display', 'search');
|
|
||||||
$this->_helper->actionStack('index', 'playlist');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function displayAction()
|
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()
|
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_group = $group_id + 1;
|
||||||
$this->search_sess->next_row[$group_id] = 2;
|
$this->search_sess->next_row[$group_id] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Application_Form_AdvancedSearch extends Zend_Form
|
||||||
$this->getElement('search_add_group')->removeDecorator('DtDdWrapper');
|
$this->getElement('search_add_group')->removeDecorator('DtDdWrapper');
|
||||||
|
|
||||||
// Add the submit button
|
// Add the submit button
|
||||||
$this->addElement('submit', 'search_submit', array(
|
$this->addElement('button', 'search_submit', array(
|
||||||
'ignore' => true,
|
'ignore' => true,
|
||||||
'label' => 'Submit',
|
'label' => 'Submit',
|
||||||
'order' => '-1'
|
'order' => '-1'
|
||||||
|
|
|
@ -11,6 +11,14 @@ class Application_Form_AdvancedSearchGroup extends Zend_Form_SubForm
|
||||||
'order' => '-2'
|
'order' => '-2'
|
||||||
));
|
));
|
||||||
$this->getElement('search_add_row')->removeDecorator('DtDdWrapper');
|
$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) {
|
public function addRow($row_id, $data=null) {
|
||||||
|
|
|
@ -19,5 +19,8 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id="advancedSearch">
|
<div id="advancedSearch">
|
||||||
Some Text
|
<div id="search">
|
||||||
|
<?php echo $this->form; ?>
|
||||||
|
</div>
|
||||||
|
<div><?php echo var_dump($this->md); ?></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$this->form->setAction($this->url());
|
|
||||||
echo $this->form;
|
echo $this->form;
|
||||||
echo var_dump($this->md);
|
echo var_dump($this->md);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -3,7 +3,7 @@ function addRemove(el) {
|
||||||
|
|
||||||
id = $(el).attr("id").split("_").pop();
|
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();
|
$(this).parent().parent().remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20,27 +20,45 @@ function ajaxAddRow() {
|
||||||
$.post(url, {group: group_id}, function(json) {
|
$.post(url, {group: group_id}, function(json) {
|
||||||
|
|
||||||
var newRow = $(json.html).find("#fieldset-row_"+json.row);
|
var newRow = $(json.html).find("#fieldset-row_"+json.row);
|
||||||
|
addRemove(newRow);
|
||||||
|
|
||||||
$("#fieldset-group_"+group_id+" dl:first").append(newRow);
|
$("#fieldset-group_"+group_id+" dl:first").append(newRow);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeGroup() {
|
||||||
|
$(this).parent().parent().remove();
|
||||||
|
}
|
||||||
|
|
||||||
function ajaxAddGroup() {
|
function ajaxAddGroup() {
|
||||||
|
|
||||||
var url = '/Search/newgroup/format/json';
|
var url = '/Search/newgroup/format/json';
|
||||||
|
|
||||||
$.post(url, function(json) {
|
$.post(url, function(json) {
|
||||||
|
|
||||||
$(".zend_form").append(json.html);
|
var group = $(json.html);
|
||||||
$('[id$="search_add_row"]').click(ajaxAddRow);
|
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() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$("#search_add_group").click(ajaxAddGroup);
|
$("#search_add_group").click(ajaxAddGroup);
|
||||||
|
$("#search_submit").click(advancedSearchSubmit);
|
||||||
|
|
||||||
$('[id$="search_add_row"]').click(ajaxAddRow);
|
$('[id$="search_add_row"]').click(ajaxAddRow);
|
||||||
|
$('[id$="search_remove_group"]').click(removeGroup);
|
||||||
|
|
||||||
$('[id^="fieldset-row_"]').each(function(i, el){
|
$('[id^="fieldset-row_"]').each(function(i, el){
|
||||||
addRemove(el);
|
addRemove(el);
|
||||||
|
|
Loading…
Reference in New Issue