mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
Merge pull request #54 from camfindlay/curentversionsearch
Pass the current version to the search
This commit is contained in:
commit
653a2c87f4
@ -3,18 +3,25 @@
|
|||||||
class DocumentationSearchForm extends Form {
|
class DocumentationSearchForm extends Form {
|
||||||
|
|
||||||
public function __construct($controller) {
|
public function __construct($controller) {
|
||||||
$versions = HiddenField::create(
|
|
||||||
'Versions',
|
|
||||||
_t('DocumentationViewer.VERSIONS', 'Versions'),
|
|
||||||
implode(',', $controller->getManifest()->getAllVersions())
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
TextField::create('q', _t('DocumentationViewer.SEARCH', 'Search'), '')
|
TextField::create('q', _t('DocumentationViewer.SEARCH', 'Search'), '')
|
||||||
->setAttribute('placeholder', _t('DocumentationViewer.SEARCH', 'Search')),
|
->setAttribute('placeholder', _t('DocumentationViewer.SEARCH', 'Search'))
|
||||||
$versions
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$page = $controller->getPage();
|
||||||
|
|
||||||
|
if($page){
|
||||||
|
$versions = HiddenField::create(
|
||||||
|
'Versions',
|
||||||
|
_t('DocumentationViewer.VERSIONS', 'Versions'),
|
||||||
|
$page->getEntity()->getVersion()
|
||||||
|
);
|
||||||
|
|
||||||
|
$fields->push($versions);
|
||||||
|
}
|
||||||
|
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
new FormAction('results', _t('DocumentationViewer.SEARCH', 'Search'))
|
new FormAction('results', _t('DocumentationViewer.SEARCH', 'Search'))
|
||||||
);
|
);
|
||||||
@ -24,7 +31,7 @@ class DocumentationSearchForm extends Form {
|
|||||||
$this->disableSecurityToken();
|
$this->disableSecurityToken();
|
||||||
$this->setFormMethod('GET');
|
$this->setFormMethod('GET');
|
||||||
$this->setFormAction($controller->Link('results'));
|
$this->setFormAction($controller->Link('results'));
|
||||||
|
|
||||||
$this->addExtraClass('search');
|
$this->addExtraClass('search');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user