mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
BUGFIX: fixed link to search query from opensearch description
This commit is contained in:
parent
13fdb8dd80
commit
94121f0a66
@ -194,7 +194,6 @@ class DocumentationSearch {
|
|||||||
$start = ($request->requestVar('start')) ? (int)$request->requestVar('start') : 0;
|
$start = ($request->requestVar('start')) ? (int)$request->requestVar('start') : 0;
|
||||||
$query = ($request->requestVar('Search')) ? $request->requestVar('Search') : '';
|
$query = ($request->requestVar('Search')) ? $request->requestVar('Search') : '';
|
||||||
|
|
||||||
|
|
||||||
$currentPage = floor( $start / $pageLength ) + 1;
|
$currentPage = floor( $start / $pageLength ) + 1;
|
||||||
|
|
||||||
$totalPages = ceil(count($this->results) / $pageLength );
|
$totalPages = ceil(count($this->results) / $pageLength );
|
||||||
@ -226,7 +225,7 @@ class DocumentationSearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data['Results'] = $results;
|
$data['Results'] = $results;
|
||||||
$data['Query'] = DBField::create('Text', $query);
|
$data['Query'] = DBField::create('Text', $query);
|
||||||
$data['TotalResults'] = DBField::create('Text', count($this->results));
|
$data['TotalResults'] = DBField::create('Text', count($this->results));
|
||||||
$data['TotalPages'] = DBField::create('Text', $totalPages);
|
$data['TotalPages'] = DBField::create('Text', $totalPages);
|
||||||
$data['ThisPage'] = DBField::create('Text', $currentPage);
|
$data['ThisPage'] = DBField::create('Text', $currentPage);
|
||||||
@ -346,11 +345,12 @@ class DocumentationSearch {
|
|||||||
$request = $this->outputController->getRequest();
|
$request = $this->outputController->getRequest();
|
||||||
|
|
||||||
$data = $this->getSearchResults($request);
|
$data = $this->getSearchResults($request);
|
||||||
|
|
||||||
$templates = array('DocumentationViewer_results', 'DocumentationViewer');
|
$templates = array('DocumentationViewer_results', 'DocumentationViewer');
|
||||||
|
|
||||||
if($request->requestVar('format') && $request->requestVar('format') == "rss") {
|
if($request->requestVar('format') && $request->requestVar('format') == "rss") {
|
||||||
// alter the fields for the opensearch xml.
|
// alter the fields for the opensearch xml.
|
||||||
$title = ($title = $this->getTitle()) ? ' | '. $title : "";
|
$title = ($title = $this->getTitle()) ? ' - '. $title : "";
|
||||||
|
|
||||||
$link = Controller::join_links($this->outputController->Link(), 'DocumentationOpenSearch_Controller/description/');
|
$link = Controller::join_links($this->outputController->Link(), 'DocumentationOpenSearch_Controller/description/');
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ class DocumentationOpenSearch_Controller extends Controller {
|
|||||||
$link = Director::absoluteBaseUrl() .
|
$link = Director::absoluteBaseUrl() .
|
||||||
$data['SearchPageLink'] = Controller::join_links(
|
$data['SearchPageLink'] = Controller::join_links(
|
||||||
$viewer->Link(),
|
$viewer->Link(),
|
||||||
'results/?query={searchTerms}&start={startIndex}&length={count}'
|
'results/?Search={searchTerms}&start={startIndex}&length={count}&action_results=1'
|
||||||
);
|
);
|
||||||
|
|
||||||
$data['SearchPageRss'] = $data['SearchPageLink'] . '&format=rss';
|
$data['SearchPageRss'] = $data['SearchPageLink'] . '&format=rss';
|
||||||
|
@ -716,9 +716,14 @@ class DocumentationViewer extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Past straight to results, display and encode the query
|
* Past straight to results, display and encode the query
|
||||||
*/
|
*/
|
||||||
function results($data, $form, $request) {
|
function results($data, $form = false) {
|
||||||
|
|
||||||
|
$query = (isset($_REQUEST['Search'])) ? $_REQUEST['Search'] : false;
|
||||||
|
|
||||||
|
if(!$query) return $this->httpError('404');
|
||||||
|
|
||||||
$search = new DocumentationSearch();
|
$search = new DocumentationSearch();
|
||||||
$search->setQuery($form->dataFieldByName('Search')->dataValue());
|
$search->setQuery($query);
|
||||||
$search->setOutputController($this);
|
$search->setOutputController($this);
|
||||||
|
|
||||||
return $search->renderResults();
|
return $search->renderResults();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user