mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Merge pull request #1734 from open-sausages/pulls/4.0/i18n-locale
Update CMS for new i18n API
This commit is contained in:
commit
dd5c050108
@ -433,12 +433,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
'q[LastEditedFrom]',
|
'q[LastEditedFrom]',
|
||||||
_t('CMSSearch.FILTERDATEFROM', 'From')
|
_t('CMSSearch.FILTERDATEFROM', 'From')
|
||||||
);
|
);
|
||||||
$dateFrom->setConfig('showcalendar', true);
|
$dateFrom->setShowCalendar(true);
|
||||||
$dateTo = new DateField(
|
$dateTo = new DateField(
|
||||||
'q[LastEditedTo]',
|
'q[LastEditedTo]',
|
||||||
_t('CMSSearch.FILTERDATETO', 'To')
|
_t('CMSSearch.FILTERDATETO', 'To')
|
||||||
);
|
);
|
||||||
$dateTo->setConfig('showcalendar', true);
|
$dateTo->setShowCalendar(true);
|
||||||
$pageFilter = new DropdownField(
|
$pageFilter = new DropdownField(
|
||||||
'q[FilterClass]',
|
'q[FilterClass]',
|
||||||
_t('CMSMain.PAGES', 'Page status'),
|
_t('CMSMain.PAGES', 'Page status'),
|
||||||
|
@ -213,7 +213,7 @@ class ContentController extends Controller
|
|||||||
if (class_exists('Translatable')) {
|
if (class_exists('Translatable')) {
|
||||||
$locale = $request->getVar('locale');
|
$locale = $request->getVar('locale');
|
||||||
if ($locale
|
if ($locale
|
||||||
&& i18n::validate_locale($locale)
|
&& i18n::getData()->validate($locale)
|
||||||
&& $this->dataRecord
|
&& $this->dataRecord
|
||||||
&& $this->dataRecord->Locale != $locale
|
&& $this->dataRecord->Locale != $locale
|
||||||
) {
|
) {
|
||||||
|
@ -9,12 +9,13 @@ use SilverStripe\Control\HTTPRequest;
|
|||||||
use SilverStripe\Control\HTTPResponse;
|
use SilverStripe\Control\HTTPResponse;
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Core\Resettable;
|
||||||
use SilverStripe\Dev\Deprecation;
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\ORM\DataModel;
|
use SilverStripe\ORM\DataModel;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use Translatable;
|
use Translatable;
|
||||||
|
|
||||||
class RootURLController extends Controller
|
class RootURLController extends Controller implements Resettable
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@ use SilverStripe\Control\RequestHandler;
|
|||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Core\Resettable;
|
||||||
use SilverStripe\Dev\Deprecation;
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Forms\CheckboxField;
|
use SilverStripe\Forms\CheckboxField;
|
||||||
use SilverStripe\Forms\CompositeField;
|
use SilverStripe\Forms\CompositeField;
|
||||||
@ -92,7 +93,7 @@ use Subsite;
|
|||||||
* @mixin Versioned
|
* @mixin Versioned
|
||||||
* @mixin SiteTreeLinkTracking
|
* @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
|
// 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
|
// 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)"
|
// "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})";
|
$result[$class] = $result[$class] . " ({$class})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\CMS\Reports;
|
namespace SilverStripe\CMS\Reports;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\Reports\Report;
|
use SilverStripe\Reports\Report;
|
||||||
@ -26,8 +27,10 @@ class RecentlyEditedReport extends Report
|
|||||||
|
|
||||||
public function sourceRecords($params = null)
|
public function sourceRecords($params = null)
|
||||||
{
|
{
|
||||||
$threshold = strtotime('-14 days', DBDatetime::now()->Format('U'));
|
$threshold = strtotime('-14 days', DBDatetime::now()->getTimestamp());
|
||||||
return DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC");
|
return SiteTree::get()
|
||||||
|
->filter('LastEdited:GreaterThan', date("Y-m-d H:i:s", $threshold))
|
||||||
|
->sort("\"SiteTree\".\"LastEdited\" DESC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns()
|
public function columns()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Model\SiteTree;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\CMS\Reports\RecentlyEditedReport;
|
use SilverStripe\CMS\Reports\RecentlyEditedReport;
|
||||||
@ -32,8 +33,8 @@ class CmsReportsTest extends SapphireTest
|
|||||||
$afterThreshold = strtotime('-'.(self::$daysAgo-1).' days', strtotime('31-06-2009 00:00:00'));
|
$afterThreshold = strtotime('-'.(self::$daysAgo-1).' days', strtotime('31-06-2009 00:00:00'));
|
||||||
$beforeThreshold = strtotime('-'.(self::$daysAgo+1).' days', strtotime('31-06-2009 00:00:00'));
|
$beforeThreshold = strtotime('-'.(self::$daysAgo+1).' days', strtotime('31-06-2009 00:00:00'));
|
||||||
|
|
||||||
$after = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after');
|
$after = $this->objFromFixture(SiteTree::class, 'after');
|
||||||
$before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before');
|
$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', $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."'");
|
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()
|
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');
|
$after = $this->objFromFixture(SiteTree::class, 'after');
|
||||||
$before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before');
|
$before = $this->objFromFixture(SiteTree::class, 'before');
|
||||||
|
|
||||||
$r = new RecentlyEditedReport();
|
$r = new RecentlyEditedReport();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user