[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZBooleanType class 4 // 5 // Created on: <27-Jun-2002 18:24:54 sp> 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 eZBooleanType ezbooleantype.php 31 \ingroup eZDatatype 32 \brief Stores a boolean value 33 34 */ 35 36 include_once ( "kernel/classes/ezdatatype.php" ); 37 38 define( "EZ_DATATYPESTRING_BOOLEAN", "ezboolean" ); 39 40 class eZBooleanType extends eZDataType 41 { 42 function eZBooleanType() 43 { 44 $this->eZDataType( EZ_DATATYPESTRING_BOOLEAN, ezi18n( 'kernel/classes/datatypes', "Checkbox", 'Datatype name' ), 45 array( 'serialize_supported' => true, 46 'object_serialize_map' => array( 'data_int' => 'value' ) ) ); 47 } 48 49 /*! 50 Store content 51 */ 52 function storeObjectAttribute( &$attribute ) 53 { 54 } 55 56 57 /*! 58 Sets the default value. 59 */ 60 function initializeObjectAttribute( &$contentObjectAttribute, $currentVersion, &$originalContentObjectAttribute ) 61 { 62 if ( $currentVersion != false ) 63 { 64 $dataInt = $originalContentObjectAttribute->attribute( "data_int" ); 65 $contentObjectAttribute->setAttribute( "data_int", $dataInt ); 66 } 67 else 68 { 69 $contentClassAttribute =& $contentObjectAttribute->contentClassAttribute(); 70 $default = $contentClassAttribute->attribute( "data_int3" ); 71 $contentObjectAttribute->setAttribute( "data_int", $default ); 72 } 73 } 74 75 /*! 76 Validates the http post var boolean input. 77 */ 78 function validateObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 79 { 80 $classAttribute =& $contentObjectAttribute->contentClassAttribute(); 81 if ( $contentObjectAttribute->validateIsRequired() and 82 !$classAttribute->attribute( 'is_information_collector' ) ) 83 { 84 if ( $http->hasPostVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) ) ) 85 { 86 $data = $http->postVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) ); 87 if ( isset( $data ) ) 88 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; 89 } 90 else 91 { 92 $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes', 93 'Input required.' ) ); 94 return EZ_INPUT_VALIDATOR_STATE_INVALID; 95 } 96 } 97 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; 98 } 99 100 /*! 101 */ 102 function validateCollectionAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 103 { 104 if ( $contentObjectAttribute->validateIsRequired() ) 105 { 106 if ( $http->hasPostVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) ) ) 107 { 108 $data = $http->postVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) ); 109 if ( isset( $data ) ) 110 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; 111 } 112 else 113 { 114 $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes', 115 'Input required.' ) ); 116 return EZ_INPUT_VALIDATOR_STATE_INVALID; 117 } 118 } 119 } 120 121 /*! 122 Fetches the http post var boolean input and stores it in the data instance. 123 */ 124 function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 125 { 126 if ( $http->hasPostVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) )) 127 { 128 $data = $http->postVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) ); 129 if ( isset( $data ) && $data !== '0' && $data !== 'false' ) 130 $data = 1; 131 else 132 $data = 0; 133 } 134 else 135 { 136 $data = 0; 137 } 138 $contentObjectAttribute->setAttribute( "data_int", $data ); 139 return true; 140 } 141 142 /*! 143 \reimp 144 Fetches the http post variables for collected information 145 */ 146 function fetchCollectionAttributeHTTPInput( &$collection, &$collectionAttribute, &$http, $base, &$contentObjectAttribute ) 147 { 148 if ( $http->hasPostVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) )) 149 { 150 $data = $http->postVariable( $base . "_data_boolean_" . $contentObjectAttribute->attribute( "id" ) ); 151 if ( isset( $data ) && $data !== '0' && $data !== 'false' ) 152 $data = 1; 153 else 154 $data = 0; 155 } 156 else 157 { 158 $data = 0; 159 } 160 $collectionAttribute->setAttribute( 'data_int', $data ); 161 return true; 162 } 163 164 function fetchClassAttributeHTTPInput( &$http, $base, &$classAttribute ) 165 { 166 if ( $http->hasPostVariable( $base . '_ezboolean_default_value_' . $classAttribute->attribute( 'id' ) . '_exists' ) ) 167 { 168 if ( $http->hasPostVariable( $base . "_ezboolean_default_value_" . $classAttribute->attribute( "id" ) )) 169 { 170 $data = $http->postVariable( $base . "_ezboolean_default_value_" . $classAttribute->attribute( "id" ) ); 171 if ( isset( $data ) ) 172 $data = 1; 173 $classAttribute->setAttribute( "data_int3", $data ); 174 } 175 else 176 { 177 $classAttribute->setAttribute( "data_int3", 0 ); 178 } 179 } 180 return true; 181 } 182 183 function metaData( &$contentObjectAttribute ) 184 { 185 return $contentObjectAttribute->attribute( "data_int" ); 186 } 187 /*! 188 \return string representation of an contentobjectattribute data for simplified export 189 190 */ 191 function toString( $contentObjectAttribute ) 192 { 193 return $contentObjectAttribute->attribute( 'data_int' ); 194 } 195 196 function fromString( &$contentObjectAttribute, $string ) 197 { 198 return $contentObjectAttribute->setAttribute( 'data_int', $string ); 199 } 200 201 /*! 202 \reimp 203 */ 204 function isIndexable() 205 { 206 return true; 207 } 208 209 /*! 210 \reimp 211 */ 212 function isInformationCollector() 213 { 214 return true; 215 } 216 217 /*! 218 \reimp 219 */ 220 function sortKey( &$contentObjectAttribute ) 221 { 222 return $contentObjectAttribute->attribute( 'data_int' ); 223 } 224 225 /*! 226 \reimp 227 */ 228 function sortKeyType() 229 { 230 return 'int'; 231 } 232 233 /*! 234 Returns the content. 235 */ 236 function &objectAttributeContent( &$contentObjectAttribute ) 237 { 238 return $contentObjectAttribute->attribute( "data_int" ); 239 } 240 241 /*! 242 Returns the integer value. 243 */ 244 function title( &$contentObjectAttribute ) 245 { 246 return $contentObjectAttribute->attribute( "data_int" ); 247 } 248 249 function hasObjectAttributeContent( &$contentObjectAttribute ) 250 { 251 return true; 252 } 253 254 /*! 255 \reimp 256 */ 257 function serializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode ) 258 { 259 $defaultValue = $classAttribute->attribute( 'data_int3' ); 260 $attributeParametersNode->appendChild( eZDOMDocument::createElementNode( 'default-value', 261 array( 'is-set' => $defaultValue ? 'true' : 'false' ) ) ); 262 } 263 264 /*! 265 \reimp 266 */ 267 function unserializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode ) 268 { 269 $defaultValue = strtolower( $attributeParametersNode->elementTextContentByName( 'default-value' ) ) == 'true'; 270 $classAttribute->setAttribute( 'data_int3', $defaultValue ); 271 } 272 } 273 274 eZDataType::register( EZ_DATATYPESTRING_BOOLEAN, "ezbooleantype" ); 275 276 ?>
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 |