.

SearchIndexBaseController Class Reference

Defines a view route for searching. More...

Inheritance diagram for SearchIndexBaseController:
ControllerBase IController IEventSink SearchIndexController

List of all members.

Public Member Functions

  action_searchindex_search ($page_data)
  Show search result.
  get_routes ()
  Return array of routes this controller takes responsability.

Protected Member Functions

  get_terms (PageData $page_data)
  Extract Terms.

Detailed Description

Defines a view route for searching.

Author:
Gerd Riesselmann

Definition at line 8 of file searchindex.basecontroller.php.


Member Function Documentation

SearchIndexBaseController::action_searchindex_search ( page_data  ) 

Show search result.

Parameters:
$page_data  PageData

Definition at line 25 of file searchindex.basecontroller.php.

00025                                                               {
00026                 $page_data->head->robots_index = ROBOTS_NOINDEX_FOLLOW;
00027                 $page_data->breadcrumb = array(tr('Search', 'searchindex'));
00028                 $view = ViewFactory::create_view(IViewFactory::CONTENT, 'searchindex/search', $page_data);
00029                 $terms = trim($this->get_terms($page_data));
00030                 if ($terms !== '') {
00031                         if (!String::check_encoding($terms)) {
00032                                 // Convert. Since autodection is not really good, try most probable encoding
00033                                 // manually: Latin1
00034                                 if (String::check_encoding($terms, 'ISO-8859-1')) {
00035                                         $newterms = String::convert($terms, 'ISO-8859-1');
00036                                 }
00037                                 else {
00038                                         $newterms = String::convert($terms);
00039                                 }
00040                                 if ($newterms != $terms) {
00041                                         Url::current()->replace_query_parameter('q', $newterms)->redirect();
00042                                 }
00043                         }
00044                         
00045                         $page_data->head->title = tr('Search »%terms«', 'searchindex', array('%terms' => $terms));
00046                         $page_data->head->description = tr('Search results for query »%terms«.', 'searchindex', array('%terms' => $terms));
00047                         
00048                         $search = SearchIndexRepository::get_index_implementation();
00049                         $search->set_search($terms);
00050                         
00051                         Load::tools('pager', 'sorter');
00052                         $pager = new Pager($page_data, $search);
00053                         $pager->apply($search);
00054                         $pager->prepare_view($view);
00055                         
00056                         $sorter = new Sorter($page_data, $search);
00057                         $sorter->apply($search);
00058                         $sorter->prepare_view($view);
00059 
00060                         $view->assign('result', $search->execute());
00061                 } else {
00062                         $page_data->head->title = tr('Search', 'searchindex');
00063                 }
00064                 $view->assign('terms', $terms);
00065                 $view->render(); 
00066         }
SearchIndexBaseController::get_routes (  ) 

Return array of routes this controller takes responsability.

Reimplemented from ControllerBase.

Definition at line 13 of file searchindex.basecontroller.php.

00013                                      {
00014                 $ret = array(
00015                         'view' => new ExactMatchRoute('search/', $this, 'searchindex_search', new NoCacheCacheManager()),
00016                 );
00017                 return $ret;
00018         }
SearchIndexBaseController::get_terms ( PageData page_data  )  [protected]

Extract Terms.

Definition at line 71 of file searchindex.basecontroller.php.

00071                                                           {
00072                 $param = Config::get_value(ConfigSearchIndex::QUERY_PARAMETER);
00073                 return $page_data->get_get()->get_item($param, '');
00074         }

The documentation for this class was generated from the following file: