2011-08-02 05:30:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public facing controller for handling an opensearch interface based on
|
|
|
|
* the standard search form.
|
|
|
|
*
|
2012-04-08 11:36:16 +02:00
|
|
|
* @package docsviewer
|
2011-08-02 05:30:58 +02:00
|
|
|
*/
|
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
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);
|
|
|
|
}
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
if (!Config::inst()->get('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'
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|