silverstripe-docsviewer/code/controllers/DocumentationOpenSearchController.php
Will Rossiter 2c00a3b20f New theme.
Clean up of existing theme, implementation of a new easier to integrate layout.
2014-09-06 11:13:12 +12:00

41 lines
991 B
PHP

<?php
/**
* Public facing controller for handling an opensearch interface based on
* the standard search form.
*
* @package docsviewer
*/
class DocumentationOpenSearchController extends Controller {
private static $allowed_actions = array(
'description'
);
public function index() {
return $this->httpError(404);
}
public function description() {
$viewer = new DocumentationViewer();
if(!$viewer->canView()) return Security::permissionFailure($this);
if(!DocumentationSearch::enabled()) return $this->httpError('404');
$data = DocumentationSearch::get_meta_data();
$link = Director::absoluteBaseUrl() .
$data['SearchPageLink'] = Controller::join_links(
$viewer->Link(),
'results/?Search={searchTerms}&start={startIndex}&length={count}&action_results=1'
);
$data['SearchPageAtom'] = $data['SearchPageLink'] . '&format=atom';
return $this->customise(
new ArrayData($data)
)->renderWith(array(
'OpenSearchDescription'
));
}
}