Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eztexttype.php
Go to the documentation of this file.
1 <?php
18 class eZTextType extends eZDataType
19 {
20 const DATA_TYPE_STRING = "eztext";
21 const COLS_FIELD = 'data_int1';
22 const COLS_VARIABLE = '_eztext_cols_';
23
24 public function __construct()
25 {
26 parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Text block", 'Datatype name' ),
27 array( 'serialize_supported' => true,
28 'object_serialize_map' => array( 'data_text' => 'text' ) ) );
29 }
30
34 function initializeClassAttribute( $classAttribute )
35 {
36 if ( $classAttribute->attribute( self::COLS_FIELD ) == null )
37 $classAttribute->setAttribute( self::COLS_FIELD, 10 );
38 $classAttribute->store();
39 }
40
44 function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
45 {
46 if ( $currentVersion != false )
47 {
48 $dataText = $originalContentObjectAttribute->attribute( "data_text" );
49 $contentObjectAttribute->setAttribute( "data_text", $dataText );
50 }
51 $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
52 if ( $contentClassAttribute->attribute( "data_int1" ) == 0 )
53 {
54 $contentClassAttribute->setAttribute( "data_int1", 10 );
55 $contentClassAttribute->store();
56 }
57 }
58
63 function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
64 {
65 $classAttribute = $contentObjectAttribute->contentClassAttribute();
66 if ( $http->hasPostVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
67 {
68 $data = $http->postVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
69
70 if ( $data == "" )
71 {
72 if ( !$classAttribute->attribute( 'is_information_collector' ) and
73 $contentObjectAttribute->validateIsRequired() )
74 {
75 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
76 'Input required.' ) );
77 return eZInputValidator::STATE_INVALID;
78 }
79 }
80 }
81 else if ( !$classAttribute->attribute( 'is_information_collector' ) and $contentObjectAttribute->validateIsRequired() )
82 {
83 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes', 'Input required.' ) );
84 return eZInputValidator::STATE_INVALID;
85 }
86
87 return eZInputValidator::STATE_ACCEPTED;
88 }
89
90 function validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute )
91 {
92 if ( $http->hasPostVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
93 {
94 $data = $http->postVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
95 $classAttribute = $contentObjectAttribute->contentClassAttribute();
96
97 if ( $data == "" )
98 {
99 if ( $contentObjectAttribute->validateIsRequired() )
100 {
101 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
102 'Input required.' ) );
103 return eZInputValidator::STATE_INVALID;
104 }
105 }
106 return eZInputValidator::STATE_ACCEPTED;
107 }
108 else
109 return eZInputValidator::STATE_INVALID;
110 }
111
115 function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
116 {
117 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) )
118 {
119 $data = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) );
120 $contentObjectAttribute->setAttribute( "data_text", $data );
121 return true;
122 }
123 return false;
124 }
125
129 function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute )
130 {
131 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) )
132 {
133 $dataText = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) );
134 $collectionAttribute->setAttribute( 'data_text', $dataText );
135 return true;
136 }
137 return false;
138 }
139
143 function storeObjectAttribute( $attribute )
144 {
145 }
146
150 function isSimpleStringInsertionSupported()
151 {
152 return true;
153 }
154
158 function insertSimpleString( $object, $objectVersion, $objectLanguage,
159 $objectAttribute, $string,
160 &$result )
161 {
162 $result = array( 'errors' => array(),
163 'require_storage' => true );
164 $objectAttribute->setContent( $string );
165 $objectAttribute->setAttribute( 'data_text', $string );
166 return true;
167 }
168
172 function objectAttributeContent( $contentObjectAttribute )
173 {
174 return $contentObjectAttribute->attribute( "data_text" );
175 }
176
177 function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
178 {
179 $column = $base . self::COLS_VARIABLE . $classAttribute->attribute( 'id' );
180 if ( $http->hasPostVariable( $column ) )
181 {
182 $columnValue = $http->postVariable( $column );
183 $classAttribute->setAttribute( self::COLS_FIELD, $columnValue );
184 return true;
185 }
186 return false;
187 }
188
192 function metaData( $contentObjectAttribute )
193 {
194 return $contentObjectAttribute->attribute( "data_text" );
195 }
196
201 function toString( $contentObjectAttribute )
202 {
203 return $contentObjectAttribute->attribute( 'data_text' );
204 }
205
206 function fromString( $contentObjectAttribute, $string )
207 {
208 return $contentObjectAttribute->setAttribute( 'data_text', $string );
209 }
210
211 function hasObjectAttributeContent( $contentObjectAttribute )
212 {
213 return trim( $contentObjectAttribute->attribute( 'data_text' ) ) != '';
214 }
215
219 function title( $data_instance, $name = null )
220 {
221 return $data_instance->attribute( "data_text" );
222 }
223
224 function isIndexable()
225 {
226 return true;
227 }
228
229 function isInformationCollector()
230 {
231 return true;
232 }
233
234 function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
235 {
236 $dom = $attributeParametersNode->ownerDocument;
237 $textColumns = $classAttribute->attribute( self::COLS_FIELD );
238
239 $textColumnCountNode = $dom->createElement( 'text-column-count' );
240 $textColumnCountNode->appendChild( $dom->createTextNode( $textColumns ) );
241 $attributeParametersNode->appendChild( $textColumnCountNode );
242 }
243
244 function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
245 {
246 $textColumns = $attributeParametersNode->getElementsByTagName( 'text-column-count' )->item( 0 )->textContent;
247 $classAttribute->setAttribute( self::COLS_FIELD, $textColumns );
248 }
249
250 function diff( $old, $new, $options = false )
251 {
252 $diff = new eZDiff();
253 $diff->setDiffEngineType( $diff->engineType( 'text' ) );
254 $diff->initDiffEngine();
255 $diffObject = $diff->diff( $old->content(), $new->content() );
256 return $diffObject;
257 }
258
259 function supportsBatchInitializeObjectAttribute()
260 {
261 return true;
262 }
263
264 public $Attributes;
265 }
266
267 eZDataType::register( eZTextType::DATA_TYPE_STRING, "eZTextType" );
268
269 ?>
eZDataType
Base class for content datatypes.
Definition: ezdatatype.php:46
eZDataType\register
static register( $dataTypeString, $className)
Definition: ezdatatype.php:203
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZInputValidator\STATE_INVALID
const STATE_INVALID
Definition: ezinputvalidator.php:81
eZTextType
Stores a text area value.
Definition: eztexttype.php:19
eZTextType\isInformationCollector
isInformationCollector()
Definition: eztexttype.php:229
eZTextType\fetchCollectionAttributeHTTPInput
fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute)
Definition: eztexttype.php:129
eZTextType\diff
diff( $old, $new, $options=false)
Definition: eztexttype.php:250
eZTextType\initializeClassAttribute
initializeClassAttribute( $classAttribute)
Definition: eztexttype.php:34
eZTextType\validateObjectAttributeHTTPInput
validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: eztexttype.php:63
eZTextType\validateCollectionAttributeHTTPInput
validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: eztexttype.php:90
eZTextType\initializeObjectAttribute
initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute)
Definition: eztexttype.php:44
eZTextType\metaData
metaData( $contentObjectAttribute)
Definition: eztexttype.php:192
eZTextType\title
title( $data_instance, $name=null)
Definition: eztexttype.php:219
eZTextType\isIndexable
isIndexable()
Definition: eztexttype.php:224
eZTextType\fromString
fromString( $contentObjectAttribute, $string)
Definition: eztexttype.php:206
eZTextType\unserializeContentClassAttribute
unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: eztexttype.php:244
eZTextType\isSimpleStringInsertionSupported
isSimpleStringInsertionSupported()
Definition: eztexttype.php:150
eZTextType\__construct
__construct()
Definition: eztexttype.php:24
eZTextType\hasObjectAttributeContent
hasObjectAttributeContent( $contentObjectAttribute)
Definition: eztexttype.php:211
eZTextType\objectAttributeContent
objectAttributeContent( $contentObjectAttribute)
Definition: eztexttype.php:172
eZTextType\storeObjectAttribute
storeObjectAttribute( $attribute)
Definition: eztexttype.php:143
eZTextType\COLS_FIELD
const COLS_FIELD
Definition: eztexttype.php:21
eZTextType\supportsBatchInitializeObjectAttribute
supportsBatchInitializeObjectAttribute()
Definition: eztexttype.php:259
eZTextType\fetchClassAttributeHTTPInput
fetchClassAttributeHTTPInput( $http, $base, $classAttribute)
Definition: eztexttype.php:177
eZTextType\COLS_VARIABLE
const COLS_VARIABLE
Definition: eztexttype.php:22
eZTextType\toString
toString( $contentObjectAttribute)
Definition: eztexttype.php:201
eZTextType\$Attributes
$Attributes
Definition: eztexttype.php:264
eZTextType\DATA_TYPE_STRING
const DATA_TYPE_STRING
Definition: eztexttype.php:20
eZTextType\fetchObjectAttributeHTTPInput
fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: eztexttype.php:115
eZTextType\insertSimpleString
insertSimpleString( $object, $objectVersion, $objectLanguage, $objectAttribute, $string, &$result)
Definition: eztexttype.php:158
eZTextType\serializeContentClassAttribute
serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: eztexttype.php:234
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.