From 9b1db223ceecc5df5343b1fdae354cb7a90e3bb0 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 16 Oct 2008 08:59:40 +0000 Subject: [PATCH] API CHANGE Removed deprecated Datetime class, use SSDatetime instead (was conflicting with PHP 5.2 integrated classes) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64394 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/DataObject.php | 12 ++++---- core/model/SiteTree.php | 4 +-- core/model/fieldtypes/Datetime.php | 48 ------------------------------ email/Email.php | 2 +- email/QueuedEmail.php | 2 +- integration/GoogleSitemap.php | 4 +-- security/Member.php | 6 ++-- tests/SearchContextTest.php | 2 +- 8 files changed, 16 insertions(+), 64 deletions(-) delete mode 100644 core/model/fieldtypes/Datetime.php diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 03f5c3045..faf52e466 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -1718,8 +1718,8 @@ class DataObject extends ViewableData implements DataObjectInterface { // Add base fields which are not defined in static $db if($field == "ID") return "Int"; if($field == "ClassName" && get_parent_class($this) == "DataObject") return "Enum"; - if($field == "LastEdited" && get_parent_class($this) == "DataObject") return "Datetime"; - if($field == "Created" && get_parent_class($this) == "DataObject") return "Datetime"; + if($field == "LastEdited" && get_parent_class($this) == "DataObject") return "SSDatetime"; + if($field == "Created" && get_parent_class($this) == "DataObject") return "SSDatetime"; // Add fields from Versioned decorator if($field == "Version") return $this->hasExtension('Versioned') ? "Int" : false; @@ -2398,8 +2398,8 @@ class DataObject extends ViewableData implements DataObjectInterface { return array_merge( array( "ClassName" => "Enum('" . implode(", ", $childClasses) . "')", - "Created" => "Datetime", - "LastEdited" => "Datetime", + "Created" => "SSDatetime", + "LastEdited" => "SSDatetime", ), (array)$this->customDatabaseFields() ); @@ -2678,8 +2678,8 @@ class DataObject extends ViewableData implements DataObjectInterface { * @var array */ public static $casting = array( - "LastEdited" => "Datetime", - "Created" => "Datetime", + "LastEdited" => "SSDatetime", + "Created" => "SSDatetime", "Title" => 'Text', ); diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index c6c5e913c..b3bf3d451 100644 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -115,8 +115,8 @@ class SiteTree extends DataObject { static $casting = array( "Breadcrumbs" => "HTMLText", - "LastEdited" => "Datetime", - "Created" => "Datetime", + "LastEdited" => "SSDatetime", + "Created" => "SSDatetime", ); static $defaults = array( diff --git a/core/model/fieldtypes/Datetime.php b/core/model/fieldtypes/Datetime.php deleted file mode 100644 index adf9354d7..000000000 --- a/core/model/fieldtypes/Datetime.php +++ /dev/null @@ -1,48 +0,0 @@ -value = date('Y-m-d H:i:s', strtotime($value)); - else $value = null; - } - - function Nice() { - return date('d/m/Y g:ia', strtotime($this->value)); - } - function Nice24() { - return date('d/m/Y H:i', strtotime($this->value)); - } - function Date() { - return date('d/m/Y', strtotime($this->value)); - } - function Time() { - return date('g:ia', strtotime($this->value)); - } - function Time24() { - return date('H:i', strtotime($this->value)); - } - - function URLDatetime() { - return date('Y-m-d%20H:i:s', strtotime($this->value)); - } - - function requireField() { - DB::requireField($this->tableName, $this->name, "datetime"); - } - - public function scaffoldFormField($title = null, $params = null) { - return new PopupDateTimeField($this->name, $title); - } - } -} -?> diff --git a/email/Email.php b/email/Email.php index decd55763..793f7790b 100755 --- a/email/Email.php +++ b/email/Email.php @@ -592,7 +592,7 @@ class Email_BounceHandler extends Controller { class Email_BounceRecord extends DataObject { static $db = array( 'BounceEmail' => 'Varchar', - 'BounceTime' => 'Datetime', + 'BounceTime' => 'SSDatetime', 'BounceMessage' => 'Varchar' ); diff --git a/email/QueuedEmail.php b/email/QueuedEmail.php index 3654e7271..e8cdd6693 100644 --- a/email/QueuedEmail.php +++ b/email/QueuedEmail.php @@ -7,7 +7,7 @@ class QueuedEmail extends DataObject { static $db = array( - 'Send' => 'Datetime', + 'Send' => 'SSDatetime', 'Subject' => 'Varchar', 'From' => 'Varchar', 'Content' => 'Text' diff --git a/integration/GoogleSitemap.php b/integration/GoogleSitemap.php index 2fe8f431b..3230905b5 100755 --- a/integration/GoogleSitemap.php +++ b/integration/GoogleSitemap.php @@ -38,8 +38,8 @@ class GoogleSitemap extends Controller { // The one field that isn't easy to deal with in the template is // Change frequency, so we set that here. $properties = $page->toMap(); - $created = new Datetime($properties['Created']); - $now = new Datetime(); + $created = new SSDatetime($properties['Created']); + $now = new SSDatetime(); $versions = $properties['Version']; $timediff = $now->format('U') - $created->format('U'); diff --git a/security/Member.php b/security/Member.php index 8c079d949..6f4cc9f35 100644 --- a/security/Member.php +++ b/security/Member.php @@ -13,15 +13,15 @@ class Member extends DataObject { 'Password' => "Varchar(64)", // support for up to SHA256! 'RememberLoginToken' => "Varchar(50)", 'NumVisit' => "Int", - 'LastVisited' => 'Datetime', + 'LastVisited' => 'SSDatetime', 'Bounced' => 'Boolean', // Note: This does not seem to be used anywhere. 'AutoLoginHash' => 'Varchar(30)', - 'AutoLoginExpired' => 'Datetime', + 'AutoLoginExpired' => 'SSDatetime', 'BlacklistedEmail' => 'Boolean', 'PasswordEncryption' => "Enum('none', 'none')", 'Salt' => 'Varchar(50)', 'PasswordExpiry' => 'Date', - 'LockedOutUntil' => 'Datetime', + 'LockedOutUntil' => 'SSDatetime', 'Locale' => 'Varchar(6)', ); diff --git a/tests/SearchContextTest.php b/tests/SearchContextTest.php index c2dba7d5d..26fd20e51 100644 --- a/tests/SearchContextTest.php +++ b/tests/SearchContextTest.php @@ -198,7 +198,7 @@ class SearchContextTest_Project extends DataObject implements TestOnly { class SearchContextTest_Deadline extends DataObject implements TestOnly { static $db = array( - "CompletionDate" => "Datetime" + "CompletionDate" => "SSDatetime" ); static $has_one = array(