From c5aa074bff83374e0d41f9cb00ea9c2101d52b92 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 14:39:02 +1200 Subject: [PATCH 01/10] BUGFIX: Fix E_STRICT errors not being reported --- dev/Debug.php | 3 ++- dev/DebugView.php | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dev/Debug.php b/dev/Debug.php index 847b3bedd..fbc90779a 100644 --- a/dev/Debug.php +++ b/dev/Debug.php @@ -220,7 +220,7 @@ class Debug { ), SS_Log::NOTICE ); - + if(Director::isDev()) { self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Notice"); } @@ -699,6 +699,7 @@ function errorHandler($errno, $errstr, $errfile, $errline) { case E_USER_NOTICE: case E_DEPRECATED: case E_USER_DEPRECATED: + case E_STRICT: Debug::noticeHandler($errno, $errstr, $errfile, $errline, null); break; } diff --git a/dev/DebugView.php b/dev/DebugView.php index 7a094d6a9..3ca978c2c 100644 --- a/dev/DebugView.php +++ b/dev/DebugView.php @@ -53,6 +53,10 @@ class DebugView extends Object { E_USER_WARNING => array( 'title' => 'User Warning', 'class' => 'warning' + ), + E_STRICT => array( + 'title' => 'Strict Notice', + 'class' => 'notice' ) ); From 501c8f3f31504fe544265fa0b2e1881568454b63 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 14:40:27 +1200 Subject: [PATCH 02/10] MINOR: Fix E_STRICT notices in php-peg --- thirdparty/php-peg/Parser.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/thirdparty/php-peg/Parser.php b/thirdparty/php-peg/Parser.php index 364f00e93..e41dedce5 100644 --- a/thirdparty/php-peg/Parser.php +++ b/thirdparty/php-peg/Parser.php @@ -269,16 +269,16 @@ class FalseOnlyPackrat extends Parser { * @author Hamish Friedlander */ class ConservativePackrat extends Parser { - function packhas( $key ) { + function packhas( $key, $pos ) { return isset( $this->packres[$key] ) && $this->packres[$key] !== NULL ; } - function packread( $key ) { + function packread( $key, $pos ) { $this->pos = $this->packpos[$key]; return $this->packres[$key] ; } - function packwrite( $key, $res ) { + function packwrite( $key, $pos, $res ) { if ( isset( $this->packres[$key] ) ) { $this->packres[$key] = $res ; $this->packpos[$key] = $this->pos ; From bdb312c6654f7bcc95137e3a8fb8a34c6524180d Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 14:48:06 +1200 Subject: [PATCH 03/10] API CHANGE: DBField::hasValue() conflicts with ViewableData::hasValue(), use DBField::exists() instead. --- model/DataObject.php | 4 ++-- model/fieldtypes/CompositeDBField.php | 2 +- model/fieldtypes/DBField.php | 12 +++--------- model/fieldtypes/HTMLText.php | 4 ++-- model/fieldtypes/HTMLVarchar.php | 4 ++-- model/fieldtypes/Money.php | 2 +- model/fieldtypes/StringField.php | 4 ++-- model/fieldtypes/Varchar.php | 2 +- tests/model/DBFieldTest.php | 26 +++++++++++++------------- tests/model/MoneyTest.php | 8 ++++---- 10 files changed, 31 insertions(+), 37 deletions(-) diff --git a/model/DataObject.php b/model/DataObject.php index bf6e78323..49f8141f4 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -596,7 +596,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if(!array_key_exists($k, $customFields)) continue; $dbObj = ($v instanceof DBField) ? $v : $this->dbObject($k); - $isEmpty = ($isEmpty && !$dbObj->hasValue()); + $isEmpty = ($isEmpty && !$dbObj->exists()); } } return $isEmpty; @@ -3346,7 +3346,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity function hasValue($field, $arguments = null, $cache = true) { $obj = $this->dbObject($field); if($obj) { - return $obj->hasValue(); + return $obj->exists(); } else { return parent::hasValue($field, $arguments, $cache); } diff --git a/model/fieldtypes/CompositeDBField.php b/model/fieldtypes/CompositeDBField.php index b562fb99f..b1aa39055 100644 --- a/model/fieldtypes/CompositeDBField.php +++ b/model/fieldtypes/CompositeDBField.php @@ -177,6 +177,6 @@ interface CompositeDBField { * * @return boolean */ - function hasValue(); + function exists(); } \ No newline at end of file diff --git a/model/fieldtypes/DBField.php b/model/fieldtypes/DBField.php index c0c1e9587..12e9714c8 100644 --- a/model/fieldtypes/DBField.php +++ b/model/fieldtypes/DBField.php @@ -120,6 +120,7 @@ abstract class DBField extends ViewableData { $this->value = $value; } + /** * Determines if the field has a value which * is not considered to be 'null' in @@ -127,15 +128,8 @@ abstract class DBField extends ViewableData { * * @return boolean */ - function hasValue() { - return ($this->value); - } - - /** - * @return bool - */ public function exists() { - return $this->hasValue(); + return ($this->value); } /** @@ -167,7 +161,7 @@ abstract class DBField extends ViewableData { * @param array $manipulation */ function writeToManipulation(&$manipulation) { - $manipulation['fields'][$this->name] = $this->hasValue() ? $this->prepValueForDB($this->value) : $this->nullValue(); + $manipulation['fields'][$this->name] = $this->exists() ? $this->prepValueForDB($this->value) : $this->nullValue(); } /** diff --git a/model/fieldtypes/HTMLText.php b/model/fieldtypes/HTMLText.php index b90c98681..de7652465 100644 --- a/model/fieldtypes/HTMLText.php +++ b/model/fieldtypes/HTMLText.php @@ -128,8 +128,8 @@ class HTMLText extends Text { return ShortcodeParser::get_active()->parse($this->value); } - public function hasValue() { - return parent::hasValue() && $this->value != '

'; + public function exists() { + return parent::exists() && $this->value != '

'; } public function scaffoldFormField($title = null, $params = null) { diff --git a/model/fieldtypes/HTMLVarchar.php b/model/fieldtypes/HTMLVarchar.php index 76cf3e049..b9ccc1859 100644 --- a/model/fieldtypes/HTMLVarchar.php +++ b/model/fieldtypes/HTMLVarchar.php @@ -14,8 +14,8 @@ class HTMLVarchar extends Varchar { return ShortcodeParser::get_active()->parse($this->value); } - public function hasValue() { - return parent::hasValue() && $this->value != '

'; + public function exists() { + return parent::exists() && $this->value != '

'; } public function scaffoldFormField($title = null, $params = null) { diff --git a/model/fieldtypes/Money.php b/model/fieldtypes/Money.php index 14c6a33ba..ac1f7586a 100644 --- a/model/fieldtypes/Money.php +++ b/model/fieldtypes/Money.php @@ -190,7 +190,7 @@ class Money extends DBField implements CompositeDBField { /** * @return boolean */ - function hasValue() { + function exists() { return ($this->getCurrency() && is_numeric($this->getAmount())); } diff --git a/model/fieldtypes/StringField.php b/model/fieldtypes/StringField.php index 5010679ed..62683c12d 100644 --- a/model/fieldtypes/StringField.php +++ b/model/fieldtypes/StringField.php @@ -64,9 +64,9 @@ abstract class StringField extends DBField { /** * (non-PHPdoc) - * @see core/model/fieldtypes/DBField#hasValue() + * @see core/model/fieldtypes/DBField#exists() */ - function hasValue() { + function exists() { return ($this->value || $this->value == '0') || ( !$this->nullifyEmpty && $this->value === ''); } diff --git a/model/fieldtypes/Varchar.php b/model/fieldtypes/Varchar.php index 5ea03f0dc..a271216b9 100644 --- a/model/fieldtypes/Varchar.php +++ b/model/fieldtypes/Varchar.php @@ -56,7 +56,7 @@ class Varchar extends StringField { * Return the first letter of the string followed by a . */ function Initial() { - if($this->hasValue()) return $this->value[0] . '.'; + if($this->exists()) return $this->value[0] . '.'; } /** diff --git a/tests/model/DBFieldTest.php b/tests/model/DBFieldTest.php index b6f3f7d29..781166509 100644 --- a/tests/model/DBFieldTest.php +++ b/tests/model/DBFieldTest.php @@ -157,42 +157,42 @@ class DBFieldTest extends SapphireTest { $this->assertEquals("00:00:00", $time->getValue()); } - function testHasValue() { + function testExists() { $varcharField = new Varchar("testfield"); $this->assertTrue($varcharField->getNullifyEmpty()); $varcharField->setValue('abc'); - $this->assertTrue($varcharField->hasValue()); + $this->assertTrue($varcharField->exists()); $varcharField->setValue(''); - $this->assertFalse($varcharField->hasValue()); + $this->assertFalse($varcharField->exists()); $varcharField->setValue(null); - $this->assertFalse($varcharField->hasValue()); + $this->assertFalse($varcharField->exists()); $varcharField = new Varchar("testfield", 50, array('nullifyEmpty'=>false)); $this->assertFalse($varcharField->getNullifyEmpty()); $varcharField->setValue('abc'); - $this->assertTrue($varcharField->hasValue()); + $this->assertTrue($varcharField->exists()); $varcharField->setValue(''); - $this->assertTrue($varcharField->hasValue()); + $this->assertTrue($varcharField->exists()); $varcharField->setValue(null); - $this->assertFalse($varcharField->hasValue()); + $this->assertFalse($varcharField->exists()); $textField = new Text("testfield"); $this->assertTrue($textField->getNullifyEmpty()); $textField->setValue('abc'); - $this->assertTrue($textField->hasValue()); + $this->assertTrue($textField->exists()); $textField->setValue(''); - $this->assertFalse($textField->hasValue()); + $this->assertFalse($textField->exists()); $textField->setValue(null); - $this->assertFalse($textField->hasValue()); + $this->assertFalse($textField->exists()); $textField = new Text("testfield", array('nullifyEmpty'=>false)); $this->assertFalse($textField->getNullifyEmpty()); $textField->setValue('abc'); - $this->assertTrue($textField->hasValue()); + $this->assertTrue($textField->exists()); $textField->setValue(''); - $this->assertTrue($textField->hasValue()); + $this->assertTrue($textField->exists()); $textField->setValue(null); - $this->assertFalse($textField->hasValue()); + $this->assertFalse($textField->exists()); } function testStringFieldsWithMultibyteData() { diff --git a/tests/model/MoneyTest.php b/tests/model/MoneyTest.php index 429769c7c..aa2bde1a6 100644 --- a/tests/model/MoneyTest.php +++ b/tests/model/MoneyTest.php @@ -207,23 +207,23 @@ class MoneyTest extends SapphireTest { ); } - function testHasValue() { + function testExists() { $m1 = new Money(); - $this->assertFalse($m1->hasValue()); + $this->assertFalse($m1->exists()); $m2 = new Money(); $m2->setValue(array( 'Currency' => 'EUR', 'Amount' => 3.44 )); - $this->assertTrue($m2->hasValue()); + $this->assertTrue($m2->exists()); $m3 = new Money(); $m3->setValue(array( 'Currency' => 'EUR', 'Amount' => 0 )); - $this->assertTrue($m3->hasValue()); + $this->assertTrue($m3->exists()); } function testLoadIntoDataObject() { From 75c5134bc9c682dc24e322806c42c2efb752923f Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 15:30:38 +1200 Subject: [PATCH 04/10] BUGFIX: Fix Money::setValue() using old api --- model/fieldtypes/Money.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/fieldtypes/Money.php b/model/fieldtypes/Money.php index ac1f7586a..1d15b3811 100644 --- a/model/fieldtypes/Money.php +++ b/model/fieldtypes/Money.php @@ -102,7 +102,7 @@ class Money extends DBField implements CompositeDBField { function setValue($value, $record = null, $markChanged = true) { // @todo Allow resetting value to NULL through Money $value field - if ($value instanceof Money && $value->hasValue()) { + if ($value instanceof Money && $value->exists()) { $this->setCurrency($value->getCurrency(), $markChanged); $this->setAmount($value->getAmount(), $markChanged); if($markChanged) $this->isChanged = true; From f811103243d67545b199d28d07b63281eadbd1a1 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 16:17:44 +1200 Subject: [PATCH 05/10] MINOR: Remove redundant setDisabled() methods - this method already exists in FormField. Fixes E_STRICT notice. --- forms/CheckboxSetField.php | 5 ----- forms/DropdownField.php | 8 -------- 2 files changed, 13 deletions(-) diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index 84f976408..3bf1289cd 100644 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -133,11 +133,6 @@ class CheckboxSetField extends OptionsetField { return $this->customise($properties)->renderWith($this->getTemplate()); } - function setDisabled($val) { - $this->disabled = $val; - return $this; - } - /** * Default selections, regardless of the {@link setValue()} settings. * Note: Items marked as disabled through {@link setDisabledItems()} can still be diff --git a/forms/DropdownField.php b/forms/DropdownField.php index 13b755d66..86d16a507 100644 --- a/forms/DropdownField.php +++ b/forms/DropdownField.php @@ -238,12 +238,4 @@ class DropdownField extends FormField { $field->setReadonly(true); return $field; } - - /** - * Set form being disabled - */ - function setDisabled($disabled = true) { - $this->disabled = $disabled; - return $this; - } } From daab8f4cbc25825b69a087bd942674d0d692e425 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 17:00:57 +1200 Subject: [PATCH 06/10] MINOR: Consistently use DataObjectInterface for saveInto() on FormField subclasses. Fixes E_STRICT notice --- forms/CheckboxSetField.php | 2 +- forms/ConfirmedPasswordField.php | 2 +- forms/FileField.php | 2 +- forms/HasManyComplexTableField.php | 2 +- forms/HasOneComplexTableField.php | 2 +- forms/HtmlEditorField.php | 2 +- forms/ListboxField.php | 2 +- forms/MoneyField.php | 2 +- forms/PhoneNumberField.php | 3 +-- forms/TableField.php | 2 +- forms/TreeMultiselectField.php | 2 +- security/PermissionCheckboxSetField.php | 2 +- 12 files changed, 12 insertions(+), 13 deletions(-) diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index 3bf1289cd..1c4650b2a 100644 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -175,7 +175,7 @@ class CheckboxSetField extends OptionsetField { * * @param DataObject $record The record to save into */ - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { $fieldname = $this->name; $relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null; if($fieldname && $record && $relation && $relation instanceof RelationList) { diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index 0e51215f5..cb2087019 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -286,7 +286,7 @@ class ConfirmedPasswordField extends FormField { * @param DataObject $record * @return bool */ - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { if(!$this->isSaveable()) return false; if(!($this->canBeEmpty && !$this->value)) { diff --git a/forms/FileField.php b/forms/FileField.php index 83027f2c2..edc365218 100644 --- a/forms/FileField.php +++ b/forms/FileField.php @@ -123,7 +123,7 @@ class FileField extends FormField { ); } - public function saveInto(DataObject $record) { + public function saveInto(DataObjectInterface $record) { if(!isset($_FILES[$this->name])) return false; $fileClass = File::get_class_for_file_extension(pathinfo($_FILES[$this->name]['name'], PATHINFO_EXTENSION)); diff --git a/forms/HasManyComplexTableField.php b/forms/HasManyComplexTableField.php index 625734585..9f6c660d4 100644 --- a/forms/HasManyComplexTableField.php +++ b/forms/HasManyComplexTableField.php @@ -87,7 +87,7 @@ class HasManyComplexTableField extends ComplexTableField { return $this->controller->ID; } - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { $fieldName = $this->name; $saveDest = $record->$fieldName(); diff --git a/forms/HasOneComplexTableField.php b/forms/HasOneComplexTableField.php index 8e2164692..06ee301e1 100644 --- a/forms/HasOneComplexTableField.php +++ b/forms/HasOneComplexTableField.php @@ -47,7 +47,7 @@ class HasOneComplexTableField extends HasManyComplexTableField { return $this->controller->{$this->joinField}; } - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { $fieldName = $this->name; $fieldNameID = $fieldName . 'ID'; diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index 283f5e063..290a96bcb 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -96,7 +96,7 @@ class HtmlEditorField extends TextareaField { ); } - public function saveInto($record) { + public function saveInto(DataObjectInterface $record) { if($record->escapeTypeForField($this->name) != 'xml') { throw new Exception ( 'HtmlEditorField->saveInto(): This field should save into a HTMLText or HTMLVarchar field.' diff --git a/forms/ListboxField.php b/forms/ListboxField.php index 5ad9d7460..0c07535c1 100644 --- a/forms/ListboxField.php +++ b/forms/ListboxField.php @@ -169,7 +169,7 @@ class ListboxField extends DropdownField { * * @param DataObject $record The record to save into */ - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { if($this->multiple) { $fieldname = $this->name; $relation = ($fieldname && $record && $record->hasMethod($fieldname)) ? $record->$fieldname() : null; diff --git a/forms/MoneyField.php b/forms/MoneyField.php index b0ae5c78b..eab6aefba 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -100,7 +100,7 @@ class MoneyField extends FormField { * * (see @link MoneyFieldTest_CustomSetter_Object for more information) */ - function saveInto($dataObject) { + function saveInto(DataObjectInterface $dataObject) { $fieldName = $this->name; if($dataObject->hasMethod("set$fieldName")) { $dataObject->$fieldName = DBField::create_field('Money', array( diff --git a/forms/PhoneNumberField.php b/forms/PhoneNumberField.php index c15fb73f0..4e756f7a9 100644 --- a/forms/PhoneNumberField.php +++ b/forms/PhoneNumberField.php @@ -103,8 +103,7 @@ class PhoneNumberField extends FormField { return $parts; } - public function saveInto( $record ) { - + public function saveInto(DataObjectInterface $record) { list( $countryCode, $areaCode, $phoneNumber, $extension ) = $this->parseValue(); $fieldName = $this->name; diff --git a/forms/TableField.php b/forms/TableField.php index 89e20c15c..0f365bab2 100644 --- a/forms/TableField.php +++ b/forms/TableField.php @@ -231,7 +231,7 @@ class TableField extends TableListField { /** * Saves the Dataobjects contained in the field */ - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { // CMS sometimes tries to set the value to one. if(is_array($this->value)){ $newFields = array(); diff --git a/forms/TreeMultiselectField.php b/forms/TreeMultiselectField.php index cdb09b0ef..bd2755417 100644 --- a/forms/TreeMultiselectField.php +++ b/forms/TreeMultiselectField.php @@ -132,7 +132,7 @@ class TreeMultiselectField extends TreeDropdownField { * Calls function $record->onChange($items) before saving to the assummed * Component set. */ - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { // Detect whether this field has actually been updated if($this->value !== 'unchanged') { $items = array(); diff --git a/security/PermissionCheckboxSetField.php b/security/PermissionCheckboxSetField.php index 2095ec087..7c95c801e 100644 --- a/security/PermissionCheckboxSetField.php +++ b/security/PermissionCheckboxSetField.php @@ -215,7 +215,7 @@ class PermissionCheckboxSetField extends FormField { * * @param DataObject $record */ - function saveInto(DataObject $record) { + function saveInto(DataObjectInterface $record) { $fieldname = $this->name; $managedClass = $this->managedClass; From d368f3605b5c75b461c88bb7084e97ce1c4cb8c9 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 17:20:49 +1200 Subject: [PATCH 07/10] MINOR: Remove default paramenter from handleRequest() so it complies with the interface correctly. Fixes E_STRICT warning. --- control/Controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control/Controller.php b/control/Controller.php index 8071387dd..b4ab3a920 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -122,7 +122,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { * @return SS_HTTPResponse The response that this controller produces, * including HTTP headers such as redirection info */ - function handleRequest(SS_HTTPRequest $request, DataModel $model = null) { + function handleRequest(SS_HTTPRequest $request, DataModel $model) { if(!$request) user_error("Controller::handleRequest() not passed a request!", E_USER_ERROR); $this->pushCurrent(); From 4be59a8d4583ab8bbc4e102cf0c43725616f33c2 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 17:33:36 +1200 Subject: [PATCH 08/10] MINOR: Ensure all form fields Field() method has the same signature as FormField::Field(). Fixes E_STRICT warnings. --- forms/AjaxUniqueTextField.php | 2 +- forms/CompositeField.php | 2 +- forms/ConfirmedPasswordField.php | 2 +- forms/CreditCardField.php | 2 +- forms/CurrencyField.php | 4 ++-- forms/DateField.php | 4 ++-- forms/DatetimeField.php | 4 ++-- forms/FieldGroup.php | 2 +- forms/FileIFrameField.php | 2 +- forms/GroupedDropdownField.php | 2 +- forms/HtmlEditorField.php | 4 ++-- forms/ImageFormAction.php | 2 +- forms/InlineFormAction.php | 4 ++-- forms/LiteralField.php | 2 +- forms/LookupField.php | 2 +- forms/MemberDatetimeOptionsetField.php | 2 +- forms/MoneyField.php | 2 +- forms/NullableField.php | 2 +- forms/NumericField.php | 2 +- forms/PhoneNumberField.php | 2 +- forms/SimpleImageField.php | 4 ++-- forms/TimeField.php | 6 +++--- forms/ToggleField.php | 2 +- forms/TreeMultiselectField.php | 4 ++-- forms/UploadField.php | 2 +- forms/gridfield/GridField.php | 2 +- security/PermissionCheckboxSetField.php | 2 +- 27 files changed, 36 insertions(+), 36 deletions(-) diff --git a/forms/AjaxUniqueTextField.php b/forms/AjaxUniqueTextField.php index f8a2ad592..c9a0254cf 100644 --- a/forms/AjaxUniqueTextField.php +++ b/forms/AjaxUniqueTextField.php @@ -28,7 +28,7 @@ class AjaxUniqueTextField extends TextField { parent::__construct($name, $title, $value); } - function Field() { + function Field($properties = array()) { Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour/behaviour.js"); Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 13377a14f..d19086af4 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -134,7 +134,7 @@ class CompositeField extends FormField { ); } - public function Field() { + public function Field($properties = array()) { $content = ''; if($this->tag == 'fieldset' && $this->legend) { diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index cb2087019..2ee1b49df 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -93,7 +93,7 @@ class ConfirmedPasswordField extends FormField { $this->setValue($value); } - function Field() { + function Field($properties = array()) { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/ConfirmedPasswordField.js'); Requirements::css(SAPPHIRE_DIR . '/css/ConfirmedPasswordField.css'); diff --git a/forms/CreditCardField.php b/forms/CreditCardField.php index 533b64269..bcf246095 100644 --- a/forms/CreditCardField.php +++ b/forms/CreditCardField.php @@ -6,7 +6,7 @@ */ class CreditCardField extends TextField { - function Field() { + function Field($properties = array()) { $parts = $this->value; if(!is_array($parts)) $parts = explode("\n", chunk_split($parts,4,"\n")); $parts = array_pad($parts, 4, ""); diff --git a/forms/CurrencyField.php b/forms/CurrencyField.php index 7298c8798..2d2d0ac05 100644 --- a/forms/CurrencyField.php +++ b/forms/CurrencyField.php @@ -67,7 +67,7 @@ class CurrencyField_Readonly extends ReadonlyField{ /** * overloaded to display the correctly formated value for this datatype */ - function Field() { + function Field($properties = array()) { if($this->value){ $val = $this->dontEscape ? $this->value : Convert::raw2xml($this->value); $val = _t('CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.]/',"",$val), 2); @@ -100,7 +100,7 @@ class CurrencyField_Disabled extends CurrencyField{ /** * overloaded to display the correctly formated value for this datatype */ - function Field() { + function Field($properties = array()) { if($this->value){ $val = $this->dontEscape ? $this->value : Convert::raw2xml($this->value); $val = _t('CurrencyField.CURRENCYSYMBOL', '$') . number_format(preg_replace('/[^0-9.]/',"",$val), 2); diff --git a/forms/DateField.php b/forms/DateField.php index 7345e6d39..576a1fd8b 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -120,7 +120,7 @@ class DateField extends TextField { return $html; } - function Field() { + function Field($properties = array()) { $config = array( 'showcalendar' => $this->getConfig('showcalendar'), 'isoDateformat' => $this->getConfig('dateformat'), @@ -425,7 +425,7 @@ class DateField_Disabled extends DateField { protected $disabled = true; - function Field() { + function Field($properties = array()) { if($this->valueObj) { if($this->valueObj->isToday()) { $val = Convert::raw2xml($this->valueObj->toString($this->getConfig('dateformat')) . ' ('._t('DateField.TODAY','today').')'); diff --git a/forms/DatetimeField.php b/forms/DatetimeField.php index ee5487dcb..167d82332 100644 --- a/forms/DatetimeField.php +++ b/forms/DatetimeField.php @@ -84,7 +84,7 @@ class DatetimeField extends FormField { return parent::FieldHolder(); } - function Field() { + function Field($properties = array()) { Requirements::css(SAPPHIRE_DIR . '/css/DatetimeField.css'); $tzField = ($this->getConfig('usertimezone')) ? $this->timezoneField->FieldHolder() : ''; @@ -287,7 +287,7 @@ class DatetimeField_Readonly extends DatetimeField { protected $readonly = true; - function Field() { + function Field($properties = array()) { $valDate = $this->dateField->dataValue(); $valTime = $this->timeField->dataValue(); if($valDate && $valTime) { diff --git a/forms/FieldGroup.php b/forms/FieldGroup.php index f16f1ed32..a6f135a58 100644 --- a/forms/FieldGroup.php +++ b/forms/FieldGroup.php @@ -92,7 +92,7 @@ class FieldGroup extends CompositeField { * @todo Shouldn't use SmallFieldHolder() (very difficult to style), * it is easier to overwrite the
behaviour in a more specific class */ - function Field() { + function Field($properties = array()) { $fs = $this->FieldList(); $spaceZebra = isset($this->zebra) ? " fieldgroup-$this->zebra" : ''; $idAtt = isset($this->id) ? " id=\"{$this->id}\"" : ''; diff --git a/forms/FileIFrameField.php b/forms/FileIFrameField.php index f23d255bb..e4345a7e7 100644 --- a/forms/FileIFrameField.php +++ b/forms/FileIFrameField.php @@ -60,7 +60,7 @@ class FileIFrameField extends FileField { /** * @return string */ - public function Field() { + public function Field($properties = array()) { Deprecation::notice('3.0', 'Use UploadField'); Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css'); diff --git a/forms/GroupedDropdownField.php b/forms/GroupedDropdownField.php index 3708cf277..a4037affd 100644 --- a/forms/GroupedDropdownField.php +++ b/forms/GroupedDropdownField.php @@ -39,7 +39,7 @@ */ class GroupedDropdownField extends DropdownField { - function Field() { + function Field($properties = array()) { $options = ''; foreach($this->getSource() as $value => $title) { if(is_array($title)) { diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index 290a96bcb..dc0e24deb 100644 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -56,7 +56,7 @@ class HtmlEditorField extends TextareaField { /** * @return string */ - function Field() { + function Field($properties = array()) { // mark up broken links $value = new SS_HTMLValue($this->value); @@ -221,7 +221,7 @@ class HtmlEditorField extends TextareaField { * @subpackage fields-formattedinput */ class HtmlEditorField_Readonly extends ReadonlyField { - function Field() { + function Field($properties = array()) { $valforInput = $this->value ? Convert::raw2att($this->value) : ""; return "id() . "\">" . ( $this->value && $this->value != '

' ? $this->value : '(not set)' ) . "
name."\" value=\"".$valforInput."\" />"; } diff --git a/forms/ImageFormAction.php b/forms/ImageFormAction.php index d6dd77b10..72d9cf6e9 100644 --- a/forms/ImageFormAction.php +++ b/forms/ImageFormAction.php @@ -26,7 +26,7 @@ class ImageFormAction extends FormAction { parent::__construct($action, $title, $form); } - function Field() { + function Field($properties = array()) { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/ImageFormAction.js'); diff --git a/forms/InlineFormAction.php b/forms/InlineFormAction.php index f79758fbb..3e715bdb7 100644 --- a/forms/InlineFormAction.php +++ b/forms/InlineFormAction.php @@ -27,7 +27,7 @@ class InlineFormAction extends FormField { return new InlineFormAction_ReadOnly( $this->name, $this->title ); } - function Field() { + function Field($properties = array()) { if($this->includeDefaultJS) { Requirements::javascriptTemplate(SAPPHIRE_DIR . '/javascript/InlineFormAction.js',array('ID'=>$this->id())); } @@ -59,7 +59,7 @@ class InlineFormAction_ReadOnly extends FormField { protected $readonly = true; - function Field() { + function Field($properties = array()) { return "name}\" value=\"{$this->title}\" id=\"{$this->id()}\" disabled=\"disabled\" class=\"action disabled$this->extraClass\" />"; } diff --git a/forms/LiteralField.php b/forms/LiteralField.php index b7890cab1..d99170025 100644 --- a/forms/LiteralField.php +++ b/forms/LiteralField.php @@ -31,7 +31,7 @@ class LiteralField extends DatalessField { return is_object($this->content) ? $this->content->forTemplate() : $this->content; } - function Field() { + function Field($properties = array()) { return $this->FieldHolder(); } diff --git a/forms/LookupField.php b/forms/LookupField.php index 6d06f27a3..f032cf27d 100644 --- a/forms/LookupField.php +++ b/forms/LookupField.php @@ -12,7 +12,7 @@ class LookupField extends DropdownField { /** * Returns a readonly span containing the correct value. */ - function Field() { + function Field($properties = array()) { $source = $this->getSource(); diff --git a/forms/MemberDatetimeOptionsetField.php b/forms/MemberDatetimeOptionsetField.php index c8bf8031b..052249445 100644 --- a/forms/MemberDatetimeOptionsetField.php +++ b/forms/MemberDatetimeOptionsetField.php @@ -5,7 +5,7 @@ */ class MemberDatetimeOptionsetField extends OptionsetField { - function Field() { + function Field($properties = array()) { $options = ''; $odd = 0; $source = $this->getSource(); diff --git a/forms/MoneyField.php b/forms/MoneyField.php index eab6aefba..5d7fd86f5 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -43,7 +43,7 @@ class MoneyField extends FormField { /** * @return string */ - function Field() { + function Field($properties = array()) { return "
" . "
" . $this->fieldCurrency->SmallFieldHolder() . "
" . "
" . $this->fieldAmount->SmallFieldHolder() . "
" . diff --git a/forms/NullableField.php b/forms/NullableField.php index 8b76db967..a427223bf 100644 --- a/forms/NullableField.php +++ b/forms/NullableField.php @@ -76,7 +76,7 @@ class NullableField extends FormField { * (non-PHPdoc) * @see sapphire/forms/FormField#Field() */ - function Field() { + function Field($properties = array()) { if ( $this->isReadonly()) { $nullableCheckbox = new CheckboxField_Readonly($this->getIsNullId()); } else { diff --git a/forms/NumericField.php b/forms/NumericField.php index 0683dd454..0951076a6 100644 --- a/forms/NumericField.php +++ b/forms/NumericField.php @@ -7,7 +7,7 @@ */ class NumericField extends TextField{ - function Field() { + function Field($properties = array()) { $html = parent::Field(); Requirements::javascript(SAPPHIRE_DIR . 'javascript/NumericField.js'); diff --git a/forms/PhoneNumberField.php b/forms/PhoneNumberField.php index 4e756f7a9..0433e31c3 100644 --- a/forms/PhoneNumberField.php +++ b/forms/PhoneNumberField.php @@ -26,7 +26,7 @@ class PhoneNumberField extends FormField { parent::__construct($name, $title, $value); } - public function Field() { + public function Field($properties = array()) { $fields = new FieldGroup( $this->name ); $fields->setID("{$this->name}_Holder"); list($countryCode, $areaCode, $phoneNumber, $extension) = $this->parseValue(); diff --git a/forms/SimpleImageField.php b/forms/SimpleImageField.php index dc9d918a2..ea06fd013 100644 --- a/forms/SimpleImageField.php +++ b/forms/SimpleImageField.php @@ -78,7 +78,7 @@ class SimpleImageField extends FileField { $this->getValidator()->setAllowedExtensions(array('jpg','gif','png')); } - function Field() { + function Field($properties = array()) { if($this->form) $record = $this->form->getRecord(); $fieldName = $this->name; if(isset($record)&&$record) { @@ -141,7 +141,7 @@ class SimpleImageField_Disabled extends FormField { protected $readonly = true; - function Field() { + function Field($properties = array()) { $record = $this->form->getRecord(); $fieldName = $this->name; diff --git a/forms/TimeField.php b/forms/TimeField.php index c98881285..38b096d4a 100644 --- a/forms/TimeField.php +++ b/forms/TimeField.php @@ -63,13 +63,13 @@ class TimeField extends TextField { parent::__construct($name,$title,$value); } - function Field() { + function Field($properties = array()) { $config = array( 'timeformat' => $this->getConfig('timeformat') ); $config = array_filter($config); $this->addExtraClass(Convert::raw2json($config)); - return parent::Field(); + return parent::Field($properties); } function Type() { @@ -206,7 +206,7 @@ class TimeField_Readonly extends TimeField { protected $readonly = true; - function Field() { + function Field($properties = array()) { if($this->valueObj) { $val = Convert::raw2xml($this->valueObj->toString($this->getConfig('timeformat'))); } else { diff --git a/forms/ToggleField.php b/forms/ToggleField.php index 0e23e3904..58b9abab7 100644 --- a/forms/ToggleField.php +++ b/forms/ToggleField.php @@ -46,7 +46,7 @@ class ToggleField extends ReadonlyField { parent::__construct($name, $title, $value); } - function Field() { + function Field($properties = array()) { $content = ''; Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js"); diff --git a/forms/TreeMultiselectField.php b/forms/TreeMultiselectField.php index bd2755417..3c8d1eb23 100644 --- a/forms/TreeMultiselectField.php +++ b/forms/TreeMultiselectField.php @@ -78,7 +78,7 @@ class TreeMultiselectField extends TreeDropdownField { * We overwrite the field attribute to add our hidden fields, as this * formfield can contain multiple values. */ - function Field() { + function Field($properties = array()) { Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); @@ -178,7 +178,7 @@ class TreeMultiselectField_Readonly extends TreeMultiselectField { protected $readonly = true; - function Field() { + function Field($properties = array()) { $titleArray = $itemIDs = array(); $titleList = $itemIDsList = ""; if($items = $this->getItems()) { diff --git a/forms/UploadField.php b/forms/UploadField.php index a4a3c7740..556f7dc87 100644 --- a/forms/UploadField.php +++ b/forms/UploadField.php @@ -310,7 +310,7 @@ class UploadField extends FileField { ); } - public function Field() { + public function Field($properties = array()) { $record = $this->getRecord(); $name = $this->getName(); diff --git a/forms/gridfield/GridField.php b/forms/gridfield/GridField.php index b4a4c4ad6..4ea749231 100755 --- a/forms/gridfield/GridField.php +++ b/forms/gridfield/GridField.php @@ -448,7 +448,7 @@ class GridField extends FormField { ); } - public function Field() { + public function Field($properties = array()) { return $this->FieldHolder(); } diff --git a/security/PermissionCheckboxSetField.php b/security/PermissionCheckboxSetField.php index 7c95c801e..db9027068 100644 --- a/security/PermissionCheckboxSetField.php +++ b/security/PermissionCheckboxSetField.php @@ -70,7 +70,7 @@ class PermissionCheckboxSetField extends FormField { return $this->hiddenPermissions; } - function Field() { + function Field($properties = array()) { Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js'); From 142a073ce30cfb0620936fb52286c92892ccaeaf Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 17:36:56 +1200 Subject: [PATCH 09/10] MINOR: Fix E_STRICT warning in SSViewer --- view/SSViewer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/view/SSViewer.php b/view/SSViewer.php index c07d8b83e..03e61b869 100644 --- a/view/SSViewer.php +++ b/view/SSViewer.php @@ -719,7 +719,9 @@ class SSViewer { if(isset($this->chosenTemplates['main'])) { $template = $this->chosenTemplates['main']; } else { - $template = $this->chosenTemplates[ reset($dummy = array_keys($this->chosenTemplates)) ]; + $keys = array_keys($this->chosenTemplates); + $key = reset($keys); + $template = $this->chosenTemplates[$key]; } if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process", " for $template"); From 716ff9dcfaedee08b63c7e61af07e1fe2a60e04d Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 11 Apr 2012 18:07:55 +1200 Subject: [PATCH 10/10] MINOR: Ensure all form fields have FieldHolder() with identical signature to FormField::FieldHolder(). Fixes E_STRICT warnings. --- forms/ComplexTableField.php | 2 +- forms/CompositeField.php | 2 +- forms/DatalessField.php | 4 ++-- forms/DateField.php | 2 +- forms/DatetimeField.php | 4 ++-- forms/FieldGroup.php | 2 +- forms/FormAction.php | 4 ++-- forms/HasManyComplexTableField.php | 4 ++-- forms/HiddenField.php | 4 ++-- forms/LiteralField.php | 13 ++++++++++--- forms/PrintableTransformation.php | 2 +- forms/SelectionGroup.php | 6 ++++-- forms/TabSet.php | 5 +++-- forms/TableField.php | 5 +++-- forms/TableListField.php | 6 ++++-- forms/ToggleCompositeField.php | 5 +++-- forms/gridfield/GridField.php | 4 ++-- 17 files changed, 44 insertions(+), 30 deletions(-) diff --git a/forms/ComplexTableField.php b/forms/ComplexTableField.php index 9374ab003..49cd9544f 100644 --- a/forms/ComplexTableField.php +++ b/forms/ComplexTableField.php @@ -206,7 +206,7 @@ class ComplexTableField extends TableListField { /** * @return String */ - function FieldHolder() { + function FieldHolder($properties = array()) { Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/greybox/AmiJS.js"); diff --git a/forms/CompositeField.php b/forms/CompositeField.php index d19086af4..dbb540c4c 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -158,7 +158,7 @@ class CompositeField extends FormField { /** * Returns the fields nested inside another DIV */ - function FieldHolder() { + function FieldHolder($properties = array()) { $content = ''; if($this->tag == 'fieldset' && $this->legend) { diff --git a/forms/DatalessField.php b/forms/DatalessField.php index cafdef336..68a081772 100644 --- a/forms/DatalessField.php +++ b/forms/DatalessField.php @@ -32,8 +32,8 @@ class DatalessField extends FormField { * Returns the field's representation in the form. * For dataless fields, this defaults to $Field. */ - function FieldHolder() { - return $this->Field(); + function FieldHolder($properties = array()) { + return $this->Field($properties); } /** diff --git a/forms/DateField.php b/forms/DateField.php index 576a1fd8b..b6d94a5fa 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -110,7 +110,7 @@ class DateField extends TextField { parent::__construct($name, $title, $value); } - function FieldHolder() { + function FieldHolder($properties = array()) { // TODO Replace with properly extensible view helper system $d = DateField_View_JQuery::create($this); $d->onBeforeRender(); diff --git a/forms/DatetimeField.php b/forms/DatetimeField.php index 167d82332..c939cbf2d 100644 --- a/forms/DatetimeField.php +++ b/forms/DatetimeField.php @@ -74,14 +74,14 @@ class DatetimeField extends FormField { return $this; } - function FieldHolder() { + function FieldHolder($properties = array()) { $config = array( 'datetimeorder' => $this->getConfig('datetimeorder'), ); $config = array_filter($config); $this->addExtraClass(Convert::raw2json($config)); - return parent::FieldHolder(); + return parent::FieldHolder($properties); } function Field($properties = array()) { diff --git a/forms/FieldGroup.php b/forms/FieldGroup.php index a6f135a58..be1476f72 100644 --- a/forms/FieldGroup.php +++ b/forms/FieldGroup.php @@ -131,7 +131,7 @@ class FieldGroup extends CompositeField { return $this; } - function FieldHolder() { + function FieldHolder($properties = array()) { $Title = $this->XML_val('Title'); $Message = $this->XML_val('Message'); $MessageType = $this->XML_val('MessageType'); diff --git a/forms/FormAction.php b/forms/FormAction.php index 7e52f7c8f..9c04a9f30 100644 --- a/forms/FormAction.php +++ b/forms/FormAction.php @@ -70,8 +70,8 @@ class FormAction extends FormField { return $this->customise($properties)->renderWith($this->getTemplate()); } - function FieldHolder() { - return $this->Field(); + function FieldHolder($properties = array()) { + return $this->Field($properties); } public function Type() { diff --git a/forms/HasManyComplexTableField.php b/forms/HasManyComplexTableField.php index 9f6c660d4..f0078e2b5 100644 --- a/forms/HasManyComplexTableField.php +++ b/forms/HasManyComplexTableField.php @@ -64,8 +64,8 @@ class HasManyComplexTableField extends ComplexTableField { } - function FieldHolder() { - $ret = parent::FieldHolder(); + function FieldHolder($properties = array()) { + $ret = parent::FieldHolder($properties); Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::javascript(SAPPHIRE_DIR . "/javascript/HasManyFileField.js"); diff --git a/forms/HiddenField.php b/forms/HiddenField.php index 1e33b080f..ddb9ff9c0 100644 --- a/forms/HiddenField.php +++ b/forms/HiddenField.php @@ -8,8 +8,8 @@ class HiddenField extends FormField { protected $template = 'HiddenField'; - function FieldHolder() { - return $this->Field(); + function FieldHolder($properties = array()) { + return $this->Field($properties); } function performReadonlyTransformation() { diff --git a/forms/LiteralField.php b/forms/LiteralField.php index d99170025..0ce883757 100644 --- a/forms/LiteralField.php +++ b/forms/LiteralField.php @@ -27,12 +27,19 @@ class LiteralField extends DatalessField { parent::__construct($name); } - function FieldHolder() { - return is_object($this->content) ? $this->content->forTemplate() : $this->content; + function FieldHolder($properties = array()) { + if(is_object($this->content)) { + $obj = $this->content; + if($properties) + $obj = $obj->customise($properties); + return $obj->forTemplate(); + } else { + return $this->content; + } } function Field($properties = array()) { - return $this->FieldHolder(); + return $this->FieldHolder($properties); } /** diff --git a/forms/PrintableTransformation.php b/forms/PrintableTransformation.php index 3e1739176..c74d52901 100644 --- a/forms/PrintableTransformation.php +++ b/forms/PrintableTransformation.php @@ -25,7 +25,7 @@ class PrintableTransformation_TabSet extends TabSet { CompositeField::__construct($tabs); } - function FieldHolder() { + function FieldHolder($properties = array()) { // This gives us support for sub-tabs. $tag = ($this->tabSet) ? "h2>" : "h1>"; diff --git a/forms/SelectionGroup.php b/forms/SelectionGroup.php index b742d5d3b..b2aabefdc 100644 --- a/forms/SelectionGroup.php +++ b/forms/SelectionGroup.php @@ -85,12 +85,14 @@ class SelectionGroup extends CompositeField { return true; } - function FieldHolder() { + function FieldHolder($properties = array()) { Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/javascript/SelectionGroup.js'); Requirements::css(SAPPHIRE_DIR . '/css/SelectionGroup.css'); + + $obj = $properties ? $this->customise($properties) : $this; - return $this->renderWith($this->template); + return $obj->renderWith($this->template); } } diff --git a/forms/TabSet.php b/forms/TabSet.php index 90bdd394d..defcfbe52 100644 --- a/forms/TabSet.php +++ b/forms/TabSet.php @@ -69,7 +69,7 @@ class TabSet extends CompositeField { * Returns a tab-strip and the associated tabs. * The HTML is a standardised format, containing a <ul; */ - public function FieldHolder() { + public function FieldHolder($properties = array()) { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js'); @@ -80,7 +80,8 @@ class TabSet extends CompositeField { Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js'); - return $this->renderWith($this->template); + $obj = $properties ? $this->customise($properties) : $this; + return $obj->renderWith($this->template); } /** diff --git a/forms/TableField.php b/forms/TableField.php index 0f365bab2..0d202ccc8 100644 --- a/forms/TableField.php +++ b/forms/TableField.php @@ -463,7 +463,7 @@ class TableField extends TableListField { /** * Sets the template to be rendered with */ - function FieldHolder() { + function FieldHolder($properties = array()) { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js"); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); @@ -472,7 +472,8 @@ class TableField extends TableListField { Requirements::javascript(SAPPHIRE_DIR . '/javascript/TableField.js'); Requirements::css(SAPPHIRE_DIR . '/css/TableListField.css'); - return $this->renderWith($this->template); + $obj = $properties ? $this->customise($properties) : $this; + return $obj->renderWith($this->template); } function setTransformationConditions($conditions) { diff --git a/forms/TableListField.php b/forms/TableListField.php index f20180d24..768283637 100644 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -278,7 +278,7 @@ class TableListField extends FormField { return new TableListField_ItemRequest($this, $request->param('ID')); } - function FieldHolder() { + function FieldHolder($properties = array()) { Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js'); Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js'); @@ -299,7 +299,9 @@ class TableListField extends FormField { }); JS );} - return $this->renderWith($this->template); + + $obj = $properties ? $this->customise($properties) : $this; + return $obj->renderWith($this->template); } function Headings() { diff --git a/forms/ToggleCompositeField.php b/forms/ToggleCompositeField.php index 9fd73036f..02607baba 100644 --- a/forms/ToggleCompositeField.php +++ b/forms/ToggleCompositeField.php @@ -22,12 +22,13 @@ class ToggleCompositeField extends CompositeField { parent::__construct($children); } - public function FieldHolder() { + public function FieldHolder($properties = array()) { Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js"); Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ToggleCompositeField.js"); - return $this->renderWith($this->template); + $obj = $properties ? $this->customise($properties) : $this; + return $obj->renderWith($this->template); } /** diff --git a/forms/gridfield/GridField.php b/forms/gridfield/GridField.php index 4ea749231..9ac434201 100755 --- a/forms/gridfield/GridField.php +++ b/forms/gridfield/GridField.php @@ -289,7 +289,7 @@ class GridField extends FormField { * * @return string */ - public function FieldHolder() { + public function FieldHolder($properties = array()) { Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css'); Requirements::css(SAPPHIRE_DIR . '/css/GridField.css'); @@ -449,7 +449,7 @@ class GridField extends FormField { } public function Field($properties = array()) { - return $this->FieldHolder(); + return $this->FieldHolder($properties); } public function getAttributes() {