diff --git a/ORM/Connect/DBSchemaManager.php b/ORM/Connect/DBSchemaManager.php
index 945fbedfc..7ac4b336f 100644
--- a/ORM/Connect/DBSchemaManager.php
+++ b/ORM/Connect/DBSchemaManager.php
@@ -8,7 +8,6 @@ use Object;
use Director;
use SilverStripe\ORM\FieldType\DBPrimaryKey;
use SilverStripe\ORM\FieldType\DBField;
-use SilverStripe\ORM\FieldType\DBPrimaryKey;
/**
diff --git a/ORM/FieldType/DBHTMLText.php b/ORM/FieldType/DBHTMLText.php
index df5983edb..13e4b57d3 100644
--- a/ORM/FieldType/DBHTMLText.php
+++ b/ORM/FieldType/DBHTMLText.php
@@ -13,10 +13,10 @@ use TextField;
* This behaves similarly to {@link Text}, but the template processor won't escape any HTML content within it.
*
* Options can be specified in a $db config via one of the following:
- * - "HTMLFragment(['shortcodes=true', 'whitelist=meta,link'])"
- * - "HTMLFragment('whitelist=meta,link')"
- * - "HTMLFragment(['shortcodes=true'])". "HTMLText" is also a synonym for this.
- * - "HTMLFragment('shortcodes=true')"
+ * - "HTMLFragment(['shortcodes' => true, 'whitelist' => 'meta,link'])"
+ * - "HTMLFragment(['whitelist' => 'meta,link'])"
+ * - "HTMLFragment(['shortcodes' => true])". "HTMLText" is also a synonym for this.
+ * - "HTMLFragment(['shortcodes' => true])"
*
* @see HTMLVarchar
* @see Text
@@ -189,35 +189,6 @@ class DBHTMLText extends DBText {
return $value;
}
- /**
- * Returns true if the field has meaningful content.
- * Excludes null content like
, ,etc
- *
- * @return boolean
- */
- public function exists() {
- // If it's blank, it's blank
- if(!parent::exists()) {
- return false;
- }
-
- $value = $this->RAW();
-
- // If it's got a content tag
- if(preg_match('/<(img|embed|object|iframe|meta|source|link)[^>]*>/i', $value)) {
- return true;
- }
-
- // If it's just one or two tags on its own (and not the above) it's empty.
- // This might be or or whatever.
- if(preg_match('/^[\\s]*(<[^>]+>[\\s]*){1,2}$/', $value)) {
- return false;
- }
-
- // Otherwise its content is genuine content
- return true;
- }
-
public function scaffoldFormField($title = null) {
return new HTMLEditorField($this->name, $title);
}
diff --git a/ORM/FieldType/DBHTMLVarchar.php b/ORM/FieldType/DBHTMLVarchar.php
index a8b0ebd75..d7c239e5f 100644
--- a/ORM/FieldType/DBHTMLVarchar.php
+++ b/ORM/FieldType/DBHTMLVarchar.php
@@ -115,33 +115,6 @@ class DBHTMLVarchar extends DBVarchar {
return trim(\Convert::xml2raw($text));
}
- /**
- * Returns true if the field has meaningful content.
- * Excludes null content like , ,etc
- *
- * @return boolean
- */
- public function exists() {
- // If it's blank, it's blank
- if(!parent::exists()) {
- return false;
- }
-
- // If it's got a content tag
- if(preg_match('/<(img|embed|object|iframe|meta|source|link)[^>]*>/i', $this->RAW())) {
- return true;
- }
-
- // If it's just one or two tags on its own (and not the above) it's empty.
- // This might be or or whatever.
- if(preg_match('/^[\\s]*(<[^>]+>[\\s]*){1,2}$/', $this->RAW())) {
- return false;
- }
-
- // Otherwise its content is genuine content
- return true;
- }
-
public function scaffoldFormField($title = null) {
return new HTMLEditorField($this->name, $title, 1);
}
@@ -150,15 +123,4 @@ class DBHTMLVarchar extends DBVarchar {
return new TextField($this->name, $title);
}
- /**
- * @return string
- */
- public function NoHTML()
- {
- // Preserve line breaks
- $text = preg_replace('/\ /i', "\n", $this->RAW());
- // Convert back to plain text
- return \Convert::xml2raw(strip_tags($text));
- }
-
}
diff --git a/ORM/FieldType/DBString.php b/ORM/FieldType/DBString.php
index 8445f28d2..880b085dc 100644
--- a/ORM/FieldType/DBString.php
+++ b/ORM/FieldType/DBString.php
@@ -35,48 +35,16 @@ abstract class DBString extends DBField {
* {@link StringField::setOptions()} for information on the available options
*/
public function __construct($name = null, $options = array()) {
- $options = $this->parseConstructorOptions($options);
if($options) {
+ if(!is_array($options)) {
+ throw new \InvalidArgumentException("Invalid options $options");
+ }
$this->setOptions($options);
}
parent::__construct($name);
}
- /**
- * Parses the "options" parameter passed to the constructor. This could be a
- * string value, or an array of options. Config specification might also
- * encode "key=value" pairs in non-associative strings.
- *
- * @param mixed $options
- * @return array The list of parsed options, or empty if there are none
- */
- protected function parseConstructorOptions($options) {
- if(is_string($options)) {
- $options = [$options];
- }
- if(!is_array($options)) {
- return [];
- }
- $parsed = [];
- foreach($options as $option => $value) {
- // Workaround for inability for config args to support associative arrays
- if(is_numeric($option) && strpos($value, '=') !== false) {
- list($option, $value) = explode('=', $value);
- $option = trim($option);
- $value = trim($value);
- }
- // Convert bool values
- if(strcasecmp($value, 'true') === 0) {
- $value = true;
- } elseif(strcasecmp($value, 'false') === 0) {
- $value = false;
- }
- $parsed[$option] = $value;
- }
- return $parsed;
- }
-
/**
* Update the optional parameters for this field.
*
diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php
index a8e76fddd..66000222e 100644
--- a/admin/code/LeftAndMain.php
+++ b/admin/code/LeftAndMain.php
@@ -6,8 +6,6 @@
*/
use SilverStripe\Forms\Schema\FormSchema;
-
-use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\SS_List;
use SilverStripe\ORM\Versioning\Versioned;
use SilverStripe\ORM\DataModel;
diff --git a/control/Controller.php b/control/Controller.php
index c7ba4d428..9ac1db9a5 100644
--- a/control/Controller.php
+++ b/control/Controller.php
@@ -1,8 +1,6 @@
Field($properties);
@@ -41,6 +43,8 @@ class DatalessField extends FormField {
/**
* Returns the field's representation in a field group.
* For dataless fields, this defaults to $Field.
+ *
+ * @return DBHTMLText
*/
public function SmallFieldHolder($properties = array()) {
return $this->Field($properties);
diff --git a/forms/Form.php b/forms/Form.php
index 92a0e6e1d..7edee9dd3 100644
--- a/forms/Form.php
+++ b/forms/Form.php
@@ -3,9 +3,7 @@
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\DataObjectInterface;
-use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\SS_List;
-use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\Security\SecurityToken;
use SilverStripe\Security\NullSecurityToken;
@@ -497,8 +495,8 @@ class Form extends RequestHandler {
|| $this->actions->dataFieldByName('action_' . $action)
// Always allow actions on fields
|| (
- $field = $this->checkFieldsForAction($this->Fields(), $action)
- && $field->checkAccessAction($action)
+ ($field = $this->checkFieldsForAction($this->Fields(), $action))
+ && $field->checkAccessAction($action)
)
);
}
diff --git a/forms/FormAction.php b/forms/FormAction.php
index 3aabbb9ed..af5613999 100644
--- a/forms/FormAction.php
+++ b/forms/FormAction.php
@@ -1,4 +1,6 @@
as well as