/** * Action to set the search form to the response * @return null */ public function indexAction() { $form = null; $node = $this->getResultNode(); if ($node) { $form = new SearchForm($this->request->getBaseUrl() . '/' . $node->getRoute()); $form->isSubmitted(); } $view = new SearchFormView($form); $this->response->setView($view); }
/** * Action to display the search results for a submitted search form * @param string $query url encoded search query, if not specified the search form will be checked for a query * @return null */ public function indexAction($query = null) { $result = null; if (!$query) { $action = $this->request->getBasePath(); $form = new SearchForm($action); if ($form->isSubmitted()) { $query = $form->getQuery(); $this->response->setRedirect($action . '/' . urlencode($query)); return; } } else { $query = urldecode($query); $numItems = $this->getNumberItemsPreview(); $contentTypes = $this->getSearchableContentTypes(); $result = SearchFacade::getInstance()->search($query, $numItems, $contentTypes); } $urlMore = $this->request->getBasePath() . '/' . self::ACTION_MORE . '/'; $view = new SearchResultView($query, $result, $urlMore); $this->response->setView($view); }