00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 include_once( 'kernel/classes/ezdatatype.php' );
00040 include_once( 'lib/ezutils/classes/ezintegervalidator.php' );
00041 include_once( 'kernel/common/i18n.php' );
00042
00043 define( 'EZ_DATATYPESTRING_INISETTING', 'ezinisetting' );
00044
00045 define( 'EZ_DATATYPEINISETTING_CLASS_TYPE', '_ezinisetting_type_' );
00046 define( 'EZ_DATATYPEINISETTING_CLASS_FILE', '_ezinisetting_file_' );
00047 define( 'EZ_DATATYPEINISETTING_CLASS_SECTION', '_ezinisetting_section_' );
00048 define( 'EZ_DATATYPEINISETTING_CLASS_PARAMETER', '_ezinisetting_parameter_' );
00049 define( 'EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE', '_ezinisetting_ini_instance_' );
00050
00051 define( 'EZ_DATATYPEINISETTING_CLASS_FILE_FIELD', 'data_text1' );
00052 define( 'EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD', 'data_text2' );
00053 define( 'EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD', 'data_text3' );
00054 define( 'EZ_DATATYPEINISETTING_CLASS_TYPE_FIELD', 'data_int1' );
00055 define( 'EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD', 'data_text4' );
00056 define( 'EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD', 'data_text5' );
00057
00058 define( 'EZ_DATATYPEINISETTING_CLASS_TYPE_ARRAY', 6 );
00059
00060 class eZIniSettingType extends eZDataType
00061 {
00062
00063
00064
00065 function eZIniSettingType()
00066 {
00067 $this->eZDataType( EZ_DATATYPESTRING_INISETTING, ezi18n( 'kernel/classes/datatypes', 'Ini Setting', 'Datatype name' ),
00068 array( 'translation_allowed' => false,
00069 'serialize_supported' => true ) );
00070 }
00071
00072
00073
00074
00075 function validateObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute )
00076 {
00077 if ( $http->hasPostVariable( $base . '_ini_setting_' . $contentObjectAttribute->attribute( 'id' ) ) )
00078 {
00079 $contentClassAttribute =& $contentObjectAttribute->attribute( 'contentclass_attribute' );
00080 $iniFile =& eZIniSettingType::iniFile( $contentClassAttribute );
00081 $iniSection =& eZIniSettingType::iniSection( $contentClassAttribute );
00082 $iniParameterName =& eZIniSettingType::iniParameterName( $contentClassAttribute );
00083
00084 $config =& eZINI::instance( $iniFile );
00085 if ( $config == null )
00086 {
00087 $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
00088 'Could not locate the ini file.' ) );
00089 return EZ_INPUT_VALIDATOR_STATE_INVALID;
00090 }
00091
00092 if ( $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_TYPE_FIELD ) == EZ_DATATYPEINISETTING_CLASS_TYPE_ARRAY )
00093 {
00094 $iniArray = array();
00095
00096 if ( eZIniSettingType::parseArrayInput( $http->postVariable( $base . '_ini_setting_' . $contentObjectAttribute->attribute( 'id' ) ), $iniArray ) === false )
00097 {
00098 $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes', 'Wrong text field value.' ) );
00099
00100 return EZ_INPUT_VALIDATOR_STATE_INVALID;
00101 }
00102 }
00103 }
00104 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
00105 }
00106
00107
00108
00109
00110 function validateClassAttributeHTTPInput( &$http, $base, &$classAttribute )
00111 {
00112 $fileParam = $base . EZ_DATATYPEINISETTING_CLASS_FILE . $classAttribute->attribute( 'id' );
00113 $sectionParam = $base . EZ_DATATYPEINISETTING_CLASS_SECTION . $classAttribute->attribute( 'id' );
00114 $parameterParam = $base . EZ_DATATYPEINISETTING_CLASS_PARAMETER . $classAttribute->attribute( 'id' );
00115 $typeParam = $base . EZ_DATATYPEINISETTING_CLASS_TYPE . $classAttribute->attribute( 'id' );
00116 $iniInstanceParam = $base . EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE . $classAttribute->attribute( 'id' );
00117
00118 if ( $http->hasPostVariable( $fileParam ) &&
00119 $http->hasPostVariable( $sectionParam ) &&
00120 $http->hasPostVariable( $parameterParam ) &&
00121 $http->hasPostVariable( $typeParam ) &&
00122 $http->hasPostVariable( $iniInstanceParam ) )
00123 {
00124 $iniFile = $http->postVariable( $fileParam );
00125 $iniSection = $http->postVariable( $sectionParam );
00126
00127 $config =& eZIni::instance( $iniFile );
00128 if ( $config == null )
00129 {
00130 return EZ_INPUT_VALIDATOR_STATE_INVALID;
00131 }
00132
00133 if ( !$config->hasGroup( $iniSection ) )
00134 {
00135 return EZ_INPUT_VALIDATOR_STATE_INVALID;
00136 }
00137 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
00138 }
00139
00140 eZDebug::writeNotice( 'Could not validate parameters: ' . "\n" .
00141 $fileParam . ': ' . $http->postVariable( $fileParam ) . "\n" .
00142 $sectionParam . ': ' . $http->postVariable( $sectionParam ) . "\n" .
00143 $parameterParam . ': ' . $http->postVariable( $parameterParam ) . "\n" .
00144 $typeParam . ': ' . $http->postVariable( $typeParam ). "\n" .
00145 $iniInstanceParam. ': '. $http->postVariable( $iniInstanceParam ), 'eZIniSettingType::validateClassAttributeHTTPInput',
00146 'eZIniSettingType::validateClassAttributeHTTPInput' );
00147 return EZ_INPUT_VALIDATOR_STATE_INVALID;
00148 }
00149
00150
00151
00152
00153 function initializeClassAttribute( &$classAttribute )
00154 {
00155 eZIniSettingType::setSiteAccessList( $classAttribute );
00156 }
00157
00158
00159
00160
00161 function initializeObjectAttribute( &$objectAttribute, $currentVersion, &$originalContentObjectAttribute )
00162 {
00163 if ( $currentVersion != false )
00164 {
00165 $objectAttribute->setAttribute( 'data_text', $originalContentObjectAttribute->attribute( 'data_text' ) );
00166 }
00167 else
00168 {
00169 $contentClassAttribute =& $objectAttribute->attribute( 'contentclass_attribute' );
00170 $iniInstanceArray = explode( ';', $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD ) );
00171 $siteAccessArray = explode( ';', $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD ) );
00172 $filename =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD );
00173 $section =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD );
00174 $parameter =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD );
00175
00176 if ( ! in_array( 0, $iniInstanceArray ) )
00177 array_unshift( $iniInstanceArray, 0 );
00178 array_unshift( $iniInstanceArray, -1 );
00179
00180 $configArray = array();
00181
00182 foreach ( $iniInstanceArray as $iniInstance )
00183 {
00184 if ( $iniInstance == -1 )
00185 $path = 'settings';
00186 else if ( $iniInstance == 0 )
00187 $path = 'settings/override';
00188 else
00189 $path = 'settings/siteaccess/' . $siteAccessArray[$iniInstance];
00190
00191 if ( !eZINI::parameterSet( $filename, $path, $section, $parameter ) )
00192 continue;
00193
00194 $config =& eZINI::instance( $filename, $path, null, null, null, true );
00195
00196 $configValue = $config->variable( $section, $parameter );
00197
00198 if ( is_array( $configValue ) )
00199 {
00200 foreach ( array_keys( $configValue ) as $key )
00201 {
00202 $configArray[$key] = $configValue[$key];
00203 }
00204 }
00205 else
00206 {
00207 $objectAttribute->setAttribute( 'data_text', $configValue );
00208 eZDebug::writeNotice( 'Loaded following values from ' . $path . '/' . $filename . ":\n" .
00209 ' ' . $configValue,
00210 'eZIniSettingType::initializeObjectAttribute');
00211 }
00212 }
00213
00214 if ( count( $configArray ) > 0 )
00215 {
00216 $data = '';
00217 foreach( array_keys( $configArray ) as $key )
00218 {
00219 if ( is_int( $key ) )
00220 {
00221 $data .= '=' . $configArray[$key] . "\n" ;
00222 }
00223 else
00224 {
00225 $data .= $key . '=' . $configArray[$key] . "\n" ;
00226 }
00227 }
00228 $objectAttribute->setAttribute( 'data_text', $data );
00229 }
00230 }
00231 }
00232
00233
00234
00235
00236 function fetchClassAttributeHTTPInput( &$http, $base, &$classAttribute )
00237 {
00238 $fileParam = $base . EZ_DATATYPEINISETTING_CLASS_FILE . $classAttribute->attribute( 'id' );
00239 $sectionParam = $base . EZ_DATATYPEINISETTING_CLASS_SECTION . $classAttribute->attribute( 'id' );
00240 $paramParam = $base . EZ_DATATYPEINISETTING_CLASS_PARAMETER . $classAttribute->attribute( 'id' );
00241 $typeParam = $base . EZ_DATATYPEINISETTING_CLASS_TYPE . $classAttribute->attribute( 'id' );
00242 $iniInstanceParam = $base . EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE . $classAttribute->attribute( 'id' );
00243
00244 if ( $http->hasPostVariable( $fileParam ) &&
00245 $http->hasPostVariable( $sectionParam ) &&
00246 $http->hasPostVariable( $paramParam ) &&
00247 $http->hasPostVariable( $typeParam ) &&
00248 $http->hasPostVariable( $iniInstanceParam ) )
00249 {
00250 $file = $http->postVariable( $fileParam );
00251 $section = $http->postVariable( $sectionParam );
00252 $parameter = $http->postVariable( $paramParam );
00253 $type = $http->postVariable( $typeParam );
00254
00255 $iniInstanceArray = $http->postVariable( $iniInstanceParam );
00256 if ( is_array( $iniInstanceArray ) )
00257 {
00258 $iniInstance = '';
00259 foreach ( $iniInstanceArray as $idx => $instance )
00260 {
00261 if ( $idx > 0 )
00262 $iniInstance .= ';';
00263 $iniInstance .= $instance;
00264 }
00265 }
00266 else
00267 {
00268 $iniInstance = $iniInstanceArray;
00269 }
00270
00271 eZIniSettingType::setSiteAccessList( $classAttribute );
00272 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD, $file );
00273 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD, $section );
00274 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD, $parameter );
00275 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_TYPE_FIELD, $type );
00276 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD, $iniInstance );
00277
00278 return true;
00279 }
00280 return false;
00281 }
00282
00283
00284
00285
00286 function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute )
00287 {
00288 if ( $http->hasPostVariable( $base . '_ini_setting_' . $contentObjectAttribute->attribute( "id" ) ) )
00289 {
00290 $data = $http->postVariable( $base . '_ini_setting_' . $contentObjectAttribute->attribute( "id" ) );
00291 $contentObjectAttribute->setAttribute( 'data_text', trim( $data ) );
00292 if ( $http->hasPostVariable( $base . '_ini_setting_make_empty_array_' . $contentObjectAttribute->attribute( "id" ) ) )
00293 {
00294 $isChecked = $http->postVariable( $base . '_ini_setting_make_empty_array_' . $contentObjectAttribute->attribute( "id" ) );
00295 if ( isset( $isChecked ) )
00296 $isChecked = 1;
00297 $contentObjectAttribute->setAttribute( 'data_int', $isChecked );
00298 }
00299 else
00300 {
00301 $contentObjectAttribute->setAttribute( 'data_int', 0 );
00302 }
00303 return true;
00304 }
00305 return false;
00306 }
00307
00308
00309
00310
00311 function onPublish( &$contentObjectAttribute, &$contentObject, &$publishedNodes )
00312 {
00313 $contentClassAttribute =& $contentObjectAttribute->attribute( 'contentclass_attribute' );
00314 $section =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD );
00315 $parameter =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD );
00316 $iniInstanceArray = explode( ';', $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD ) );
00317 $siteAccessArray = explode( ';', $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD ) );
00318 $filename =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD );
00319 $makeEmptyArray = $contentObjectAttribute->attribute( 'data_int' );
00320
00321 foreach ( $iniInstanceArray as $iniInstance )
00322 {
00323 if ( $iniInstance == 0 )
00324 $path = 'settings/override';
00325 else
00326 $path = 'settings/siteaccess/' . $siteAccessArray[$iniInstance];
00327
00328 $config =& eZINI::instance( $filename . '.append', $path, null, false, null, true, true );
00329
00330 if ( $config == null )
00331 {
00332 eZDebug::writeError( 'Could not open ' . $path . '/' . $filename );
00333 continue;
00334 }
00335 if ( $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_TYPE_FIELD ) == EZ_DATATYPEINISETTING_CLASS_TYPE_ARRAY )
00336 {
00337 if ( $contentObjectAttribute->attribute( 'data_text' ) != null )
00338 {
00339 $iniArray = array();
00340 eZIniSettingType::parseArrayInput( $contentObjectAttribute->attribute( 'data_text' ), $iniArray, $makeEmptyArray );
00341 $config->setVariable( $section, $parameter, $iniArray );
00342 }
00343 else
00344 {
00345 $config->removeSetting( $section, $parameter );
00346 }
00347 }
00348 else
00349 {
00350 $config->setVariable( $section, $parameter, $contentObjectAttribute->attribute( 'data_text' ) );
00351 eZDebug::writeNotice( 'Saved ini settings to file: ' . $path . '/' . $filename . "\n" .
00352 ' ['. $section . ']' . "\n" .
00353 ' ' . $parameter . '=' . $contentObjectAttribute->attribute( 'data_text' ),
00354 'eZIniSettingType::onPublish' );
00355 }
00356 $config->save();
00357 }
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 function parseArrayInput( $inputText, &$outputArray, $makeEmptyArray = false )
00370 {
00371 $lineArray = explode( "\n", $inputText );
00372
00373 if( $makeEmptyArray )
00374 {
00375 $outputArray[] = "";
00376 }
00377
00378 foreach ( array_keys( $lineArray ) as $key )
00379 {
00380 $line = str_replace( "\r", '', $lineArray[$key] );
00381
00382 if ( strlen( $line ) <= 2 )
00383 continue;
00384
00385 if ( strstr( $line, '=' ) === false )
00386 return false;
00387
00388 $lineElements = explode( '=', $line );
00389 if ( count( $lineElements ) == 1 )
00390 {
00391 $outputArray[] = $lineElements[0];
00392 }
00393 else
00394 {
00395 if ( $lineElements[0] != '' )
00396 {
00397 $outputArray[ $lineElements[0] ] = implode( '=', array_slice( $lineElements, 1 ) );
00398 }
00399 else
00400 $outputArray[] = implode( '=', array_slice( $lineElements, 1 ) );
00401 }
00402 }
00403 return true;
00404 }
00405
00406
00407
00408
00409 function &objectAttributeContent( &$contentObjectAttribute )
00410 {
00411 $contentClassAttribute =& $contentObjectAttribute->attribute( 'contentclass_attribute' );
00412 $section =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD );
00413 $parameter =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD );
00414
00415 $iniInstanceArray = explode( ';', $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD ) );
00416 $siteAccessArray = explode( ';', $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD ) );
00417 $filename =& $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD );
00418
00419 $modified = array();
00420
00421 $contentObject =& $contentObjectAttribute->attribute( 'object' );
00422 foreach ( $iniInstanceArray as $iniInstance )
00423 {
00424 if ( $iniInstance == 0 )
00425 $path = 'settings/override';
00426 else
00427 $path = 'settings/siteaccess/' . $siteAccessArray[$iniInstance];
00428
00429 if ( !eZINI::parameterSet( $filename, $path, $section, $parameter ) )
00430 continue;
00431
00432 $config =& eZINI::instance( $filename, $path, null, null, null, true );
00433
00434 if ( is_array( $config->variable( $section, $parameter ) ) )
00435 {
00436 $objectIniArray = array();
00437 eZIniSettingType::parseArrayInput( $contentObjectAttribute->attribute( 'data_text' ), $objectIniArray );
00438 $existingIniArray = $config->variable( $section, $parameter );
00439 foreach ( array_keys( $existingIniArray ) as $key )
00440 {
00441 if ( !is_int( $key ) && $existingIniArray[$key] != $objectIniArray[$key] )
00442 {
00443 $modified[] = array( 'ini_value' => $parameter . '[' . $key . ']=' . $existingIniArray[$key],
00444 'file' => $path . '/' . $filename );
00445 }
00446 }
00447 }
00448 else if ( $config->variable( $section, $parameter ) != $contentObjectAttribute->attribute( 'data_text' ) )
00449 {
00450 $modified[] = array( 'ini_value' => $parameter . '=' . $config->variable( $section, $parameter ),
00451 'file' => $path . '/' . $filename );
00452 }
00453 }
00454
00455 $data = array( 'data' => $contentObjectAttribute->attribute( 'data_text' ),
00456 'modified' => $modified );
00457 return $data;
00458 }
00459
00460
00461
00462
00463 function title( &$contentObjectAttribute )
00464 {
00465 return $contentObjectAttribute->attribute( 'data_text' );
00466 }
00467
00468 function hasObjectAttributeContent( &$contentObjectAttribute )
00469 {
00470 return true;
00471 }
00472
00473
00474
00475
00476 function serializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode )
00477 {
00478 include_once( 'lib/ezxml/classes/ezdomdocument.php' );
00479
00480 $file =& $classAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD );
00481 $section =& $classAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD );
00482 $parameter =& $classAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD );
00483 $type =& $classAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_TYPE_FIELD );
00484 $iniInstance =& $classAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD );
00485 $siteAccess =& $classAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD );
00486
00487 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'file', $file ) );
00488 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'section', $section ) );
00489 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'parameter', $parameter ) );
00490 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'type', $type ) );
00491 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'ini_instance', $iniInstance ) );
00492 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'site_access_list', $siteAccess ) );
00493 }
00494
00495
00496
00497
00498
00499
00500 function unserializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode )
00501 {
00502 $file = $attributeParametersNode->elementTextContentByName( 'file' );
00503 $section = $attributeParametersNode->elementTextContentByName( 'section' );
00504 $parameter = $attributeParametersNode->elementTextContentByName( 'parameter' );
00505 $type = $attributeParametersNode->elementTextContentByName( 'type' );
00506
00507 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD, $file );
00508 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD, $section );
00509 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD, $parameter );
00510 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_TYPE_FIELD, $type );
00511
00512
00513
00514 $remoteIniInstanceList = $attributeParametersNode->elementTextContentByName( 'ini_instance' );
00515 $remoteSiteAccessList = $attributeParametersNode->elementTextContentByName( 'site_access_list' );
00516 $remoteIniInstanceArray = explode( ';', $remoteIniInstanceList );
00517 $remoteSiteAccessArray = explode( ';', $remoteSiteAccessList );
00518
00519 $config =& eZINI::instance( 'site.ini' );
00520 $localSiteAccessArray = array_merge( array( 'override' ), $config->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' ) );
00521
00522 $localIniInstanceArray = array();
00523 foreach ( $remoteIniInstanceArray as $remoteIniInstance )
00524 {
00525 if ( isset( $remoteSiteAccessArray[$remoteIniInstance] ) and in_array( $remoteSiteAccessArray[$remoteIniInstance], $localSiteAccessArray ) )
00526 {
00527 $localSiteAccessArray[] = array_keys( $localSiteAccessArray, $remoteSiteAccessArray[$remoteIniInstance] );
00528 }
00529 }
00530
00531 if ( count( $localSiteAccessArray ) == 0 )
00532 {
00533 $localIniInstanceArray = array( 0 );
00534 }
00535
00536 $iniInstance = '';
00537 foreach( $localIniInstanceArray as $idx => $localIniInstance )
00538 {
00539 if ( $idx > 0 )
00540 $iniInstance .= ';';
00541 $iniInstance .= $localIniInstance;
00542 }
00543
00544 $siteAccess = '';
00545 foreach( $localSiteAccessArray as $idx => $localSiteAccess )
00546 {
00547 if ( $idx > 0 )
00548 $siteAccess .= ';';
00549 $siteAccess .= $localSiteAccess;
00550 }
00551
00552 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_INI_INSTANCE_FIELD, $iniInstance );
00553 $classAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD, $siteAccess );
00554 }
00555
00556
00557
00558
00559
00560
00561
00562
00563 function &iniParameterName( &$contentClassAttribute )
00564 {
00565 return $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_PARAMETER_FIELD );
00566 }
00567
00568
00569
00570
00571
00572
00573
00574 function &iniFile( &$contentClassAttribute )
00575 {
00576 return $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_FILE_FIELD );
00577 }
00578
00579
00580
00581
00582
00583
00584
00585 function &iniSection( &$contentClassAttribute )
00586 {
00587 return $contentClassAttribute->attribute( EZ_DATATYPEINISETTING_CLASS_SECTION_FIELD );
00588 }
00589
00590
00591
00592
00593
00594
00595
00596
00597 function setSiteAccessList( &$contentClassAttribute )
00598 {
00599 $config =& eZINI::instance( 'site.ini' );
00600 $siteAccessArray = $config->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' );
00601 $siteAccessList = 'override';
00602 foreach ( $siteAccessArray as $idx => $siteAccess )
00603 {
00604 $siteAccessList .= ';' . $siteAccess;
00605 }
00606
00607 $contentClassAttribute->setAttribute( EZ_DATATYPEINISETTING_CLASS_SITE_ACCESS_LIST_FIELD, $siteAccessList );
00608 }
00609
00610 function toString( $contentObjectAttribute )
00611 {
00612 $makeEmptyArray = $contentObjectAttribute->attribute( 'data_int' );
00613 $value = $contentObjectAttribute->attribute( 'data_text' );
00614 return implode( '|', array( $value, $makeEmptyArray ) );
00615 }
00616
00617
00618 function fromString( &$contentObjectAttribute, $string )
00619 {
00620 if ( $string == '' )
00621 return true;
00622 $iniData = explode( '|', $string );
00623
00624 $contentObjectAttribute->setAttribute( 'data_text', $value );
00625 if ( isset ( $iniData[1] ) )
00626 $contentObjectAttribute->setAttribute( 'data_int', $makeEmptyArray );
00627 return true;
00628 }
00629
00630
00631
00632
00633 function serializeContentObjectAttribute( &$package, &$objectAttribute )
00634 {
00635 $node = $this->createContentObjectAttributeDOMNode( $objectAttribute );
00636 $makeEmptyArray = $objectAttribute->attribute( 'data_int' );
00637 $value = $objectAttribute->attribute( 'data_text' );
00638
00639 $node->appendChild( eZDOMDocument::createElementTextNode( 'make_empty_array', $makeEmptyArray ) );
00640 $node->appendChild( eZDOMDocument::createElementTextNode( 'value', $value ) );
00641
00642 return $node;
00643 }
00644
00645
00646
00647
00648 function unserializeContentObjectAttribute( &$package, &$objectAttribute, $attributeNode )
00649 {
00650 $makeEmptyArray = $attributeNode->elementTextContentByName( 'make_empty_array' );
00651 $value = $attributeNode->elementTextContentByName( 'value' );
00652
00653 if ( $makeEmptyArray === false )
00654 $makeEmptyArray = 0;
00655
00656 if ( $value === false )
00657 $value = '';
00658
00659 $objectAttribute->setAttribute( 'data_int', $makeEmptyArray );
00660 $objectAttribute->setAttribute( 'data_text', $value );
00661 }
00662
00663
00664
00665
00666 function diff( $old, $new, $options = false )
00667 {
00668 return null;
00669 }
00670 }
00671
00672 eZDataType::register( EZ_DATATYPESTRING_INISETTING, 'ezinisettingtype' );
00673
00674 ?>