mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX Updating SiteTree search fields to work with new search namespacing
This commit is contained in:
parent
44b92c90bc
commit
b0c4c5a177
@ -903,13 +903,20 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$params = $this->getRequest()->requestVar('q') ?: [];
|
$params = $this->getRequest()->requestVar('q') ?: [];
|
||||||
$context->setSearchParams($params);
|
$context->setSearchParams($params);
|
||||||
|
|
||||||
$placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERLABELTEXT', 'Search') . ' "' . SiteTree::singleton()->i18n_plural_name() . '"';
|
$placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERLABELTEXT', 'Search') . ' "' .
|
||||||
|
SiteTree::singleton()->i18n_plural_name() . '"';
|
||||||
|
|
||||||
|
$searchParams = $context->getSearchParams();
|
||||||
|
|
||||||
|
$searchParams = array_combine(array_map(function($key) {
|
||||||
|
return 'Search__' . $key;
|
||||||
|
}, array_keys($searchParams)), $searchParams);
|
||||||
|
|
||||||
$schema = [
|
$schema = [
|
||||||
'formSchemaUrl' => $schemaUrl,
|
'formSchemaUrl' => $schemaUrl,
|
||||||
'name' => 'Term',
|
'name' => 'Term',
|
||||||
'placeholder' => $placeholder,
|
'placeholder' => $placeholder,
|
||||||
'filters' => $context->getSearchParams() ?: new \stdClass // stdClass maps to empty json object '{}'
|
'filters' => $searchParams ?: new \stdClass // stdClass maps to empty json object '{}'
|
||||||
];
|
];
|
||||||
|
|
||||||
return Convert::raw2json($schema);
|
return Convert::raw2json($schema);
|
||||||
@ -926,24 +933,24 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
{
|
{
|
||||||
// Create the fields
|
// Create the fields
|
||||||
$dateFrom = DateField::create(
|
$dateFrom = DateField::create(
|
||||||
'LastEditedFrom',
|
'Search__LastEditedFrom',
|
||||||
_t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATEFROM', 'From')
|
_t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATEFROM', 'From')
|
||||||
)->setLocale(Security::getCurrentUser()->Locale);
|
)->setLocale(Security::getCurrentUser()->Locale);
|
||||||
$dateTo = DateField::create(
|
$dateTo = DateField::create(
|
||||||
'LastEditedTo',
|
'Search__LastEditedTo',
|
||||||
_t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATETO', 'To')
|
_t('SilverStripe\\CMS\\Search\\SearchForm.FILTERDATETO', 'To')
|
||||||
)->setLocale(Security::getCurrentUser()->Locale);
|
)->setLocale(Security::getCurrentUser()->Locale);
|
||||||
$filters = CMSSiteTreeFilter::get_all_filters();
|
$filters = CMSSiteTreeFilter::get_all_filters();
|
||||||
// Remove 'All pages' as we set that to empty/default value
|
// Remove 'All pages' as we set that to empty/default value
|
||||||
unset($filters[CMSSiteTreeFilter_Search::class]);
|
unset($filters[CMSSiteTreeFilter_Search::class]);
|
||||||
$pageFilter = DropdownField::create(
|
$pageFilter = DropdownField::create(
|
||||||
'FilterClass',
|
'Search__FilterClass',
|
||||||
_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGES', 'Page status'),
|
_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGES', 'Page status'),
|
||||||
$filters
|
$filters
|
||||||
);
|
);
|
||||||
$pageFilter->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGESALLOPT', 'All pages'));
|
$pageFilter->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGESALLOPT', 'All pages'));
|
||||||
$pageClasses = DropdownField::create(
|
$pageClasses = DropdownField::create(
|
||||||
'ClassName',
|
'Search__ClassName',
|
||||||
_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'),
|
_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'),
|
||||||
$this->getPageTypes()
|
$this->getPageTypes()
|
||||||
);
|
);
|
||||||
@ -953,7 +960,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$dateGroup = FieldGroup::create(
|
$dateGroup = FieldGroup::create(
|
||||||
_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'),
|
_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'),
|
||||||
[$dateFrom, $dateTo]
|
[$dateFrom, $dateTo]
|
||||||
)->setName('LastEdited')
|
)->setName('Search__LastEdited')
|
||||||
->addExtraClass('fieldgroup--fill-width');
|
->addExtraClass('fieldgroup--fill-width');
|
||||||
|
|
||||||
// Create the Field list
|
// Create the Field list
|
||||||
|
Loading…
Reference in New Issue
Block a user