| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZTextType class 4 // 5 // Created on: <06-May-2002 20:02:55 bf> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! 30 \class eZTextType eztexttype.php 31 \ingroup eZDatatype 32 \brief Stores a text area value 33 34 */ 35 36 include_once ( "kernel/classes/ezdatatype.php" ); 37 38 define( "EZ_DATATYPESTRING_TEXT", "eztext" ); 39 define( 'EZ_DATATYPESTRING_TEXT_COLS_FIELD', 'data_int1' ); 40 define( 'EZ_DATATYPESTRING_TEXT_COLS_VARIABLE', '_eztext_cols_' ); 41 42 class eZTextType extends eZDataType 43 { 44 function eZTextType() 45 { 46 $this->eZDataType( EZ_DATATYPESTRING_TEXT, ezi18n( 'kernel/classes/datatypes', "Text block", 'Datatype name' ), 47 array( 'serialize_supported' => true, 48 'object_serialize_map' => array( 'data_text' => 'text' ) ) ); 49 } 50 51 /*! 52 Set class attribute value for template version 53 */ 54 function initializeClassAttribute( &$classAttribute ) 55 { 56 if ( $classAttribute->attribute( EZ_DATATYPESTRING_TEXT_COLS_FIELD ) == null ) 57 $classAttribute->setAttribute( EZ_DATATYPESTRING_TEXT_COLS_FIELD, 10 ); 58 $classAttribute->store(); 59 } 60 61 /*! 62 Sets the default value. 63 */ 64 function initializeObjectAttribute( &$contentObjectAttribute, $currentVersion, &$originalContentObjectAttribute ) 65 { 66 if ( $currentVersion != false ) 67 { 68 $dataText = $originalContentObjectAttribute->attribute( "data_text" ); 69 $contentObjectAttribute->setAttribute( "data_text", $dataText ); 70 } 71 $contentClassAttribute =& $contentObjectAttribute->contentClassAttribute(); 72 if ( $contentClassAttribute->attribute( "data_int1" ) == 0 ) 73 { 74 $contentClassAttribute->setAttribute( "data_int1", 10 ); 75 $contentClassAttribute->store(); 76 } 77 } 78 79 /*! 80 Validates the input and returns true if the input was 81 valid for this datatype. 82 */ 83 function validateObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 84 { 85 if ( $http->hasPostVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) ) 86 { 87 $data = $http->postVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ); 88 $classAttribute =& $contentObjectAttribute->contentClassAttribute(); 89 90 if ( $data == "" ) 91 { 92 if ( !$classAttribute->attribute( 'is_information_collector' ) and 93 $contentObjectAttribute->validateIsRequired() ) 94 { 95 $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes', 96 'Input required.' ) ); 97 return EZ_INPUT_VALIDATOR_STATE_INVALID; 98 } 99 } 100 } 101 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; 102 } 103 104 /*! 105 */ 106 function validateCollectionAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 107 { 108 if ( $http->hasPostVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) ) 109 { 110 $data = $http->postVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ); 111 $classAttribute =& $contentObjectAttribute->contentClassAttribute(); 112 113 if ( $data == "" ) 114 { 115 if ( $contentObjectAttribute->validateIsRequired() ) 116 { 117 $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes', 118 'Input required.' ) ); 119 return EZ_INPUT_VALIDATOR_STATE_INVALID; 120 } 121 } 122 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; 123 } 124 else 125 return EZ_INPUT_VALIDATOR_STATE_INVALID; 126 } 127 128 /*! 129 Fetches the http post var string input and stores it in the data instance. 130 */ 131 function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 132 { 133 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) ) 134 { 135 $data = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ); 136 $contentObjectAttribute->setAttribute( "data_text", $data ); 137 return true; 138 } 139 return false; 140 } 141 142 /*! 143 Fetches the http post variables for collected information 144 */ 145 function fetchCollectionAttributeHTTPInput( &$collection, &$collectionAttribute, &$http, $base, &$contentObjectAttribute ) 146 { 147 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) ) 148 { 149 $dataText = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ); 150 $collectionAttribute->setAttribute( 'data_text', $dataText ); 151 return true; 152 } 153 return false; 154 } 155 156 /*! 157 Store the content. 158 */ 159 function storeObjectAttribute( &$attribute ) 160 { 161 } 162 163 /*! 164 \reimp 165 Simple string insertion is supported. 166 */ 167 function isSimpleStringInsertionSupported() 168 { 169 return true; 170 } 171 172 /*! 173 \reimp 174 Inserts the string \a $string in the \c 'data_text' database field. 175 */ 176 function insertSimpleString( &$object, $objectVersion, $objectLanguage, 177 &$objectAttribute, $string, 178 &$result ) 179 { 180 $result = array( 'errors' => array(), 181 'require_storage' => true ); 182 $objectAttribute->setContent( $string ); 183 $objectAttribute->setAttribute( 'data_text', $string ); 184 return true; 185 } 186 187 /*! 188 Returns the content. 189 */ 190 function &objectAttributeContent( &$contentObjectAttribute ) 191 { 192 return $contentObjectAttribute->attribute( "data_text" ); 193 } 194 195 function fetchClassAttributeHTTPInput( &$http, $base, &$classAttribute ) 196 { 197 $column = $base .EZ_DATATYPESTRING_TEXT_COLS_VARIABLE . $classAttribute->attribute( 'id' ); 198 if ( $http->hasPostVariable( $column ) ) 199 { 200 $columnValue = $http->postVariable( $column ); 201 $classAttribute->setAttribute( EZ_DATATYPESTRING_TEXT_COLS_FIELD, $columnValue ); 202 return true; 203 } 204 return false; 205 } 206 207 /*! 208 Returns the meta data used for storing search indeces. 209 */ 210 function metaData( $contentObjectAttribute ) 211 { 212 return $contentObjectAttribute->attribute( "data_text" ); 213 } 214 215 /*! 216 \return string representation of an contentobjectattribute data for simplified export 217 218 */ 219 function toString( $contentObjectAttribute ) 220 { 221 return $contentObjectAttribute->attribute( 'data_text' ); 222 } 223 224 function fromString( &$contentObjectAttribute, $string ) 225 { 226 return $contentObjectAttribute->setAttribute( 'data_text', $string ); 227 } 228 229 function hasObjectAttributeContent( &$contentObjectAttribute ) 230 { 231 return trim( $contentObjectAttribute->attribute( 'data_text' ) ) != ''; 232 } 233 234 /*! 235 Returns the text. 236 */ 237 function title( &$data_instance ) 238 { 239 return $data_instance->attribute( "data_text" ); 240 } 241 242 /*! 243 \reimp 244 */ 245 function isIndexable() 246 { 247 return true; 248 } 249 250 /*! 251 \reimp 252 */ 253 function isInformationCollector() 254 { 255 return true; 256 } 257 258 /*! 259 \reimp 260 */ 261 function serializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode ) 262 { 263 $textColumns = $classAttribute->attribute( EZ_DATATYPESTRING_TEXT_COLS_FIELD ); 264 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'text-column-count', $textColumns ) ); 265 } 266 267 /*! 268 \reimp 269 */ 270 function unserializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode ) 271 { 272 $textColumns = $attributeParametersNode->elementTextContentByName( 'text-column-count' ); 273 $classAttribute->setAttribute( EZ_DATATYPESTRING_TEXT_COLS_FIELD, $textColumns ); 274 } 275 276 /*! 277 \reimp 278 */ 279 function diff( $old, $new, $options = false ) 280 { 281 include_once ( 'lib/ezdiff/classes/ezdiff.php' ); 282 $diff = new eZDiff(); 283 $diff->setDiffEngineType( $diff->engineType( 'text' ) ); 284 $diff->initDiffEngine(); 285 $diffObject = $diff->diff( $old->content(), $new->content() ); 286 return $diffObject; 287 } 288 289 } 290 291 eZDataType::register( EZ_DATATYPESTRING_TEXT, "eztexttype" ); 292 293 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |