From a1451739a4fc9a6de8d38efead4bd1acdee09a79 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 17 Jan 2008 04:23:31 +0000 Subject: [PATCH] Merged revisions 48168 via svnmerge from svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r48168 | ischommer | 2008-01-17 17:20:45 +1300 (Thu, 17 Jan 2008) | 1 line renamed escapeFlagForField() to escapeTypeForField(), updated documentation ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@48163 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Convert.php | 6 +++++- core/ViewableData.php | 5 +++-- forms/HtmlEditorField.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/Convert.php b/core/Convert.php index dee2b7889..1dd5bf107 100755 --- a/core/Convert.php +++ b/core/Convert.php @@ -19,7 +19,11 @@ * * html: HTML source suitable for use in a page or email * text: Plain-text content, suitable for display to a user as-is, or insertion in a plaintext email. - * + * + * Objects of type {@link ViewableData} can have an "escaping type", + * which determines if they are automatically escaped before output by {@link SSViewer}. + * + * @usedby ViewableData::XML_val() * @package sapphire * @subpackage misc */ diff --git a/core/ViewableData.php b/core/ViewableData.php index 79d7819e7..f76c888d3 100644 --- a/core/ViewableData.php +++ b/core/ViewableData.php @@ -273,10 +273,11 @@ class ViewableData extends Object implements Iterator { /** * Return the string-format type for the given field. * + * @usedby ViewableData::XML_val() * @param string $fieldName * @return string 'xml'|'raw' */ - function escapeFlagForField($fieldName) { + function escapeTypeForField($fieldName) { $helperPair = $this->castingHelperPair($fieldName); $castedClass = $helperPair['className']; if(!$castedClass || $castedClass == 'HTMLText' || $castedClass == 'HTMLVarchar') return "xml"; @@ -417,7 +418,7 @@ class ViewableData extends Object implements Iterator { } // Case 2: Check if the value is raw and must be made XML-safe - if($this->escapeFlagForField($fieldName) != 'xml') $val = Convert::raw2xml($val); + if($this->escapeTypeForField($fieldName) != 'xml') $val = Convert::raw2xml($val); if(isset($_GET['debug_profile'])) { Profiler::unmark('casting cost'); diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index ecd303877..dc37d2d01 100755 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -90,7 +90,7 @@ class HtmlEditorField extends TextareaField { } function saveInto($record) { - if(!$record->escapeFlagForField($this->name) != 'xml') { + if($record->escapeTypeForField($this->name) != 'xml') { user_error("HTMLEditorField should save into an HTMLText or HTMLVarchar field. If you don't, your template won't display properly. This changed in version 2.2.2, so please update