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
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 include_once( "kernel/classes/ezpersistentobject.php" );
00066 include_once( "lib/ezutils/classes/ezinputvalidator.php" );
00067
00068 class eZDataType
00069 {
00070
00071
00072
00073
00074 function eZDataType( $dataTypeString, $name, $properties = array() )
00075 {
00076 $this->DataTypeString = $dataTypeString;
00077 $this->Name = $name;
00078
00079 $translationAllowed = true;
00080 $serializeSupported = false;
00081 $objectSerializeMap = false;
00082 if ( isset( $properties['translation_allowed'] ) )
00083 $translationAllowed = $properties['translation_allowed'];
00084 if ( isset( $properties['serialize_supported'] ) )
00085 $serializeSupported = $properties['serialize_supported'];
00086 if ( isset( $properties['object_serialize_map'] ) )
00087 $objectSerializeMap = $properties['object_serialize_map'];
00088
00089 $this->Attributes = array();
00090 $this->Attributes["is_indexable"] = $this->isIndexable();
00091 $this->Attributes["is_information_collector"] = $this->isInformationCollector();
00092
00093 $this->Attributes["information"] = array( "string" => $this->DataTypeString,
00094 "name" => $this->Name );
00095 $this->Attributes["properties"] = array( "translation_allowed" => $translationAllowed,
00096 'serialize_supported' => $serializeSupported,
00097 'object_serialize_map' => $objectSerializeMap );
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 function &viewTemplate( &$contentobjectAttribute )
00109 {
00110 return $this->DataTypeString;
00111 }
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 function &editTemplate( &$contentobjectAttribute )
00122 {
00123 return $this->DataTypeString;
00124 }
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 function &informationTemplate( &$contentobjectAttribute )
00135 {
00136 return $this->DataTypeString;
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 function &resultTemplate( &$collectionAttribute )
00149 {
00150 return $this->DataTypeString;
00151 }
00152
00153
00154
00155
00156
00157
00158 function create( $dataTypeString )
00159 {
00160 $def = null;
00161 if ( !isset( $GLOBALS["eZDataTypes"][$dataTypeString] ) )
00162 {
00163 eZDataType::loadAndRegisterType( $dataTypeString );
00164 }
00165
00166 if ( isset( $GLOBALS['eZDataTypes'][$dataTypeString] ) )
00167 {
00168 $className = $GLOBALS['eZDataTypes'][$dataTypeString];
00169
00170 if ( !isset( $GLOBALS["eZDataTypeObjects"][$dataTypeString] ) ||
00171 get_class( $GLOBALS["eZDataTypeObjects"][$dataTypeString] ) != $className )
00172 {
00173 $GLOBALS["eZDataTypeObjects"][$dataTypeString] = new $className();
00174 }
00175 return $GLOBALS["eZDataTypeObjects"][$dataTypeString];
00176 }
00177
00178 return null;
00179 }
00180
00181
00182
00183
00184
00185
00186 function ®isteredDataTypes()
00187 {
00188 $types =& $GLOBALS["eZDataTypes"];
00189 $type_objects =& $GLOBALS["eZDataTypeObjects"];
00190 if ( isset( $types ) )
00191 {
00192 foreach ( $types as $dataTypeString => $className )
00193 {
00194 $def =& $type_objects[$dataTypeString];
00195 if ( get_class( $def ) != $className )
00196 $def = new $className();
00197 }
00198 uasort( $type_objects,
00199 create_function( '$a, $b',
00200 'return strcmp( $a->Name, $b->Name);' ) );
00201 }
00202 return $type_objects;
00203 }
00204
00205
00206
00207
00208
00209
00210
00211 function register( $dataTypeString, $className )
00212 {
00213 $types =& $GLOBALS["eZDataTypes"];
00214 if ( !is_array( $types ) )
00215 $types = array();
00216 $types[$dataTypeString] = $className;
00217 }
00218
00219
00220
00221
00222 function isA()
00223 {
00224 return $this->Attributes["information"]["string"];
00225 }
00226
00227
00228
00229
00230 function attributes()
00231 {
00232 return array_keys( $this->Attributes );
00233 }
00234
00235
00236
00237
00238 function hasAttribute( $attr )
00239 {
00240 return isset( $this->Attributes[$attr] );
00241 }
00242
00243
00244
00245
00246 function &attribute( $attr )
00247 {
00248 if ( isset( $this->Attributes[$attr] ) )
00249 return $this->Attributes[$attr];
00250 else
00251 {
00252 eZDebug::writeError( "Attribute '$attr' does not exist", 'eZDataType::attribute' );
00253 $attributeData = null;
00254 return $attributeData;
00255 }
00256 }
00257
00258
00259
00260
00261
00262
00263 function isHTTPFileInsertionSupported()
00264 {
00265 return false;
00266 }
00267
00268
00269
00270
00271
00272
00273 function isRegularFileInsertionSupported()
00274 {
00275 return false;
00276 }
00277
00278
00279
00280
00281
00282
00283 function isSimpleStringInsertionSupported()
00284 {
00285 return false;
00286 }
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 function insertHTTPFile( &$object, $objectVersion, $objectLanguage,
00310 &$objectAttribute, &$httpFile, $mimeData,
00311 &$result )
00312 {
00313 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support insertion of HTTP files",
00314 'eZDataType::insertHTTPFile' );
00315 return null;
00316 }
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 function insertRegularFile( &$object, $objectVersion, $objectLanguage,
00338 &$objectAttribute, $filePath,
00339 &$result )
00340 {
00341 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support insertion of regular files",
00342 'eZDataType::insertRegularFile' );
00343 return null;
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 function insertSimpleString( &$object, $objectVersion, $objectLanguage,
00366 &$objectAttribute, $string,
00367 &$result )
00368 {
00369 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support insertion of simple strings",
00370 'eZDataType::insertSimplestring' );
00371 return null;
00372 }
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 function hasStoredFileInformation( &$object, $objectVersion, $objectLanguage,
00386 &$objectAttribute )
00387 {
00388 return false;
00389 }
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402 function handleDownload( &$object, $objectVersion, $objectLanguage,
00403 &$objectAttribute )
00404 {
00405 return false;
00406 }
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430 function storedFileInformation( &$object, $objectVersion, $objectLanguage,
00431 &$objectAttribute )
00432 {
00433 return false;
00434 }
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453 function productOptionInformation( &$objectAttribute, $optionID, &$productItem )
00454 {
00455 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support product options",
00456 'eZDataType::productOptionInformation' );
00457 return null;
00458 }
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 function objectDisplayInformation( &$objectAttribute, $mergeInfo = false )
00489 {
00490 $datatype = $objectAttribute->attribute( 'data_type_string' );
00491 $ini =& eZINI::instance( 'datatype.ini' );
00492 $editGrouped = in_array( $datatype, $ini->variable( 'EditSettings', 'GroupedInput' ) );
00493 $viewGrouped = in_array( $datatype, $ini->variable( 'ViewSettings', 'GroupedInput' ) );
00494 $resultGrouped = in_array( $datatype, $ini->variable( 'ResultSettings', 'GroupedInput' ) );
00495 $collectionGrouped = in_array( $datatype, $ini->variable( 'CollectionSettings', 'GroupedInput' ) );
00496
00497 $info = array( 'edit' => array( 'grouped_input' => false ),
00498 'view' => array( 'grouped_input' => false),
00499 'collection' => array( 'grouped_input' => false ),
00500 'result' => array( 'grouped_input' => false ) );
00501 $override = array();
00502 if ( $editGrouped )
00503 $override['edit']['grouped_input'] = true;
00504 if ( $collectionGrouped )
00505 $override['collection']['grouped_input'] = true;
00506 if ( $viewGrouped )
00507 $override['view']['grouped_input'] = true;
00508 if ( $resultGrouped )
00509 $override['result']['grouped_input'] = true;
00510
00511 if ( $mergeInfo )
00512 {
00513
00514 foreach ( array( 'edit', 'view', 'collection', 'result' ) as $view )
00515 {
00516 if ( isset( $mergeInfo[$view] ) )
00517 $info[$view] = array_merge( $info[$view], $mergeInfo[$view] );
00518 if ( isset( $override[$view] ) )
00519 $info[$view] = array_merge( $info[$view], $override[$view] );
00520 }
00521 }
00522 else
00523 {
00524
00525 foreach ( array( 'edit', 'view', 'collection', 'result' ) as $view )
00526 {
00527 if ( isset( $override[$view] ) )
00528 $info[$view] = array_merge( $info[$view], $override[$view] );
00529 }
00530 }
00531 return $info;
00532 }
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555 function &classDisplayInformation( &$classAttribute, $mergeInfo = false )
00556 {
00557 $datatype = $classAttribute->attribute( 'data_type_string' );
00558 $ini =& eZINI::instance( 'datatype.ini' );
00559 $editGrouped = in_array( $datatype, $ini->variable( 'ClassEditSettings', 'GroupedInput' ) );
00560
00561 $info = array( 'edit' => array( 'grouped_input' => false ),
00562 'view' => array() );
00563 $override = array();
00564 if ( $editGrouped )
00565 $override['edit']['grouped_input'] = true;
00566
00567 if ( $mergeInfo )
00568 {
00569
00570 foreach ( array( 'edit', 'view' ) as $view )
00571 {
00572 if ( isset( $mergeInfo[$view] ) )
00573 $info[$view] = array_merge( $info[$view], $mergeInfo[$view] );
00574 if ( isset( $override[$view] ) )
00575 $info[$view] = array_merge( $info[$view], $override[$view] );
00576 }
00577 }
00578 else
00579 {
00580
00581 foreach ( array( 'edit', 'view' ) as $view )
00582 {
00583 if ( isset( $override[$view] ) )
00584 $info[$view] = array_merge( $info[$view], $override[$view] );
00585 }
00586 }
00587 return $info;
00588 }
00589
00590
00591
00592
00593 function &objectAttributeContent( &$objectAttribute )
00594 {
00595 $retValue = '';
00596 return $retValue;
00597 }
00598
00599
00600
00601
00602 function hasObjectAttributeContent( &$contentObjectAttribute )
00603 {
00604 return false;
00605 }
00606
00607
00608
00609
00610 function &classAttributeContent( &$classAttribute )
00611 {
00612 $retValue = '';
00613 return $retValue;
00614 }
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 function storeObjectAttribute( &$objectAttribute )
00626 {
00627 }
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639 function onPublish( &$contentObjectAttribute, &$contentObject, &$publishedNodes )
00640 {
00641 }
00642
00643
00644
00645
00646
00647
00648
00649
00650 function preStoreClassAttribute( &$classAttribute, $version )
00651 {
00652 }
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667 function storeClassAttribute( &$classAttribute, $version )
00668 {
00669 }
00670
00671
00672
00673
00674
00675
00676 function storeDefinedClassAttribute( &$classAttribute )
00677 {
00678 }
00679
00680 function preStoreDefinedClassAttribute( &$classAttribute )
00681 {
00682 $this->preStoreClassAttribute( $classAttribute, $classAttribute->attribute( 'version' ) );
00683 }
00684
00685
00686
00687
00688
00689
00690 function validateClassAttributeHTTPInput( &$http, $base, &$classAttribute )
00691 {
00692 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
00693 }
00694
00695
00696
00697
00698
00699
00700 function fixupClassAttributeHTTPInput( &$http, $base, &$classAttribute )
00701 {
00702 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
00703 }
00704
00705
00706
00707
00708
00709 function fetchClassAttributeHTTPInput( &$http, $base, &$classAttribute )
00710 {
00711 }
00712
00713
00714
00715
00716
00717 function customClassAttributeHTTPAction( &$http, $action, &$classAttribute )
00718 {
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728 function fetchActionValue( $action, $actionName, &$value )
00729 {
00730 if ( preg_match( "#^" . $actionName . "_(.+)$#", $action, $matches ) )
00731 {
00732 $value = $matches[1];
00733 return true;
00734 }
00735 return false;
00736 }
00737
00738
00739
00740
00741
00742
00743 function validateObjectAttributeHTTPInput( &$http, $base, &$objectAttribute )
00744 {
00745 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
00746 }
00747
00748
00749
00750
00751
00752
00753 function fixupObjectAttributeHTTPInput( &$http, $base, &$objectAttribute )
00754 {
00755 }
00756
00757
00758
00759
00760
00761 function fetchObjectAttributeHTTPInput( &$http, $base, &$objectAttribute )
00762 {
00763 }
00764
00765
00766
00767
00768
00769
00770 function validateCollectionAttributeHTTPInput( &$http, $base, &$objectAttribute )
00771 {
00772 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
00773 }
00774
00775
00776
00777
00778
00779
00780 function fixupCollectionAttributeHTTPInput( &$http, $base, &$objectAttribute )
00781 {
00782 }
00783
00784
00785
00786
00787
00788
00789
00790 function fetchCollectionAttributeHTTPInput( &$collection, &$collectionAttribute, &$http, $base, &$objectAttribute )
00791 {
00792 }
00793
00794
00795
00796
00797
00798 function customObjectAttributeHTTPAction( &$http, $action, &$objectAttribute )
00799 {
00800 }
00801
00802
00803
00804
00805
00806
00807
00808 function handleCustomObjectHTTPActions( &$http, $attributeDataBaseName,
00809 $customActionAttributeArray, $customActionParameters )
00810 {
00811 }
00812
00813
00814
00815
00816
00817 function initializeClassAttribute( &$classAttribute )
00818 {
00819 }
00820
00821
00822
00823
00824
00825 function cloneClassAttribute( &$oldClassAttribute, &$newClassAttribute )
00826 {
00827 }
00828
00829
00830
00831
00832
00833 function initializeObjectAttribute( &$objectAttribute, $currentVersion, &$originalContentObjectAttribute )
00834 {
00835 }
00836
00837
00838
00839
00840
00841 function repairContentObjectAttribute( &$contentObjectAttribute )
00842 {
00843 return null;
00844 }
00845
00846
00847
00848
00849
00850 function postInitializeObjectAttribute( &$objectAttribute, $currentVersion, &$originalContentObjectAttribute )
00851 {
00852 }
00853
00854
00855
00856
00857 function postStore( &$objectAttribute )
00858 {
00859 }
00860
00861
00862
00863
00864
00865 function deleteStoredObjectAttribute( &$objectAttribute, $version = null )
00866 {
00867 }
00868
00869
00870
00871
00872
00873 function deleteStoredClassAttribute( &$classAttribute, $version = null )
00874 {
00875 }
00876
00877
00878
00879
00880
00881 function contentActionList( &$classAttribute )
00882 {
00883 $actionList = array();
00884 if ( is_object( $classAttribute ) )
00885 {
00886 if ( $classAttribute->attribute( 'is_information_collector' ) == true )
00887 {
00888 $actionList[] = array( 'name' => ezi18n( 'kernel/classes/datatypes', 'Send', 'Datatype information collector action' ),
00889 'action' => 'ActionCollectInformation' );
00890 }
00891 }
00892 else
00893 {
00894 eZDebug::writeError( '$classAttribute isn\'t an object.', 'eZDataType::contentActionList' );
00895 }
00896 return $actionList;
00897 }
00898
00899
00900
00901
00902 function hasInformationCollection()
00903 {
00904 return false;
00905 }
00906
00907
00908
00909
00910
00911 function title( &$objectAttribute, $name = null )
00912 {
00913 return "";
00914 }
00915
00916
00917
00918
00919 function isIndexable()
00920 {
00921 return false;
00922 }
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938 function isClassAttributeRemovable( &$classAttribute )
00939 {
00940 $info = $this->classAttributeRemovableInformation( $classAttribute, false );
00941 return ( $info === false or count( $info['list'] ) == 0 );
00942 }
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956 function classAttributeRemovableInformation( &$classAttribute, $includeAll = true )
00957 {
00958 return false;
00959 }
00960
00961
00962
00963
00964 function isInformationCollector()
00965 {
00966 return false;
00967 }
00968
00969
00970
00971
00972 function sortKey( &$objectAttribute )
00973 {
00974 return "";
00975 }
00976
00977
00978
00979
00980
00981 function sortKeyType()
00982 {
00983 return false;
00984 }
00985
00986 function customSorting()
00987 {
00988 return false;
00989 }
00990
00991 function customSortingSQL( $params )
00992 {
00993 return false;
00994 }
00995
00996
00997
00998
00999
01000
01001 function metaData()
01002 {
01003 return '';
01004 }
01005
01006
01007
01008 function toString( $objectAttribute )
01009 {
01010 return '';
01011 }
01012 function fromString( &$objectAttribute, $string )
01013 {
01014 }
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028 function templateList()
01029 {
01030 return false;
01031 }
01032
01033
01034
01035
01036
01037
01038 function serializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode )
01039 {
01040 if ( !$this->Attributes['properties']['serialize_supported'] )
01041 $attributeNode->appendAttribute( eZDOMDocument::createAttributeNode( 'unsupported', 'true' ) );
01042 }
01043
01044
01045
01046
01047
01048
01049 function unserializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode )
01050 {
01051 }
01052
01053
01054
01055
01056
01057
01058
01059 function serializeContentObjectAttribute( &$package, &$objectAttribute )
01060 {
01061 $node = new eZDOMNode();
01062
01063 $node->setPrefix( 'ezobject' );
01064 $node->setName( 'attribute' );
01065 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'id', $objectAttribute->attribute( 'id' ), 'ezremote' ) );
01066 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'identifier', $objectAttribute->contentClassAttributeIdentifier(), 'ezremote' ) );
01067 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'name', $objectAttribute->contentClassAttributeName() ) );
01068 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'type', $this->isA() ) );
01069
01070 if ( $this->Attributes["properties"]['object_serialize_map'] )
01071 {
01072 $map = $this->Attributes["properties"]['object_serialize_map'];
01073 foreach ( $map as $attributeName => $xmlName )
01074 {
01075 if ( $objectAttribute->hasAttribute( $attributeName ) )
01076 {
01077 $value = $objectAttribute->attribute( $attributeName );
01078 $node->appendChild( eZDOMDocument::createElementTextNode( $xmlName, (string)$value ) );
01079 }
01080 else
01081 {
01082 eZDebug::writeError( "The attribute '$attributeName' does not exists for contentobject attribute " . $objectAttribute->attribute( 'id' ),
01083 'eZDataType::serializeContentObjectAttribute' );
01084 }
01085 }
01086 }
01087 else
01088 {
01089 $node->appendChild( eZDOMDocument::createElementTextNode( 'data-int', (string)$objectAttribute->attribute( 'data_int' ) ) );
01090 $node->appendChild( eZDOMDocument::createElementTextNode( 'data-float', (string)$objectAttribute->attribute( 'data_float' ) ) );
01091 $node->appendChild( eZDOMDocument::createElementTextNode( 'data-text', $objectAttribute->attribute( 'data_text' ) ) );
01092 }
01093 return $node;
01094 }
01095
01096
01097
01098
01099
01100
01101
01102
01103 function unserializeContentObjectAttribute( &$package, &$objectAttribute, $attributeNode )
01104 {
01105 if ( $this->Attributes["properties"]['object_serialize_map'] )
01106 {
01107 $map = $this->Attributes["properties"]['object_serialize_map'];
01108 foreach ( $map as $attributeName => $xmlName )
01109 {
01110 if ( $objectAttribute->hasAttribute( $attributeName ) )
01111 {
01112 if ( $attributeNode->elementByName( $xmlName ) !== false )
01113 {
01114 $value = $attributeNode->elementTextContentByName( $xmlName );
01115 $objectAttribute->setAttribute( $attributeName, $value );
01116 }
01117 else
01118 {
01119 eZDebug::writeError( "The xml element '$xmlName' does not exist for contentobject attribute " . $objectAttribute->attribute( 'id' ),
01120 'eZDataType::unserializeContentObjectAttribute' );
01121 }
01122 }
01123 else
01124 {
01125 eZDebug::writeError( "The attribute '$attributeName' does not exist for contentobject attribute " . $objectAttribute->attribute( 'id' ),
01126 'eZDataType::unserializeContentObjectAttribute' );
01127 }
01128 }
01129 }
01130 else
01131 {
01132 $objectAttribute->setAttribute( 'data_int', (int)$attributeNode->elementTextContentByName( 'data-int' ) );
01133 $objectAttribute->setAttribute( 'data_float', (float)$attributeNode->elementTextContentByName( 'data-float' ) );
01134 $objectAttribute->setAttribute( 'data_text', $attributeNode->elementTextContentByName( 'data-text' ) );
01135 }
01136 }
01137
01138
01139
01140
01141
01142 function postUnserializeContentObjectAttribute( &$package, &$objectAttribute )
01143 {
01144 return false;
01145 }
01146
01147 function allowedTypes()
01148 {
01149 $allowedTypes =& $GLOBALS["eZDataTypeAllowedTypes"];
01150 if ( !is_array( $allowedTypes ) )
01151 {
01152 $contentINI =& eZINI::instance( 'content.ini' );
01153 $dataTypes = $contentINI->variable( 'DataTypeSettings', 'AvailableDataTypes' );
01154 $allowedTypes = array_unique( $dataTypes );
01155 }
01156 return $allowedTypes;
01157 }
01158
01159 function loadAndRegisterAllTypes()
01160 {
01161 $allowedTypes = eZDataType::allowedTypes();
01162 foreach( $allowedTypes as $type )
01163 {
01164 eZDataType::loadAndRegisterType( $type );
01165 }
01166 }
01167
01168 function loadAndRegisterType( $type )
01169 {
01170 $types =& $GLOBALS["eZDataTypes"];
01171 if ( isset( $types[$type] ) )
01172 {
01173 return false;
01174 }
01175
01176 include_once( 'lib/ezutils/classes/ezextension.php' );
01177 $baseDirectory = eZExtension::baseDirectory();
01178 $contentINI =& eZINI::instance( 'content.ini' );
01179
01180 $extensionDirectories = $contentINI->variable( 'DataTypeSettings', 'ExtensionDirectories' );
01181 $extensionDirectories = array_unique( $extensionDirectories );
01182 $repositoryDirectories = $contentINI->variable( 'DataTypeSettings', 'RepositoryDirectories' );
01183 $triedDirectories = $repositoryDirectories;
01184
01185 foreach ( $extensionDirectories as $extensionDirectory )
01186 {
01187 $extensionPath = $baseDirectory . '/' . $extensionDirectory . '/datatypes';
01188 $triedDirectories[] = $extensionPath;
01189 if ( file_exists( $extensionPath ) )
01190 {
01191 $repositoryDirectories[] = $extensionPath;
01192 }
01193 else
01194 {
01195 eZDebug::writeWarning( "Extension '$extensionDirectory' does not have the subdirectory 'datatypes'\n" .
01196 "Looked for directory '" . $extensionPath . "'\n" .
01197 "Cannot look for datatype '$type' in this extension." );
01198 }
01199 }
01200 $foundEventType = false;
01201 $repositoryDirectories = array_unique( $repositoryDirectories );
01202 foreach ( $repositoryDirectories as $repositoryDirectory )
01203 {
01204 $includeFile = "$repositoryDirectory/$type/" . $type . "type.php";
01205 if ( file_exists( $includeFile ) )
01206 {
01207 $foundEventType = true;
01208 break;
01209 }
01210 }
01211 if ( !$foundEventType )
01212 {
01213 eZDebug::writeError( "Datatype not found: '$type', searched in these directories: " . implode( ', ', $triedDirectories ), "eZDataType::loadAndRegisterType" );
01214 return false;
01215 }
01216 include_once( $includeFile );
01217 return true;
01218 }
01219
01220
01221
01222
01223
01224 function removeRelatedObjectItem( &$contentObjectAttribute, $objectID )
01225 {
01226 }
01227
01228
01229
01230
01231
01232 function fixRelatedObjectItem( &$contentObjectAttribute, $objectID, $mode )
01233 {
01234 }
01235
01236
01237
01238
01239
01240
01241
01242
01243 function createContentObjectAttributeDOMNode( $objectAttribute )
01244 {
01245 $node = new eZDOMNode();
01246
01247 $node->setPrefix( 'ezobject' );
01248 $node->setName( 'attribute' );
01249 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'id', $objectAttribute->attribute( 'id' ), 'ezremote' ) );
01250 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'identifier', $objectAttribute->contentClassAttributeIdentifier(), 'ezremote' ) );
01251 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'name', $objectAttribute->contentClassAttributeName() ) );
01252 $node->appendAttribute( eZDOMDocument::createAttributeNode( 'type', $this->isA() ) );
01253
01254 return $node;
01255 }
01256
01257
01258
01259
01260
01261
01262 function diff( $old, $new, $options = false )
01263 {
01264 include_once( 'lib/ezdiff/classes/ezdiff.php' );
01265 $diff = new eZDiff();
01266 $diff->setDiffEngineType( $diff->engineType( 'container' ) );
01267 $diff->initDiffEngine();
01268 $diffObject = $diff->diff( $old, $new );
01269 return $diffObject;
01270 }
01271
01272
01273
01274 var $DataTypeString;
01275
01276 var $Name;
01277 }
01278
01279 ?>