This commit is contained in:
Damian Mooyman 2016-07-14 11:49:22 +12:00
parent e5aad336ce
commit f8b1c27e3c

View File

@ -1,6 +1,7 @@
<?php <?php
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\ValidationException; use SilverStripe\ORM\ValidationException;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\Security\Security; use SilverStripe\Security\Security;
@ -30,7 +31,7 @@ class CMSPageAddController extends CMSPageEditController {
$type->getField('AddAction'), $type->getField('AddAction'),
$type->getField('Description') $type->getField('Description')
); );
$pageTypes[$type->getField('ClassName')] = $html; $pageTypes[$type->getField('ClassName')] = DBField::create_field('HTMLFragment', $html);
} }
// Ensure generic page type shows on top // Ensure generic page type shows on top
if(isset($pageTypes['Page'])) { if(isset($pageTypes['Page'])) {
@ -68,7 +69,10 @@ class CMSPageAddController extends CMSPageEditController {
), ),
$typeField = new OptionsetField( $typeField = new OptionsetField(
"PageType", "PageType",
sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), DBField::create_field(
'HTMLFragment',
sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type'))
),
$pageTypes, $pageTypes,
'Page' 'Page'
), ),
@ -84,14 +88,11 @@ class CMSPageAddController extends CMSPageEditController {
) )
); );
$parentField->setSearchFunction(function ($sourceObject, $labelField, $search) { $parentField->setSearchFunction(function ($sourceObject, $labelField, $search) {
return DataObject::get( return DataObject::get($sourceObject)
$sourceObject, ->filterAny([
sprintf( 'MenuTitle:PartialMatch' => $search,
"\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'", 'Title:PartialMatch' => $search,
Convert::raw2sql($search), ]);
Convert::raw2sql($search)
)
);
}); });
// TODO Re-enable search once it allows for HTML title display, // TODO Re-enable search once it allows for HTML title display,