Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezpackage.php
Go to the documentation of this file.
1 <?php
19 class eZPackage
20 {
21 public $RepositoryPath;
22 public $RepositoryInformation;
23 public $PolicyCache;
24 public $InstallData;
25 const VERSION = '3.5.2';
26 const DEVELOPMENT = false;
27 const USE_CACHE = true;
28 const CACHE_CODE_DATE = 1069339607;
29
30 const STATUS_ALREADY_EXISTS = 1;
31 const STATUS_INVALID_NAME = 2;
32
33 const NON_INTERACTIVE = -1;
34
41 public function __construct( $parameters = array(), $repositoryPath = false )
42 {
43 $this->setParameters( $parameters );
44 if ( !$repositoryPath )
45 $repositoryPath = eZPackage::repositoryPath();
46 $this->RepositoryPath = $repositoryPath;
47 $this->RepositoryInformation = null;
48 }
49
53 function remove()
54 {
55 $path = $this->path();
56 if ( file_exists( $path ) )
57 {
58 eZDir::recursiveDelete( $path );
59 }
60 $this->setInstalled( false );
61 }
62
66 function setParameters( $parameters = array() )
67 {
68 $timestamp = time();
69 if ( isset( $_SERVER['HOSTNAME'] ) )
70 $host = $_SERVER['HOSTNAME'];
71 else if ( isset( $_SERVER['HTTP_HOST'] ) )
72 $host = $_SERVER['HTTP_HOST'];
73 else
74 $host = 'localhost';
75 $packaging = array( 'timestamp' => $timestamp,
76 'host' => $host,
77 'packager' => false );
78 $ezpublishVersion = eZPublishSDK::version( true );
79 $ezpublishNamedVersion = eZPublishSDK::version( false, false, true );
80 $ezpublish = array( 'version' => $ezpublishVersion,
81 'named-version' => $ezpublishNamedVersion );
82 $defaults = array( 'name' => false,
83 'development' => eZPackage::DEVELOPMENT,
84 'summary' => false,
85 'description' => false,
86 'vendor' => false,
87 'vendor-dir' => false,
88 'priority' => false,
89 'type' => false,
90 'extension' => false,
91 'install_type' => 'install',
92 'ezpublish' => $ezpublish,
93 'maintainers' => array(),
94 'packaging' => $packaging,
95 'source' => false,
96 'documents' => array(),
97 'groups' => array(),
98 'changelog' => array(),
99 'file-list' => array(),
100 'simple-file-list' => array(),
101 'version-number' => false,
102 'release-number' => false,
103 'release-timestamp' => false,
104 'licence' => false,
105 'state' => false,
106 'dependencies' => array( 'provides' => array(),
107 'requires' => array(),
108 'obsoletes' => array(),
109 'conflicts' => array() ),
110 'install' => array(),
111 'uninstall' => array() );
112 $this->PolicyCache = array();
113 $this->InstallData = array();
114 $this->Parameters = array_merge( $defaults, $parameters );
115 }
116
122 static function typeList()
123 {
124 $typeList =& $GLOBALS['eZPackageTypeList'];
125 if ( !isset( $typeList ) )
126 {
127 $typeList = array();
128 $ini = eZINI::instance( 'package.ini' );
129 $types = $ini->variable( 'PackageSettings', 'TypeList' );
130 foreach ( $types as $typeID => $typeName )
131 {
132 $typeList[] = array( 'name' => $typeName,
133 'id' => $typeID );
134 }
135 }
136 return $typeList;
137 }
138
144 static function stateList()
145 {
146 $stateList =& $GLOBALS['eZPackageStateList'];
147 if ( !isset( $stateList ) )
148 {
149 $stateList = array();
150 $ini = eZINI::instance( 'package.ini' );
151 $states = $ini->variable( 'PackageSettings', 'StateList' );
152 foreach ( $states as $stateID => $stateName )
153 {
154 $stateList[] = array( 'name' => $stateName,
155 'id' => $stateID);
156 }
157 }
158 return $stateList;
159 }
160
165 static function create( $name, $parameters = array(), $repositoryPath = false, $repositoryID = false )
166 {
167 $parameters['name'] = $name;
168 $handler = new eZPackage( $parameters, $repositoryPath );
169
170 // New packages always use local repository
171 if ( $repositoryID === false )
172 $repositoryID = 'local';
173 $repositoryInformation = $handler->repositoryInformation( $repositoryID );
174 if ( $repositoryPath !== false )
175 $repositoryInformation['path'] = $repositoryPath;
176 $handler->setCurrentRepositoryInformation( $repositoryInformation );
177 return $handler;
178 }
179
183 function attributes()
184 {
185 return array( 'is_local',
186 'development',
187 'name', 'summary', 'description',
188 'vendor', 'vendor-dir', 'priority', 'type',
189 'extension', 'source',
190 'version-number', 'release-number', 'release-timestamp',
191 'maintainers', 'documents', 'groups',
192 'simple-file-list', 'file-list', 'file-count',
193 'can_read', 'can_export', 'can_import', 'can_install',
194 'changelog', 'dependencies',
195 'is_installed',
196 'install_type',
197 'thumbnail-list',
198 'install', 'uninstall',
199 'licence', 'state',
200 'ezpublish-version', 'ezpublish-named-version', 'packaging-timestamp',
201 'packaging-host', 'packaging-packager' );
202 }
203
207 function setAttribute( $attributeName, $attributeValue )
208 {
209 if ( !in_array( $attributeName,
210 array( 'development',
211 'name', 'summary', 'description',
212 'vendor', 'vendor-dir', 'priority', 'type',
213 'install_type',
214 'extension', 'source',
215 'licence', 'state' ) ) )
216 return false;
217 if ( array_key_exists( $attributeName, $this->Parameters ) and
218 !is_array( $this->Parameters[$attributeName] ))
219 {
220 $this->Parameters[$attributeName] = $attributeValue;
221 return true;
222 }
223 return false;
224 }
225
229 function hasAttribute( $attributeName /*, $attributeList = false*/ )
230 {
231 return in_array( $attributeName, $this->attributes() );
232 }
233
237 function attribute( $attributeName /*, $attributeList = false*/ )
238 {
239 if ( in_array( $attributeName,
240 array( 'development',
241 'name', 'summary', 'description',
242 'vendor', 'vendor-dir', 'priority', 'type',
243 'extension', 'source',
244 'version-number', 'release-number', 'release-timestamp',
245 'maintainers', 'documents', 'groups',
246 'simple-file-list', 'file-list',
247 'changelog', 'dependencies',
248 'install', 'uninstall',
249 'install_type',
250 'licence', 'state', 'settings-files' ) ) )
251 return $this->Parameters[$attributeName];
252 else if ( $attributeName == 'is_installed' )
253 return $this->isInstalled;
254 else if ( $attributeName == 'ezpublish-version' )
255 return $this->Parameters['ezpublish']['version'];
256 else if ( $attributeName == 'ezpublish-named-version' )
257 return $this->Parameters['ezpublish']['named-version'];
258 else if ( $attributeName == 'packaging-timestamp' )
259 return $this->Parameters['packaging']['timestamp'];
260 else if ( $attributeName == 'packaging-host' )
261 return $this->Parameters['packaging']['host'];
262 else if ( $attributeName == 'packaging-packager' )
263 return $this->Parameters['packaging']['packager'];
264 else if ( $attributeName == 'can_read' )
265 {
266 return $this->canRead();
267 }
268 else if ( $attributeName == 'can_export' )
269 {
270 return $this->canExport();
271 }
272 else if ( $attributeName == 'can_import' )
273 {
274 return $this->canImport();
275 }
276 else if ( $attributeName == 'can_install' )
277 {
278 return $this->canInstall();
279 }
280 else if ( $attributeName == 'file-count' )
281 {
282 return $this->fileCount();
283 }
284 else if ( $attributeName == 'thumbnail-list' )
285 {
286 return $this->thumbnailList( 'default' );
287 }
288 else if ( $attributeName == 'is_local' )
289 {
290 $repositoryInformation = $this->currentRepositoryInformation();
291 return ( $repositoryInformation['type'] == 'local' );
292 }
293
294 eZDebug::writeError( "No such attribute: $attributeName for eZPackage", __METHOD__ );
295 return null;
296 }
297
298 static function canUsePolicyFunction( $functionName )
299 {
300 $currentUser = eZUser::currentUser();
301 $accessResult = $currentUser->hasAccessTo( 'package', $functionName );
302 if ( in_array( $accessResult['accessWord'], array( 'yes', 'limited' ) ) )
303 {
304 return true;
305 }
306 return false;
307 }
308
309 function canRead()
310 {
311 return $this->canUsePackagePolicyFunction( 'read' );
312 }
313
314 function canExport()
315 {
316 return $this->canUsePackagePolicyFunction( 'export' );
317 }
318
319 function canImport()
320 {
321 return $this->canUsePackagePolicyFunction( 'import' );
322 }
323
324 function canInstall()
325 {
326 return $this->canUsePackagePolicyFunction( 'install' );
327 }
328
329 function canUsePackagePolicyFunction( $functionName )
330 {
331 if ( !isset( $this->PolicyCache[$functionName] ) )
332 {
333 $currentUser = eZUser::currentUser();
334 $accessResult = $currentUser->hasAccessTo( 'package', $functionName );
335 $limitationList = array();
336 $canUse = false;
337 if ( $accessResult['accessWord'] == 'yes' )
338 {
339 $this->PolicyCache[$functionName] = true;
340 }
341 else if ( $accessResult['accessWord'] == 'limited' )
342 {
343 $allRoles = array();
344 $limitationList = $accessResult['policies'];
345 $typeList = false;
346 foreach( $limitationList as $limitationArray )
347 {
348 foreach ( $limitationArray as $key => $limitation )
349 {
350 if ( $key == 'Type' )
351 {
352 if ( !is_array( $typeList ) )
353 $typeList = array();
354 $typeList = array_merge( $typeList, $limitation );
355 }
356 }
357 }
358 if ( $typeList === false )
359 {
360 $this->PolicyCache[$functionName] = true;
361 }
362 else
363 {
364 $this->PolicyCache[$functionName] = in_array( $this->attribute( 'type' ), $typeList );
365 }
366 }
367 }
368 return $this->PolicyCache[$functionName];
369 }
370
371 static function fetchMaintainerRoleIDList( $packageType = false, $checkRoles = false )
372 {
373 $allRoles = false;
374 if ( $checkRoles )
375 {
376 $currentUser = eZUser::currentUser();
377 $accessResult = $currentUser->hasAccessTo( 'package', 'create' );
378 $limitationList = array();
379 if ( $accessResult['accessWord'] == 'limited' )
380 {
381 $allRoles = array();
382 $limitationList = $accessResult['policies'];
383 foreach( $limitationList as $limitationArray )
384 {
385 $allowedType = true;
386 $allowedRoles = false;
387 foreach ( $limitationArray as $key => $limitation )
388 {
389 if ( $key == 'Role' )
390 {
391 $allowedRoles = $limitation;
392 }
393 else if ( $key == 'Type' )
394 {
395 $typeList = $limitation;
396 if ( $packageType === false )
397 {
398 $allowedType = in_array( $packageType, $typeList );
399 }
400 }
401 }
402 if ( $allowedType and
403 count( $allowedRoles ) > 0 )
404 {
405 $allRoles = array_merge( $allRoles, $allowedRoles );
406 }
407 }
408 }
409 }
410 if ( is_array( $allRoles ) and count( $allRoles ) == 0 )
411 return array();
412 $ini = eZINI::instance( 'package.ini' );
413 $roleList = $ini->variable( 'MaintainerSettings', 'RoleList' );
414 if ( $allRoles !== false )
415 {
416 $roleList = array_intersect( $roleList, $allRoles );
417 }
418 return $roleList;
419 }
420
421 static function fetchMaintainerRoleList( $packageType = false, $checkRoles = false )
422 {
423 $roleList = eZPackage::fetchMaintainerRoleIDList( $packageType, $checkRoles );
424 $roleNameList = array();
425 foreach ( $roleList as $roleID )
426 {
427 $roleName = eZPackage::maintainerRoleName( $roleID );
428 $roleNameList[] = array( 'name' => $roleName,
429 'id' => $roleID );
430 }
431 return $roleNameList;
432 }
433
434 static function maintainerRoleListForRoles()
435 {
436 $ini = eZINI::instance( 'package.ini' );
437 $roleList = $ini->variable( 'MaintainerSettings', 'RoleList' );
438 $roleNameList = array();
439 foreach ( $roleList as $roleID )
440 {
441 $roleName = eZPackage::maintainerRoleName( $roleID );
442 $roleNameList[] = array( 'name' => $roleName,
443 'id' => $roleID );
444 }
445 return $roleNameList;
446 }
447
448 static function maintainerRoleName( $roleID )
449 {
450 $nameMap = array( 'lead' => ezpI18n::tr( 'kernel/package', 'Lead' ),
451 'developer' => ezpI18n::tr( 'kernel/package', 'Developer' ),
452 'designer' => ezpI18n::tr( 'kernel/package', 'Designer' ),
453 'contributor' => ezpI18n::tr( 'kernel/package', 'Contributor' ),
454 'tester' => ezpI18n::tr( 'kernel/package', 'Tester' ) );
455 if ( isset( $nameMap[$roleID] ) )
456 return $nameMap[$roleID];
457 return false;
458 }
459
460 function appendMaintainer( $name, $email, $role = false )
461 {
462 $this->Parameters['maintainers'][] = array( 'name' => $name,
463 'email' => $email,
464 'role' => $role );
465 }
466
467 function appendDocument( $name, $mimeType = false, $os = false, $audience = false,
468 $create = false, $data = false )
469 {
470 if ( !$mimeType )
471 $mimeType = 'text/plain';
472 $this->Parameters['documents'][] = array( 'name' => $name,
473 'mime-type' => $mimeType,
474 'os' => $os,
475 // 'create-document' => $create,
476 'data' => $data,
477 'audience' => $audience );
478 if ( $create )
479 {
480 eZFile::create( $name, $this->path() . '/' . eZPackage::documentDirectory(),
481 $data );
482 }
483 }
484
485 function appendGroup( $name )
486 {
487 $index = count( $this->Parameters['groups'] );
488 $this->Parameters['groups'][$index] = array( 'name' => $name );
489 }
490
491 function appendChange( $person, $email, $changes,
492 $release = false, $timestamp = null )
493 {
494 if ( $timestamp === null )
495 $timestamp = time();
496 if ( !is_array( $changes ) )
497 $changes = array( $changes );
498 if ( !$release )
499 $release = $this->Parameters['release-number'];
500 if ( !$release )
501 $release = 1;
502 $this->Parameters['changelog'][] = array( 'timestamp' => $timestamp,
503 'person' => $person,
504 'email' => $email,
505 'changes' => $changes,
506 'release' => $release );
507 }
508
509 static function md5sum( $file )
510 {
511 if ( function_exists( 'md5_file' ) )
512 {
513 if ( is_file( $file ) )
514 {
515 return md5_file( $file );
516 }
517 else
518 {
519 eZDebug::writeError( "Could not open file $file for md5sum calculation" );
520 }
521 }
522 else
523 {
524 $fd = @fopen( $file, 'rb' );
525 if ( $fd )
526 {
527 $data = '';
528 while ( !@feof( $fd ) )
529 {
530 $data .= @fread( $fd, 4096 );
531 }
532 @fclose( $fd );
533 return md5( $data );
534 }
535 }
536 return false;
537 }
538
539 function fileStorePath( $fileItem, $collectionName, $path = false, $installVariables = array() )
540 {
541 $type = $fileItem['type'];
542 $variableName = $fileItem['variable-name'];
543 if ( $type == 'file' )
544 {
545 $pathArray = array( $path, $fileItem['subdirectory'] );
546 $pathArray[] = $fileItem['name'];
547 $path = eZDir::path( $pathArray );
548 }
549 else if ( $type == 'design' )
550 {
551 $roleFileName = false;
552 $design = $fileItem['design'];
553 switch ( $fileItem['role'] )
554 {
555 case 'template':
556 {
557 $roleFileName = 'templates';
558 } break;
559 case 'image':
560 {
561 $roleFileName = 'images';
562 } break;
563 case 'stylesheet':
564 {
565 $roleFileName = 'stylesheets';
566 } break;
567 case 'font':
568 {
569 $roleFileName = 'fonts';
570 } break;
571 }
572 if ( $variableName and
573 isset( $installVariables[$variableName] ) )
574 $design = $installVariables[$variableName];
575 $pathArray = array( $path, 'design', $design, $roleFileName, $fileItem['subdirectory'] );
576 if ( $fileItem['file-type'] != 'dir' )
577 $pathArray[] = $fileItem['name'];
578 $path = eZDir::path( $pathArray );
579 }
580 else if ( $type == 'ini' )
581 {
582 $roleValue = false;
583 $roleFileName = false;
584 switch ( $fileItem['role'] )
585 {
586 case 'override':
587 {
588 $roleFileName = 'override';
589 } break;
590 case 'siteaccess':
591 {
592 $roleFileName = 'siteaccess';
593 $roleValue = $fileItem['role-value'];
594 if ( $variableName and
595 isset( $installVariables[$variableName] ) )
596 $roleValue = $installVariables[$variableName];
597 } break;
598 case 'standard':
599 default:
600 {
601 $roleFileName = '';
602 } break;
603 }
604 $pathArray = array( $path, 'settings', $roleFileName, $roleValue, $fileItem['subdirectory'] );
605 if ( $fileItem['file-type'] != 'dir' )
606 $pathArray[] = $fileItem['name'];
607 $path = eZDir::path( $pathArray );
608 }
609 return $path;
610 }
611
612 function fileItemPath( $fileItem, $collectionName, $path = false )
613 {
614 if ( !$path )
615 {
616 $repositoryInformation = $this->currentRepositoryInformation();
617 $path = $repositoryInformation['path'];
618 }
619 $typeDir = $fileItem['type'];
620 if ( $fileItem['type'] == 'design' )
621 $typeDir .= '.' . $fileItem['design'];
622 if ( isset( $fileItem['role'] ) && $fileItem['role'] )
623 {
624 $typeDir .= '.' . $fileItem['role'];
625 if ( $fileItem['role-value'] )
626 $typeDir .= '-' . $fileItem['role-value'];
627 }
628 $path .= '/' . $this->attribute( 'name' ) . '/' . eZPackage::filesDirectory() . '/' . $collectionName . '/' . $typeDir;
629 if ( isset( $fileItem['subdirectory'] ) && $fileItem['subdirectory'] )
630 $path .= '/' . $fileItem['subdirectory'];
631 $path .= '/' . $fileItem['name'];
632 return $path;
633 }
634
635 function fileList( $collectionName )
636 {
637 $fileCollections = $this->Parameters['file-list'];
638 if ( isset( $fileCollections[$collectionName] ) )
639 return $fileCollections[$collectionName];
640 return false;
641 }
642
643 function thumbnailList( $collectionName )
644 {
645 $thumbnails = array();
646 $fileList = $this->fileList( $collectionName );
647 if ( !is_array( $fileList ) )
648 return $thumbnails;
649
650 foreach ( $fileList as $fileItem )
651 {
652 if ( $fileItem['type'] == 'thumbnail' )
653 {
654 $thumbnails[] = $fileItem;
655 }
656 }
657 return $thumbnails;
658 }
659
660 function fileCount()
661 {
662 $count = 0;
663 foreach ( $this->Parameters['file-list'] as $collection )
664 {
665 $count += count( $collection );
666 }
667 return $count;
668 }
669
670 function appendFile( $file, $type, $role,
671 $design, $filePath, $collection,
672 $subDirectory = null, $md5 = null,
673 $copyFile = false, $modified = null, $fileType = false,
674 $roleValue = false, $variableName = false,
675 $packagePath = false )
676 {
677 if ( !$collection )
678 $collection = 'default';
679 if ( $subDirectory === null )
680 {
681 $subDirectory = false;
682 if ( preg_match( '#^(.+)/([^/]+)$#', $file, $matches ) )
683 {
684 $subDirectory = $matches[1];
685 $file = $matches[2];
686 }
687 }
688 if ( $packagePath )
689 $subDirectory = $packagePath;
690
691 $fileItem = array( 'name' => $file,
692 'subdirectory' => $subDirectory,
693 'type' => $type,
694 'role' => $role,
695 'role-value' => $roleValue,
696 'variable-name' => $variableName,
697 'path' => $filePath,
698 'file-type' => $fileType,
699 'design' => $design );
700 if ( $md5 === null )
701 {
702 $md5 = $this->md5sum( $filePath );
703 }
704 $fileItem['md5'] = $md5;
705 $this->Parameters['file-list'][$collection][] = $fileItem;
706
707 if ( $copyFile )
708 {
709 // copying file
710 $typeDir = $type;
711 if ( $type == 'design' )
712 $typeDir .= '.' . $fileItem['design'];
713 if ( $role )
714 {
715 $typeDir .= '.' . $role;
716 if ( $roleValue )
717 $typeDir .= '-' . $roleValue;
718 }
719 $path = $this->path() . '/' . eZPackage::filesDirectory() . '/' . $collection . '/' . $typeDir;
720 if ( $subDirectory )
721 $path .= '/' . $subDirectory;
722 if ( !file_exists( $path ) )
723 eZDir::mkdir( $path, false, true );
724
725 if ( is_dir( $fileItem['path'] ) )
726 {
727 eZDir::copy( $fileItem['path'], $path,
728 $fileItem['name'] != false, true, false, eZDir::temporaryFileRegexp() );
729 }
730 else
731 {
732 eZFileHandler::copy( $fileItem['path'], $path . '/' . $fileItem['name'] );
733 }
734 }
735 }
736
741 function appendProvides( $type, $name, $value, $parameters = false )
742 {
743 $dependencyParameters = array( 'type' => $type,
744 'name' => $name,
745 'value' => $value );
746
747 if ( $parameters !== false )
748 $dependencyParameters = array_merge( $dependencyParameters, $parameters );
749
750 $this->appendDependency( 'provides', $dependencyParameters );
751 }
752
758 function appendDependency( $dependencySection, $parameters )
759 {
760 if ( !in_array( $dependencySection,
761 array( 'provides', 'requires',
762 'obsoletes', 'conflicts' ) ) )
763 return false;
764
765 $this->Parameters['dependencies'][$dependencySection][] = $parameters;
766 }
767
768 function dependencyOperatorText( $dependencyItem )
769 {
770 return '=';
771 }
772
773 function createDependencyText( $cli, $dependencyItem, $dependencySection )
774 {
775 $text = ( $cli->stylize( 'emphasize', $dependencyItem['type'] ) .
776 '(' .
777 $cli->stylize( 'emphasize', $dependencyItem['name'] ) .
778 ')' );
779 if ( $dependencyItem['value'] )
780 $text .= ' ' . $this->dependencyOperatorText( $dependencyItem ) .' ' . $cli->stylize( 'symbol', $dependencyItem['value'] );
781 $handler = $this->packageHandler( $dependencyItem['type'] );
782 if ( $handler )
783 {
784 $specialText = $handler->createDependencyText( $this, $dependencyItem, $dependencySection );
785 if ( $specialText )
786 $text .= ' ( ' . $specialText . ' ) ';
787 }
788 return $text;
789 }
790
791 function groupDependencyItemsByType( $dependencyItems )
792 {
793 $types = array();
794 foreach ( $dependencyItems as $dependencyItem )
795 {
796 if ( !isset( $types[$dependencyItem['type']] ) )
797 $types[$dependencyItem['type']] = array();
798 $types[$dependencyItem['type']][] = $dependencyItem;
799 }
800 return $types;
801 }
802
806 function dependencyItems( $dependencySection, $parameters = false )
807 {
808 if ( !in_array( $dependencySection,
809 array( 'provides', 'requires',
810 'obsoletes', 'conflicts' ) ) )
811 return false;
812
813 if ( $parameters === false )
814 {
815 return $this->Parameters['dependencies'][$dependencySection];
816 }
817
818 $matches = array();
819 $dependencyItems = $this->Parameters['dependencies'][$dependencySection];
820 foreach ( $dependencyItems as $dependencyItem )
821 {
822 $found = true;
823
824 foreach ( $parameters as $paramName => $paramValue )
825 {
826 if ( !isset( $dependencyItem[$paramName] ) ||
827 $dependencyItem[$paramName] != $paramValue )
828 {
829 $found = false;
830 break;
831 }
832 }
833
834 if ( $found )
835 $matches[] = $dependencyItem;
836 }
837
838 return $matches;
839 }
840
844 function installItemsList( $type = false, $os = false, $name = false, $isInstall = true )
845 {
846 $installName = 'install';
847 if ( !$isInstall )
848 $installName = 'uninstall';
849 if ( !$name and !$type and !$os )
850 {
851 return $this->Parameters[$installName];
852 }
853 else
854 {
855 $matches = array();
856 $installItems = $this->Parameters[$installName];
857 foreach ( $installItems as $installItem )
858 {
859 $found = false;
860 if ( $name and $installItem['name'] == $name )
861 $found = true;
862 if ( !$found and $type and $installItem['type'] == $type )
863 $found = true;
864 if ( !$found )
865 {
866 if ( $os )
867 {
868 if ( !$installItem['os'] )
869 $found = true;
870 else if ( $os and $installItem['os'] == $os )
871 $found = true;
872 }
873 else
874 $found = true;
875 }
876 if ( $found )
877 $matches[] = $installItem;
878 }
879 return $matches;
880 }
881 }
882
883 function appendInstall( $type, $name, $os = false, $isInstall = true,
884 $filename = false, $subdirectory = false,
885 $parameters = false )
886 {
887 $installEntry = $parameters;
888 $installEntry['type'] = $type;
889 $installEntry['name'] = $name;
890 $installEntry['os'] = $os;
891 $installEntry['filename'] = $filename;
892 $installEntry['sub-directory'] = $subdirectory;
893 if ( $installEntry['filename'] )
894 {
895 $content = false;
896 if ( isset( $installEntry['content'] ) )
897 $content = $installEntry['content'];
898 if ( $content instanceof DOMElement )
899 {
900 $path = $this->path();
901 if ( $installEntry['sub-directory'] )
902 {
903 $path .= '/' . $installEntry['sub-directory'];
904 }
905 $filePath = $path . '/' . $installEntry['filename'] . '.xml';
906 if ( !file_exists( $path ) )
907 {
908 eZDir::mkdir( $path, false, true );
909 }
910 $partDOM = new DOMDocument( '1.0', 'utf-8' );
911 $partDOM->formatOutput = true;
912 $contentImport = $partDOM->importNode( $content, true );
913 $partDOM->appendChild( $contentImport );
914 $this->storeDOM( $filePath, $partDOM );
915 $installEntry['content'] = false;
916 }
917 }
918 $installName = 'install';
919 if ( !$isInstall )
920 $installName = 'uninstall';
921 $this->Parameters[$installName][] = $installEntry;
922 }
923
927 function setPackager( $timestamp = false, $host = false, $packager = false )
928 {
929 if ( $timestamp )
930 $this->Parameters['packaging']['timestamp'] = $timestamp;
931 if ( $host )
932 $this->Parameters['packaging']['host'] = $host;
933 if ( $packager )
934 $this->Parameters['packaging']['packager'] = $packager;
935 }
936
945 function setRelease( $version = false, $release = false, $timestamp = false,
946 $licence = false, $state = false )
947 {
948 if ( $version !== false )
949 {
950 $this->Parameters['version-number'] = $version;
951 }
952 if ( $release !== false )
953 {
954 $this->Parameters['release-number'] = $release;
955 }
956 if ( $timestamp !== false )
957 {
958 $this->Parameters['release-timestamp'] = $timestamp;
959 }
960 if ( $licence !== false )
961 {
962 $this->Parameters['licence'] = $licence;
963 }
964 if ( $state !== false )
965 {
966 $this->Parameters['state'] = $state;
967 }
968 }
969
974 function toString()
975 {
976 $dom = $this->domStructure();
977 $string = $dom->saveXML();
978 return $string;
979 }
980
986 function storeCache( $directory = false )
987 {
988 if ( !file_exists( $directory ) )
989 eZDir::mkdir( $directory, false, true );
990 $php = new eZPHPCreator( $directory, 'package.php' );
991 $php->addComment( "Automatically created cache file for the package format\n" .
992 "Do not modify this file" );
993 $php->addSpace();
994 $php->addVariable( 'CacheCodeDate', eZPackage::CACHE_CODE_DATE );
995 $php->addSpace();
996 $php->addVariable( 'Parameters', $this->Parameters, eZPHPCreator::VARIABLE_ASSIGNMENT,
997 array( 'full-tree' => true ) );
998 $php->addVariable( 'InstallData', $this->InstallData, eZPHPCreator::VARIABLE_ASSIGNMENT,
999 array( 'full-tree' => true ) );
1000 $php->addVariable( 'RepositoryPath', $this->RepositoryPath );
1001 $php->store();
1002 }
1003
1007 function store()
1008 {
1009 $path = $this->path();
1010 return $this->storePackageFile( $path );
1011 }
1012
1016 function storePackageFile( $path, $storeCache = true )
1017 {
1018 if ( !file_exists( $path ) )
1019 {
1020 eZDir::mkdir( $path, false, true );
1021 }
1022 $filePath = $path . '/' . eZPackage::definitionFilename();
1023
1024 $packageFileString = $this->toString();
1025 $result = $this->storeString( $filePath, $packageFileString );
1026
1027 if ( $storeCache )
1028 $this->storeCache( $path . '/' . $this->cacheDirectory() );
1029 return $result;
1030 }
1031
1035 static function removeFiles( $path )
1036 {
1037 if ( file_exists( $path ) )
1038 {
1039 eZDir::recursiveDelete( $path );
1040 }
1041 }
1042
1046 function exportToArchive( $archivePath )
1047 {
1048 $temporaryExportPath = eZPackage::temporaryExportPath();
1049 $tempPath = $temporaryExportPath . '/' . $this->attribute( 'name' );
1050 $this->removeFiles( $tempPath );
1051
1052 // Create package temp dir and copy package's XML file there
1053 $this->storePackageFile( $tempPath, false );
1054
1055 // Copy package's directories
1056 $directoryList = array( $this->documentDirectory(),
1057 $this->filesDirectory(),
1058 $this->simpleFilesDirectory(),
1059 $this->settingsDirectory() );
1060 $installItems = $this->Parameters['install'];
1061 foreach( $installItems as $installItem )
1062 {
1063 if ( !in_array( $installItem['sub-directory'], $directoryList ) )
1064 $directoryList[] = $installItem['sub-directory'];
1065 }
1066
1067 $path = $this->path();
1068 foreach( $directoryList as $dirName )
1069 {
1070 $destDir = $tempPath;
1071 $dir = $path . '/' . $dirName;
1072 if ( file_exists( $dir ) )
1073 eZDir::copy( $dir, $destDir );
1074 }
1075
1076 $tarArchivePath = $temporaryExportPath . '/archive.tmp';
1077 $tarArchive = ezcArchive::open( $tarArchivePath, ezcArchive::TAR_USTAR );
1078 $tarArchive->truncate();
1079
1080 $prefix = $tempPath . '/';
1081 $fileList = array();
1082 eZDir::recursiveList( $tempPath, $tempPath, $fileList );
1083
1084 foreach ( $fileList as $fileInfo )
1085 {
1086 $path = $fileInfo['type'] === 'dir' ?
1087 $fileInfo['path'] . '/' . $fileInfo['name'] . '/' :
1088 $fileInfo['path'] . '/' . $fileInfo['name'];
1089 $tarArchive->append( array( $path ), $prefix );
1090 }
1091
1092 $tarArchive->close();
1093
1094 copy( $tarArchivePath, "compress.zlib://$archivePath" );
1095
1096 unlink( $tarArchivePath );
1097
1098 $this->removeFiles( $tempPath );
1099 return $archivePath;
1100 }
1101
1113 static function import( $archiveName, &$packageName, $dbAvailable = true, $repositoryID = false )
1114 {
1115 if ( is_dir( $archiveName ) )
1116 {
1117 eZDebug::writeError( "Importing from directory is not supported." );
1118 $retValue = false;
1119 return $retValue;
1120 }
1121 else
1122 {
1123 $tempDirPath = eZPackage::temporaryImportPath();
1124 // make a temporary directory to extract the package file to
1125 do
1126 {
1127 $archivePath = eZDir::path( array( $tempDirPath, mt_rand() ) );
1128 } while ( file_exists( $archivePath ) );
1129
1130 eZDir::mkdir( $archivePath, false, true );
1131
1132 $archiveOptions = new ezcArchiveOptions( array( 'readOnly' => true ) );
1133
1134 // Fix for issue #15891: ezjscore - file names are cutted
1135 // Force the type of the archive as ezcArchive::TAR_GNU so that long file names are supported on Windows
1136 // The previous value for the second parameter was null which meant the type was guessed from the
1137 // archive, but on Windows it was detected as TAR_USTAR and this lead to filenames being limited
1138 // to 100 characters
1139 $archive = ezcArchive::open( "compress.zlib://$archiveName", ezcArchive::TAR_GNU, $archiveOptions );
1140
1141 $fileList = array();
1142 $fileList[] = eZPackage::definitionFilename();
1143
1144 // Search for the files we want to extract
1145 foreach( $archive as $entry )
1146 {
1147 if ( in_array( $entry->getPath(), $fileList ) )
1148 {
1149 if ( !$archive->extractCurrent( $archivePath ) )
1150 {
1151 eZDebug::writeError( "Failed extracting package definition file from $archivePath" );
1152 return false;
1153 }
1154 }
1155 }
1156
1157 $definitionFileName = eZDir::path( array( $archivePath, self::definitionFilename() ) );
1158
1159 $package = eZPackage::fetchFromFile( $definitionFileName );
1160
1161 eZPackage::removeFiles( $archivePath );
1162
1163 if ( $package )
1164 {
1165 $packageName = $package->attribute( 'name' );
1166
1167 if ( !self::isValidName( $packageName ) )
1168 {
1169 return eZPackage::STATUS_INVALID_NAME;
1170 }
1171
1172 if ( !$repositoryID )
1173 {
1174 $repositoryID = $package->attribute( 'vendor-dir' );
1175 }
1176
1177 $existingPackage = eZPackage::fetch( $packageName, false, false, $dbAvailable );
1178 if ( $existingPackage )
1179 {
1180 return eZPackage::STATUS_ALREADY_EXISTS;
1181 }
1182
1183 unset( $package );
1184
1185 $fullRepositoryPath = eZPackage::repositoryPath() . '/' . $repositoryID;
1186 $packagePath = $fullRepositoryPath . '/' . $packageName;
1187 if ( !file_exists( $packagePath ) )
1188 {
1189 eZDir::mkdir( $packagePath, false, true );
1190 }
1191 $archive->extract( $packagePath );
1192
1193 $package = eZPackage::fetch( $packageName, $fullRepositoryPath, false, $dbAvailable );
1194 if ( !$package )
1195 {
1196 eZDebug::writeError( "Failed loading imported package $packageName from $fullRepositoryPath" );
1197 }
1198 }
1199 else
1200 {
1201 eZDebug::writeError( "Failed loading temporary package $packageName" );
1202 }
1203
1204 return $package;
1205 }
1206 }
1207
1212 static function suffix()
1213 {
1214 return 'ezpkg';
1215 }
1216
1220 function exportName()
1221 {
1222 return $this->attribute( 'name' ) . '-' . $this->attribute( 'version-number' ) . '-' . $this->attribute( 'release-number' ) . '.' . eZPackage::suffix();
1223 }
1224
1228 function storeToFile( $filename )
1229 {
1230 $dom = $this->domStructure();
1231 return eZPackage::storeDOM( $filename, $dom );
1232 }
1233
1237 static function applyStorageFilePermissions( $filename )
1238 {
1239 $siteConfig = eZINI::instance( 'site.ini' );
1240 $filePermissions = $siteConfig->variable( 'FileSettings', 'StorageFilePermissions');
1241 chmod( $filename, octdec( $filePermissions ) );
1242 }
1243
1247 static function storeDOM( $filename, $dom )
1248 {
1249 $bytes = $dom->save( $filename );
1250
1251 if ( $bytes !== false )
1252 {
1253 eZPackage::applyStorageFilePermissions( $filename );
1254
1255 eZDebugSetting::writeNotice( 'kernel-ezpackage-store',
1256 "Stored file $filename",
1257 'eZPackage::storeDOM' );
1258 return true;
1259 }
1260 else
1261 {
1262 eZDebug::writeError( "Saving DOM tree to $filename failed", __METHOD__ );
1263 }
1264
1265 return false;
1266 }
1267
1274 static function storeString( $filename, $data )
1275 {
1276 $file = @fopen( $filename, 'w' );
1277 if ( $file )
1278 {
1279 fwrite( $file, $data );
1280 fclose( $file );
1281
1282 eZPackage::applyStorageFilePermissions( $filename );
1283
1284 eZDebugSetting::writeNotice( 'kernel-ezpackage-store',
1285 "Stored file $filename",
1286 'eZPackage::storeString' );
1287 return true;
1288 }
1289 else
1290 {
1291 eZDebug::writeError( "Failed to write package '$filename'" );
1292 }
1293 return false;
1294 }
1295
1296
1302 static function fetchDOMFromFile( $filename )
1303 {
1304 if ( file_exists( $filename ) )
1305 {
1306 $dom = new DOMDocument( '1.0', 'utf-8' );
1307 $dom->preserveWhiteSpace = false;
1308 $success = $dom->load( $filename );
1309
1310 if ( !$success )
1311 {
1312 return false;
1313 }
1314 else
1315 {
1316 return $dom;
1317 }
1318 }
1319 return false;
1320 }
1321
1328 static function fetchFromFile( $filename )
1329 {
1330 $dom = eZPackage::fetchDOMFromFile( $filename );
1331
1332 if ( $dom === false )
1333 {
1334 return false;
1335 }
1336
1337 $package = new eZPackage();
1338 $parameters = $package->parseDOMTree( $dom );
1339 if ( !$parameters )
1340 {
1341 return false;
1342 }
1343
1344 return $package;
1345 }
1346
1358 static function fetch( $packageName, $packagePath = false, $repositoryID = false, $dbAvailable = true )
1359 {
1360 $packageRepositories = eZPackage::packageRepositories( array( 'path' => $packagePath ) );
1361
1362 if ( $repositoryID === true )
1363 $repositoryID = 'local';
1364
1365 foreach ( $packageRepositories as $packageRepository )
1366 {
1367 if ( $repositoryID !== false and
1368 $packageRepository['id'] != $repositoryID )
1369 continue;
1370 $path = $packageRepository['path'];
1371
1372 $path .= '/' . $packageName;
1373 $filePath = $path . '/' . eZPackage::definitionFilename();
1374
1375 if ( file_exists( $filePath ) )
1376 {
1377 $fileModification = filemtime( $filePath );
1378 $package = false;
1379 $cacheExpired = false;
1380
1381 if ( eZPackage::useCache() )
1382 {
1383 $package = eZPackage::fetchFromCache( $path, $fileModification, $cacheExpired );
1384 }
1385
1386 if ( $package )
1387 {
1388 $package->setCurrentRepositoryInformation( $packageRepository );
1389 }
1390 else
1391 {
1392 $package = eZPackage::fetchFromFile( $filePath );
1393
1394 if ( $package )
1395 {
1396 $package->setCurrentRepositoryInformation( $packageRepository );
1397 if ( $packagePath )
1398 $package->RepositoryPath = $packagePath;
1399 if ( $cacheExpired and
1400 eZPackage::useCache() )
1401 {
1402 $package->storeCache( $path . '/' . eZPackage::cacheDirectory() );
1403 }
1404 }
1405 }
1406 if ( $dbAvailable )
1407 $package->getInstallState();
1408
1409 return $package;
1410 }
1411 }
1412 return false;
1413 }
1414
1415 static function useCache()
1416 {
1417 return eZPackage::USE_CACHE;
1418 }
1419
1423 static function fetchFromCache( $packagePath, $packageModification, &$cacheExpired )
1424 {
1425 $packageCachePath = $packagePath . '/' . eZPackage::cacheDirectory() . '/package.php';
1426
1427 if ( file_exists( $packageCachePath ) )
1428 {
1429 $cacheModification = filemtime( $packageCachePath );
1430 if ( $cacheModification >= $packageModification )
1431 {
1432 include( $packageCachePath );
1433 if ( !isset( $CacheCodeDate ) or
1434 $CacheCodeDate != eZPackage::CACHE_CODE_DATE )
1435 {
1436 $cacheExpired = true;
1437 return false;
1438 }
1439 if ( isset( $Parameters ) and
1440 isset( $InstallData ) )
1441 {
1442 $cacheExpired = false;
1443 $package = new eZPackage( $Parameters, $RepositoryPath );
1444 $package->InstallData = $InstallData;
1445 return $package;
1446 }
1447 }
1448 else
1449 $cacheExpired = true;
1450 }
1451 $cacheExpired = true;
1452 return false;
1453 }
1454
1458 function path()
1459 {
1460 $path = $this->currentRepositoryPath();
1461 $path .= '/' . $this->attribute( 'name' );
1462 return $path;
1463 }
1464
1468 function currentRepositoryPath()
1469 {
1470 $repositoryInformation = $this->currentRepositoryInformation();
1471 if ( $repositoryInformation )
1472 return $repositoryInformation['path'];
1473 return $this->RepositoryPath;
1474 }
1475
1480 static function temporaryExportPath()
1481 {
1482 $path = eZDir::path( array( eZSys::cacheDirectory(),
1483 'packages',
1484 'export' . eZUser::currentUserID() ) );
1485 return $path;
1486 }
1487
1492 static function temporaryImportPath()
1493 {
1494 $path = eZDir::path( array( eZSys::cacheDirectory(),
1495 'packages',
1496 'import' ) );
1497 return $path;
1498 }
1499
1504 static function repositoryPath()
1505 {
1506 $ini = eZINI::instance();
1507 $packageIni = eZINI::instance( 'package.ini' );
1508
1509 return eZDir::path( array( 'var',
1510 $ini->variable( 'FileSettings', 'StorageDir' ),
1511 $packageIni->variable( 'RepositorySettings', 'RepositoryDirectory' ) ) );
1512 }
1513
1518 static function cacheDirectory()
1519 {
1520 return '.cache';
1521 }
1522
1527 static function definitionFilename()
1528 {
1529 return 'package.xml';
1530 }
1531
1536 static function documentDirectory()
1537 {
1538 return 'documents';
1539 }
1540
1545 static function filesDirectory()
1546 {
1547 return 'files';
1548 }
1549
1554 static function simpleFilesDirectory()
1555 {
1556 return 'simplefiles';
1557 }
1558
1559 static function settingsDirectory()
1560 {
1561 return 'settings';
1562 }
1563
1568 function fetchDependentPackages( $dependencyType, &$failedList )
1569 {
1570 $packages = array();
1571 $provides = $this->Parameters['dependencies'][$dependencyType];
1572
1573 if ( $provides != null )
1574 {
1575 foreach ( $provides as $provide )
1576 {
1577 // fetch only dependent packages, not package items.
1578 if ( $provide['type'] == 'ezpackage' )
1579 {
1580 // TODO: Add fetching from URL (not here ?)
1581 $package = $this->fetch( $provide['name'] );
1582
1583 if ( !$package )
1584 {
1585 $failedList[] = $provide['name'];
1586 continue;
1587 }
1588 $packages[] =& $package;
1589 }
1590 }
1591 }
1592 return $packages;
1593 }
1594
1605 static function packageRepositories( $parameters = array() )
1606 {
1607 if ( isset( $parameters['path'] ) and $parameters['path'] )
1608 {
1609 $path = $parameters['path'];
1610 $packageRepositories = array( array( 'path' => $path,
1611 'id' => 'local',
1612 'name' => ezpI18n::tr( 'kernel/package', 'Local' ),
1613 'type' => 'local' ) );
1614 }
1615 else
1616 {
1617 $repositoryPath = eZPackage::repositoryPath();
1618 $packageRepositories = array( array( 'path' => $repositoryPath . '/local',
1619 'id' => 'local',
1620 'name' => ezpI18n::tr( 'kernel/package', 'Local' ),
1621 'type' => 'local' ) );
1622
1623 $subdirs = eZDir::findSubitems( $repositoryPath, 'd' );
1624 foreach( $subdirs as $dir )
1625 {
1626 if ( $dir == 'local' )
1627 continue;
1628
1629 $packageRepositories[] = array( 'path' => $repositoryPath . '/' . $dir,
1630 'id' => $dir,
1631 'name' => $dir,
1632 'type' => 'global' );
1633 }
1634 }
1635 return $packageRepositories;
1636 }
1637
1642 static function repositoryInformation( $repositoryID )
1643 {
1644 $packageRepositories = eZPackage::packageRepositories();
1645 foreach ( $packageRepositories as $packageRepository )
1646 {
1647 if ( $packageRepository['id'] == $repositoryID )
1648 return $packageRepository;
1649 }
1650 return false;
1651 }
1652
1657 static function systemRepositoryInformation()
1658 {
1659 $ini = eZINI::instance( 'package.ini' );
1660 $vendor = $ini->variable( 'RepositorySettings', 'Vendor' );
1661 return eZPackage::repositoryInformation( $vendor );
1662 }
1663
1668 function setCurrentRepositoryInformation( $information )
1669 {
1670 $this->RepositoryInformation = $information;
1671 }
1672
1679 function currentRepositoryInformation()
1680 {
1681 return $this->RepositoryInformation;
1682 }
1683
1690 static function fetchPackages( $parameters = array(), $filterArray = array() )
1691 {
1692 $packageRepositories = eZPackage::packageRepositories( $parameters );
1693
1694 $packages = array();
1695
1696 $requiredType = null;
1697 $requiredPriority = null;
1698 $requiredVendor = null;
1699 $requiredExtension = null;
1700 if ( isset( $filterArray['type'] ) )
1701 $requiredType = $filterArray['type'];
1702 if ( isset( $filterArray['priority'] ) )
1703 $requiredPriority = $filterArray['priority'];
1704 if ( isset( $filterArray['vendor'] ) )
1705 $requiredVendor = $filterArray['vendor'];
1706 if ( isset( $filterArray['extension'] ) )
1707 $requiredExtension = $filterArray['extension'];
1708 $repositoryID = false;
1709 if ( isset( $parameters['repository_id'] ) )
1710 $repositoryID = $parameters['repository_id'];
1711 $dbAvailable = true;
1712 if ( isset( $parameters['db_available'] ) )
1713 $dbAvailable = $parameters['db_available'];
1714
1715 foreach ( $packageRepositories as $packageRepository )
1716 {
1717 if ( strlen( $repositoryID ) == 0 or
1718 $repositoryID == $packageRepository['id'] )
1719 {
1720 $path = $packageRepository['path'];
1721 if ( file_exists( $path ) )
1722 {
1723 $fileList = array();
1724 $dir = opendir( $path );
1725 while( ( $file = readdir( $dir ) ) !== false )
1726 {
1727 if ( $file == '.' or
1728 $file == '..' )
1729 continue;
1730 $fileList[] = $file;
1731 }
1732 closedir( $dir );
1733 sort( $fileList );
1734 foreach ( $fileList as $file )
1735 {
1736 $dirPath = $path . '/' . $file;
1737 if ( !is_dir( $dirPath ) )
1738 continue;
1739 $filePath = $dirPath . '/' . eZPackage::definitionFilename();
1740 if ( file_exists( $filePath ) )
1741 {
1742 $fileModification = filemtime( $filePath );
1743 $name = $file;
1744 $packageCachePath = $dirPath . '/' . eZPackage::cacheDirectory() . '/package.php';
1745 unset( $package );
1746 $package = false;
1747 $cacheExpired = false;
1748 if ( eZPackage::useCache() )
1749 {
1750 $package = eZPackage::fetchFromCache( $dirPath, $fileModification, $cacheExpired );
1751 }
1752 if ( !$package )
1753 {
1754 $package = eZPackage::fetchFromFile( $filePath );
1755 if ( $package and
1756 $cacheExpired and
1757 eZPackage::useCache() )
1758 {
1759 $package->storeCache( $dirPath . '/' . eZPackage::cacheDirectory() );
1760 }
1761 }
1762 if ( !$package )
1763 continue;
1764
1765 if ( $dbAvailable )
1766 $package->getInstallState();
1767
1768 if ( $requiredType !== null )
1769 {
1770 $type = $package->attribute( 'type' );
1771 if ( $type != $requiredType )
1772 continue;
1773 }
1774
1775 if ( $requiredPriority !== null )
1776 {
1777 $priority = $package->attribute( 'priority' );
1778 if ( $priority != $requiredPriority )
1779 continue;
1780 }
1781
1782 if ( $requiredExtension !== null )
1783 {
1784 $extension = $package->attribute( 'extension' );
1785 if ( $extension != $requiredExtension )
1786 continue;
1787 }
1788
1789 if ( $requiredVendor !== null )
1790 {
1791 $vendor = $package->attribute( 'vendor' );
1792 if ( $vendor != $requiredVendor )
1793 continue;
1794 }
1795
1796 $package->setCurrentRepositoryInformation( $packageRepository );
1797
1798 $packages[] =& $package;
1799 }
1800 }
1801 }
1802 }
1803 }
1804 return $packages;
1805 }
1806
1813 function installItem( $item, &$installParameters )
1814 {
1815 $type = $item['type'];
1816 $name = $item['name'];
1817 $os = $item['os'];
1818 $filename = $item['filename'];
1819 $subdirectory = $item['sub-directory'];
1820 $content = false;
1821 if ( isset( $item['content'] ) )
1822 $content = $item['content'];
1823 $handler = $this->packageHandler( $type );
1824 $installResult = false;
1825 if ( $handler )
1826 {
1827 if ( $handler->extractInstallContent() )
1828 {
1829 if ( !$content and
1830 $filename )
1831 {
1832 if ( $subdirectory )
1833 $filepath = $subdirectory . '/' . $filename . '.xml';
1834 else
1835 $filepath = $filename . '.xml';
1836
1837 $filepath = $this->path() . '/' . $filepath;
1838
1839 $dom = eZPackage::fetchDOMFromFile( $filepath );
1840 if ( $dom )
1841 {
1842 $content = $dom->documentElement;
1843 }
1844 else
1845 {
1846 eZDebug::writeError( "Failed fetching dom from file $filepath", __METHOD__ );
1847 }
1848 }
1849 }
1850 $installData =& $this->InstallData[$type];
1851 if ( !isset( $installData ) )
1852 $installData = array();
1853 $installResult = $handler->install( $this, $type, $item,
1854 $name, $os, $filename, $subdirectory,
1855 $content, $installParameters,
1856 $installData );
1857 }
1858 return $installResult;
1859 }
1860
1868 function install( &$installParameters )
1869 {
1870 if ( $this->Parameters['install_type'] != 'install' )
1871 return;
1872 $installItems = $this->Parameters['install'];
1873 if ( !isset( $installParameters['path'] ) )
1874 $installParameters['path'] = false;
1875 $installResult = true;
1876 foreach ( $installItems as $item )
1877 {
1878 if ( !$this->installItem( $item, $installParameters ) )
1879 {
1880 eZDebug::writeDebug( $item, 'item which failed installing' );
1881 $installResult = false;
1882 }
1883 }
1884 $this->setInstalled();
1885 return $installResult;
1886 }
1887
1888 function uninstallItem( $item, &$uninstallParameters )
1889 {
1890 $type = $item['type'];
1891 $name = $item['name'];
1892 $os = $item['os'];
1893 $filename = $item['filename'];
1894 $subdirectory = $item['sub-directory'];
1895 $content = false;
1896 if ( isset( $item['content'] ) )
1897 $content = $item['content'];
1898
1899 $handler = $this->packageHandler( $type );
1900 if ( $handler )
1901 {
1902 if ( $handler->extractInstallContent() )
1903 {
1904 if ( !$content and
1905 $filename )
1906 {
1907 if ( $subdirectory )
1908 $filepath = $subdirectory . '/' . $filename . '.xml';
1909 else
1910 $filepath = $filename . '.xml';
1911
1912 $filepath = $this->path() . '/' . $filepath;
1913
1914 $dom = eZPackage::fetchDOMFromFile( $filepath );
1915 if ( $dom )
1916 {
1917 $content = $dom->documentElement;
1918 }
1919 else
1920 {
1921 eZDebug::writeError( "Failed fetching dom from file $filepath", __METHOD__ );
1922 }
1923 }
1924 }
1925
1926 if ( isset( $this->InstallData[$type] ) )
1927 {
1928 $installData =& $this->InstallData[$type];
1929 }
1930 else
1931 {
1932 unset( $installData );
1933 $installData = array();
1934 }
1935 $uninstallResult = $handler->uninstall( $this, $type, $item,
1936 $name, $os, $filename, $subdirectory,
1937 $content, $uninstallParameters,
1938 $installData );
1939 }
1940 return $uninstallResult;
1941 }
1942
1946 function uninstall( $uninstallParameters = array() )
1947 {
1948 if ( $this->Parameters['install_type'] != 'install' )
1949 return;
1950 if ( !$this->isInstalled() )
1951 return;
1952 $uninstallItems = $this->installItemsList();
1953 if ( !isset( $installParameters['path'] ) )
1954 $installParameters['path'] = false;
1955
1956 $uninstallResult = true;
1957 foreach ( $uninstallItems as $item )
1958 {
1959 if ( !$this->uninstallItem( $item, $uninstallParameters ) )
1960 {
1961 $uninstallResult = false;
1962 }
1963 }
1964
1965 $this->InstallData = array();
1966 $this->setInstalled( false );
1967 return $uninstallResult;
1968 }
1969
1973 function parseDOMTree( DOMDocument $dom )
1974 {
1975 $root = $dom->documentElement;
1976
1977 // Read basic info
1978 $parameters = array();
1979 $parameters['name'] = $root->getElementsByTagName( 'name' )->item( 0 )->textContent;
1980 $vendorNode = $root->getElementsByTagName( 'vendor' )->item( 0 );
1981 $parameters['vendor'] = is_object( $vendorNode ) ? $vendorNode->textContent : false;
1982 $parameters['summary'] = $root->getElementsByTagName( 'summary' )->item( 0 )->textContent;
1983 $description = $root->getElementsByTagName( 'description' );
1984 if ( $description->length > 0 )
1985 {
1986 $parameters['description'] = $description->item( 0 )->textContent;
1987 }
1988 $priorities = $root->getElementsByTagName( 'priority' );
1989 if ( $priorities->length > 0 )
1990 {
1991 $parameters['priority'] = $priorities->item( 0 )->getAttribute( 'value' );
1992 }
1993 $type = $root->getElementsByTagName( 'type' );
1994 if ( $type->length > 0 )
1995 {
1996 $parameters['type'] = $type->item( 0 )->getAttribute( 'value' );
1997 }
1998
1999 if ( $parameters['vendor'] )
2000 {
2001 // Creating nice vendor directory name
2002 $trans = eZCharTransform::instance();
2003 $parameters['vendor-dir'] = $trans->transformByGroup( $parameters['vendor'], 'urlalias' );
2004 }
2005 else
2006 {
2007 $parameters['vendor-dir'] = 'local';
2008 }
2009
2010 $parameters['install_type'] = 'install';
2011 $installType = $root->getAttribute( 'install_type' );
2012 if ( $installType )
2013 $parameters['install_type'] = $installType;
2014 $sourceNodes = $root->getElementsByTagName( 'source' );
2015 if ( $sourceNodes->length > 0 )
2016 {
2017 $parameters['source'] = $sourceNodes->item( 0 )->textContent;
2018 }
2019 $parameters['development'] = $root->getAttribute( 'development' ) == 'true';
2020 $extensionNode = $root->getElementsByTagName( 'extension' )->item( 0 );
2021 if ( $extensionNode )
2022 $parameters['extension'] = $extensionNode->getAttribute( 'name' );
2023 $ezpublishNode = $root->getElementsByTagName( 'ezpublish' )->item( 0 );
2024 $parameters['ezpublish']['version'] = $ezpublishNode->getElementsByTagName( 'version' )->item( 0 )->textContent;
2025 $parameters['ezpublish']['named-version'] = $ezpublishNode->getElementsByTagName( 'named-version' )->item( 0 )->textContent;
2026 $this->setParameters( $parameters );
2027
2028 // Read maintainers
2029 $maintainersNode = $root->getElementsByTagName( 'maintainers' )->item( 0 );
2030 if ( $maintainersNode )
2031 {
2032 $maintainerNodes = $maintainersNode->getElementsByTagName( 'maintainer' );
2033 foreach ( $maintainerNodes as $maintainerNode )
2034 {
2035 $maintainerName = $maintainerNode->getElementsByTagName( 'name' )->item( 0 )->textContent;
2036 $maintainerEmail = $maintainerNode->getElementsByTagName( 'email' )->item( 0 )->textContent;
2037 $maintainerRole = $maintainerNode->getElementsByTagName( 'role' )->item( 0 )->textContent;
2038 $this->appendMaintainer( $maintainerName, $maintainerEmail, $maintainerRole );
2039 }
2040 }
2041
2042 // Read packaging info
2043 $packagingNode = $root->getElementsByTagName( 'packaging' )->item( 0 );
2044 $packagingTimestamp = $packagingNode->getElementsByTagName( 'timestamp' )->item( 0 )->textContent;
2045 $packagingHost = $packagingNode->getElementsByTagName( 'host' )->item( 0 )->textContent;
2046 $packagerNodes = $packagingNode->getElementsByTagName( 'packager' );
2047 if ( $packagerNodes->length > 0 )
2048 {
2049 $packagingPackager = $packagerNodes->item( 0 )->textContent;
2050 }
2051 else
2052 {
2053 $packagingPackager = false;
2054 }
2055 $this->setPackager( $packagingTimestamp, $packagingHost, $packagingPackager );
2056
2057 // Read documents
2058 $documentsNode = $root->getElementsByTagName( 'documents' )->item( 0 );
2059 $documentNodes = $documentsNode->getElementsByTagName( 'document' );
2060
2061 foreach ( $documentNodes as $documentNode )
2062 {
2063 $documentName = $documentNode->getAttribute( 'name' );
2064 $documentMimeType = $documentNode->getAttribute( 'mime-type' );
2065 $documentOS = $documentNode->getAttribute( 'os' );
2066 $documentAudience = $documentNode->getAttribute( 'audience' );
2067 $this->appendDocument( $documentName, $documentMimeType,
2068 $documentOS, $documentAudience,
2069 false, false );
2070 }
2071
2072 // Read changelog
2073 $changelogNode = $root->getElementsByTagName( 'changelog' )->item( 0 );
2074 if ( $changelogNode )
2075 {
2076 $changelogEntryNodes = $changelogNode->getElementsByTagName( 'entry' );
2077 foreach ( $changelogEntryNodes as $changelogEntryNode )
2078 {
2079 $changelogTimestamp = $changelogEntryNode->getAttribute( 'timestamp' );
2080 $changelogPerson = $changelogEntryNode->getAttribute( 'person' );
2081 $changelogEmail = $changelogEntryNode->getAttribute( 'email' );
2082 $changelogRelease = $changelogEntryNode->getAttribute( 'release' );
2083 $changelogChangeList = $changelogEntryNode->getElementsByTagName( 'change' )->item( 0 )->textContent;
2084 $this->appendChange( $changelogPerson, $changelogEmail, $changelogChangeList,
2085 $changelogRelease, $changelogTimestamp );
2086 }
2087 }
2088
2089 // Read simple files
2090 $this->Parameters['simple-file-list'] = array();
2091 $simpleFilesNode = $root->getElementsByTagName( 'simple-files' )->item( 0 );
2092 if ( $simpleFilesNode && $simpleFilesNode->hasChildNodes() )
2093 {
2094 $simpleFileNodes = $simpleFilesNode->getElementsByTagName( 'simple-file' );
2095 foreach ( $simpleFileNodes as $simpleFileNode )
2096 {
2097 $key = $simpleFileNode->getAttribute( 'key' );
2098 $originalPath = $simpleFileNode->getAttribute( 'original-path' );
2099 $packagePath = $simpleFileNode->getAttribute( 'package-path' );
2100 $this->Parameters['simple-file-list'][$key] = array( 'original-path' => $originalPath,
2101 'package-path' => $packagePath );
2102 }
2103 }
2104
2105 // Read files
2106 $filesList = $root->getElementsByTagName( 'files' );
2107 if ( $filesList )
2108 {
2109 foreach ( $filesList as $fileCollectionNode )
2110 {
2111 $fileCollectionName = $fileCollectionNode->getAttribute( 'name' );
2112 $fileLists = $fileCollectionNode->getElementsByTagName( 'file-list' );
2113 foreach ( $fileLists as $fileListNode )
2114 {
2115 $fileType = $fileListNode->getAttribute( 'type' );
2116 $fileDesign = $fileListNode->getAttribute( 'design' );
2117 $fileRole = $fileListNode->getAttribute( 'role' );
2118 $fileVariableName = $fileListNode->getAttribute( 'variable-name' );
2119 $fileRoleValue = $fileListNode->getAttribute( 'role-value' );
2120 $files = $fileListNode->getElementsByTagName( 'file' );
2121 if ( count( $files ) > 0 )
2122 {
2123 foreach ( $files as $fileNode )
2124 {
2125 $fileFileType = $fileNode->getAttribute( 'type' );
2126 $fileName = $fileNode->getAttribute( 'name' );
2127 if ( $fileNode->getAttribute( 'variable-name' ) )
2128 $fileVariableName = $fileNode->getAttribute( 'variable-name' );
2129 $fileSubDirectory = $fileNode->getAttribute( 'sub-directory' );
2130 $filePath = $fileNode->getAttribute( 'path' );
2131 $fileMD5 = $fileNode->getAttribute( 'md5sum' );
2132 $this->appendFile( $fileName, $fileType, $fileRole,
2133 $fileDesign, $filePath, $fileCollectionName,
2134 $fileSubDirectory, $fileMD5, false, null,
2135 $fileFileType,
2136 $fileRoleValue, $fileVariableName );
2137 }
2138 }
2139 else
2140 {
2141 $this->appendFile( false, $fileType, $fileRole,
2142 $fileDesign, false, $fileCollectionName,
2143 false, false, false, null );
2144 }
2145 unset( $files );
2146 }
2147 }
2148 }
2149 // Read release info
2150 $xpath = new DOMXPath( $dom );
2151 $versionNode = $xpath->query( 'version' )->item( 0 );
2152 $versionNumber = false;
2153 $versionRelease = false;
2154 if ( $versionNode )
2155 {
2156 $versionNumber = $versionNode->getElementsByTagName( 'number' )->item( 0 )->textContent;
2157 $versionRelease = $versionNode->getElementsByTagName( 'release' )->item( 0 )->textContent;
2158 }
2159 $licence = $root->getElementsByTagName( 'licence' )->item( 0 )->textContent;
2160 $state = $root->getElementsByTagName( 'state' )->item( 0 )->textContent;
2161 $this->setRelease( $versionNumber, $versionRelease, false,
2162 $licence, $state );
2163
2164 $dependenciesNode = $root->getElementsByTagName( 'dependencies' )->item( 0 );
2165 if ( $dependenciesNode )
2166 {
2167 $providesNode = $dependenciesNode->getElementsByTagName( 'provides' )->item( 0 );
2168 $providesList = $providesNode->getElementsByTagName( 'provide' );
2169 $requiresNode = $dependenciesNode->getElementsByTagName( 'requires' )->item( 0 );
2170 $requiresList = $requiresNode->getElementsByTagName( 'require' );
2171 $obsoletesNode = $dependenciesNode->getElementsByTagName( 'obsoletes' )->item( 0 );
2172 $obsoletesList = $obsoletesNode->getElementsByTagName( 'obsolete' );
2173 $conflictsNode = $dependenciesNode->getElementsByTagName( 'conflicts' )->item( 0 );
2174 $conflictsList = $conflictsNode->getElementsByTagName( 'conflict' );
2175 $this->parseDependencyTree( $providesList, 'provides' );
2176 $this->parseDependencyTree( $requiresList, 'requires' );
2177 $this->parseDependencyTree( $obsoletesList, 'obsoletes' );
2178 $this->parseDependencyTree( $conflictsList, 'conflicts' );
2179 }
2180
2181 $settingsNode = $root->getElementsByTagName( 'settings' )->item( 0 );
2182
2183 if ( $settingsNode )
2184 {
2185 $settingsFileNodes = $settingsNode->getElementsByTagName( 'settings-file' );
2186 $this->Parameters['settings-files'] = array();
2187
2188 foreach( $settingsFileNodes as $settingsFileNode )
2189 {
2190 $this->Parameters['settings-files'][] = $settingsFileNode->getAttribute( 'filename' );
2191 }
2192 }
2193
2194 $installNode = $root->getElementsByTagName( 'install' )->item( 0 );
2195 $installList = $installNode->getElementsByTagName( 'item' );
2196 $uninstallNode = $root->getElementsByTagName( 'uninstall' )->item( 0 );
2197 $uninstallList = $uninstallNode->getElementsByTagName( 'item' );
2198 $this->parseInstallTree( $installList, true );
2199 $this->parseInstallTree( $uninstallList, false );
2200
2201 $installDataList = $root->getElementsByTagName( 'install-data' );
2202 if ( $installDataList )
2203 {
2204 $this->InstallData = array();
2205 foreach( $installDataList as $installDataNode )
2206 {
2207 if ( is_object( $installDataNode ) &&
2208 $installDataNode->getAttribute( 'name' ) == 'data' )
2209 {
2210 $installDataType = $installDataNode->getAttribute( 'type' );
2211 $installDataElements = $installDataNode->getElementsByTagName( 'data' );
2212 $installData = array();
2213 foreach ( $installDataElements as $installDataElement )
2214 {
2215 if ( $installDataElement->attribute( 'name' ) == 'element' )
2216 {
2217 $name = $installDataElement->getAttribute( 'name' );
2218 $value = $installDataElement->getAttribute( 'value' );
2219 $installData[$name] = $value;
2220 }
2221 else if ( $installDataElement->attribute( 'name' ) == 'array' )
2222 {
2223 $arrayName = $installDataElement->getAttribute( 'name' );
2224 $installDataElementArray = $installDataElement->childNodes;
2225 $array = array();
2226 foreach ( $installDataElementArray as $installDataElementArrayElement )
2227 {
2228 $name = $installDataElementArrayElement->getAttribute( 'name' );
2229 $value = $installDataElementArrayElement->getAttribute( 'value' );
2230 $array[$name] = $value;
2231 }
2232 $installData[$arrayName] = $array;
2233 }
2234 }
2235 if ( count( $installData ) > 0 )
2236 $this->InstallData[$installDataType] = $installData;
2237 }
2238 }
2239 }
2240
2241 $retValue = true;
2242 return $retValue;
2243 }
2244
2248 function parseDependencyTree( $dependenciesList, $dependencySection )
2249 {
2250 foreach ( $dependenciesList as $dependencyNode )
2251 {
2252 $dependencyType = $dependencyNode->getAttribute( 'type' );
2253 $dependencyAttributes = $dependencyNode->attributes;
2254 $dependencyParameters = array();
2255 for ( $i = 0; $i < $dependencyAttributes->length; $i++ )
2256 {
2257 $dependencyAttribute = $dependencyAttributes->item( $i );
2258 $dependencyParameters[$dependencyAttribute->name] = $dependencyAttribute->value;
2259 }
2260
2261 $additionalDependencyParameters = array();
2262 $handler = $this->packageHandler( $dependencyType );
2263 if ( $handler )
2264 {
2265 $handler->parseDependencyNode( $this, $dependencyNode, $additionalDependencyParameters, $dependencySection );
2266 }
2267
2268 if ( count( $additionalDependencyParameters ) > 0 )
2269 $dependencyParameters = array_merge( $dependencyParameters, $additionalDependencyParameters );
2270
2271 $this->appendDependency( $dependencySection, $dependencyParameters );
2272 }
2273 }
2274
2278 function parseInstallTree( $installList, $isInstall )
2279 {
2280 foreach( $installList as $installNode )
2281 {
2282 $installType = $installNode->getAttribute( 'type' );
2283 $installName = $installNode->getAttribute( 'name' );
2284 $installFilename = $installNode->getAttribute( 'filename' );
2285 $installSubdirectory = $installNode->getAttribute( 'sub-directory' );
2286 $installOS = $installNode->getAttribute( 'os' );
2287
2288 $handler = $this->packageHandler( $installType );
2289 $installParameters = array();
2290 if ( $handler )
2291 {
2292 $handler->parseInstallNode( $this, $installNode, $installParameters, $isInstall );
2293 }
2294 if ( count( $installParameters ) == 0 )
2295 $installParameters = false;
2296
2297 $this->appendInstall( $installType, $installName, $installOS, $isInstall,
2298 $installFilename, $installSubdirectory,
2299 $installParameters );
2300 }
2301 }
2302
2306 function &domStructure()
2307 {
2308 $dom = new DOMDocument( '1.0', 'utf-8' );
2309 $dom->formatOutput = true;
2310 $root = $dom->createElement( 'package' );
2311 $root->setAttribute( 'version', eZPackage::VERSION );
2312 $root->setAttribute( 'development', ( eZPackage::DEVELOPMENT ? 'true' : 'false' ) );
2313 $dom->appendChild( $root );
2314
2315 if ( eZPackage::DEVELOPMENT )
2316 {
2317 $warningText = "This format was made with a development version and will not work with any release versions.\n" .
2318 "The format of this file is also subject to change until the release version.\n" .
2319 "Upgrades to the development format will not be supported.";
2320
2321 $warningNode = $dom->createElement( 'warning' );
2322 $warningNode->appendChild( $dom->createTextNode( $warningText ) );
2323 $root->appendChild( $warningNode );
2324 }
2325
2326 $name = $this->attribute( 'name' );
2327 $summary = $this->attribute( 'summary' );
2328 $description = $this->attribute( 'description' );
2329 $priority = $this->attribute( 'priority' );
2330 $type = $this->attribute( 'type' );
2331 $extension = $this->attribute( 'extension' );
2332 $installType = $this->attribute( 'install_type' );
2333 $vendorName = $this->attribute( 'vendor' );
2334 $source = $this->attribute( 'source' );
2335
2336 $ezpublishVersion = $this->attribute( 'ezpublish-version' );
2337 $ezpublishNamedVersion = $this->attribute( 'ezpublish-named-version' );
2338
2339 $packagingTimestamp = $this->attribute( 'packaging-timestamp' );
2340 $packagingHost = $this->attribute( 'packaging-host' );
2341 $packagingPackager = $this->attribute( 'packaging-packager' );
2342
2343 $maintainers = $this->attribute( 'maintainers' );
2344 $documents = $this->attribute( 'documents' );
2345 $groups = $this->attribute( 'groups' );
2346
2347 $versionNumber = $this->attribute( 'version-number' );
2348 $releaseNumber = $this->attribute( 'release-number' );
2349 $releaseTimestamp = $this->attribute( 'release-timestamp' );
2350
2351 $licence = $this->attribute( 'licence' );
2352 $state = $this->attribute( 'state' );
2353
2354 $simpleFileList = $this->attribute( 'simple-file-list' );
2355 $fileList = $this->attribute( 'file-list' );
2356 $dependencies = $this->attribute( 'dependencies' );
2357 $install = $this->attribute( 'install' );
2358 $uninstall = $this->attribute( 'uninstall' );
2359 $changelog = $this->attribute( 'changelog' );
2360
2361 $rootNameTextNode = $dom->createElement( 'name' );
2362 $rootNameTextNode->appendChild( $dom->createTextNode( $name ) );
2363 $root->appendChild( $rootNameTextNode );
2364
2365 if ( $summary )
2366 {
2367 $rootSummaryTextNode = $dom->createElement( 'summary' );
2368 $rootSummaryTextNode->appendChild( $dom->createTextNode( $summary ) );
2369 $root->appendChild( $rootSummaryTextNode );
2370 }
2371
2372 if ( $description )
2373 {
2374 $rootDescriptionTextNode = $dom->createElement( 'description' );
2375 $rootDescriptionTextNode->appendChild( $dom->createTextNode( $description ) );
2376 $root->appendChild( $rootDescriptionTextNode );
2377 }
2378
2379 if ( $vendorName )
2380 {
2381 $rootVendorTextNode = $dom->createElement( 'vendor' );
2382 $rootVendorTextNode->appendChild( $dom->createTextNode( $vendorName ) );
2383 $root->appendChild( $rootVendorTextNode );
2384 }
2385
2386 if ( $priority )
2387 {
2388 $rootPriorityTextNode = $dom->createElement( 'priority' );
2389 $rootPriorityTextNode->setAttribute( 'value', $priority );
2390 $root->appendChild( $rootPriorityTextNode );
2391 }
2392
2393 if ( $type )
2394 {
2395 $rootTypeTextNode = $dom->createElement( 'type' );
2396 $rootTypeTextNode->setAttribute( 'value', $type );
2397 $root->appendChild( $rootTypeTextNode );
2398 }
2399
2400 if ( $extension )
2401 {
2402 $rootExtensionTextNode = $dom->createElement( 'extension' );
2403 $rootExtensionTextNode->setAttribute( 'name', $extension );
2404 $root->appendChild( $rootExtensionTextNode );
2405 }
2406
2407 if ( $source )
2408 {
2409 $rootSourceTextNode = $dom->createElement( 'source' );
2410 $rootSourceTextNode->appendChild( $dom->createTextNode( $source ) );
2411 $root->appendChild( $rootSourceTextNode );
2412 }
2413
2414 $root->setAttribute( 'install_type', $installType );
2415
2416 $ezpublishNode = $dom->createElement( 'ezpublish' );
2417
2418 $ezpublishVersionTextNode = $dom->createElement( 'version' );
2419 $ezpublishVersionTextNode->appendChild( $dom->createTextNode( $ezpublishVersion ) );
2420 $ezpublishNode->appendChild( $ezpublishVersionTextNode );
2421
2422 $ezpublishNamedVersionTextNode = $dom->createElement( 'named-version' );
2423 $ezpublishNamedVersionTextNode->appendChild( $dom->createTextNode( $ezpublishNamedVersion ) );
2424 $ezpublishNode->appendChild( $ezpublishNamedVersionTextNode );
2425
2426 $root->appendChild( $ezpublishNode );
2427
2428 if ( count( $maintainers ) > 0 )
2429 {
2430 $maintainersNode = $dom->createElement( 'maintainers' );
2431 foreach ( $maintainers as $maintainer )
2432 {
2433 unset( $maintainerNode );
2434 $maintainerNode = $dom->createElement( 'maintainer' );
2435
2436 unset( $maintainerName );
2437 $maintainerName = $dom->createElement( 'name' );
2438 $maintainerName->appendChild( $dom->createTextNode( $maintainer['name'] ) );
2439 $maintainerNode->appendChild( $maintainerName );
2440
2441 unset( $maintainerEmail );
2442 $maintainerEmail = $dom->createElement( 'email' );
2443 $maintainerEmail->appendChild( $dom->createTextNode( $maintainer['email'] ) );
2444 $maintainerNode->appendChild( $maintainerEmail );
2445 if ( $maintainer['role'] )
2446 {
2447 unset( $maintainerRole );
2448 $maintainerRole = $dom->createElement( 'role' );
2449 $maintainerRole->appendChild( $dom->createTextNode( $maintainer['role'] ) );
2450 $maintainerNode->appendChild( $maintainerRole );
2451 }
2452
2453 $maintainersNode->appendChild( $maintainerNode );
2454 }
2455 $root->appendChild( $maintainersNode );
2456 }
2457
2458 $packagingNode = $dom->createElement( 'packaging' );
2459
2460 $packagingTimestampNode = $dom->createElement( 'timestamp' );
2461 $packagingTimestampNode->appendChild( $dom->createTextNode( $packagingTimestamp ) );
2462 $packagingNode->appendChild( $packagingTimestampNode );
2463
2464 $packagingHostNode = $dom->createElement( 'host' );
2465 $packagingHostNode->appendChild( $dom->createTextNode( $packagingHost ) );
2466 $packagingNode->appendChild( $packagingHostNode );
2467 if ( $packagingPackager )
2468 {
2469 $packagingPackagerNode = $dom->createElement( 'packager' );
2470 $packagingPackagerNode->appendChild( $dom->createTextNode( $packagingPackager ) );
2471 $packagingNode->appendChild( $packagingPackagerNode );
2472 }
2473
2474 $root->appendChild( $packagingNode );
2475
2476 if ( count( $documents ) > 0 )
2477 {
2478 $documentsNode = $dom->createElement( 'documents' );
2479 foreach ( $documents as $document )
2480 {
2481 unset( $documentNode );
2482 $documentNode = $dom->createElement( 'document' );
2483 $documentNode->setAttribute( 'mime-type', $document['mime-type'] );
2484 $documentNode->setAttribute( 'name', $document['name'] );
2485 if ( $document['os'] )
2486 $documentNode->setAttribute( 'os', $document['os'] );
2487
2488 if ( $document['audience'] )
2489 $documentNode->setAttribute( 'audience', $document['audience'] );
2490
2491 $documentsNode->appendChild( $documentNode );
2492 }
2493 $root->appendChild( $documentsNode );
2494 }
2495
2496 if ( count( $groups ) > 0 )
2497 {
2498 $groupsNode = $dom->createElement( 'groups' );
2499 foreach ( $groups as $group )
2500 {
2501 unset( $groupNode );
2502 $groupNode = $dom->createElement( 'group' );
2503 $groupNode->setAttribute( 'name', $group['name'] );
2504 $groupsNode->appendChild( $groupNode );
2505 }
2506 $root->appendChild( $groupsNode );
2507 }
2508
2509 if ( count( $changelog ) > 0 )
2510 {
2511 $changelogNode = $dom->createElement( 'changelog' );
2512 foreach ( $changelog as $changeEntry )
2513 {
2514 unset( $changeEntryNode );
2515 $changeEntryNode = $dom->createElement( 'entry' );
2516 $changeEntryNode->setAttribute( 'timestamp', $changeEntry['timestamp'] );
2517 $changeEntryNode->setAttribute( 'person', $changeEntry['person'] );
2518 $changeEntryNode->setAttribute( 'email', $changeEntry['email'] );
2519 $changeEntryNode->setAttribute( 'release', $changeEntry['release'] );
2520
2521 foreach ( $changeEntry['changes'] as $change )
2522 {
2523 unset( $changeEntryChange );
2524 $changeEntryChange = $dom->createElement( 'change' );
2525 $changeEntryChange->appendChild( $dom->createTextNode( $change ) );
2526 $changeEntryNode->appendChild( $changeEntryChange );
2527 }
2528 $changelogNode->appendChild( $changeEntryNode );
2529 }
2530 $root->appendChild( $changelogNode );
2531 }
2532
2533 // Avoid a PHP warning if 'simple-file-list' is not an array
2534 if ( is_array( $this->Parameters['simple-file-list'] ) )
2535 {
2536 $rootSimpleFiles = $dom->createElement( 'simple-files' );
2537 foreach( $this->Parameters['simple-file-list'] as $key => $value )
2538 {
2539 $simpleFileNode = $dom->createElement( 'simple-file' );
2540 $simpleFileNode->setAttribute( 'key', $key );
2541 $simpleFileNode->setAttribute( 'original-path', $value['original-path'] );
2542 $simpleFileNode->setAttribute( 'package-path', $value['package-path'] );
2543 $rootSimpleFiles->appendChild( $simpleFileNode );
2544 unset( $simpleFileNode );
2545 }
2546 $root->appendChild( $rootSimpleFiles );
2547 }
2548 else
2549 {
2550 $rootSimpleFiles = $dom->createElement( 'simple-files' );
2551 $root->appendChild( $rootSimpleFiles );
2552 }
2553
2554 // Handle files
2555 $filesNode = $dom->createElement( 'files' );
2556
2557 $hasFileItems = false;
2558 foreach ( $fileList as $fileCollectionName => $fileCollection )
2559 {
2560 if ( count( $fileCollection ) > 0 )
2561 {
2562 $hasFileItems = true;
2563
2564 unset( $fileCollectionNode );
2565 $fileCollectionNode = $dom->createElement( 'collection' );
2566 $fileCollectionNode->setAttribute( 'name', $fileCollectionName );
2567
2568 unset( $fileLists );
2569 unset( $fileDesignLists );
2570 unset( $fileThumbnailLists );
2571 $fileList = array();
2572 $fileDesignList = array();
2573 $fileINIList = array();
2574 $fileThumbnailList = array();
2575 $fileListNode = null;
2576 foreach ( $fileCollection as $fileItem )
2577 {
2578 if ( $fileItem['type'] == 'design' )
2579 $fileListNode =& $fileDesignLists[$fileItem['design']][$fileItem['role']][$fileItem['role-value']][$fileItem['variable-name']];
2580 else if ( $fileItem['type'] == 'ini' )
2581 $fileListNode =& $fileINILists[$fileItem['role']][$fileItem['role-value']][$fileItem['variable-name']];
2582 else if ( $fileItem['type'] == 'thumbnail' )
2583 $fileListNode =& $fileThumbnailLists[$fileItem['role']];
2584 else
2585 $fileListNode =& $fileLists[$fileItem['type']][$fileItem['role']][$fileItem['role-value']][$fileItem['variable-name']];
2586
2587 if ( !$fileListNode ||
2588 $fileListNode->getAttribute( 'type' ) != $fileItem['type'] ||
2589 $fileListNode->getAttribute( 'role' ) != $fileItem['role'] ||
2590 $fileListNode->getAttribute( 'role-value' ) != $fileItem['role-value'] ||
2591 $fileListNode->getAttribute( 'variable-name' ) != $fileItem['variable-name'] )
2592 {
2593 unset( $fileListNode );
2594 $fileListNode = $dom->createElement( 'file-list' );
2595 $fileListNode->setAttribute( 'type', $fileItem['type'] );
2596
2597 if ( $fileItem['type'] == 'design' )
2598 $fileListNode->setAttribute( 'design', $fileItem['design'] );
2599 if ( $fileItem['role'] )
2600 $fileListNode->setAttribute( 'role', $fileItem['role'] );
2601 if ( $fileItem['role-value'] )
2602 $fileListNode->setAttribute( 'role-value', $fileItem['role-value'] );
2603 if ( $fileItem['variable-name'] )
2604 $fileListNode->setAttribute( 'variable-name', $fileItem['variable-name'] );
2605
2606 $fileCollectionNode->appendChild( $fileListNode );
2607 }
2608
2609 if ( $fileItem['name'] )
2610 {
2611 unset( $fileListFile );
2612 $fileListFile = $dom->createElement( 'file' );
2613 $fileListFile->setAttribute( 'path', $fileItem['path'] );
2614 $fileListFile->setAttribute( 'name', $fileItem['name'] );
2615
2616 if ( $fileItem['md5'] )
2617 $fileListFile->setAttribute( 'md5sum', $fileItem['md5'] );
2618
2619 if ( $fileItem['subdirectory'] )
2620 $fileListFile->setAttribute( 'sub-directory', $fileItem['subdirectory'] );
2621
2622 $fileListNode->appendChild( $fileListFile );
2623 }
2624 }
2625 $filesNode->appendChild( $fileCollectionNode );
2626 }
2627 }
2628 if ( $hasFileItems )
2629 $root->appendChild( $filesNode );
2630
2631 $versionNode = $dom->createElement( 'version' );
2632 $versionNumberTextNode = $dom->createElement( 'number' );
2633 $versionNumberTextNode->appendChild( $dom->createTextNode( $versionNumber ) );
2634 $versionNode->appendChild( $versionNumberTextNode );
2635 $versionReleaseNumberTextNode = $dom->createElement( 'release' );
2636 $versionReleaseNumberTextNode->appendChild( $dom->createTextNode( $releaseNumber ) );
2637 $versionNode->appendChild( $versionReleaseNumberTextNode );
2638 $root->appendChild( $versionNode );
2639
2640 if ( $releaseTimestamp )
2641 {
2642 $rootTimestampTextNode = $dom->createElement( 'timestamp' );
2643 $rootTimestampTextNode->appendChild( $dom->createTextNode( $releaseTimestamp ) );
2644 $root->appendChild( $rootTimestampTextNode );
2645 }
2646
2647 if ( $licence )
2648 {
2649 $rootLicenceTextNode = $dom->createElement( 'licence' );
2650 $rootLicenceTextNode->appendChild( $dom->createTextNode( $licence ) );
2651 $root->appendChild( $rootLicenceTextNode );
2652 }
2653
2654 if ( $state )
2655 {
2656 $rootStateTextNode = $dom->createElement( 'state' );
2657 $rootStateTextNode->appendChild( $dom->createTextNode( $state ) );
2658 $root->appendChild( $rootStateTextNode );
2659 }
2660
2661 $dependencyNode = $dom->createElement( 'dependencies' );
2662
2663 $providesNode = $dom->createElement( 'provides' );
2664 $dependencyNode->appendChild( $providesNode );
2665 $requiresNode = $dom->createElement( 'requires' );
2666 $dependencyNode->appendChild( $requiresNode );
2667 $obsoletesNode = $dom->createElement( 'obsoletes' );
2668 $dependencyNode->appendChild( $obsoletesNode );
2669 $conflictsNode = $dom->createElement( 'conflicts' );
2670 $dependencyNode->appendChild( $conflictsNode );
2671
2672 $this->createDependencyTree( $providesNode, 'provide', $dependencies['provides'] );
2673 $this->createDependencyTree( $requiresNode, 'require', $dependencies['requires'] );
2674 $this->createDependencyTree( $obsoletesNode, 'obsolete', $dependencies['obsoletes'] );
2675 $this->createDependencyTree( $conflictsNode, 'conflict', $dependencies['conflicts'] );
2676
2677 $root->appendChild( $dependencyNode );
2678
2679 $installNode = $dom->createElement( 'install' );
2680
2681 $uninstallNode = $dom->createElement( 'uninstall' );
2682
2683 $this->createInstallTree( $installNode, $dom, $install, 'install' );
2684 $this->createInstallTree( $uninstallNode, $dom, $uninstall, 'uninstall' );
2685
2686 $root->appendChild( $installNode );
2687 $root->appendChild( $uninstallNode );
2688
2689 if ( count( $this->InstallData ) > 0 )
2690 {
2691 $installDataNode = $dom->createElement( 'install-data' );
2692 foreach ( $this->InstallData as $installDataType => $installData )
2693 {
2694 if ( count( $installData ) > 0 )
2695 {
2696 unset( $dataNode );
2697 $dataNode = $dom->createElement( 'data' );
2698 $dataNode->setAttribute( 'type', $installDataType );
2699 $installDataNode->appendChild( $dataNode );
2700 foreach ( $installData as $installDataName => $installDataValue )
2701 {
2702 if ( is_array( $installDataValue ) )
2703 {
2704 unset( $dataArrayNode );
2705 $dataArrayNode = $dom->createElement( 'array' );
2706 $dataArrayNode->setAttribute( 'name', $installDataName );
2707 $dataNode->appendChild( $dataArrayNode );
2708 foreach ( $installDataValue as $installDataValueName => $installDataValueValue )
2709 {
2710 unset( $dataArrayElement );
2711 $dataArrayElement = $dom->createElement( 'element' );
2712 $dataArrayElement->setAttribute( 'name', $installDataValueName );
2713 $dataArrayElement->setAttribute( 'value', $installDataValueValue );
2714 $dataArrayNode->appendChild( $dataArrayElement );
2715 }
2716 }
2717 else
2718 {
2719 unset( $dataArrayElement );
2720 $dataArrayElement = $dom->createElement( 'element' );
2721 $dataArrayElement->setAttribute( 'name', $installDataName );
2722 $dataArrayElement->setAttribute( 'value', $installDataValue );
2723 $dataNode->appendChild( $dataArrayElement );
2724 }
2725 }
2726 }
2727 }
2728 $root->appendChild( $installDataNode );
2729 }
2730
2731 return $dom;
2732 }
2733
2740 function createInstallTree( $installNode, $dom, $list, $installType )
2741 {
2742 foreach ( $list as $installItem )
2743 {
2744 $type = $installItem['type'];
2745 unset( $installItemNode );
2746 $installItemNode = $dom->createElement( 'item' );
2747 $installItemNode->setAttribute( 'type', $type );
2748 $installNode->appendChild( $installItemNode );
2749
2750 if ( $installItem['os'] )
2751 $installItemNode->setAttribute( 'os', $installItem['os'] );
2752
2753 if ( $installItem['name'] )
2754 $installItemNode->setAttribute( 'name', $installItem['name'] );
2755
2756 if ( $installItem['filename'] )
2757 {
2758 $installItemNode->setAttribute( 'filename', $installItem['filename'] );
2759
2760 if ( $installItem['sub-directory'] )
2761 $installItemNode->setAttribute( 'sub-directory', $installItem['sub-directory'] );
2762 }
2763 else if ( isset( $installItem['content'] ) && $installItem['content'] instanceof DOMElement )
2764 {
2765 $importedContentNode = $installItemNode->ownerDocument->importNode( $installItem['content'], true );
2766 $installItemNode->appendChild( $importedContentNode );
2767 }
2768
2769 $handler = $this->packageHandler( $type );
2770 if ( $handler )
2771 {
2772 $handler->createInstallNode( $this, $installItemNode, $installItem, $installType );
2773 }
2774 }
2775 }
2776
2782 function createDependencyTree( &$dependenciesNode, $dependencyType, $list )
2783 {
2784 $dom = $dependenciesNode->ownerDocument;
2785
2786 foreach ( $list as $dependencyItem )
2787 {
2788 unset( $dependencyNode );
2789 $dependencyNode = $dom->createElement( $dependencyType );
2790 $dependencyNode->setAttribute( 'type', $dependencyItem['type'] );
2791 $dependencyNode->setAttribute( 'name', $dependencyItem['name'] );
2792 if ( $dependencyItem['value'] )
2793 $dependencyNode->setAttribute( 'value', $dependencyItem['value'] );
2794 $dependenciesNode->appendChild( $dependencyNode );
2795 $handler = $this->packageHandler( $dependencyItem['name'] );
2796 if ( $handler )
2797 {
2798 $handler->createDependencyNode( $this, $dependencyNode, $dependencyItem, $dependencyType );
2799 }
2800 }
2801 }
2802
2806 static function packageHandler( $handlerName )
2807 {
2808 if ( !isset( $GLOBALS['eZPackageHandlers'] ) )
2809 {
2810 $handlers = array();
2811 }
2812 else
2813 {
2814 $handlers = $GLOBALS['eZPackageHandlers'];
2815 }
2816 $handler = false;
2817
2818 if( isset( $handlers[$handlerName] ) )
2819 {
2820 $handler = $handlers[$handlerName];
2821 $handler->reset();
2822 }
2823 else
2824 {
2825 $optionArray = array( 'iniFile' => 'package.ini',
2826 'iniSection' => 'PackageSettings',
2827 'iniVariable' => 'HandlerAlias',
2828 'handlerIndex' => $handlerName );
2829
2830 $options = new ezpExtensionOptions( $optionArray );
2831
2832 $handler = eZExtension::getHandlerClass( $options );
2833 $handlers[$handlerName] = $handler;
2834 }
2835
2836 $GLOBALS['eZPackageHandlers'] = $handlers;
2837 return $handler;
2838 }
2839
2846 function appendSimpleFile( $key, $filepath )
2847 {
2848 if ( !isset( $this->Parameters['simple-file-list'] ) )
2849 {
2850 $this->Parameters['simple-file-list'] = array();
2851 }
2852
2853 $suffix = eZFile::suffix( $filepath );
2854 //$sourcePath = $fileInfo['original-path'];
2855 $packagePath = eZPackage::simpleFilesDirectory() . '/' . substr( md5( mt_rand() ), 0, 8 ) . '.' . $suffix;
2856 $destinationPath = $this->path() . '/' . $packagePath;
2857 eZDir::mkdir( eZDir::dirpath( $destinationPath ), false, true );
2858
2859 //SP DBfile
2860 $fileHandler = eZClusterFileHandler::instance();
2861 $fileHandler->fileFetch( $filepath );
2862
2863 eZFileHandler::copy( $filepath, $destinationPath );
2864
2865 $this->Parameters['simple-file-list'][$key] = array( 'original-path' => $filepath,
2866 'package-path' => $packagePath );
2867 }
2868
2876 function simpleFilePath( $fileKey )
2877 {
2878 if ( !isset( $this->Parameters['simple-file-list'] ) )
2879 {
2880 return false;
2881 }
2882 if ( !isset( $this->Parameters['simple-file-list'][$fileKey] ) )
2883 {
2884 return false;
2885 }
2886
2887 return $this->path() . '/' . $this->Parameters['simple-file-list'][$fileKey]['package-path'];
2888 }
2889
2898 function getVersion()
2899 {
2900 return $this->Parameters['version-number'] . '-' . $this->Parameters['release-number'];
2901 }
2902
2907 function setInstalled( $installed = true )
2908 {
2909 if ( $this->Parameters['install_type'] != 'install' )
2910 return;
2911
2912 $name = $this->Parameters['name'];
2913 $version = $this->getVersion();
2914 $db = eZDB::instance();
2915 if ( $installed )
2916 {
2917 if ( !$this->getInstallState() )
2918 {
2919 $timestamp = time();
2920 $db->query( "INSERT INTO ezpackage ( name, version, install_date ) VALUES ( '$name', '$version', '$timestamp' )" );
2921 $this->isInstalled = true;
2922 }
2923 }
2924 else
2925 {
2926 $db->query( "DELETE FROM ezpackage WHERE name='$name' AND version='$version'" );
2927 $this->isInstalled = false;
2928 }
2929 }
2930
2931 function isInstalled()
2932 {
2933 return $this->isInstalled;
2934 }
2935
2936 function getInstallState()
2937 {
2938 // TODO installation date
2939
2940 if ( $this->Parameters['install_type'] != 'install' )
2941 return;
2942
2943 $name = $this->Parameters['name'];
2944 $version = $this->getVersion();
2945
2946 $db = eZDB::instance();
2947 $result = $db->arrayQuery( "SELECT count(*) AS count FROM ezpackage WHERE name='$name' AND version='$version'" );
2948
2949 if ( !count( $result ) )
2950 return false;
2951 $installed = $result[0]['count'] == '0' ? false : true;
2952 $this->isInstalled = $installed;
2953 return $installed;
2954 }
2955
2965 static function languageInfoFromPackageList( $packageNameList, $withLanguageNames = false )
2966 {
2967 $languageInfo = array();
2968 foreach( $packageNameList as $packageName )
2969 {
2970 $package = eZPackage::fetch( $packageName, false, false, false );
2971 if( is_object( $package ) )
2972 {
2973 $packageLanguageInfo = $package->languageInfo( $withLanguageNames );
2974 // merge arrays
2975 if( $withLanguageNames )
2976 {
2977 // we have array like 'locale' => 'name'. can use array_merge
2978 $languageInfo = array_merge( $languageInfo, $packageLanguageInfo );
2979 }
2980 else
2981 {
2982 foreach( $packageLanguageInfo as $languageLocale )
2983 {
2984 if( !in_array( $languageLocale, $languageInfo ) )
2985 {
2986 $languageInfo[] = $languageLocale;
2987 }
2988 }
2989 }
2990 }
2991 else
2992 {
2993 eZDebug::writeWarning( "Unable to fetch package '$packageName'", __METHOD__ );
2994 }
2995 }
2996
2997 return $languageInfo;
2998 }
2999
3003 function languageInfo( $withLanguageNames = false )
3004 {
3005 $langaugeInfo = array();
3006
3007 $classHandler = eZPackage::packageHandler( 'ezcontentclass' );
3008 $objectHandler = eZPackage::packageHandler( 'ezcontentobject' );
3009
3010 $explainClassInfo = array( 'language_info' );
3011
3012 $packageItems = $this->installItemsList();
3013 foreach( $packageItems as $item )
3014 {
3015 $itemLanguageInfo = array();
3016
3017 if( $item['type'] == 'ezcontentclass' )
3018 {
3019 $classInfo = $classHandler->explainInstallItem( $this, $item, $explainClassInfo );
3020 $itemLanguageInfo = isset( $classInfo['language_info'] ) ? $classInfo['language_info'] : array();
3021 }
3022 else if( $item['type'] == 'ezcontentobject' )
3023 {
3024 $objectsInfo = $objectHandler->explainInstallItem( $this, $item );
3025
3026 // merge objects info
3027 foreach( $objectsInfo as $objectInfo )
3028 {
3029 $objectLanguages = isset( $objectInfo['language_info'] ) ? $objectInfo['language_info'] : array();
3030 foreach( $objectLanguages as $objectLanguage )
3031 {
3032 if( !in_array( $objectLanguage, $itemLanguageInfo ) )
3033 {
3034 $itemLanguageInfo[] = $objectLanguage;
3035 }
3036 }
3037 }
3038 }
3039
3040 // merge class and objects infos
3041 foreach( $itemLanguageInfo as $languageLocale )
3042 {
3043 if( !in_array( $languageLocale, $langaugeInfo ) )
3044 {
3045 $langaugeInfo[] = $languageLocale;
3046 }
3047 }
3048 }
3049
3050 if( $withLanguageNames )
3051 {
3052 $langaugeInfoWithNames = array();
3053 foreach( $langaugeInfo as $languageLocale )
3054 {
3055 $language = eZContentLanguage::fetchByLocale( $languageLocale );
3056 $languageName = $language->attribute( 'name' );
3057 $langaugeInfoWithNames[$languageLocale] = $languageName;
3058 }
3059
3060 $langaugeInfo = $langaugeInfoWithNames;
3061 }
3062
3063 return $langaugeInfo;
3064 }
3065
3066 function defaultLanguageMap()
3067 {
3068 $languageMap = array();
3069 $packageLanguages = $this->languageInfo();
3070 foreach( $packageLanguages as $language )
3071 {
3072 $languageMap[$language] = $language;
3073 }
3074
3075 return $languageMap;
3076 }
3077
3086 static function isValidName( $packageName, &$transformedPackageName = null )
3087 {
3088 $trans = eZCharTransform::instance();
3089 $transformedPackageName = $trans->transformByGroup( $packageName, 'identifier' );
3090
3091 return $transformedPackageName === $packageName;
3092 }
3093
3094
3095 public $isInstalled = false;
3098 public $Parameters;
3100 }
3101
3102 ?>
eZCharTransform\instance
static instance()
Definition: ezchartransform.php:434
eZClusterFileHandler\instance
static instance( $filename=false)
Definition: ezclusterfilehandler.php:21
eZContentLanguage\fetchByLocale
static fetchByLocale( $locale, $createIfNotExist=false)
Definition: ezcontentlanguage.php:264
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZDebugSetting\writeNotice
static writeNotice( $conditionName, $string, $label="")
Definition: ezdebugsetting.php:85
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:588
eZDebug\writeWarning
static writeWarning( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:502
eZDir\mkdir
static mkdir( $dir, $perm=false, $recursive=false)
Definition: ezdir.php:73
eZDir\recursiveList
static recursiveList( $dir, $path, &$fileList)
Definition: ezdir.php:332
eZDir\dirpath
static dirpath( $filepath)
Definition: ezdir.php:129
eZDir\findSubitems
static findSubitems( $dir, $types=false, $fullPath=false, $includeHidden=false, $excludeItems=false)
Definition: ezdir.php:528
eZDir\copy
static copy( $sourceDirectory, &$destinationDirectory, $asChild=true, $recursive=true, $includeHidden=false, $excludeItems=false)
Definition: ezdir.php:577
eZDir\recursiveDelete
static recursiveDelete( $dir, $rootCheck=true)
Definition: ezdir.php:264
eZDir\temporaryFileRegexp
static temporaryFileRegexp( $standalone=true)
Definition: ezdir.php:628
eZDir\path
static path( $names, $includeEndSeparator=false, $type=self::SEPARATOR_UNIX)
Definition: ezdir.php:237
eZExtension\getHandlerClass
static getHandlerClass(ezpExtensionOptions $options)
Definition: ezextension.php:531
eZFileHandler\copy
static copy( $sourceFilename, $destinationFilename)
Definition: ezfilehandler.php:356
eZFile\suffix
static suffix( $filename)
Definition: ezfile.php:102
eZFile\create
static create( $filename, $directory=false, $data=false, $atomic=false)
Definition: ezfile.php:41
eZPHPCreator
eZPHPCreator provides a simple interface for creating and executing PHP code.
eZPackage
Maintains eZ Publish packages.
Definition: ezpackage.php:20
eZPackage\uninstall
uninstall( $uninstallParameters=array())
Definition: ezpackage.php:1946
eZPackage\exportName
exportName()
Definition: ezpackage.php:1220
eZPackage\installItem
installItem( $item, &$installParameters)
Definition: ezpackage.php:1813
eZPackage\appendGroup
appendGroup( $name)
Definition: ezpackage.php:485
eZPackage\defaultLanguageMap
defaultLanguageMap()
Definition: ezpackage.php:3066
eZPackage\path
path()
Definition: ezpackage.php:1458
eZPackage\$Parameters
$Parameters
Definition: ezpackage.php:3098
eZPackage\repositoryPath
static repositoryPath()
Definition: ezpackage.php:1504
eZPackage\cacheDirectory
static cacheDirectory()
Definition: ezpackage.php:1518
eZPackage\fetch
static fetch( $packageName, $packagePath=false, $repositoryID=false, $dbAvailable=true)
Definition: ezpackage.php:1358
eZPackage\createInstallTree
createInstallTree( $installNode, $dom, $list, $installType)
Definition: ezpackage.php:2740
eZPackage\VERSION
const VERSION
Definition: ezpackage.php:25
eZPackage\hasAttribute
hasAttribute( $attributeName)
Definition: ezpackage.php:229
eZPackage\fetchMaintainerRoleList
static fetchMaintainerRoleList( $packageType=false, $checkRoles=false)
Definition: ezpackage.php:421
eZPackage\languageInfo
languageInfo( $withLanguageNames=false)
Definition: ezpackage.php:3003
eZPackage\installItemsList
installItemsList( $type=false, $os=false, $name=false, $isInstall=true)
Definition: ezpackage.php:844
eZPackage\DEVELOPMENT
const DEVELOPMENT
Definition: ezpackage.php:26
eZPackage\storeString
static storeString( $filename, $data)
Definition: ezpackage.php:1274
eZPackage\appendDocument
appendDocument( $name, $mimeType=false, $os=false, $audience=false, $create=false, $data=false)
Definition: ezpackage.php:467
eZPackage\storeToFile
storeToFile( $filename)
Definition: ezpackage.php:1228
eZPackage\md5sum
static md5sum( $file)
Definition: ezpackage.php:509
eZPackage\$isInstalled
$isInstalled
Definition: ezpackage.php:3095
eZPackage\create
static create( $name, $parameters=array(), $repositoryPath=false, $repositoryID=false)
Definition: ezpackage.php:165
eZPackage\currentRepositoryPath
currentRepositoryPath()
Definition: ezpackage.php:1468
eZPackage\canUsePolicyFunction
static canUsePolicyFunction( $functionName)
Definition: ezpackage.php:298
eZPackage\thumbnailList
thumbnailList( $collectionName)
Definition: ezpackage.php:643
eZPackage\fileItemPath
fileItemPath( $fileItem, $collectionName, $path=false)
Definition: ezpackage.php:612
eZPackage\attributes
attributes()
Definition: ezpackage.php:183
eZPackage\useCache
static useCache()
Definition: ezpackage.php:1415
eZPackage\__construct
__construct( $parameters=array(), $repositoryPath=false)
Definition: ezpackage.php:41
eZPackage\canInstall
canInstall()
Definition: ezpackage.php:324
eZPackage\definitionFilename
static definitionFilename()
Definition: ezpackage.php:1527
eZPackage\parseInstallTree
parseInstallTree( $installList, $isInstall)
Definition: ezpackage.php:2278
eZPackage\store
store()
Definition: ezpackage.php:1007
eZPackage\appendMaintainer
appendMaintainer( $name, $email, $role=false)
Definition: ezpackage.php:460
eZPackage\appendDependency
appendDependency( $dependencySection, $parameters)
Definition: ezpackage.php:758
eZPackage\createDependencyTree
createDependencyTree(&$dependenciesNode, $dependencyType, $list)
Definition: ezpackage.php:2782
eZPackage\CACHE_CODE_DATE
const CACHE_CODE_DATE
Definition: ezpackage.php:28
eZPackage\setRelease
setRelease( $version=false, $release=false, $timestamp=false, $licence=false, $state=false)
Definition: ezpackage.php:945
eZPackage\$RepositoryPath
$RepositoryPath
Definition: ezpackage.php:21
eZPackage\$PolicyCache
$PolicyCache
Definition: ezpackage.php:23
eZPackage\fetchMaintainerRoleIDList
static fetchMaintainerRoleIDList( $packageType=false, $checkRoles=false)
Definition: ezpackage.php:371
eZPackage\documentDirectory
static documentDirectory()
Definition: ezpackage.php:1536
eZPackage\fileList
fileList( $collectionName)
Definition: ezpackage.php:635
eZPackage\toString
toString()
Definition: ezpackage.php:974
eZPackage\canImport
canImport()
Definition: ezpackage.php:319
eZPackage\appendSimpleFile
appendSimpleFile( $key, $filepath)
Definition: ezpackage.php:2846
eZPackage\temporaryImportPath
static temporaryImportPath()
Definition: ezpackage.php:1492
eZPackage\temporaryExportPath
static temporaryExportPath()
Definition: ezpackage.php:1480
eZPackage\dependencyItems
dependencyItems( $dependencySection, $parameters=false)
Definition: ezpackage.php:806
eZPackage\STATUS_ALREADY_EXISTS
const STATUS_ALREADY_EXISTS
Definition: ezpackage.php:30
eZPackage\fetchFromCache
static fetchFromCache( $packagePath, $packageModification, &$cacheExpired)
Definition: ezpackage.php:1423
eZPackage\stateList
static stateList()
Definition: ezpackage.php:144
eZPackage\parseDependencyTree
parseDependencyTree( $dependenciesList, $dependencySection)
Definition: ezpackage.php:2248
eZPackage\appendFile
appendFile( $file, $type, $role, $design, $filePath, $collection, $subDirectory=null, $md5=null, $copyFile=false, $modified=null, $fileType=false, $roleValue=false, $variableName=false, $packagePath=false)
Definition: ezpackage.php:670
eZPackage\canRead
canRead()
Definition: ezpackage.php:309
eZPackage\setParameters
setParameters( $parameters=array())
Definition: ezpackage.php:66
eZPackage\install
install(&$installParameters)
Definition: ezpackage.php:1868
eZPackage\attribute
attribute( $attributeName)
Definition: ezpackage.php:237
eZPackage\storeDOM
static storeDOM( $filename, $dom)
Definition: ezpackage.php:1247
eZPackage\parseDOMTree
parseDOMTree(DOMDocument $dom)
Definition: ezpackage.php:1973
eZPackage\fetchPackages
static fetchPackages( $parameters=array(), $filterArray=array())
Definition: ezpackage.php:1690
eZPackage\exportToArchive
exportToArchive( $archivePath)
Definition: ezpackage.php:1046
eZPackage\packageHandler
static packageHandler( $handlerName)
Definition: ezpackage.php:2806
eZPackage\repositoryInformation
static repositoryInformation( $repositoryID)
Definition: ezpackage.php:1642
eZPackage\NON_INTERACTIVE
const NON_INTERACTIVE
Definition: ezpackage.php:33
eZPackage\setCurrentRepositoryInformation
setCurrentRepositoryInformation( $information)
Definition: ezpackage.php:1668
eZPackage\USE_CACHE
const USE_CACHE
Definition: ezpackage.php:27
eZPackage\packageRepositories
static packageRepositories( $parameters=array())
Definition: ezpackage.php:1605
eZPackage\typeList
static typeList()
Definition: ezpackage.php:122
eZPackage\fileStorePath
fileStorePath( $fileItem, $collectionName, $path=false, $installVariables=array())
Definition: ezpackage.php:539
eZPackage\filesDirectory
static filesDirectory()
Definition: ezpackage.php:1545
eZPackage\uninstallItem
uninstallItem( $item, &$uninstallParameters)
Definition: ezpackage.php:1888
eZPackage\storeCache
storeCache( $directory=false)
Definition: ezpackage.php:986
eZPackage\languageInfoFromPackageList
static languageInfoFromPackageList( $packageNameList, $withLanguageNames=false)
Definition: ezpackage.php:2965
eZPackage\fileCount
fileCount()
Definition: ezpackage.php:660
eZPackage\getVersion
getVersion()
Definition: ezpackage.php:2898
eZPackage\setAttribute
setAttribute( $attributeName, $attributeValue)
Definition: ezpackage.php:207
eZPackage\setPackager
setPackager( $timestamp=false, $host=false, $packager=false)
Definition: ezpackage.php:927
eZPackage\simpleFilesDirectory
static simpleFilesDirectory()
Definition: ezpackage.php:1554
eZPackage\settingsDirectory
static settingsDirectory()
Definition: ezpackage.php:1559
eZPackage\appendProvides
appendProvides( $type, $name, $value, $parameters=false)
Definition: ezpackage.php:741
eZPackage\simpleFilePath
simpleFilePath( $fileKey)
Definition: ezpackage.php:2876
eZPackage\storePackageFile
storePackageFile( $path, $storeCache=true)
Definition: ezpackage.php:1016
eZPackage\isValidName
static isValidName( $packageName, &$transformedPackageName=null)
Definition: ezpackage.php:3086
eZPackage\fetchFromFile
static fetchFromFile( $filename)
Definition: ezpackage.php:1328
eZPackage\isInstalled
isInstalled()
Definition: ezpackage.php:2931
eZPackage\fetchDependentPackages
fetchDependentPackages( $dependencyType, &$failedList)
Definition: ezpackage.php:1568
eZPackage\currentRepositoryInformation
currentRepositoryInformation()
Definition: ezpackage.php:1679
eZPackage\domStructure
& domStructure()
Definition: ezpackage.php:2306
eZPackage\STATUS_INVALID_NAME
const STATUS_INVALID_NAME
Definition: ezpackage.php:31
eZPackage\fetchDOMFromFile
static fetchDOMFromFile( $filename)
Definition: ezpackage.php:1302
eZPackage\suffix
static suffix()
Definition: ezpackage.php:1212
eZPackage\setInstalled
setInstalled( $installed=true)
Definition: ezpackage.php:2907
eZPackage\canUsePackagePolicyFunction
canUsePackagePolicyFunction( $functionName)
Definition: ezpackage.php:329
eZPackage\applyStorageFilePermissions
static applyStorageFilePermissions( $filename)
Definition: ezpackage.php:1237
eZPackage\canExport
canExport()
Definition: ezpackage.php:314
eZPackage\$InstallData
$InstallData
Definition: ezpackage.php:24
eZPackage\createDependencyText
createDependencyText( $cli, $dependencyItem, $dependencySection)
Definition: ezpackage.php:773
eZPackage\$RepositoryInformation
$RepositoryInformation
Definition: ezpackage.php:22
eZPackage\getInstallState
getInstallState()
Definition: ezpackage.php:2936
eZPackage\maintainerRoleListForRoles
static maintainerRoleListForRoles()
Definition: ezpackage.php:434
eZPackage\appendInstall
appendInstall( $type, $name, $os=false, $isInstall=true, $filename=false, $subdirectory=false, $parameters=false)
Definition: ezpackage.php:883
eZPackage\removeFiles
static removeFiles( $path)
Definition: ezpackage.php:1035
eZPackage\dependencyOperatorText
dependencyOperatorText( $dependencyItem)
Definition: ezpackage.php:768
eZPackage\systemRepositoryInformation
static systemRepositoryInformation()
Definition: ezpackage.php:1657
eZPackage\appendChange
appendChange( $person, $email, $changes, $release=false, $timestamp=null)
Definition: ezpackage.php:491
eZPackage\maintainerRoleName
static maintainerRoleName( $roleID)
Definition: ezpackage.php:448
eZPackage\groupDependencyItemsByType
groupDependencyItemsByType( $dependencyItems)
Definition: ezpackage.php:791
eZSys\cacheDirectory
static cacheDirectory()
Definition: ezsys.php:527
eZUser\currentUserID
static currentUserID()
Definition: ezuser.php:1731
eZUser\currentUser
static currentUser()
Definition: ezuser.php:1716
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+.