public function testConstructForAuthorSearch()
 {
     $form = new Solrsearch_Form_AdvancedSearch('authorsearch');
     $this->assertEquals(18, count($form->getElements()));
     $this->assertNull($form->getElement('rows'));
     $this->assertNull($form->getElement('year'));
     $this->assertNull($form->getElement('yearmodifier'));
     // check search fields (14)
     $fields = array('author', 'title', 'persons', 'referee', 'abstract', 'fulltext');
     foreach ($fields as $name) {
         $this->assertNotNull($form->getElement($name), "Element {$name} is missing.");
         $this->assertNotNull($form->getElement($name . 'modifier'), "Element {$name}" . 'modifier is missing.');
     }
     // check other elements (7)
     $elements = array('searchtype', 'start', 'sortfield', 'sortorder', 'Search', 'Reset');
     foreach ($elements as $name) {
         $this->assertNotNull($form->getElement($name), "Element {$name} is missing.");
     }
 }
 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');
         }
     }
 }