2014-09-06 01:22:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package docsviewer
|
|
|
|
*/
|
|
|
|
class DocumentationAdvancedSearchForm extends Form {
|
|
|
|
|
|
|
|
public function __construct($controller) {
|
2014-09-19 13:29:22 +02:00
|
|
|
$versions = $controller->getManifest()->getAllVersions();
|
2014-09-15 11:47:45 +02:00
|
|
|
$entities = $controller->getManifest()->getEntities();
|
2014-11-28 01:58:12 +01:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$q = ($q = $controller->getSearchQuery()) ? $q->NoHTML() : "";
|
2014-09-19 13:29:22 +02:00
|
|
|
|
2014-09-06 01:22:05 +02:00
|
|
|
// klude to take an array of objects down to a simple map
|
2014-11-28 01:58:12 +01:00
|
|
|
$entities = $entities->map('Key', 'Title');
|
2014-09-19 13:29:22 +02:00
|
|
|
|
2014-09-06 01:22:05 +02:00
|
|
|
// if we haven't gone any search limit then we're searching everything
|
|
|
|
$searchedEntities = $controller->getSearchedEntities();
|
|
|
|
|
|
|
|
if(count($searchedEntities) < 1) {
|
|
|
|
$searchedEntities = $entities;
|
|
|
|
}
|
|
|
|
|
|
|
|
$searchedVersions = $controller->getSearchedVersions();
|
|
|
|
|
|
|
|
if(count($searchedVersions) < 1) {
|
2014-09-19 13:29:22 +02:00
|
|
|
$searchedVersions = $versions;
|
2014-09-06 01:22:05 +02:00
|
|
|
}
|
|
|
|
|
2014-11-28 01:58:12 +01:00
|
|
|
$fields = FieldList::create(
|
|
|
|
TextField::create('q', _t('DocumentationViewer.KEYWORDS', 'Keywords'), $q),
|
|
|
|
//CheckboxSetField::create('Entities', _t('DocumentationViewer.MODULES', 'Modules'), $entities, $searchedEntities),
|
|
|
|
CheckboxSetField::create(
|
2014-09-15 11:47:45 +02:00
|
|
|
'Versions',
|
|
|
|
_t('DocumentationViewer.VERSIONS', 'Versions'),
|
2014-09-19 13:29:22 +02:00
|
|
|
$versions, $searchedVersions
|
2014-09-06 01:22:05 +02:00
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2014-11-28 01:58:12 +01:00
|
|
|
$actions = FieldList::create(
|
|
|
|
FormAction::create('results', _t('DocumentationViewer.SEARCH', 'Search'))
|
2014-09-06 01:22:05 +02:00
|
|
|
);
|
|
|
|
|
2014-11-28 01:58:12 +01:00
|
|
|
$required = RequiredFields::create(array('Search'));
|
2014-09-06 01:22:05 +02:00
|
|
|
|
|
|
|
parent::__construct(
|
|
|
|
$controller,
|
|
|
|
'AdvancedSearchForm',
|
|
|
|
$fields,
|
|
|
|
$actions,
|
|
|
|
$required
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->disableSecurityToken();
|
|
|
|
$this->setFormMethod('GET');
|
2014-09-19 13:29:22 +02:00
|
|
|
$this->setFormAction($controller->Link('results'));
|
2014-09-15 11:47:45 +02:00
|
|
|
}
|
|
|
|
}
|