mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2593 from silverstripe-terraformers/bugfix/url-segment-page-search
BUG: URL segment filter correction for CMS page search.
This commit is contained in:
commit
546663da56
@ -5,6 +5,7 @@ namespace SilverStripe\CMS\Controllers;
|
|||||||
use SilverStripe\Admin\LeftAndMain_SearchFilter;
|
use SilverStripe\Admin\LeftAndMain_SearchFilter;
|
||||||
use SilverStripe\CMS\Model\SiteTree;
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\Core\Injector\Injectable;
|
use SilverStripe\Core\Injector\Injectable;
|
||||||
use SilverStripe\Forms\DateField;
|
use SilverStripe\Forms\DateField;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
@ -203,13 +204,19 @@ abstract class CMSSiteTreeFilter implements LeftAndMain_SearchFilter
|
|||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'Term':
|
case 'Term':
|
||||||
$query = $query->filterAny(array(
|
$query = $query->filterAny(array(
|
||||||
'URLSegment:PartialMatch' => $val,
|
'URLSegment:PartialMatch' => Convert::raw2url($val),
|
||||||
'Title:PartialMatch' => $val,
|
'Title:PartialMatch' => $val,
|
||||||
'MenuTitle:PartialMatch' => $val,
|
'MenuTitle:PartialMatch' => $val,
|
||||||
'Content:PartialMatch' => $val
|
'Content:PartialMatch' => $val
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'URLSegment':
|
||||||
|
$query = $query->filter([
|
||||||
|
'URLSegment:PartialMatch' => Convert::raw2url($val),
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'LastEditedFrom':
|
case 'LastEditedFrom':
|
||||||
$fromDate = new DateField(null, null, $val);
|
$fromDate = new DateField(null, null, $val);
|
||||||
$query = $query->filter("LastEdited:GreaterThanOrEqual", $fromDate->dataValue().' 00:00:00');
|
$query = $query->filter("LastEdited:GreaterThanOrEqual", $fromDate->dataValue().' 00:00:00');
|
||||||
|
@ -47,6 +47,17 @@ class CMSSiteTreeFilterTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUrlSegmentFilter()
|
||||||
|
{
|
||||||
|
$page = $this->objFromFixture(Page::class, 'page8');
|
||||||
|
|
||||||
|
$filter = CMSSiteTreeFilter_Search::create(['Term' => 'lake-wanaka+adventure']);
|
||||||
|
$this->assertTrue($filter->isPageIncluded($page));
|
||||||
|
|
||||||
|
$filter = CMSSiteTreeFilter_Search::create(['URLSegment' => 'lake-wanaka+adventure']);
|
||||||
|
$this->assertTrue($filter->isPageIncluded($page));
|
||||||
|
}
|
||||||
|
|
||||||
public function testIncludesParentsForNestedMatches()
|
public function testIncludesParentsForNestedMatches()
|
||||||
{
|
{
|
||||||
$parent = $this->objFromFixture('Page', 'page3');
|
$parent = $this->objFromFixture('Page', 'page3');
|
||||||
|
@ -29,3 +29,6 @@ Page:
|
|||||||
page3b:
|
page3b:
|
||||||
Parent: =>Page.page3
|
Parent: =>Page.page3
|
||||||
Title: Page 3b
|
Title: Page 3b
|
||||||
|
page8:
|
||||||
|
Title: EncodedUrlSegment
|
||||||
|
URLSegment: lake-wanaka+adventure
|
||||||
|
Loading…
Reference in New Issue
Block a user