diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index ef18bae8..4022ff31 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -433,12 +433,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 'q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From') ); - $dateFrom->setConfig('showcalendar', true); + $dateFrom->setShowCalendar(true); $dateTo = new DateField( 'q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To') ); - $dateTo->setConfig('showcalendar', true); + $dateTo->setShowCalendar(true); $pageFilter = new DropdownField( 'q[FilterClass]', _t('CMSMain.PAGES', 'Page status'), diff --git a/code/Controllers/ContentController.php b/code/Controllers/ContentController.php index 69e5f4d5..32797f0c 100644 --- a/code/Controllers/ContentController.php +++ b/code/Controllers/ContentController.php @@ -213,7 +213,7 @@ class ContentController extends Controller if (class_exists('Translatable')) { $locale = $request->getVar('locale'); if ($locale - && i18n::validate_locale($locale) + && i18n::getData()->validate($locale) && $this->dataRecord && $this->dataRecord->Locale != $locale ) { diff --git a/code/Controllers/RootURLController.php b/code/Controllers/RootURLController.php index d7dc96f5..13d2602d 100644 --- a/code/Controllers/RootURLController.php +++ b/code/Controllers/RootURLController.php @@ -9,12 +9,13 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPResponse; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; +use SilverStripe\Core\Resettable; use SilverStripe\Dev\Deprecation; use SilverStripe\ORM\DataModel; use SilverStripe\ORM\DB; use Translatable; -class RootURLController extends Controller +class RootURLController extends Controller implements Resettable { /** diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 414d74e3..03164f61 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -17,6 +17,7 @@ use SilverStripe\Control\RequestHandler; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Convert; +use SilverStripe\Core\Resettable; use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CompositeField; @@ -92,7 +93,7 @@ use Subsite; * @mixin Versioned * @mixin SiteTreeLinkTracking */ -class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvider, CMSPreviewable +class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvider, CMSPreviewable, Resettable { /** @@ -2687,7 +2688,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi // If we're in translation mode, the link between the translated pagetype title and the actual classname // might not be obvious, so we add it in parantheses. Example: class "RedirectorPage" has the title // "Weiterleitung" in German, so it shows up as "Weiterleitung (RedirectorPage)" - if (i18n::get_lang_from_locale(i18n::get_locale()) != 'en') { + if (i18n::getData()->langFromLocale(i18n::get_locale()) != 'en') { $result[$class] = $result[$class] . " ({$class})"; } } diff --git a/code/Reports/RecentlyEditedReport.php b/code/Reports/RecentlyEditedReport.php index 4d468d8e..eee55bf8 100644 --- a/code/Reports/RecentlyEditedReport.php +++ b/code/Reports/RecentlyEditedReport.php @@ -2,6 +2,7 @@ namespace SilverStripe\CMS\Reports; +use SilverStripe\CMS\Model\SiteTree; use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\DataObject; use SilverStripe\Reports\Report; @@ -26,8 +27,10 @@ class RecentlyEditedReport extends Report public function sourceRecords($params = null) { - $threshold = strtotime('-14 days', DBDatetime::now()->Format('U')); - return DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC"); + $threshold = strtotime('-14 days', DBDatetime::now()->getTimestamp()); + return SiteTree::get() + ->filter('LastEdited:GreaterThan', date("Y-m-d H:i:s", $threshold)) + ->sort("\"SiteTree\".\"LastEdited\" DESC"); } public function columns() diff --git a/tests/reports/CmsReportsTest.php b/tests/reports/CmsReportsTest.php index d00fa2ca..ed54b652 100644 --- a/tests/reports/CmsReportsTest.php +++ b/tests/reports/CmsReportsTest.php @@ -1,5 +1,6 @@ objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after'); - $before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before'); + $after = $this->objFromFixture(SiteTree::class, 'after'); + $before = $this->objFromFixture(SiteTree::class, 'before'); DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $afterThreshold)."' WHERE \"ID\"='".$after->ID."'"); DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $beforeThreshold)."' WHERE \"ID\"='".$before->ID."'"); @@ -65,10 +66,10 @@ class CmsReportsTest extends SapphireTest public function testRecentlyEdited() { - DBDatetime::set_mock_now('31-06-2009 00:00:00'); + DBDatetime::set_mock_now('2009-06-30 00:00:00'); - $after = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after'); - $before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before'); + $after = $this->objFromFixture(SiteTree::class, 'after'); + $before = $this->objFromFixture(SiteTree::class, 'before'); $r = new RecentlyEditedReport();