getEntity()) { $entities[$entity->getFolder()] = Convert::raw2att($entity->getTitle()); } return $entities; } /** * Return an array of versions that we're allowed to return * * @return array */ public function getSearchedVersions() { $versions = array(); if(!empty($_REQUEST['Versions'])) { if(is_array($_REQUEST['Versions'])) { $versions = Convert::raw2att($_REQUEST['Versions']); $versions = array_combine($versions, $versions); } else { $version = Convert::raw2att($_REQUEST['Versions']); $versions[$version] = $version; } } else if($version = $this->getVersion()) { $version = Convert::raw2att($version); $versions[$version] = $version; } return $versions; } /** * Return the current search query * * @return HTMLText|null */ public function getSearchQuery() { if(isset($_REQUEST['Search'])) { return DBField::create_field('HTMLText', $_REQUEST['Search']); } } /** * Past straight to results, display and encode the query */ public function results($data, $form = false) { $query = (isset($_REQUEST['Search'])) ? $_REQUEST['Search'] : false; $search = new DocumentationSearch(); $search->setQuery($query); $search->setVersions($this->getSearchedVersions()); $search->setModules($this->getSearchedEntities()); $search->setOutputController($this); return $search->renderResults(); } /** * Returns an search form which allows people to express more complex rules * and options than the plain search form. * * @todo client side filtering of checkable option based on the module selected. * * @return Form */ public function AdvancedSearchForm() { return new DocumentationAdvancedSearchForm($this); } /** * Check if the Advanced SearchForm can be displayed. It is enabled by * default, to disable use: * * * DocumentationSearch::enable_advanced_search(false); * * * @return bool */ public function getAdvancedSearchEnabled() { return DocumentationSearch::advanced_search_enabled(); } }