/** * The main workshop page. It has the list of all the workshops that are * available in the system. * */ public function indexAction() { $this->view->acl = array('workshopList' => $this->_helper->hasAccess('workshop-list')); $get = Zend_Registry::get('getFilter'); $form = new Zend_Form(); $form->setAttrib('id', 'workshopForm')->setMethod(Zend_Form::METHOD_GET)->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'filterForm')), 'Form')); $searchField = $form->createElement('text', 'search', array('label' => 'workshop-index-index:searchWorkshops')); $searchField->setRequired(false)->addFilter('StringTrim')->addFilter('StripTags')->setValue(isset($get->search) ? $get->search : ''); $category = new Category(); $categoryList = $category->fetchAll(null, 'name'); $categories = $form->createElement('select', 'categoryId'); $categories->addMultiOption('', '-- Search By Category -- '); foreach ($categoryList as $c) { $categories->addMultiOption($c['categoryId'], $c['name']); } $categories->setValue(isset($get->categoryId) ? $get->categoryId : ''); $submit = $form->createElement('submit', 'submitButton', array('label' => 'workshop-index-index:search')); $submit->setDecorators(array(array('ViewHelper', array('helper' => 'formSubmit')))); $form->addElements(array($searchField, $categories)); $form->setElementDecorators(array('ViewHelper', 'Errors', array('HtmlTag', array('tag' => 'div', 'class' => 'elm')), array('Label', array('tag' => 'span'))))->addElements(array($submit)); $this->view->form = $form; $searchTerm = new Search_Term(); $workshops = array(); if ($get->search != '' || $get->categoryId != 0) { $workshop = new Workshop(); $query = new Zend_Search_Lucene_Search_Query_MultiTerm(); if ($get->search != '') { $query->addTerm(new Zend_Search_Lucene_Index_Term($get->search), true); } if ($get->categoryId != 0) { $query->addTerm(new Zend_Search_Lucene_Index_Term($get->categoryId, 'categoryId'), true); } $workshops = $workshop->search($query); $searchTerm->increment($get->search); $this->view->searchTerm = $get->search; } $this->view->workshops = $workshops; $this->view->topTerms = $searchTerm->getTopSearchTerms(10); $this->view->layout()->setLayout('search'); $this->view->layout()->rightContent = $this->view->render('index/top-terms.phtml'); $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.autocomplete.js'); $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.autocomplete.css'); $this->_helper->pageTitle("workshop-index-index:title"); }