src/controllers/ExtensibleSearchPageController.php
public function index() {

		// Determine whether a search engine has been selected.

		$engine = $this->data()->SearchEngine;
		$classes = Config::inst()->get(FulltextSearchable::class, 'searchable_classes');
		if(!$engine || (($engine !== 'Full-Text') && !ClassInfo::exists($engine)) || (($engine === 'Full-Text') && (!is_array($classes) || (count($classes) === 0)))) {

			// The search engine has not been selected.

			return $this->httpError(404);
		}

		// Determine whether the search page should start with a listing.

		if($this->data()->StartWithListing) {

			// Display some search results.

			$request = $this->getRequest();
			return $this->getSearchResults(array(
				'Search' => $request->getVar('Search'),
				'SortBy' => $request->getVar('SortBy'),
				'SortDirection' => $request->getVar('SortDirection')
			), $this->getForm($request));
		}
		else {

			// Instantiate some default templates.

			$templates = array(
				'ExtensibleSearch',
				'ExtensibleSearchPage',
				'Page'
			);

			// Instantiate the search engine specific templates.

			if($engine !== 'Full-Text') {
				$explode = explode('\\', $engine);
				$explode = end($explode);
				$templates = array_merge(array(
					$explode,
					"{$explode}Page"
				), $templates);
			}

			// Determine the template to use.

			$this->extend('updateTemplates', $templates);
			return $this->renderWith($templates);
		}
	}
public function index() {

		// Determine whether a search engine has been selected.

		$engine = $this->data()->SearchEngine;
		$classes = Config::inst()->get(FulltextSearchable::class, 'searchable_classes');
		if(!$engine || (($engine !== 'Full-Text') && !ClassInfo::exists($engine)) || (($engine === 'Full-Text') && (!is_array($classes) || (count($classes) === 0)))) {

			// The search engine has not been selected.

			return $this->httpError(404);
		}

		// Determine whether the search page should start with a listing.

		if($this->data()->StartWithListing) {

			// Display some search results.

			$request = $this->getRequest();
			return $this->getSearchResults(array(
				'Search' => $request->getVar('Search'),
				'SortBy' => $request->getVar('SortBy'),
				'SortDirection' => $request->getVar('SortDirection')
			), $this->getForm($request));
		}
		else {

			// Instantiate some default templates.

			$templates = array(
				'ExtensibleSearch',
				'ExtensibleSearchPage',
				'Page'
			);

			// Instantiate the search engine specific templates.

			if($engine !== 'Full-Text') {
				$explode = explode('\\', $engine);
				$explode = end($explode);
				$templates = array_merge(array(
					$explode,
					"{$explode}Page"
				), $templates);
			}

			// Determine the template to use.

			$this->extend('updateTemplates', $templates);
			return $this->renderWith($templates);
		}
	}
public function index ( ) { // Determine whether a search engine has been selected. $ engine = $ this -> data ( ) -> SearchEngine ; $ classes = Config :: inst ( ) -> get ( FulltextSearchable :: class , 'searchable_classes' ) ; if ( ! $ engine || ( ( $ engine !== 'Full-Text' ) && ! ClassInfo :: exists ( $ engine ) ) || ( ( $ engine === 'Full-Text' ) && ( ! is_array ( $ classes ) || ( count ( $ classes ) === 0 ) ) ) ) { // The search engine has not been selected. return $ this -> httpError ( 404 ) ; } // Determine whether the search page should start with a listing. if ( $ this -> data ( ) -> StartWithListing ) { // Display some search results. $ request = $ this -> getRequest ( ) ; return $ this -> getSearchResults ( array ( 'Search' => $ request -> getVar ( 'Search' ) , 'SortBy' => $ request -> getVar ( 'SortBy' ) , 'SortDirection' => $ request -> getVar ( 'SortDirection' ) ) , $ this -> getForm ( $ request ) ) ; } else { // Instantiate some default templates. $ templates = array ( 'ExtensibleSearch' , 'ExtensibleSearchPage' , 'Page' ) ; // Instantiate the search engine specific templates. if ( $ engine !== 'Full-Text' ) { $ explode = explode ( '\\' , $ engine ) ; $ explode = end ( $ explode ) ; $ templates = array_merge ( array ( $ explode , "{$explode}Page" ) , $ templates ) ; } // Determine the template to use. $ this -> extend ( 'updateTemplates' , $ templates ) ; return $ this -> renderWith ( $ templates ) ; } }
Determine whether the search page should start with a listing.
Determine whether the search page should start with a listing .