Ejemplo n.º 1
0
 public function testInit()
 {
     $form = new Solrsearch_Form_Options();
     $this->assertEquals(3, count($form->getElements()));
     $this->assertNotNull($form->getElement('rows'));
     $this->assertNotNull($form->getElement('searchtype'));
     $this->assertNotNull($form->getElement('search'));
     $this->assertEquals('latest', $form->getElement('searchtype')->getValue());
 }
Ejemplo n.º 2
0
 public function searchAction()
 {
     // TODO OPUSVIER-3324 Mischform in der url entfernen
     // check if searchtype = latest and params parsed incorrect
     $searchType = $this->getParam('searchtype');
     $request = $this->getRequest();
     if (in_array($searchType, array('advanced', 'authorsearch')) && !is_null($this->getParam('Reset'))) {
         $this->_redirectTo('advanced', null, 'index', 'solrsearch');
         return;
     }
     if (strpos($searchType, 'latest/export') !== false) {
         $paramArray = explode('/', $searchType);
         $params = $request->getParams();
         $params['searchtype'] = 'latest';
         $params['export'] = $paramArray[2];
         $params['stylesheet'] = $paramArray[4];
         $this->redirectToExport($params);
         return;
     }
     if (!is_null($request->getParam('export'))) {
         $params = $request->getParams();
         // export module ignores pagination parameters
         $this->redirectToExport($params);
         return;
     }
     // TODO does the following make sense after the above?
     $config = $this->getConfig();
     if (isset($config->export->stylesheet->search) && Opus_Security_Realm::getInstance()->checkModule('export')) {
         $this->view->stylesheet = $config->export->stylesheet->search;
     }
     $query = $this->buildQuery();
     // if query is null, redirect has already been set
     if (!is_null($query)) {
         $this->_query = $query;
         $this->performSearch();
         $this->setViewValues();
         $this->_facetMenu->prepareViewFacets($this->_resultList, $this->getRequest());
         $this->view->facets = $this->_facetMenu->getFacets();
         $this->view->selectedFacets = $this->_facetMenu->getSelectedFacets();
         $this->view->facetNumberContainer = $this->_facetMenu->getFacetNumberContainer();
         $this->view->showFacetExtender = $this->_facetMenu->getShowFacetExtender();
         $this->setLinkRelCanonical();
         switch ($searchType) {
             case 'advanced':
             case 'authorsearch':
                 $form = new Solrsearch_Form_AdvancedSearch($searchType);
                 $form->populate($this->getAllParams());
                 $form->setAction($this->view->url(array('module' => 'solrsearch', 'controller' => 'dispatch', 'action' => 'index'), null, true));
                 $this->view->form = $form;
                 break;
             case 'latest':
                 $form = new Solrsearch_Form_Options();
                 $form->setMethod(Zend_FORM::METHOD_GET);
                 $form->setAction($this->view->url(array('module' => 'solrsearch', 'controller' => 'index', 'action' => 'search'), null, true));
                 $form->populate($this->getAllParams());
                 $this->view->form = $form;
                 break;
             default:
                 break;
         }
         if ($this->_numOfHits === 0 || $this->_query->getStart() >= $this->_numOfHits) {
             $this->render('nohits');
         } else {
             $this->render('results');
         }
     }
 }