Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezdatatype.php
Go to the documentation of this file.
1 <?php
45 class eZDataType
46 {
47 public $Attributes;
55 public function __construct( $dataTypeString, $name, $properties = array() )
56 {
57 $this->DataTypeString = $dataTypeString;
58 $this->Name = $name;
59
60 $translationAllowed = true;
61 $serializeSupported = false;
62 $objectSerializeMap = false;
63 if ( isset( $properties['translation_allowed'] ) )
64 $translationAllowed = $properties['translation_allowed'];
65 if ( isset( $properties['serialize_supported'] ) )
66 $serializeSupported = $properties['serialize_supported'];
67 if ( isset( $properties['object_serialize_map'] ) )
68 $objectSerializeMap = $properties['object_serialize_map'];
69
70 $this->Attributes = array();
71 $this->Attributes["is_indexable"] = $this->isIndexable();
72 $this->Attributes["is_information_collector"] = $this->isInformationCollector();
73
74 $this->Attributes["information"] = array( "string" => $this->DataTypeString,
75 "name" => $this->Name );
76 $this->Attributes["properties"] = array( "translation_allowed" => $translationAllowed,
77 'serialize_supported' => $serializeSupported,
78 'object_serialize_map' => $objectSerializeMap );
79 }
80
87 public function eZDataType( $dataTypeString, $name, $properties = array() )
88 {
89 self::__construct( $dataTypeString, $name, $properties );
90
91 }
92
101 function viewTemplate( $contentobjectAttribute )
102 {
103 return $this->DataTypeString;
104 }
105
114 function editTemplate( $contentobjectAttribute )
115 {
116 return $this->DataTypeString;
117 }
118
127 function informationTemplate( $contentobjectAttribute )
128 {
129 return $this->DataTypeString;
130 }
131
141 function resultTemplate( &$collectionAttribute )
142 {
143 return $this->DataTypeString;
144 }
145
151 static function create( $dataTypeString )
152 {
153 $def = null;
154 if ( !isset( $GLOBALS["eZDataTypes"][$dataTypeString] ) )
155 {
156 eZDataType::loadAndRegisterType( $dataTypeString );
157 }
158
159 if ( isset( $GLOBALS['eZDataTypes'][$dataTypeString] ) )
160 {
161 $className = $GLOBALS['eZDataTypes'][$dataTypeString];
162
163 if ( !isset( $GLOBALS["eZDataTypeObjects"][$dataTypeString] ) ||
164 get_class( $GLOBALS["eZDataTypeObjects"][$dataTypeString] ) != $className )
165 {
166 $GLOBALS["eZDataTypeObjects"][$dataTypeString] = new $className();
167 }
168 return $GLOBALS["eZDataTypeObjects"][$dataTypeString];
169 }
170
171 return null;
172 }
173
179 static function registeredDataTypes()
180 {
181 $types = isset( $GLOBALS["eZDataTypes"] ) ? $GLOBALS["eZDataTypes"] : null;
182 if ( isset( $types ) )
183 {
184 foreach ( $types as $dataTypeString => $className )
185 {
186 if ( !isset( $GLOBALS["eZDataTypeObjects"][$dataTypeString] ) )
187 {
188 $GLOBALS["eZDataTypeObjects"][$dataTypeString] = new $className( $dataTypeString, $className );
189 }
190 }
191 uasort( $GLOBALS["eZDataTypeObjects"], function ( $a, $b ) { return strcmp( $a->Name, $b->Name); } );
192 return $GLOBALS["eZDataTypeObjects"];
193 }
194 return null;
195 }
196
203 static function register( $dataTypeString, $className )
204 {
205 $types =& $GLOBALS["eZDataTypes"];
206 if ( !is_array( $types ) )
207 $types = array();
208 $types[$dataTypeString] = $className;
209 }
210
214 function isA()
215 {
216 return $this->Attributes["information"]["string"];
217 }
218
224 function isTranslatable()
225 {
226 return $this->Attributes['properties']['translation_allowed'];
227 }
228
232 function attributes()
233 {
234 return array_keys( $this->Attributes );
235 }
236
240 function hasAttribute( $attr )
241 {
242 return isset( $this->Attributes[$attr] );
243 }
244
248 function attribute( $attr )
249 {
250 if ( isset( $this->Attributes[$attr] ) )
251 {
252 return $this->Attributes[$attr];
253 }
254
255 eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
256 $attributeData = null;
257 return $attributeData;
258 }
259
265 function isHTTPFileInsertionSupported()
266 {
267 return false;
268 }
269
275 function isRegularFileInsertionSupported()
276 {
277 return false;
278 }
279
285 function isSimpleStringInsertionSupported()
286 {
287 return false;
288 }
289
295 public function isRelationType()
296 {
297 return false;
298 }
299
321 function insertHTTPFile( $object, $objectVersion, $objectLanguage,
322 $objectAttribute, $httpFile, $mimeData,
323 &$result )
324 {
325 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support insertion of HTTP files", __METHOD__ );
326 return null;
327 }
328
348 function insertRegularFile( $object, $objectVersion, $objectLanguage,
349 $objectAttribute, $filePath,
350 &$result )
351 {
352 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support insertion of regular files", __METHOD__ );
353 return null;
354 }
355
375 function insertSimpleString( $object, $objectVersion, $objectLanguage,
376 $objectAttribute, $string,
377 &$result )
378 {
379 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support insertion of simple strings", __METHOD__ );
380 return null;
381 }
382
394 function hasStoredFileInformation( $object, $objectVersion, $objectLanguage,
395 $objectAttribute )
396 {
397 return false;
398 }
399
411 function handleDownload( $object, $objectVersion, $objectLanguage,
412 $objectAttribute )
413 {
414 return false;
415 }
416
439 function storedFileInformation( $object, $objectVersion, $objectLanguage,
440 $objectAttribute )
441 {
442 return false;
443 }
444
462 function productOptionInformation( $objectAttribute, $optionID, $productItem )
463 {
464 eZDebug::writeWarning( "The datatype " . get_class( $this ) . " for attribute ID " . $objectAttribute->attribute( 'id' ) . " does not support product options", __METHOD__ );
465 return null;
466 }
467
496 function objectDisplayInformation( $objectAttribute, $mergeInfo = false )
497 {
498 $datatype = $objectAttribute->attribute( 'data_type_string' );
499 $ini = eZINI::instance( 'datatype.ini' );
500 $editGrouped = in_array( $datatype, $ini->variable( 'EditSettings', 'GroupedInput' ) );
501 $viewGrouped = in_array( $datatype, $ini->variable( 'ViewSettings', 'GroupedInput' ) );
502 $resultGrouped = in_array( $datatype, $ini->variable( 'ResultSettings', 'GroupedInput' ) );
503 $collectionGrouped = in_array( $datatype, $ini->variable( 'CollectionSettings', 'GroupedInput' ) );
504
505 $info = array( 'edit' => array( 'grouped_input' => false ),
506 'view' => array( 'grouped_input' => false),
507 'collection' => array( 'grouped_input' => false ),
508 'result' => array( 'grouped_input' => false ) );
509 $override = array();
510 if ( $editGrouped )
511 $override['edit']['grouped_input'] = true;
512 if ( $collectionGrouped )
513 $override['collection']['grouped_input'] = true;
514 if ( $viewGrouped )
515 $override['view']['grouped_input'] = true;
516 if ( $resultGrouped )
517 $override['result']['grouped_input'] = true;
518
519 if ( $mergeInfo )
520 {
521 // All entries in $mergeInfo will override the defaults
522 foreach ( array( 'edit', 'view', 'collection', 'result' ) as $view )
523 {
524 if ( isset( $mergeInfo[$view] ) )
525 $info[$view] = array_merge( $info[$view], $mergeInfo[$view] );
526 if ( isset( $override[$view] ) )
527 $info[$view] = array_merge( $info[$view], $override[$view] );
528 }
529 }
530 else
531 {
532 // All entries in $override will override the defaults
533 foreach ( array( 'edit', 'view', 'collection', 'result' ) as $view )
534 {
535 if ( isset( $override[$view] ) )
536 $info[$view] = array_merge( $info[$view], $override[$view] );
537 }
538 }
539 return $info;
540 }
541
563 function classDisplayInformation( $classAttribute, $mergeInfo = false )
564 {
565 $datatype = $classAttribute->attribute( 'data_type_string' );
566 $ini = eZINI::instance( 'datatype.ini' );
567 $editGrouped = in_array( $datatype, $ini->variable( 'ClassEditSettings', 'GroupedInput' ) );
568
569 $info = array( 'edit' => array( 'grouped_input' => false ),
570 'view' => array() );
571 $override = array();
572 if ( $editGrouped )
573 $override['edit']['grouped_input'] = true;
574
575 if ( $mergeInfo )
576 {
577 // All entries in $mergeInfo will override the defaults
578 foreach ( array( 'edit', 'view' ) as $view )
579 {
580 if ( isset( $mergeInfo[$view] ) )
581 $info[$view] = array_merge( $info[$view], $mergeInfo[$view] );
582 if ( isset( $override[$view] ) )
583 $info[$view] = array_merge( $info[$view], $override[$view] );
584 }
585 }
586 else
587 {
588 // All entries in $override will override the defaults
589 foreach ( array( 'edit', 'view' ) as $view )
590 {
591 if ( isset( $override[$view] ) )
592 $info[$view] = array_merge( $info[$view], $override[$view] );
593 }
594 }
595 return $info;
596 }
597
601 function objectAttributeContent( $objectAttribute )
602 {
603 $retValue = '';
604 return $retValue;
605 }
606
610 function hasObjectAttributeContent( $contentObjectAttribute )
611 {
612 return false;
613 }
614
618 function classAttributeContent( $classAttribute )
619 {
620 return '';
621 }
622
632 function storeObjectAttribute( $objectAttribute )
633 {
634 }
635
646 function onPublish( $contentObjectAttribute, $contentObject, $publishedNodes )
647 {
648 }
649
657 function preStoreClassAttribute( $classAttribute, $version )
658 {
659 }
660
674 function storeClassAttribute( $classAttribute, $version )
675 {
676 }
677
678
685 function storeDefinedClassAttribute( $classAttribute )
686 {
687 }
688
694 function storeModifiedClassAttribute( $classAttribute )
695 {
696 }
697
704 function storeVersionedClassAttribute( $classAttribute, $version )
705 {
706 switch ( $version )
707 {
708 case eZContentClass::VERSION_STATUS_DEFINED:
709 $this->storeDefinedClassAttribute( $classAttribute );
710 break;
711
712 case eZContentClass::VERSION_STATUS_MODIFIED:
713 $this->storeModifiedClassAttribute( $classAttribute );
714 break;
715 }
716 }
717
721 function preStoreDefinedClassAttribute( $classAttribute )
722 {
723 $this->preStoreClassAttribute( $classAttribute, $classAttribute->attribute( 'version' ) );
724 }
725
729 function preStoreModifiedClassAttribute( $classAttribute )
730 {
731 $this->preStoreClassAttribute( $classAttribute, $classAttribute->attribute( 'version' ) );
732 }
733
741 function preStoreVersionedClassAttribute( $classAttribute, $version )
742 {
743 switch ( $version )
744 {
745 case eZContentClass::VERSION_STATUS_DEFINED:
746 $this->preStoreDefinedClassAttribute( $classAttribute );
747 break;
748
749 case eZContentClass::VERSION_STATUS_MODIFIED:
750 $this->preStoreModifiedClassAttribute( $classAttribute );
751 break;
752 }
753 }
754
760 function validateClassAttributeHTTPInput( $http, $base, $classAttribute )
761 {
762 return eZInputValidator::STATE_ACCEPTED;
763 }
764
770 function fixupClassAttributeHTTPInput( $http, $base, $classAttribute )
771 {
772 return eZInputValidator::STATE_ACCEPTED;
773 }
774
779 function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
780 {
781 }
782
787 function customClassAttributeHTTPAction( $http, $action, $classAttribute )
788 {
789 }
790
798 function fetchActionValue( $action, $actionName, &$value )
799 {
800 if ( preg_match( "#^" . $actionName . "_(.+)$#", $action, $matches ) )
801 {
802 $value = $matches[1];
803 return true;
804 }
805 return false;
806 }
807
813 function validateObjectAttributeHTTPInput( $http, $base, $objectAttribute )
814 {
815 return eZInputValidator::STATE_ACCEPTED;
816 }
817
823 function fixupObjectAttributeHTTPInput( $http, $base, $objectAttribute )
824 {
825 }
826
831 function fetchObjectAttributeHTTPInput( $http, $base, $objectAttribute )
832 {
833 }
834
840 function validateCollectionAttributeHTTPInput( $http, $base, $objectAttribute )
841 {
842 return eZInputValidator::STATE_ACCEPTED;
843 }
844
850 function fixupCollectionAttributeHTTPInput( $http, $base, $objectAttribute )
851 {
852 }
853
860 function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $objectAttribute )
861 {
862 }
863
868 function customObjectAttributeHTTPAction( $http, $action, $objectAttribute, $parameters )
869 {
870 }
871
878 function handleCustomObjectHTTPActions( $http, $attributeDataBaseName,
879 $customActionAttributeArray, $customActionParameters )
880 {
881 }
882
887 function initializeClassAttribute( $classAttribute )
888 {
889 }
890
895 function cloneClassAttribute( $oldClassAttribute, $newClassAttribute )
896 {
897 }
898
905 function initializeObjectAttribute( $objectAttribute, $currentVersion, $originalContentObjectAttribute )
906 {
907 }
908
913 function repairContentObjectAttribute( $contentObjectAttribute )
914 {
915 return null;
916 }
917
922 function postInitializeObjectAttribute( $objectAttribute, $currentVersion, $originalContentObjectAttribute )
923 {
924 }
925
926 /*
927 Makes some post-store operations. Called by framework after store of eZContentObjectAttribute object.
928 */
929 function postStore( $objectAttribute )
930 {
931 }
932
937 function trashStoredObjectAttribute( $objectAttribute, $version = null )
938 {
939 }
940
946 public function restoreTrashedObjectAttribute( $objectAttribute )
947 {
948 }
949
956 function deleteStoredObjectAttribute( $objectAttribute, $version = null )
957 {
958 }
959
964 function deleteStoredClassAttribute( $classAttribute, $version = null )
965 {
966 }
967
974 function deleteNotVersionedStoredClassAttribute( eZContentClassAttribute $classAttribute )
975 {
976 }
977
986 function contentActionList( $classAttribute )
987 {
988 $actionList = array();
989 if ( $classAttribute instanceof eZContentClassAttribute )
990 {
991 if ( $classAttribute->attribute( 'is_information_collector' ) == true )
992 {
993 $actionList[] = array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Send', 'Datatype information collector action' ),
994 'action' => 'ActionCollectInformation' );
995 }
996 }
997 else
998 {
999 eZDebug::writeError( '$classAttribute isn\'t an object.', __METHOD__ );
1000 }
1001 return $actionList;
1002 }
1003
1007 function hasInformationCollection()
1008 {
1009 return false;
1010 }
1011
1016 function title( $objectAttribute, $name = null )
1017 {
1018 return "";
1019 }
1020
1024 function isIndexable()
1025 {
1026 return false;
1027 }
1028
1032 function isAddToBasketValidationRequired()
1033 {
1034 return false;
1035 }
1041 function validateAddToBasket( $objectAttribute, $data, &$errors )
1042 {
1043 return eZInputValidator::STATE_ACCEPTED;
1044 }
1045
1060 function isClassAttributeRemovable( $classAttribute )
1061 {
1062 $info = $this->classAttributeRemovableInformation( $classAttribute, false );
1063 return ( $info === false or count( $info['list'] ) == 0 );
1064 }
1065
1078 function classAttributeRemovableInformation( $classAttribute, $includeAll = true )
1079 {
1080 return false;
1081 }
1082
1086 function isInformationCollector()
1087 {
1088 return false;
1089 }
1090
1094 function sortKey( $objectAttribute )
1095 {
1096 return "";
1097 }
1098
1103 function sortKeyType()
1104 {
1105 return false;
1106 }
1107
1108 function customSorting()
1109 {
1110 return false;
1111 }
1112
1113 function customSortingSQL( $params )
1114 {
1115 return false;
1116 }
1117
1123 function metaData( $contentObjectAttribute )
1124 {
1125 return '';
1126 }
1130 function toString( $objectAttribute )
1131 {
1132 return '';
1133 }
1134 function fromString( $objectAttribute, $string )
1135 {
1136 }
1137
1150 function templateList()
1151 {
1152 return false;
1153 }
1154
1160 function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
1161 {
1162 if ( !$this->Attributes['properties']['serialize_supported'] )
1163 $attributeNode->setAttribute( 'unsupported', 'true' );
1164 }
1165
1171 function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
1172 {
1173 }
1174
1181 function serializeContentObjectAttribute( $package, $objectAttribute )
1182 {
1183 $dom = new DOMDocument( '1.0', 'utf-8' );
1184
1185 $node = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:attribute' );
1186
1187 $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:id', $objectAttribute->attribute( 'id' ) );
1188 $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:identifier', $objectAttribute->contentClassAttributeIdentifier() );
1189 $node->setAttribute( 'name', $objectAttribute->contentClassAttributeName() );
1190 $node->setAttribute( 'type', $this->isA() );
1191
1192 if ( $this->Attributes["properties"]['object_serialize_map'] )
1193 {
1194 $map = $this->Attributes["properties"]['object_serialize_map'];
1195 foreach ( $map as $attributeName => $xmlName )
1196 {
1197 if ( $objectAttribute->hasAttribute( $attributeName ) )
1198 {
1199 $value = $objectAttribute->attribute( $attributeName );
1200 unset( $attributeNode );
1201 $attributeNode = $dom->createElement( $xmlName );
1202 $attributeNode->appendChild( $dom->createTextNode( (string)$value ) );
1203 $node->appendChild( $attributeNode );
1204 }
1205 else
1206 {
1207 eZDebug::writeError( "The attribute '$attributeName' does not exist for contentobject attribute " . $objectAttribute->attribute( 'id' ), __METHOD__ );
1208 }
1209 }
1210 }
1211 else
1212 {
1213 $dataIntNode = $dom->createElement( 'data-int' );
1214 $dataIntNode->appendChild( $dom->createTextNode( (string)$objectAttribute->attribute( 'data_int' ) ) );
1215 $node->appendChild( $dataIntNode );
1216 $dataFloatNode = $dom->createElement( 'data-float' );
1217 $dataFloatNode->appendChild( $dom->createTextNode( (string)$objectAttribute->attribute( 'data_float' ) ) );
1218 $node->appendChild( $dataFloatNode );
1219 $dataTextNode = $dom->createElement( 'data-text' );
1220 $dataTextNode->appendChild( $dom->createTextNode( $objectAttribute->attribute( 'data_text' ) ) );
1221 $node->appendChild( $dataTextNode );
1222 }
1223 return $node;
1224 }
1225
1233 function unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode )
1234 {
1235 if ( $this->Attributes["properties"]['object_serialize_map'] )
1236 {
1237 $map = $this->Attributes["properties"]['object_serialize_map'];
1238 foreach ( $map as $attributeName => $xmlName )
1239 {
1240 if ( $objectAttribute->hasAttribute( $attributeName ) )
1241 {
1242 $elements = $attributeNode->getElementsByTagName( $xmlName );
1243 if ( $elements->length !== 0 )
1244 {
1245 $value = $elements->item( 0 )->textContent;
1246 $objectAttribute->setAttribute( $attributeName, $value );
1247 }
1248 else
1249 {
1250 eZDebug::writeError( "The xml element '$xmlName' does not exist for contentobject attribute " . $objectAttribute->attribute( 'id' ), __METHOD__ );
1251 }
1252 }
1253 else
1254 {
1255 eZDebug::writeError( "The attribute '$attributeName' does not exist for contentobject attribute " . $objectAttribute->attribute( 'id' ), __METHOD__ );
1256 }
1257 }
1258 }
1259 else
1260 {
1261 $objectAttribute->setAttribute( 'data_int', (int)$attributeNode->getElementsByTagName( 'data-int' )->item( 0 )->textContent );
1262 $objectAttribute->setAttribute( 'data_float', (float)$attributeNode->getElementsByTagName( 'data-float' )->item( 0 )->textContent );
1263 $objectAttribute->setAttribute( 'data_text', $attributeNode->getElementsByTagName( 'data-text' )->item( 0 )->textContent );
1264 }
1265 }
1266
1267 /*
1268 Post unserialize. Called after all related objects are created.
1269 \return true means that attribute has been modified and should be stored
1270 */
1271 function postUnserializeContentObjectAttribute( $package, $objectAttribute )
1272 {
1273 return false;
1274 }
1275
1276 static function allowedTypes()
1277 {
1278 $allowedTypes =& $GLOBALS["eZDataTypeAllowedTypes"];
1279 if ( !is_array( $allowedTypes ) )
1280 {
1281 $contentINI = eZINI::instance( 'content.ini' );
1282 $dataTypes = $contentINI->variable( 'DataTypeSettings', 'AvailableDataTypes' );
1283 $allowedTypes = array_unique( $dataTypes );
1284 }
1285 return $allowedTypes;
1286 }
1287
1288 static function loadAndRegisterAllTypes()
1289 {
1290 $allowedTypes = eZDataType::allowedTypes();
1291 foreach( $allowedTypes as $type )
1292 {
1293 eZDataType::loadAndRegisterType( $type );
1294 }
1295 }
1296
1297 static function loadAndRegisterType( $type )
1298 {
1299 $types =& $GLOBALS["eZDataTypes"];
1300 if ( isset( $types[$type] ) )
1301 {
1302 return false;
1303 }
1304
1305 $baseDirectory = eZExtension::baseDirectory();
1306 $contentINI = eZINI::instance( 'content.ini' );
1307
1308 $extensionDirectories = $contentINI->variable( 'DataTypeSettings', 'ExtensionDirectories' );
1309 $extensionDirectories = array_unique( $extensionDirectories );
1310 $repositoryDirectories = $contentINI->variable( 'DataTypeSettings', 'RepositoryDirectories' );
1311 $triedDirectories = $repositoryDirectories;
1312
1313 foreach ( $extensionDirectories as $extensionDirectory )
1314 {
1315 $extensionPath = $baseDirectory . '/' . $extensionDirectory . '/datatypes';
1316 $triedDirectories[] = $extensionPath;
1317 if ( file_exists( $extensionPath ) )
1318 {
1319 $repositoryDirectories[] = $extensionPath;
1320 }
1321 else
1322 {
1323 eZDebug::writeWarning( "Extension '$extensionDirectory' does not have the subdirectory 'datatypes'\n" .
1324 "Looked for directory '" . $extensionPath . "'\n" .
1325 "Cannot look for datatype '$type' in this extension." );
1326 }
1327 }
1328 $foundEventType = false;
1329 $repositoryDirectories = array_unique( $repositoryDirectories );
1330 foreach ( $repositoryDirectories as $repositoryDirectory )
1331 {
1332 $includeFile = "$repositoryDirectory/$type/" . $type . "type.php";
1333 if ( file_exists( $includeFile ) )
1334 {
1335 $foundEventType = true;
1336 break;
1337 }
1338 }
1339 if ( !$foundEventType )
1340 {
1341 eZDebug::writeError( "Datatype not found: '$type', searched in these directories: " . implode( ', ', $triedDirectories ), __METHOD__ );
1342 return false;
1343 }
1344 include_once( $includeFile );
1345 return true;
1346 }
1347
1352 function removeRelatedObjectItem( $contentObjectAttribute, $objectID )
1353 {
1354 }
1355
1360 function fixRelatedObjectItem( $contentObjectAttribute, $objectID, $mode )
1361 {
1362 }
1371 function createContentObjectAttributeDOMNode( $objectAttribute )
1372 {
1373 $dom = new DOMDocument( '1.0', 'utf-8' );
1374
1375 $node = $dom->createElementNS( 'http://ez.no/object/', 'ezobject:attribute' );
1376
1377 $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:id', $objectAttribute->attribute( 'id' ) );
1378 $node->setAttributeNS( 'http://ez.no/ezobject', 'ezremote:identifier', $objectAttribute->contentClassAttributeIdentifier() );
1379 $node->setAttribute( 'name', $objectAttribute->contentClassAttributeName() );
1380 $node->setAttribute( 'type', $this->isA() );
1381
1382 return $node;
1383 }
1384
1390 function diff( $old, $new, $options = false )
1391 {
1392 $diff = new eZDiff();
1393 $diff->setDiffEngineType( $diff->engineType( 'container' ) );
1394 $diff->initDiffEngine();
1395 $diffObject = $diff->diff( $old, $new );
1396 return $diffObject;
1397 }
1398
1403 function getDBAFileName()
1404 {
1405 return 'share/db_data.dba';
1406 }
1407
1411 function getDBAFilePath( $checkExtensions = true )
1412 {
1413 $fileName = 'kernel/classes/datatypes/' . $this->DataTypeString . '/' . $this->getDBAFileName();
1414 if ( $checkExtensions === true && !file_exists( $fileName ) )
1415 {
1416 $fileName = $this->getDBAExtensionFilePath();
1417 }
1418 return $fileName;
1419 }
1420
1425 function getDBAExtensionFilePath()
1426 {
1427 $activeExtensions = eZExtension::activeExtensions();
1428 $dataTypeString = $this->DataTypeString;
1429 $dbaFileName = $this->getDBAFileName();
1430 $fileName = false;
1431 foreach ( $activeExtensions as $activeExtension )
1432 {
1433 $extesionFileName = eZExtension::baseDirectory() . '/' . $activeExtension .
1434 '/datatypes/' . $dataTypeString . '/' . $dbaFileName;
1435 if ( file_exists( $extesionFileName ) )
1436 {
1437 $fileName = $extesionFileName;
1438 break;
1439 }
1440 }
1441 return $fileName;
1442 }
1443
1450 function importDBDataFromDBAFile( $dbaFilePath = false )
1451 {
1452 // If no file path is passed then get the common dba-data file name for the datatype
1453 if ( $dbaFilePath === false )
1454 $dbaFilePath = $this->getDBAFilePath();
1455
1456 $fileExist = true;
1457 if ( !file_exists( $dbaFilePath ) )
1458 {
1459 $fileExist = false;
1460 }
1461 $result = true;
1462 if ( $fileExist === true )
1463 {
1464 $dataArray = eZDbSchema::read( $dbaFilePath, true );
1465 if ( is_array( $dataArray ) and count( $dataArray ) > 0 )
1466 {
1467 $db = eZDB::instance();
1468 $dataArray['type'] = strtolower( $db->databaseName() );
1469 $dataArray['instance'] =& $db;
1470 $dbSchema = eZDbSchema::instance( $dataArray );
1471
1472 $result = false;
1473 if ( $dbSchema )
1474 {
1475 // Before adding the schema, make sure that the tables are empty.
1476 if ( $this->cleanDBDataBeforeImport() )
1477 {
1478 // This will insert the data and
1479 // run any sequence value correction SQL if required
1480 $result = $dbSchema->insertSchema( array( 'schema' => false,
1481 'data' => true ) );
1482 }
1483 }
1484 }
1485 }
1486 else
1487 {
1488 $result = false;
1489 }
1490 return $result;
1491 }
1492
1498 function cleanDBDataBeforeImport()
1499 {
1500 return true;
1501 }
1502
1503 function batchInitializeObjectAttributeData( $classAttribute )
1504 {
1505 return array();
1506 }
1507
1508 function supportsBatchInitializeObjectAttribute()
1509 {
1510 return false;
1511 }
1512
1515 public $DataTypeString;
1517 public $Name;
1518
1519
1520 }
1521
1522 ?>
eZContentClassAttribute
Encapsulates data for a class attribute.
Definition: ezcontentclassattribute.php:19
eZContentClass\VERSION_STATUS_MODIFIED
const VERSION_STATUS_MODIFIED
Definition: ezcontentclass.php:24
eZContentClass\VERSION_STATUS_DEFINED
const VERSION_STATUS_DEFINED
Definition: ezcontentclass.php:22
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZDataType
Base class for content datatypes.
Definition: ezdatatype.php:46
eZDataType\fixupCollectionAttributeHTTPInput
fixupCollectionAttributeHTTPInput( $http, $base, $objectAttribute)
Definition: ezdatatype.php:850
eZDataType\loadAndRegisterType
static loadAndRegisterType( $type)
Definition: ezdatatype.php:1297
eZDataType\supportsBatchInitializeObjectAttribute
supportsBatchInitializeObjectAttribute()
Definition: ezdatatype.php:1508
eZDataType\initializeClassAttribute
initializeClassAttribute( $classAttribute)
Definition: ezdatatype.php:887
eZDataType\informationTemplate
informationTemplate( $contentobjectAttribute)
Definition: ezdatatype.php:127
eZDataType\sortKeyType
sortKeyType()
Definition: ezdatatype.php:1103
eZDataType\isRegularFileInsertionSupported
isRegularFileInsertionSupported()
Definition: ezdatatype.php:275
eZDataType\fetchActionValue
fetchActionValue( $action, $actionName, &$value)
Definition: ezdatatype.php:798
eZDataType\title
title( $objectAttribute, $name=null)
Definition: ezdatatype.php:1016
eZDataType\fetchObjectAttributeHTTPInput
fetchObjectAttributeHTTPInput( $http, $base, $objectAttribute)
Definition: ezdatatype.php:831
eZDataType\attribute
attribute( $attr)
Definition: ezdatatype.php:248
eZDataType\cloneClassAttribute
cloneClassAttribute( $oldClassAttribute, $newClassAttribute)
Definition: ezdatatype.php:895
eZDataType\customSortingSQL
customSortingSQL( $params)
Definition: ezdatatype.php:1113
eZDataType\classDisplayInformation
classDisplayInformation( $classAttribute, $mergeInfo=false)
Definition: ezdatatype.php:563
eZDataType\getDBAFileName
getDBAFileName()
Definition: ezdatatype.php:1403
eZDataType\templateList
templateList()
Definition: ezdatatype.php:1150
eZDataType\unserializeContentObjectAttribute
unserializeContentObjectAttribute( $package, $objectAttribute, $attributeNode)
Definition: ezdatatype.php:1233
eZDataType\storedFileInformation
storedFileInformation( $object, $objectVersion, $objectLanguage, $objectAttribute)
Definition: ezdatatype.php:439
eZDataType\cleanDBDataBeforeImport
cleanDBDataBeforeImport()
Definition: ezdatatype.php:1498
eZDataType\productOptionInformation
productOptionInformation( $objectAttribute, $optionID, $productItem)
Definition: ezdatatype.php:462
eZDataType\storeModifiedClassAttribute
storeModifiedClassAttribute( $classAttribute)
Definition: ezdatatype.php:694
eZDataType\validateCollectionAttributeHTTPInput
validateCollectionAttributeHTTPInput( $http, $base, $objectAttribute)
Definition: ezdatatype.php:840
eZDataType\metaData
metaData( $contentObjectAttribute)
Definition: ezdatatype.php:1123
eZDataType\isA
isA()
Definition: ezdatatype.php:214
eZDataType\getDBAExtensionFilePath
getDBAExtensionFilePath()
Definition: ezdatatype.php:1425
eZDataType\resultTemplate
resultTemplate(&$collectionAttribute)
Definition: ezdatatype.php:141
eZDataType\deleteStoredClassAttribute
deleteStoredClassAttribute( $classAttribute, $version=null)
Definition: ezdatatype.php:964
eZDataType\__construct
__construct( $dataTypeString, $name, $properties=array())
Definition: ezdatatype.php:55
eZDataType\fixupObjectAttributeHTTPInput
fixupObjectAttributeHTTPInput( $http, $base, $objectAttribute)
Definition: ezdatatype.php:823
eZDataType\hasStoredFileInformation
hasStoredFileInformation( $object, $objectVersion, $objectLanguage, $objectAttribute)
Definition: ezdatatype.php:394
eZDataType\classAttributeRemovableInformation
classAttributeRemovableInformation( $classAttribute, $includeAll=true)
Definition: ezdatatype.php:1078
eZDataType\$Attributes
$Attributes
Definition: ezdatatype.php:47
eZDataType\isIndexable
isIndexable()
Definition: ezdatatype.php:1024
eZDataType\registeredDataTypes
static registeredDataTypes()
Definition: ezdatatype.php:179
eZDataType\customSorting
customSorting()
Definition: ezdatatype.php:1108
eZDataType\objectDisplayInformation
objectDisplayInformation( $objectAttribute, $mergeInfo=false)
Definition: ezdatatype.php:496
eZDataType\customObjectAttributeHTTPAction
customObjectAttributeHTTPAction( $http, $action, $objectAttribute, $parameters)
Definition: ezdatatype.php:868
eZDataType\preStoreVersionedClassAttribute
preStoreVersionedClassAttribute( $classAttribute, $version)
Definition: ezdatatype.php:741
eZDataType\isTranslatable
isTranslatable()
Definition: ezdatatype.php:224
eZDataType\toString
toString( $objectAttribute)
Definition: ezdatatype.php:1130
eZDataType\validateObjectAttributeHTTPInput
validateObjectAttributeHTTPInput( $http, $base, $objectAttribute)
Definition: ezdatatype.php:813
eZDataType\postStore
postStore( $objectAttribute)
Definition: ezdatatype.php:929
eZDataType\storeDefinedClassAttribute
storeDefinedClassAttribute( $classAttribute)
Definition: ezdatatype.php:685
eZDataType\hasInformationCollection
hasInformationCollection()
Definition: ezdatatype.php:1007
eZDataType\isAddToBasketValidationRequired
isAddToBasketValidationRequired()
Definition: ezdatatype.php:1032
eZDataType\$Name
$Name
The descriptive name of the datatype, usually used for displaying to the user.
Definition: ezdatatype.php:1517
eZDataType\isClassAttributeRemovable
isClassAttributeRemovable( $classAttribute)
Definition: ezdatatype.php:1060
eZDataType\fixRelatedObjectItem
fixRelatedObjectItem( $contentObjectAttribute, $objectID, $mode)
Definition: ezdatatype.php:1360
eZDataType\hasObjectAttributeContent
hasObjectAttributeContent( $contentObjectAttribute)
Definition: ezdatatype.php:610
eZDataType\fetchClassAttributeHTTPInput
fetchClassAttributeHTTPInput( $http, $base, $classAttribute)
Definition: ezdatatype.php:779
eZDataType\objectAttributeContent
objectAttributeContent( $objectAttribute)
Definition: ezdatatype.php:601
eZDataType\preStoreModifiedClassAttribute
preStoreModifiedClassAttribute( $classAttribute)
Definition: ezdatatype.php:729
eZDataType\removeRelatedObjectItem
removeRelatedObjectItem( $contentObjectAttribute, $objectID)
Definition: ezdatatype.php:1352
eZDataType\deleteStoredObjectAttribute
deleteStoredObjectAttribute( $objectAttribute, $version=null)
Definition: ezdatatype.php:956
eZDataType\eZDataType
eZDataType( $dataTypeString, $name, $properties=array())
Definition: ezdatatype.php:87
eZDataType\classAttributeContent
classAttributeContent( $classAttribute)
Definition: ezdatatype.php:618
eZDataType\storeVersionedClassAttribute
storeVersionedClassAttribute( $classAttribute, $version)
Definition: ezdatatype.php:704
eZDataType\allowedTypes
static allowedTypes()
Definition: ezdatatype.php:1276
eZDataType\fetchCollectionAttributeHTTPInput
fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $objectAttribute)
Definition: ezdatatype.php:860
eZDataType\insertHTTPFile
insertHTTPFile( $object, $objectVersion, $objectLanguage, $objectAttribute, $httpFile, $mimeData, &$result)
Definition: ezdatatype.php:321
eZDataType\contentActionList
contentActionList( $classAttribute)
Definition: ezdatatype.php:986
eZDataType\attributes
attributes()
Definition: ezdatatype.php:232
eZDataType\diff
diff( $old, $new, $options=false)
Definition: ezdatatype.php:1390
eZDataType\importDBDataFromDBAFile
importDBDataFromDBAFile( $dbaFilePath=false)
Definition: ezdatatype.php:1450
eZDataType\fromString
fromString( $objectAttribute, $string)
Definition: ezdatatype.php:1134
eZDataType\preStoreClassAttribute
preStoreClassAttribute( $classAttribute, $version)
Definition: ezdatatype.php:657
eZDataType\getDBAFilePath
getDBAFilePath( $checkExtensions=true)
Definition: ezdatatype.php:1411
eZDataType\storeObjectAttribute
storeObjectAttribute( $objectAttribute)
Definition: ezdatatype.php:632
eZDataType\isRelationType
isRelationType()
Definition: ezdatatype.php:295
eZDataType\isSimpleStringInsertionSupported
isSimpleStringInsertionSupported()
Definition: ezdatatype.php:285
eZDataType\repairContentObjectAttribute
repairContentObjectAttribute( $contentObjectAttribute)
Definition: ezdatatype.php:913
eZDataType\isInformationCollector
isInformationCollector()
Definition: ezdatatype.php:1086
eZDataType\storeClassAttribute
storeClassAttribute( $classAttribute, $version)
Definition: ezdatatype.php:674
eZDataType\postInitializeObjectAttribute
postInitializeObjectAttribute( $objectAttribute, $currentVersion, $originalContentObjectAttribute)
Definition: ezdatatype.php:922
eZDataType\batchInitializeObjectAttributeData
batchInitializeObjectAttributeData( $classAttribute)
Definition: ezdatatype.php:1503
eZDataType\create
static create( $dataTypeString)
Definition: ezdatatype.php:151
eZDataType\handleDownload
handleDownload( $object, $objectVersion, $objectLanguage, $objectAttribute)
Definition: ezdatatype.php:411
eZDataType\customClassAttributeHTTPAction
customClassAttributeHTTPAction( $http, $action, $classAttribute)
Definition: ezdatatype.php:787
eZDataType\onPublish
onPublish( $contentObjectAttribute, $contentObject, $publishedNodes)
Definition: ezdatatype.php:646
eZDataType\fixupClassAttributeHTTPInput
fixupClassAttributeHTTPInput( $http, $base, $classAttribute)
Definition: ezdatatype.php:770
eZDataType\serializeContentClassAttribute
serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: ezdatatype.php:1160
eZDataType\serializeContentObjectAttribute
serializeContentObjectAttribute( $package, $objectAttribute)
Definition: ezdatatype.php:1181
eZDataType\loadAndRegisterAllTypes
static loadAndRegisterAllTypes()
Definition: ezdatatype.php:1288
eZDataType\postUnserializeContentObjectAttribute
postUnserializeContentObjectAttribute( $package, $objectAttribute)
Definition: ezdatatype.php:1271
eZDataType\handleCustomObjectHTTPActions
handleCustomObjectHTTPActions( $http, $attributeDataBaseName, $customActionAttributeArray, $customActionParameters)
Definition: ezdatatype.php:878
eZDataType\insertRegularFile
insertRegularFile( $object, $objectVersion, $objectLanguage, $objectAttribute, $filePath, &$result)
Definition: ezdatatype.php:348
eZDataType\$DataTypeString
$DataTypeString
The datatype string ID, used for uniquely identifying a datatype.
Definition: ezdatatype.php:1515
eZDataType\createContentObjectAttributeDOMNode
createContentObjectAttributeDOMNode( $objectAttribute)
Definition: ezdatatype.php:1371
eZDataType\sortKey
sortKey( $objectAttribute)
Definition: ezdatatype.php:1094
eZDataType\trashStoredObjectAttribute
trashStoredObjectAttribute( $objectAttribute, $version=null)
Definition: ezdatatype.php:937
eZDataType\preStoreDefinedClassAttribute
preStoreDefinedClassAttribute( $classAttribute)
Definition: ezdatatype.php:721
eZDataType\restoreTrashedObjectAttribute
restoreTrashedObjectAttribute( $objectAttribute)
Definition: ezdatatype.php:946
eZDataType\unserializeContentClassAttribute
unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: ezdatatype.php:1171
eZDataType\viewTemplate
viewTemplate( $contentobjectAttribute)
Definition: ezdatatype.php:101
eZDataType\validateAddToBasket
validateAddToBasket( $objectAttribute, $data, &$errors)
Definition: ezdatatype.php:1041
eZDataType\validateClassAttributeHTTPInput
validateClassAttributeHTTPInput( $http, $base, $classAttribute)
Definition: ezdatatype.php:760
eZDataType\editTemplate
editTemplate( $contentobjectAttribute)
Definition: ezdatatype.php:114
eZDataType\insertSimpleString
insertSimpleString( $object, $objectVersion, $objectLanguage, $objectAttribute, $string, &$result)
Definition: ezdatatype.php:375
eZDataType\initializeObjectAttribute
initializeObjectAttribute( $objectAttribute, $currentVersion, $originalContentObjectAttribute)
Definition: ezdatatype.php:905
eZDataType\deleteNotVersionedStoredClassAttribute
deleteNotVersionedStoredClassAttribute(eZContentClassAttribute $classAttribute)
Definition: ezdatatype.php:974
eZDataType\isHTTPFileInsertionSupported
isHTTPFileInsertionSupported()
Definition: ezdatatype.php:265
eZDataType\hasAttribute
hasAttribute( $attr)
Definition: ezdatatype.php:240
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZExtension\activeExtensions
static activeExtensions( $extensionType=false, eZINI|null $siteINI=null)
Definition: ezextension.php:60
eZExtension\baseDirectory
static baseDirectory(eZINI|null $siteINI=null)
Definition: ezextension.php:39
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
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+.