public function indexAction()
 {
     $this->getLogger()->debug('Received new search request. Redirecting to search action of IndexController.');
     $params = array();
     $action = 'search';
     $searchModel = new Solrsearch_Model_Search();
     $request = $this->getRequest();
     $searchType = $request->getParam('searchtype', 'invalid searchtype');
     if (in_array($searchType, array('advanced', 'authorsearch')) && !is_null($this->getParam('Reset'))) {
         $this->_redirectTo('advanced', null, 'index', 'solrsearch');
         return;
     }
     switch ($searchType) {
         case Application_Util_Searchtypes::SIMPLE_SEARCH:
             if (!$searchModel->isSimpleSearchRequestValid($request)) {
                 $action = 'invalidsearchterm';
                 $params = array('searchtype' => Application_Util_Searchtypes::SIMPLE_SEARCH);
             } else {
                 $params = $searchModel->createSimpleSearchUrlParams($request);
             }
             break;
         case Application_Util_Searchtypes::ADVANCED_SEARCH:
         case Application_Util_Searchtypes::AUTHOR_SEARCH:
             if (!$searchModel->isAdvancedSearchRequestValid($request)) {
                 $action = 'invalidsearchterm';
                 $params = array('searchtype' => $searchType);
             } else {
                 $params = $searchModel->createAdvancedSearchUrlParams($request);
             }
             break;
         default:
             break;
     }
     $this->_redirectToPermanentAndExit($action, null, 'index', null, $params);
 }
Пример #2
0
 public function testIsAdvancedSearchRequestValidFalse()
 {
     $model = new Solrsearch_Model_Search();
     $request = $this->getRequest();
     $this->assertFalse($model->isAdvancedSearchRequestValid($request));
     $request->setParam('persons', '   ');
     $this->assertFalse($model->isAdvancedSearchRequestValid($request));
 }