Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentclasspackagehandler.php
Go to the documentation of this file.
1 <?php
17 class eZContentClassPackageHandler extends eZPackageHandler
18 {
19 public $HandlerType;
20 const ERROR_EXISTS = 1;
21 const ERROR_HAS_OBJECTS = 101;
22
23 const ACTION_REPLACE = 1;
24 const ACTION_SKIP = 2;
25 const ACTION_NEW = 3;
26 const ACTION_DELETE = 4;
27
28 public function __construct()
29 {
30 parent::__construct( 'ezcontentclass', array( 'extract-install-content' => true ) );
31 }
32
37 function explainInstallItem( $package, $installItem, $requestedInfo = array( 'name', 'identifier', 'description', 'language_info' ) )
38 {
39 if ( $installItem['filename'] )
40 {
41 $explainClassName = in_array( 'name', $requestedInfo );
42 $explainClassIdentitier = in_array( 'identifier', $requestedInfo );
43 $explainDescription = in_array( 'description', $requestedInfo );
44 $explainLanguageInfo = in_array( 'language_info', $requestedInfo );
45
46 $filename = $installItem['filename'];
47 $subdirectory = $installItem['sub-directory'];
48 if ( $subdirectory )
49 $filepath = $subdirectory . '/' . $filename . '.xml';
50 else
51 $filepath = $filename . '.xml';
52
53 $filepath = $package->path() . '/' . $filepath;
54
55 $dom = $package->fetchDOMFromFile( $filepath );
56 if ( $dom )
57 {
58 $languageInfo = array();
59
60 $content = $dom->documentElement;
61 $classIdentifier = $explainClassIdentitier ? $content->getElementsByTagName( 'identifier' )->item( 0 )->textContent : '';
62
63 $className = '';
64 if ( $explainClassName )
65 {
66 // BC ( <= 3.8 )
67 $classNameNode = $content->getElementsByTagName( 'name' )->item( 0 );
68
69 if( $classNameNode )
70 {
71 $className = $classNameNode->textContent;
72 }
73 else
74 {
75 // get info about translations.
76 $serializedNameListNode = $content->getElementsByTagName( 'serialized-name-list' )->item( 0 );
77 if( $serializedNameListNode )
78 {
79 $serializedNameList = $serializedNameListNode->textContent;
80 $nameList = new eZContentClassNameList( $serializedNameList );
81 $languageInfo = $explainLanguageInfo ? $nameList->languageLocaleList() : array();
82 $className = $nameList->name();
83 }
84 }
85 }
86
87 $description = $explainDescription ? ezpI18n::tr( 'kernel/package', "Content class '%classname' (%classidentifier)", false,
88 array( '%classname' => $className,
89 '%classidentifier' => $classIdentifier ) ) : '';
90 $explainInfo = array( 'description' => $description,
91 'language_info' => $languageInfo );
92 return $explainInfo;
93 }
94 }
95 }
96
100 function uninstall( $package, $installType, $parameters,
101 $name, $os, $filename, $subdirectory,
102 $content, &$installParameters,
103 &$installData )
104 {
105 $classRemoteID = $content->getElementsByTagName( 'remote-id' )->item( 0 )->textContent;
106
107 $class = eZContentClass::fetchByRemoteID( $classRemoteID );
108
109 if ( $class == null )
110 {
111 eZDebug::writeNotice( "Class having remote id '$classRemoteID' not found.", __METHOD__ );
112 return true;
113 }
114
115 if ( $class->isRemovable() )
116 {
117 $choosenAction = $this->errorChoosenAction( self::ERROR_HAS_OBJECTS,
118 $installParameters, false, $this->HandlerType );
119 if ( $choosenAction == self::ACTION_SKIP )
120 {
121 return true;
122 }
123 if ( $choosenAction != self::ACTION_DELETE )
124 {
125 $objectsCount = eZContentObject::fetchSameClassListCount( $class->attribute( 'id' ) );
126 $name = $class->attribute( 'name' );
127 if ( $objectsCount )
128 {
129 $installParameters['error'] = array( 'error_code' => self::ERROR_HAS_OBJECTS,
130 'element_id' => $classRemoteID,
131 'description' => ezpI18n::tr( 'kernel/package',
132 "Removing class '%classname' will result in the removal of %objectscount object(s) of this class and all their sub-items. Are you sure you want to uninstall it?",
133 false,
134 array( '%classname' => $name,
135 '%objectscount' => $objectsCount ) ),
136 'actions' => array( self::ACTION_DELETE => "Uninstall class and object(s)",
137 self::ACTION_SKIP => 'Skip' ) );
138 return false;
139 }
140 }
141
142 eZDebug::writeNotice( sprintf( "Removing class '%s' (%d)", $class->attribute( 'name' ), $class->attribute( 'id' ) ) );
143
144 eZContentClassOperations::remove( $class->attribute( 'id' ) );
145 }
146
147 return true;
148 }
149
153 function install( $package, $installType, $parameters,
154 $name, $os, $filename, $subdirectory,
155 $content, &$installParameters,
156 &$installData )
157 {
158 $serializedNameListNode = $content->getElementsByTagName( 'serialized-name-list' )->item( 0 );
159 $serializedNameList = $serializedNameListNode ? $serializedNameListNode->textContent : false;
160 $classNameList = new eZContentClassNameList( $serializedNameList );
161 if ( $classNameList->isEmpty() )
162 {
163 $classNameList->initFromString( $content->getElementsByTagName( 'name' )->item( 0 )->textContent ); // for backward compatibility( <= 3.8 )
164 }
165 $classNameList->validate( );
166
167 $serializedDescriptionListNode = $content->getElementsByTagName( 'serialized-description-list' )->item( 0 );
168 $serializedDescriptionList = $serializedDescriptionListNode ? $serializedDescriptionListNode->textContent : false;
169 $classDescriptionList = new eZSerializedObjectNameList( $serializedDescriptionList );
170
171 $classIdentifier = $content->getElementsByTagName( 'identifier' )->item( 0 )->textContent;
172 $classRemoteID = $content->getElementsByTagName( 'remote-id' )->item( 0 )->textContent;
173 $classObjectNamePattern = $content->getElementsByTagName( 'object-name-pattern' )->item( 0 )->textContent;
174 $classURLAliasPattern = is_object( $content->getElementsByTagName( 'url-alias-pattern' )->item( 0 ) ) ?
175 $content->getElementsByTagName( 'url-alias-pattern' )->item( 0 )->textContent :
176 null;
177 $classIsContainer = $content->getAttribute( 'is-container' );
178 if ( $classIsContainer !== false )
179 $classIsContainer = $classIsContainer == 'true' ? 1 : 0;
180
181 $classRemoteNode = $content->getElementsByTagName( 'remote' )->item( 0 );
182 $classID = $classRemoteNode->getElementsByTagName( 'id' )->item( 0 )->textContent;
183 $classGroupsNode = $classRemoteNode->getElementsByTagName( 'groups' )->item( 0 );
184 $classCreated = $classRemoteNode->getElementsByTagName( 'created' )->item( 0 )->textContent;
185 $classModified = $classRemoteNode->getElementsByTagName( 'modified' )->item( 0 )->textContent;
186 $classCreatorNode = $classRemoteNode->getElementsByTagName( 'creator' )->item( 0 );
187 $classModifierNode = $classRemoteNode->getElementsByTagName( 'modifier' )->item( 0 );
188
189 $classAttributesNode = $content->getElementsByTagName( 'attributes' )->item( 0 );
190
191 $dateTime = time();
192 $classCreated = $dateTime;
193 $classModified = $dateTime;
194
195 $userID = false;
196 if ( isset( $installParameters['user_id'] ) )
197 $userID = $installParameters['user_id'];
198
199 $class = eZContentClass::fetchByRemoteID( $classRemoteID );
200
201 if ( $class )
202 {
203 $className = $class->name();
204 $description = ezpI18n::tr( 'kernel/package', "Class '%classname' already exists.", false,
205 array( '%classname' => $className ) );
206
207 $choosenAction = $this->errorChoosenAction( self::ERROR_EXISTS,
208 $installParameters, $description, $this->HandlerType );
209 switch( $choosenAction )
210 {
211 case eZPackage::NON_INTERACTIVE:
212 case self::ACTION_REPLACE:
213 if ( eZContentClassOperations::remove( $class->attribute( 'id' ) ) == false )
214 {
215 eZDebug::writeWarning( "Unable to remove class '$className'." );
216 return true;
217 }
218 eZDebug::writeNotice( "Class '$className' will be replaced.", 'eZContentClassPackageHandler' );
219 break;
220
221 case self::ACTION_SKIP:
222 return true;
223
224 case self::ACTION_NEW:
225 $class->setAttribute( 'remote_id', eZRemoteIdUtility::generate( 'class' ) );
226 $class->store();
227 $classNameList->appendGroupName( " (imported)" );
228 break;
229
230 default:
231 $installParameters['error'] = array( 'error_code' => self::ERROR_EXISTS,
232 'element_id' => $classRemoteID,
233 'description' => $description,
234 'actions' => array() );
235 if ( $class->isRemovable() )
236 {
237 $errorMsg = ezpI18n::tr( 'kernel/package', "Replace existing class" );
238 $objectsCount = eZContentObject::fetchSameClassListCount( $class->attribute( 'id' ) );
239 if ( $objectsCount )
240 $errorMsg .= ' ' . ezpI18n::tr( 'kernel/package', "(Warning! $objectsCount content object(s) and their sub-items will be removed)" );
241 $installParameters['error']['actions'][self::ACTION_REPLACE] = $errorMsg;
242 }
243 $installParameters['error']['actions'][self::ACTION_SKIP] = ezpI18n::tr( 'kernel/package', 'Skip installing this class' );
244 $installParameters['error']['actions'][self::ACTION_NEW] = ezpI18n::tr( 'kernel/package', 'Keep existing and create a new one' );
245 return false;
246 }
247 }
248
249 unset( $class );
250
251 // Try to create a unique class identifier
252 $currentClassIdentifier = $classIdentifier;
253 $unique = false;
254
255 while( !$unique )
256 {
257 $classList = eZContentClass::fetchByIdentifier( $currentClassIdentifier );
258 if ( $classList )
259 {
260 // "increment" class identifier
261 if ( preg_match( '/^(.*)_(\d+)$/', $currentClassIdentifier, $matches ) )
262 $currentClassIdentifier = $matches[1] . '_' . ( $matches[2] + 1 );
263 else
264 $currentClassIdentifier = $currentClassIdentifier . '_1';
265 }
266 else
267 $unique = true;
268
269 unset( $classList );
270 }
271
272 $classIdentifier = $currentClassIdentifier;
273
274 $values = array( 'version' => 0,
275 'serialized_name_list' => $classNameList->serializeNames(),
276 'serialized_description_list' => $classDescriptionList->serializeNames(),
277 'create_lang_if_not_exist' => true,
278 'identifier' => $classIdentifier,
279 'remote_id' => $classRemoteID,
280 'contentobject_name' => $classObjectNamePattern,
281 'url_alias_name' => $classURLAliasPattern,
282 'is_container' => $classIsContainer,
283 'created' => $classCreated,
284 'modified' => $classModified );
285
286 if ( $content->hasAttribute( 'sort-field' ) )
287 {
288 $values['sort_field'] = eZContentObjectTreeNode::sortFieldID( $content->getAttribute( 'sort-field' ) );
289 }
290 else
291 {
292 eZDebug::writeNotice( 'The sort field was not specified in the content class package. ' .
293 'This property is exported and imported since eZ Publish 4.0.2', __METHOD__ );
294 }
295
296 if ( $content->hasAttribute( 'sort-order' ) )
297 {
298 $values['sort_order'] = $content->getAttribute( 'sort-order' );
299 }
300 else
301 {
302 eZDebug::writeNotice( 'The sort order was not specified in the content class package. ' .
303 'This property is exported and imported since eZ Publish 4.0.2', __METHOD__ );
304 }
305
306 if ( $content->hasAttribute( 'always-available' ) )
307 {
308 $values['always_available'] = ( $content->getAttribute( 'always-available' ) === 'true' ? 1 : 0 );
309 }
310 else
311 {
312 eZDebug::writeNotice( 'The default object availability was not specified in the content class package. ' .
313 'This property is exported and imported since eZ Publish 4.0.2', __METHOD__ );
314 }
315
316 // create class
317 $class = eZContentClass::create( $userID,
318 $values );
319 $class->store();
320
321 $classID = $class->attribute( 'id' );
322
323 if ( !isset( $installData['classid_list'] ) )
324 $installData['classid_list'] = array();
325 if ( !isset( $installData['classid_map'] ) )
326 $installData['classid_map'] = array();
327 $installData['classid_list'][] = $class->attribute( 'id' );
328 $installData['classid_map'][$classID] = $class->attribute( 'id' );
329
330 // create class attributes
331 $classAttributeList = $classAttributesNode->getElementsByTagName( 'attribute' );
332 foreach ( $classAttributeList as $classAttributeNode )
333 {
334 $isNotSupported = strtolower( $classAttributeNode->getAttribute( 'unsupported' ) ) == 'true';
335 if ( $isNotSupported )
336 continue;
337
338 $attributeDatatype = $classAttributeNode->getAttribute( 'datatype' );
339 $attributeIsRequired = strtolower( $classAttributeNode->getAttribute( 'required' ) ) == 'true';
340 $attributeIsSearchable = strtolower( $classAttributeNode->getAttribute( 'searchable' ) ) == 'true';
341 $attributeIsInformationCollector = strtolower( $classAttributeNode->getAttribute( 'information-collector' ) ) == 'true';
342 $attributeIsTranslatable = strtolower( $classAttributeNode->getAttribute( 'translatable' ) ) == 'true';
343 $attributeSerializedNameListNode = $classAttributeNode->getElementsByTagName( 'serialized-name-list' )->item( 0 );
344 $attributeSerializedNameListContent = $attributeSerializedNameListNode ? $attributeSerializedNameListNode->textContent : false;
345 $attributeSerializedNameList = new eZSerializedObjectNameList( $attributeSerializedNameListContent );
346 if ( $attributeSerializedNameList->isEmpty() )
347 $attributeSerializedNameList->initFromString( $classAttributeNode->getElementsByTagName( 'name' )->item( 0 )->textContent ); // for backward compatibility( <= 3.8 )
348 $attributeSerializedNameList->validate( );
349
350 $attributeSerializedDescriptionListNode = $classAttributeNode->getElementsByTagName( 'serialized-description-list' )->item( 0 );
351 $attributeSerializedDescriptionListContent = $attributeSerializedDescriptionListNode ? $attributeSerializedDescriptionListNode->textContent : false;
352 $attributeSerializedDescriptionList = new eZSerializedObjectNameList( $attributeSerializedDescriptionListContent );
353
354 $attributeCategoryNode = $classAttributeNode->getElementsByTagName( 'category' )->item( 0 );
355 $attributeCategory = $attributeCategoryNode ? $attributeCategoryNode->textContent : '';
356
357 $attributeSerializedDataTextNode = $classAttributeNode->getElementsByTagName( 'serialized-description-text' )->item( 0 );
358 $attributeSerializedDataTextContent = $attributeSerializedDataTextNode ? $attributeSerializedDataTextNode->textContent : false;
359 $attributeSerializedDataText = new eZSerializedObjectNameList( $attributeSerializedDataTextContent );
360
361 $attributeIdentifier = $classAttributeNode->getElementsByTagName( 'identifier' )->item( 0 )->textContent;
362 $attributePlacement = $classAttributeNode->getElementsByTagName( 'placement' )->item( 0 )->textContent;
363 $attributeDatatypeParameterNode = $classAttributeNode->getElementsByTagName( 'datatype-parameters' )->item( 0 );
364
365 $classAttribute = $class->fetchAttributeByIdentifier( $attributeIdentifier );
366 if ( !$classAttribute )
367 {
368 $classAttribute = eZContentClassAttribute::create( $class->attribute( 'id' ),
369 $attributeDatatype,
370 array( 'version' => 0,
371 'identifier' => $attributeIdentifier,
372 'serialized_name_list' => $attributeSerializedNameList->serializeNames(),
373 'serialized_description_list' => $attributeSerializedDescriptionList->serializeNames(),
374 'category' => $attributeCategory,
375 'serialized_data_text' => $attributeSerializedDataText->serializeNames(),
376 'is_required' => $attributeIsRequired,
377 'is_searchable' => $attributeIsSearchable,
378 'is_information_collector' => $attributeIsInformationCollector,
379 'can_translate' => $attributeIsTranslatable,
380 'placement' => $attributePlacement ) );
381
382 $dataType = $classAttribute->dataType();
383 $classAttribute->store();
384 if ( $dataType != null )
385 $dataType->unserializeContentClassAttribute( $classAttribute, $classAttributeNode, $attributeDatatypeParameterNode );
386 $classAttribute->sync();
387 }
388 }
389
390 // add class to a class group
391 $classGroupsList = $classGroupsNode->getElementsByTagName( 'group' );
392 foreach ( $classGroupsList as $classGroupNode )
393 {
394 $classGroupName = $classGroupNode->getAttribute( 'name' );
395 $classGroup = eZContentClassGroup::fetchByName( $classGroupName );
396 if ( !$classGroup )
397 {
398 $classGroup = eZContentClassGroup::create();
399 $classGroup->setAttribute( 'name', $classGroupName );
400 $classGroup->store();
401 }
402 $classGroup->appendClass( $class );
403 }
404 return true;
405 }
406
407 function add( $packageType, $package, $cli, $parameters )
408 {
409 foreach ( $parameters['class-list'] as $classItem )
410 {
411 $classID = $classItem['id'];
412 $classIdentifier = $classItem['identifier'];
413 $classValue = $classItem['value'];
414 $cli->notice( "Adding class $classValue to package" );
415 $this->addClass( $package, $classID, $classIdentifier );
416 }
417 }
418
424 static function addClass( $package, $classID, $classIdentifier = false )
425 {
426 $class = false;
427 if ( is_numeric( $classID ) )
428 $class = eZContentClass::fetch( $classID );
429 if ( !$class )
430 return;
431 $classNode = eZContentClassPackageHandler::classDOMTree( $class );
432 if ( !$classNode )
433 return;
434 if ( !$classIdentifier )
435 $classIdentifier = $class->attribute( 'identifier' );
436 $package->appendInstall( 'ezcontentclass', false, false, true,
437 'class-' . $classIdentifier, 'ezcontentclass',
438 array( 'content' => $classNode ) );
439 $package->appendProvides( 'ezcontentclass', 'contentclass', $class->attribute( 'identifier' ) );
440 $package->appendInstall( 'ezcontentclass', false, false, false,
441 'class-' . $classIdentifier, 'ezcontentclass',
442 array( 'content' => false ) );
443 }
444
445 function handleAddParameters( $packageType, $package, $cli, $arguments )
446 {
447 return $this->handleParameters( $packageType, $package, $cli, 'add', $arguments );
448 }
449
453 function handleParameters( $packageType, $package, $cli, $type, $arguments )
454 {
455 $classList = false;
456 foreach ( $arguments as $argument )
457 {
458 if ( $argument[0] == '-' )
459 {
460 if ( strlen( $argument ) > 1 and
461 $argument[1] == '-' )
462 {
463 }
464 else
465 {
466 }
467 }
468 else
469 {
470 if ( $classList === false )
471 {
472 $classList = array();
473 $classArray = explode( ',', $argument );
474 $error = false;
475 foreach ( $classArray as $classID )
476 {
477 if ( in_array( $classID, $classList ) )
478 {
479 $cli->notice( "Content class $classID already in list" );
480 continue;
481 }
482 if ( is_numeric( $classID ) )
483 {
484 if ( !eZContentClass::exists( $classID, 0, false, false ) )
485 {
486 $cli->error( "Content class with ID $classID does not exist" );
487 $error = true;
488 }
489 else
490 {
491 unset( $class );
492 $class = eZContentClass::fetch( $classID );
493 $classList[] = array( 'id' => $classID,
494 'identifier' => $class->attribute( 'identifier' ),
495 'value' => $classID );
496 }
497 }
498 else
499 {
500 $realClassID = eZContentClass::exists( $classID, 0, false, true );
501 if ( !$realClassID )
502 {
503 $cli->error( "Content class with identifier $classID does not exist" );
504 $error = true;
505 }
506 else
507 {
508 unset( $class );
509 $class = eZContentClass::fetch( $realClassID );
510 $classList[] = array( 'id' => $realClassID,
511 'identifier' => $class->attribute( 'identifier' ),
512 'value' => $classID );
513 }
514 }
515 }
516 if ( $error )
517 return false;
518 }
519 }
520 }
521 if ( $classList === false )
522 {
523 $cli->error( "No class ids chosen" );
524 return false;
525 }
526 return array( 'class-list' => $classList );
527 }
528
533 static function classDOMTree( $class )
534 {
535 if ( !$class )
536 {
537 $retValue = false;
538 return $retValue;
539 }
540
541 $dom = new DOMDocument( '1.0', 'utf-8' );
542 $classNode = $dom->createElement( 'content-class' );
543 $dom->appendChild( $classNode );
544
545 $serializedNameListNode = $dom->createElement( 'serialized-name-list' );
546 $serializedNameListNode->appendChild( $dom->createTextNode( $class->attribute( 'serialized_name_list' ) ) );
547 $classNode->appendChild( $serializedNameListNode );
548
549 $identifierNode = $dom->createElement( 'identifier' );
550 $identifierNode->appendChild( $dom->createTextNode( $class->attribute( 'identifier' ) ) );
551 $classNode->appendChild( $identifierNode );
552
553 $serializedDescriptionListNode = $dom->createElement( 'serialized-description-list' );
554 $serializedDescriptionListNode->appendChild( $dom->createTextNode( $class->attribute( 'serialized_description_list' ) ) );
555 $classNode->appendChild( $serializedDescriptionListNode );
556
557 $remoteIDNode = $dom->createElement( 'remote-id' );
558 $remoteIDNode->appendChild( $dom->createTextNode( $class->attribute( 'remote_id' ) ) );
559 $classNode->appendChild( $remoteIDNode );
560
561 $objectNamePatternNode = $dom->createElement( 'object-name-pattern' );
562 $objectNamePatternNode->appendChild( $dom->createTextNode( $class->attribute( 'contentobject_name' ) ) );
563 $classNode->appendChild( $objectNamePatternNode );
564
565 $urlAliasPatternNode = $dom->createElement( 'url-alias-pattern' );
566 $urlAliasPatternNode->appendChild( $dom->createTextNode( $class->attribute( 'url_alias_name' ) ) );
567 $classNode->appendChild( $urlAliasPatternNode );
568
569 $isContainer = $class->attribute( 'is_container' ) ? 'true' : 'false';
570 $classNode->setAttribute( 'is-container', $isContainer );
571 $classNode->setAttribute( 'always-available', $class->attribute( 'always_available' ) ? 'true' : 'false' );
572 $classNode->setAttribute( 'sort-field', eZContentObjectTreeNode::sortFieldName( $class->attribute( 'sort_field' ) ) );
573 $classNode->setAttribute( 'sort-order', $class->attribute( 'sort_order' ) );
574
575 // Remote data start
576 $remoteNode = $dom->createElement( 'remote' );
577 $classNode->appendChild( $remoteNode );
578
579 $ini = eZINI::instance();
580 $siteName = $ini->variable( 'SiteSettings', 'SiteURL' );
581
582 $classURL = 'http://' . $siteName . '/class/view/' . $class->attribute( 'id' );
583 $siteURL = 'http://' . $siteName . '/';
584
585 $siteUrlNode = $dom->createElement( 'site-url' );
586 $siteUrlNode->appendChild( $dom->createTextNode( $siteURL ) );
587 $remoteNode->appendChild( $siteUrlNode );
588
589 $urlNode = $dom->createElement( 'url' );
590 $urlNode->appendChild( $dom->createTextNode( $classURL ) );
591 $remoteNode->appendChild( $urlNode );
592
593 $classGroupsNode = $dom->createElement( 'groups' );
594
595 $classGroupList = eZContentClassClassGroup::fetchGroupList( $class->attribute( 'id' ),
596 $class->attribute( 'version' ) );
597 foreach ( $classGroupList as $classGroupLink )
598 {
599 $classGroup = eZContentClassGroup::fetch( $classGroupLink->attribute( 'group_id' ) );
600 if ( $classGroup )
601 {
602 unset( $groupNode );
603 $groupNode = $dom->createElement( 'group' );
604 $groupNode->setAttribute( 'id', $classGroup->attribute( 'id' ) );
605 $groupNode->setAttribute( 'name', $classGroup->attribute( 'name' ) );
606 $classGroupsNode->appendChild( $groupNode );
607 }
608 }
609 $remoteNode->appendChild( $classGroupsNode );
610
611 $idNode = $dom->createElement( 'id' );
612 $idNode->appendChild( $dom->createTextNode( $class->attribute( 'id' ) ) );
613 $remoteNode->appendChild( $idNode );
614 $createdNode = $dom->createElement( 'created' );
615 $createdNode->appendChild( $dom->createTextNode( $class->attribute( 'created' ) ) );
616 $remoteNode->appendChild( $createdNode );
617 $modifiedNode = $dom->createElement( 'modified' );
618 $modifiedNode->appendChild( $dom->createTextNode( $class->attribute( 'modified' ) ) );
619 $remoteNode->appendChild( $modifiedNode );
620
621 $creatorNode = $dom->createElement( 'creator' );
622 $remoteNode->appendChild( $creatorNode );
623 $creatorIDNode = $dom->createElement( 'user-id' );
624 $creatorIDNode->appendChild( $dom->createTextNode( $class->attribute( 'creator_id' ) ) );
625 $creatorNode->appendChild( $creatorIDNode );
626 $creator = $class->attribute( 'creator' );
627 if ( $creator )
628 {
629 $creatorLoginNode = $dom->createElement( 'user-login' );
630 $creatorLoginNode->appendChild( $dom->createTextNode( $creator->attribute( 'login' ) ) );
631 $creatorNode->appendChild( $creatorLoginNode );
632 }
633
634 $modifierNode = $dom->createElement( 'modifier' );
635 $remoteNode->appendChild( $modifierNode );
636 $modifierIDNode = $dom->createElement( 'user-id' );
637 $modifierIDNode->appendChild( $dom->createTextNode( $class->attribute( 'modifier_id' ) ) );
638 $modifierNode->appendChild( $modifierIDNode );
639 $modifier = $class->attribute( 'modifier' );
640 if ( $modifier )
641 {
642 $modifierLoginNode = $dom->createElement( 'user-login' );
643 $modifierLoginNode->appendChild( $dom->createTextNode( $modifier->attribute( 'login' ) ) );
644 $modifierNode->appendChild( $modifierLoginNode );
645 }
646 // Remote data end
647
648 $attributesNode = $dom->createElementNS( 'http://ezpublish/contentclassattribute', 'ezcontentclass-attribute:attributes' );
649 $classNode->appendChild( $attributesNode );
650
651 $attributes = $class->fetchAttributes();
652 foreach( $attributes as $attribute )
653 {
654 $attributeNode = $dom->createElement( 'attribute' );
655 $attributeNode->setAttribute( 'datatype', $attribute->attribute( 'data_type_string' ) );
656 $required = $attribute->attribute( 'is_required' ) ? 'true' : 'false';
657 $attributeNode->setAttribute( 'required' , $required );
658 $searchable = $attribute->attribute( 'is_searchable' ) ? 'true' : 'false';
659 $attributeNode->setAttribute( 'searchable' , $searchable );
660 $informationCollector = $attribute->attribute( 'is_information_collector' ) ? 'true' : 'false';
661 $attributeNode->setAttribute( 'information-collector' , $informationCollector );
662 $translatable = $attribute->attribute( 'can_translate' ) ? 'true' : 'false';
663 $attributeNode->setAttribute( 'translatable' , $translatable );
664
665 $attributeRemoteNode = $dom->createElement( 'remote' );
666 $attributeNode->appendChild( $attributeRemoteNode );
667
668 $attributeIDNode = $dom->createElement( 'id' );
669 $attributeIDNode->appendChild( $dom->createTextNode( $attribute->attribute( 'id' ) ) );
670 $attributeRemoteNode->appendChild( $attributeIDNode );
671
672 $attributeSerializedNameListNode = $dom->createElement( 'serialized-name-list' );
673 $attributeSerializedNameListNode->appendChild( $dom->createTextNode( $attribute->attribute( 'serialized_name_list' ) ) );
674 $attributeNode->appendChild( $attributeSerializedNameListNode );
675
676 $attributeIdentifierNode = $dom->createElement( 'identifier' );
677 $attributeIdentifierNode->appendChild( $dom->createTextNode( $attribute->attribute( 'identifier' ) ) );
678 $attributeNode->appendChild( $attributeIdentifierNode );
679
680 $attributeSerializedDescriptionListNode = $dom->createElement( 'serialized-description-list' );
681 $attributeSerializedDescriptionListNode->appendChild( $dom->createTextNode( $attribute->attribute( 'serialized_description_list' ) ) );
682 $attributeNode->appendChild( $attributeSerializedDescriptionListNode );
683
684 $attributeCategoryNode = $dom->createElement( 'category' );
685 $attributeCategoryNode->appendChild( $dom->createTextNode( $attribute->attribute( 'category' ) ) );
686 $attributeNode->appendChild( $attributeCategoryNode );
687
688 $attributeSerializedDataTextNode = $dom->createElement( 'serialized-data-text' );
689 $attributeSerializedDataTextNode->appendChild( $dom->createTextNode( $attribute->attribute( 'serialized_data_text' ) ) );
690 $attributeNode->appendChild( $attributeSerializedDataTextNode );
691
692 $attributePlacementNode = $dom->createElement( 'placement' );
693 $attributePlacementNode->appendChild( $dom->createTextNode( $attribute->attribute( 'placement' ) ) );
694 $attributeNode->appendChild( $attributePlacementNode );
695
696 $attributeParametersNode = $dom->createElement( 'datatype-parameters' );
697 $attributeNode->appendChild( $attributeParametersNode );
698
699 $dataType = $attribute->dataType();
700 if ( is_object( $dataType ) )
701 {
702 $dataType->serializeContentClassAttribute( $attribute, $attributeNode, $attributeParametersNode );
703 }
704
705 $attributesNode->appendChild( $attributeNode );
706 }
707 eZDebug::writeDebug( $dom->saveXML(), 'content class package XML' );
708 return $classNode;
709 }
710
711 function contentclassDirectory()
712 {
713 return 'ezcontentclass';
714 }
715 }
716
717 ?>
eZContentClassAttribute\create
static create( $class_id, $data_type_string, $optionalValues=array(), $languageLocale=false)
Definition: ezcontentclassattribute.php:221
eZContentClassClassGroup\fetchGroupList
static fetchGroupList( $contentclass_id, $contentclass_version, $asObject=true)
Definition: ezcontentclassclassgroup.php:201
eZContentClassGroup\fetch
static fetch( $id, $user_id=false, $asObject=true)
Definition: ezcontentclassgroup.php:118
eZContentClassGroup\fetchByName
static fetchByName( $name, $asObject=true)
Definition: ezcontentclassgroup.php:109
eZContentClassGroup\create
static create( $userID=false)
Definition: ezcontentclassgroup.php:60
eZContentClassNameList
Definition: ezcontentclassnamelist.php:12
eZContentClassOperations\remove
static remove( $classID)
Definition: ezcontentclassoperations.php:25
eZContentClassPackageHandler
Handles content classes in the package system.
Definition: ezcontentclasspackagehandler.php:18
eZContentClassPackageHandler\$HandlerType
$HandlerType
Definition: ezcontentclasspackagehandler.php:19
eZContentClassPackageHandler\contentclassDirectory
contentclassDirectory()
Definition: ezcontentclasspackagehandler.php:711
eZContentClassPackageHandler\__construct
__construct()
Definition: ezcontentclasspackagehandler.php:28
eZContentClassPackageHandler\explainInstallItem
explainInstallItem( $package, $installItem, $requestedInfo=array( 'name', 'identifier', 'description', 'language_info'))
Definition: ezcontentclasspackagehandler.php:37
eZContentClassPackageHandler\ERROR_EXISTS
const ERROR_EXISTS
Definition: ezcontentclasspackagehandler.php:20
eZContentClassPackageHandler\install
install( $package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData)
Definition: ezcontentclasspackagehandler.php:153
eZContentClassPackageHandler\ACTION_SKIP
const ACTION_SKIP
Definition: ezcontentclasspackagehandler.php:24
eZContentClassPackageHandler\add
add( $packageType, $package, $cli, $parameters)
Definition: ezcontentclasspackagehandler.php:407
eZContentClassPackageHandler\ACTION_REPLACE
const ACTION_REPLACE
Definition: ezcontentclasspackagehandler.php:23
eZContentClassPackageHandler\addClass
static addClass( $package, $classID, $classIdentifier=false)
Definition: ezcontentclasspackagehandler.php:424
eZContentClassPackageHandler\ACTION_NEW
const ACTION_NEW
Definition: ezcontentclasspackagehandler.php:25
eZContentClassPackageHandler\classDOMTree
static classDOMTree( $class)
Definition: ezcontentclasspackagehandler.php:533
eZContentClassPackageHandler\handleParameters
handleParameters( $packageType, $package, $cli, $type, $arguments)
Definition: ezcontentclasspackagehandler.php:453
eZContentClassPackageHandler\uninstall
uninstall( $package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData)
Definition: ezcontentclasspackagehandler.php:100
eZContentClassPackageHandler\ACTION_DELETE
const ACTION_DELETE
Definition: ezcontentclasspackagehandler.php:26
eZContentClassPackageHandler\ERROR_HAS_OBJECTS
const ERROR_HAS_OBJECTS
Definition: ezcontentclasspackagehandler.php:21
eZContentClassPackageHandler\handleAddParameters
handleAddParameters( $packageType, $package, $cli, $arguments)
Definition: ezcontentclasspackagehandler.php:445
eZContentClass\fetchByRemoteID
static fetchByRemoteID( $remoteID, $asObject=true, $version=eZContentClass::VERSION_STATUS_DEFINED, $user_id=false, $parent_id=null)
Definition: ezcontentclass.php:1170
eZContentClass\fetchByIdentifier
static fetchByIdentifier( $identifier, $asObject=true, $version=eZContentClass::VERSION_STATUS_DEFINED, $user_id=false, $parent_id=null)
Definition: ezcontentclass.php:1203
eZContentClass\fetch
static fetch( $id, $asObject=true, $version=eZContentClass::VERSION_STATUS_DEFINED, $user_id=false, $parent_id=null)
Definition: ezcontentclass.php:1116
eZContentClass\exists
static exists( $id, $version=eZContentClass::VERSION_STATUS_DEFINED, $userID=false, $useIdentifier=false)
Definition: ezcontentclass.php:1092
eZContentClass\create
static create( $userID=false, $optionalValues=array(), $languageLocale=false)
Definition: ezcontentclass.php:207
eZContentObjectTreeNode\sortFieldName
static sortFieldName( $sortFieldID)
Definition: ezcontentobjecttreenode.php:2725
eZContentObjectTreeNode\sortFieldID
static sortFieldID( $sortFieldName)
Definition: ezcontentobjecttreenode.php:2764
eZContentObject\fetchSameClassListCount
static fetchSameClassListCount( $contentClassID)
Definition: ezcontentobject.php:1259
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:588
eZDebug\writeNotice
static writeNotice( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:459
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZPackageHandler
The class eZPackageHandler does.
Definition: ezpackagehandler.php:18
eZPackageHandler\errorChoosenAction
static errorChoosenAction( $errorCode, &$installParameters, $description, $handlerType, $resetError=true)
Definition: ezpackagehandler.php:213
eZPackage\NON_INTERACTIVE
const NON_INTERACTIVE
Definition: ezpackage.php:33
eZRemoteIdUtility\generate
static generate( $type='')
Definition: ezremoteidutility.php:21
eZSerializedObjectNameList
Definition: ezserializedobjectnamelist.php:12
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+.