silverstripe-docsviewer/code/controllers/DocumentationOpenSearchController.php

39 lines
999 B
PHP
Raw Normal View History

<?php
/**
* Public facing controller for handling an opensearch interface based on
* the standard search form.
*
* @package docsviewer
*/
2012-09-05 11:42:06 +02:00
class DocumentationOpenSearchController extends Controller {
2012-09-05 11:42:06 +02:00
public static $allowed_actions = array(
'description'
);
2012-09-05 11:42:06 +02:00
public function index() {
return $this->httpError(404);
}
2012-09-05 11:42:06 +02:00
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}&amp;start={startIndex}&amp;length={count}&amp;action_results=1'
);
$data['SearchPageAtom'] = $data['SearchPageLink'] . '&amp;format=atom';
return $this->customise(
new ArrayData($data)
)->renderWith(array('OpenSearchDescription'));
}
}