Пример #1
0
 /**
  * shows the homepage
  *
  */
 public function indexAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (isset($get->shelf)) {
         $this->view->hideFeature = true;
     }
     $event = new Event();
     $upcoming = $event->getEvents(null, null, null, time(), null, 'open', 5)->toArray();
     $workshop = new Workshop();
     foreach ($upcoming as &$u) {
         $u['workshop'] = $workshop->find($u['workshopId'])->toArray();
         if (Zend_Auth::getInstance()->hasIdentity()) {
             $u['status'] = $event->getStatusOfUserForEvent(Zend_Auth::getInstance()->getIdentity()->accountId, $u['eventId']);
         } else {
             $u['status'] = '';
         }
     }
     $this->view->upcoming = $upcoming;
     $searchTerm = new Search_Term();
     $this->view->popularSearchTerms = $searchTerm->getTopSearchTerms(5)->toArray();
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->loggedIn = true;
         $myEvents = $event->getEventsForUser(Zend_Auth::getInstance()->getIdentity()->accountId);
         $this->view->myEvents = $myEvents['currentEvents'];
         $this->view->account = Zend_Auth::getInstance()->getIdentity()->toArray();
     }
     $this->_helper->layout->setLayout('homepage');
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
Пример #2
0
 /**
  * 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");
 }