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
This commit is contained in:
Ingo Schommer 2008-01-17 04:23:31 +00:00
parent 0b5ab1fc7b
commit a1451739a4
3 changed files with 9 additions and 4 deletions

View File

@ -20,6 +20,10 @@
* 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
*/

View File

@ -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');

View File

@ -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