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
This commit is contained in:
Ingo Schommer 2008-10-16 08:59:40 +00:00
parent bd1633d742
commit 9b1db223ce
8 changed files with 16 additions and 64 deletions

View File

@ -1718,8 +1718,8 @@ class DataObject extends ViewableData implements DataObjectInterface {
// Add base fields which are not defined in static $db // Add base fields which are not defined in static $db
if($field == "ID") return "Int"; if($field == "ID") return "Int";
if($field == "ClassName" && get_parent_class($this) == "DataObject") return "Enum"; if($field == "ClassName" && get_parent_class($this) == "DataObject") return "Enum";
if($field == "LastEdited" && 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 "Datetime"; if($field == "Created" && get_parent_class($this) == "DataObject") return "SSDatetime";
// Add fields from Versioned decorator // Add fields from Versioned decorator
if($field == "Version") return $this->hasExtension('Versioned') ? "Int" : false; if($field == "Version") return $this->hasExtension('Versioned') ? "Int" : false;
@ -2398,8 +2398,8 @@ class DataObject extends ViewableData implements DataObjectInterface {
return array_merge( return array_merge(
array( array(
"ClassName" => "Enum('" . implode(", ", $childClasses) . "')", "ClassName" => "Enum('" . implode(", ", $childClasses) . "')",
"Created" => "Datetime", "Created" => "SSDatetime",
"LastEdited" => "Datetime", "LastEdited" => "SSDatetime",
), ),
(array)$this->customDatabaseFields() (array)$this->customDatabaseFields()
); );
@ -2678,8 +2678,8 @@ class DataObject extends ViewableData implements DataObjectInterface {
* @var array * @var array
*/ */
public static $casting = array( public static $casting = array(
"LastEdited" => "Datetime", "LastEdited" => "SSDatetime",
"Created" => "Datetime", "Created" => "SSDatetime",
"Title" => 'Text', "Title" => 'Text',
); );

View File

@ -115,8 +115,8 @@ class SiteTree extends DataObject {
static $casting = array( static $casting = array(
"Breadcrumbs" => "HTMLText", "Breadcrumbs" => "HTMLText",
"LastEdited" => "Datetime", "LastEdited" => "SSDatetime",
"Created" => "Datetime", "Created" => "SSDatetime",
); );
static $defaults = array( static $defaults = array(

View File

@ -1,48 +0,0 @@
<?php
if(!class_exists('Datetime')) {
/**
* @package sapphire
* @subpackage model
* @deprecated Use {@link SSDatetime} instead, as PHP 5.2 has its own Datetime class. Object::create('Datetime') will instantiate an SSDatetime object.
*/
class Datetime extends Date {
function __construct($name) {
user_error('Datetime is deprecated. Use SSDatetime instead.', E_USER_NOTICE);
parent::__construct($name);
}
function setValue($value) {
if($value) $this->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);
}
}
}
?>

View File

@ -592,7 +592,7 @@ class Email_BounceHandler extends Controller {
class Email_BounceRecord extends DataObject { class Email_BounceRecord extends DataObject {
static $db = array( static $db = array(
'BounceEmail' => 'Varchar', 'BounceEmail' => 'Varchar',
'BounceTime' => 'Datetime', 'BounceTime' => 'SSDatetime',
'BounceMessage' => 'Varchar' 'BounceMessage' => 'Varchar'
); );

View File

@ -7,7 +7,7 @@
class QueuedEmail extends DataObject { class QueuedEmail extends DataObject {
static $db = array( static $db = array(
'Send' => 'Datetime', 'Send' => 'SSDatetime',
'Subject' => 'Varchar', 'Subject' => 'Varchar',
'From' => 'Varchar', 'From' => 'Varchar',
'Content' => 'Text' 'Content' => 'Text'

View File

@ -38,8 +38,8 @@ class GoogleSitemap extends Controller {
// The one field that isn't easy to deal with in the template is // The one field that isn't easy to deal with in the template is
// Change frequency, so we set that here. // Change frequency, so we set that here.
$properties = $page->toMap(); $properties = $page->toMap();
$created = new Datetime($properties['Created']); $created = new SSDatetime($properties['Created']);
$now = new Datetime(); $now = new SSDatetime();
$versions = $properties['Version']; $versions = $properties['Version'];
$timediff = $now->format('U') - $created->format('U'); $timediff = $now->format('U') - $created->format('U');

View File

@ -13,15 +13,15 @@ class Member extends DataObject {
'Password' => "Varchar(64)", // support for up to SHA256! 'Password' => "Varchar(64)", // support for up to SHA256!
'RememberLoginToken' => "Varchar(50)", 'RememberLoginToken' => "Varchar(50)",
'NumVisit' => "Int", 'NumVisit' => "Int",
'LastVisited' => 'Datetime', 'LastVisited' => 'SSDatetime',
'Bounced' => 'Boolean', // Note: This does not seem to be used anywhere. 'Bounced' => 'Boolean', // Note: This does not seem to be used anywhere.
'AutoLoginHash' => 'Varchar(30)', 'AutoLoginHash' => 'Varchar(30)',
'AutoLoginExpired' => 'Datetime', 'AutoLoginExpired' => 'SSDatetime',
'BlacklistedEmail' => 'Boolean', 'BlacklistedEmail' => 'Boolean',
'PasswordEncryption' => "Enum('none', 'none')", 'PasswordEncryption' => "Enum('none', 'none')",
'Salt' => 'Varchar(50)', 'Salt' => 'Varchar(50)',
'PasswordExpiry' => 'Date', 'PasswordExpiry' => 'Date',
'LockedOutUntil' => 'Datetime', 'LockedOutUntil' => 'SSDatetime',
'Locale' => 'Varchar(6)', 'Locale' => 'Varchar(6)',
); );

View File

@ -198,7 +198,7 @@ class SearchContextTest_Project extends DataObject implements TestOnly {
class SearchContextTest_Deadline extends DataObject implements TestOnly { class SearchContextTest_Deadline extends DataObject implements TestOnly {
static $db = array( static $db = array(
"CompletionDate" => "Datetime" "CompletionDate" => "SSDatetime"
); );
static $has_one = array( static $has_one = array(