mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
bd1633d742
commit
9b1db223ce
@ -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',
|
||||
);
|
||||
|
||||
|
@ -115,8 +115,8 @@ class SiteTree extends DataObject {
|
||||
|
||||
static $casting = array(
|
||||
"Breadcrumbs" => "HTMLText",
|
||||
"LastEdited" => "Datetime",
|
||||
"Created" => "Datetime",
|
||||
"LastEdited" => "SSDatetime",
|
||||
"Created" => "SSDatetime",
|
||||
);
|
||||
|
||||
static $defaults = array(
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -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'
|
||||
);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
class QueuedEmail extends DataObject {
|
||||
|
||||
static $db = array(
|
||||
'Send' => 'Datetime',
|
||||
'Send' => 'SSDatetime',
|
||||
'Subject' => 'Varchar',
|
||||
'From' => 'Varchar',
|
||||
'Content' => 'Text'
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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)',
|
||||
);
|
||||
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user