mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
(merged from branches/roa. use "svn log -c <changeset> -g <module-svn-path>" for detailed commit message)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60338 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a1b0987c23
commit
b932a251b1
@ -1349,8 +1349,19 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
|||||||
|
|
||||||
// If we explicitly set a field, then construct that
|
// If we explicitly set a field, then construct that
|
||||||
if(isset($spec['field'])) {
|
if(isset($spec['field'])) {
|
||||||
$fieldClass = $spec['field'];
|
// If it's a string, use it as a class name and construct
|
||||||
$field = new $fieldClass($fieldName);
|
if(is_string($spec['field'])) {
|
||||||
|
$fieldClass = $spec['field'];
|
||||||
|
$field = new $fieldClass($fieldName);
|
||||||
|
|
||||||
|
// If it's a FormField object, then just use that object directly.
|
||||||
|
} else if($spec['field'] instanceof FormField) {
|
||||||
|
$field = $spec['field'];
|
||||||
|
|
||||||
|
// Otherwise we have a bug
|
||||||
|
} else {
|
||||||
|
user_error("Bad value for searchable_fields, 'field' value: " . var_export($spec['field'], true), E_USER_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
// Otherwise, use the database field's scaffolder
|
// Otherwise, use the database field's scaffolder
|
||||||
} else {
|
} else {
|
||||||
@ -1497,10 +1508,20 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
|||||||
* Level 2 is more lenient, it will onlr return real data changes, for example a change from 0 to null
|
* Level 2 is more lenient, it will onlr return real data changes, for example a change from 0 to null
|
||||||
* would not be included.
|
* would not be included.
|
||||||
*
|
*
|
||||||
|
* Example return:
|
||||||
|
* <code>
|
||||||
|
* array(
|
||||||
|
* 'Title' = array('before' => 'Home', 'after' => 'Home-Changed', 'level' => 2)
|
||||||
|
* )
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param boolean $databaseFieldsOnly Get only database fields that have changed
|
* @param boolean $databaseFieldsOnly Get only database fields that have changed
|
||||||
* @param int $changeLevel The strictness of what is defined as change
|
* @param int $changeLevel The strictness of what is defined as change
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getChangedFields($databaseFieldsOnly = false, $changeLevel = 1) {
|
public function getChangedFields($databaseFieldsOnly = false, $changeLevel = 1) {
|
||||||
|
$changedFields = array();
|
||||||
|
|
||||||
if($databaseFieldsOnly) {
|
if($databaseFieldsOnly) {
|
||||||
$customDatabaseFields = $this->customDatabaseFields();
|
$customDatabaseFields = $this->customDatabaseFields();
|
||||||
$fields = array_intersect_key($this->changed, $customDatabaseFields);
|
$fields = array_intersect_key($this->changed, $customDatabaseFields);
|
||||||
@ -1516,8 +1537,17 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($fields as $name => $level) {
|
||||||
|
if(!isset($this->original[$name])) continue;
|
||||||
|
$changedFields[$name] = array(
|
||||||
|
'before' => $this->original[$name],
|
||||||
|
'after' => $this->record[$name],
|
||||||
|
'level' => $level
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $fields;
|
return $changedFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1540,13 +1570,10 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
|||||||
if(!isset($this->record[$fieldName]) || $this->record[$fieldName] !== $val) {
|
if(!isset($this->record[$fieldName]) || $this->record[$fieldName] !== $val) {
|
||||||
// TODO Add check for php-level defaults which are not set in the db
|
// TODO Add check for php-level defaults which are not set in the db
|
||||||
// TODO Add check for hidden input-fields (readonly) which are not set in the db
|
// TODO Add check for hidden input-fields (readonly) which are not set in the db
|
||||||
|
|
||||||
if(
|
if(
|
||||||
// Only existing fields
|
// Main non type-based check
|
||||||
$this->fieldExists($fieldName)
|
(isset($this->record[$fieldName]) && $this->record[$fieldName] != $val)
|
||||||
// Catches "0"==NULL
|
|
||||||
&& (isset($this->record[$fieldName]) && (intval($val) != intval($this->record[$fieldName])))
|
|
||||||
// Main non type-based check
|
|
||||||
&& (isset($this->record[$fieldName]) && $this->record[$fieldName] != $val)
|
|
||||||
) {
|
) {
|
||||||
// Non-strict check fails, so value really changed, e.g. "abc" != "cde"
|
// Non-strict check fails, so value really changed, e.g. "abc" != "cde"
|
||||||
$this->changed[$fieldName] = 2;
|
$this->changed[$fieldName] = 2;
|
||||||
|
@ -118,7 +118,7 @@ table.CMSList tbody td.checkbox {
|
|||||||
table.TableField tbody tr.over td,
|
table.TableField tbody tr.over td,
|
||||||
.TableListField table.data tbody tr.over td,
|
.TableListField table.data tbody tr.over td,
|
||||||
table.CMSList tbody td.over td{
|
table.CMSList tbody td.over td{
|
||||||
background-color: #FF6600;
|
background-color: #FFCC66;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.TableField tbody tr.current td,
|
table.TableField tbody tr.current td,
|
||||||
|
Loading…
Reference in New Issue
Block a user