2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SearchController extends Zend_Controller_Action
|
|
|
|
{
|
2011-01-05 01:18:44 +01:00
|
|
|
protected $search_sess = null;
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-01-05 01:18:44 +01:00
|
|
|
private function addGroup($group_id) {
|
|
|
|
|
|
|
|
$form = new Application_Form_AdvancedSearch();
|
|
|
|
|
|
|
|
$form->addGroup($group_id, 1);
|
|
|
|
$group = $form->getSubForm('group_'.$group_id);
|
|
|
|
|
|
|
|
return $group->__toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function addFieldToGroup($group_id, $row_id) {
|
|
|
|
|
|
|
|
$form = new Application_Form_AdvancedSearch();
|
|
|
|
|
|
|
|
$form->addGroup($group_id);
|
|
|
|
$group = $form->getSubForm('group_'.$group_id);
|
|
|
|
|
|
|
|
$group->addRow($row_id);
|
|
|
|
|
|
|
|
return $group->__toString();
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
2011-01-05 01:18:44 +01:00
|
|
|
$ajaxContext->addActionContext('newfield', 'json')
|
|
|
|
->addActionContext('newgroup', 'json')
|
2011-02-10 04:37:18 +01:00
|
|
|
->addActionContext('index', 'json')
|
|
|
|
->addActionContext('display', 'json')
|
2010-12-07 20:19:27 +01:00
|
|
|
->initContext();
|
|
|
|
|
2010-12-22 21:08:38 +01:00
|
|
|
$this->search_sess = new Zend_Session_Namespace("search");
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2011-02-10 04:37:18 +01:00
|
|
|
$data = $this->_getParam('data');
|
2011-01-05 01:18:44 +01:00
|
|
|
$form = new Application_Form_AdvancedSearch();
|
|
|
|
|
|
|
|
// Form has been submitted
|
2011-02-10 04:37:18 +01:00
|
|
|
$form->preValidation($data);
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-02-10 04:37:18 +01:00
|
|
|
//if (!$form->isValid($data)) {
|
|
|
|
//$this->view->form = $form->__toString();
|
|
|
|
//return;
|
|
|
|
//}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-01-03 17:47:21 +01:00
|
|
|
// valid form was submitted set as search criteria.
|
2011-02-10 04:37:18 +01:00
|
|
|
$this->search_sess->md = $data;
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-02-10 04:37:18 +01:00
|
|
|
public function displayAction()
|
|
|
|
{
|
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function newfieldAction()
|
|
|
|
{
|
2011-01-05 01:18:44 +01:00
|
|
|
$group_id = $this->_getParam('group', 1);
|
|
|
|
$row_id = $this->search_sess->next_row[$group_id];
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-01-05 01:18:44 +01:00
|
|
|
$this->view->html = $this->addFieldToGroup($group_id, $row_id);
|
|
|
|
$this->view->row = $row_id;
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-01-05 01:18:44 +01:00
|
|
|
$this->search_sess->next_row[$group_id] = $row_id + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function newgroupAction()
|
|
|
|
{
|
|
|
|
$group_id = $this->search_sess->next_group;
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-01-05 01:18:44 +01:00
|
|
|
$this->view->html = $this->addGroup($group_id);
|
|
|
|
|
|
|
|
$this->search_sess->next_group = $group_id + 1;
|
|
|
|
$this->search_sess->next_row[$group_id] = 2;
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-05 01:18:44 +01:00
|
|
|
|
|
|
|
|