Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentclasspackagecreator.php
Go to the documentation of this file.
1 <?php
18 class eZContentClassPackageCreator extends eZPackageCreationHandler
19 {
20 public function __construct( $id )
21 {
22 $steps = array();
23 $steps[] = array( 'id' => 'class',
24 'name' => ezpI18n::tr( 'kernel/package', 'Content classes to include' ),
25 'methods' => array( 'initialize' => 'initializeClassData',
26 'validate' => 'validateClassData',
27 'commit' => 'commitClassData' ),
28 'template' => 'class.tpl' );
29 $steps[] = $this->packageInformationStep();
30 $steps[] = $this->packageMaintainerStep();
31 $steps[] = $this->packageChangelogStep();
32 parent::__construct( $id, ezpI18n::tr( 'kernel/package', 'Content class export' ), $steps );
33 }
34
38 function finalize( &$package, $http, &$persistentData )
39 {
40 $this->createPackage( $package, $http, $persistentData, $cleanupFiles );
41
42 $classHandler = eZPackage::packageHandler( 'ezcontentclass' );
43 $classList = $persistentData['classlist'];
44 foreach ( $classList as $classID )
45 {
46 $classHandler->addClass( $package, $classID );
47 }
48 $package->setAttribute( 'is_active', true );
49 $package->store();
50 }
51
55 function packageInitialState( $package, &$persistentData )
56 {
57 return 'stable';
58 }
59
63 function packageType( $package, &$persistentData )
64 {
65 return 'contentclass';
66 }
67
68 function initializeClassData( $package, $http, $step, &$persistentData, $tpl )
69 {
70 }
71
75 function validateClassData( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
76 {
77 $classList = array();
78 if ( $http->hasPostVariable( 'ClassList' ) )
79 $classList = $http->postVariable( 'ClassList' );
80
81 $persistentData['classlist'] = $classList;
82
83 $result = true;
84 if ( count( $classList ) == 0 )
85 {
86 $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Class list' ),
87 'description' => ezpI18n::tr( 'kernel/package', 'You must select at least one class for inclusion' ) );
88 $result = false;
89 }
90 return $result;
91 }
92
93 function commitClassData( $package, $http, $step, &$persistentData, $tpl )
94 {
95 }
96
100 function generatePackageInformation( &$packageInformation, $package, $http, $step, &$persistentData )
101 {
102 $classList = $persistentData['classlist'];
103
104 if ( count( $classList ) == 1 )
105 {
106 $classID = $classList[0];
107 $class = eZContentClass::fetch( $classID );
108 if ( $class )
109 {
110 $packageInformation['name'] = $class->attribute( 'name' );
111 $packageInformation['summary'] = 'Export of content class ' . $class->attribute( 'name' );
112 $packageInformation['description'] = 'This package contains an exported definition of the content class ' . $class->attribute( 'name' ) . ' which can be imported to another eZ Publish site';
113 }
114 }
115 else if ( count( $classList ) > 1 )
116 {
117 $classNames = array();
118 foreach ( $classList as $classID )
119 {
120 $class = eZContentClass::fetch( $classID );
121 if ( $class )
122 {
123 $classNames[] = $class->attribute( 'name' );
124 }
125 }
126 $packageInformation['name'] = count( $classList ) . ' Classes';
127 $packageInformation['summary'] = 'Export of ' . count( $classList ) . ' content classes';
128 $description = 'This package contains exported definitions of the following content classes:' . "\n";
129 foreach ( $classNames as $className )
130 {
131 $description .= '- ' . $className . "\n";
132 }
133 $packageInformation['description'] = $description;
134 }
135 }
136 }
137
138 ?>
eZContentClassPackageCreator
A package creator for content classes.
Definition: ezcontentclasspackagecreator.php:19
eZContentClassPackageCreator\packageType
packageType( $package, &$persistentData)
Definition: ezcontentclasspackagecreator.php:63
eZContentClassPackageCreator\finalize
finalize(&$package, $http, &$persistentData)
Definition: ezcontentclasspackagecreator.php:38
eZContentClassPackageCreator\commitClassData
commitClassData( $package, $http, $step, &$persistentData, $tpl)
Definition: ezcontentclasspackagecreator.php:93
eZContentClassPackageCreator\__construct
__construct( $id)
Definition: ezcontentclasspackagecreator.php:20
eZContentClassPackageCreator\generatePackageInformation
generatePackageInformation(&$packageInformation, $package, $http, $step, &$persistentData)
Definition: ezcontentclasspackagecreator.php:100
eZContentClassPackageCreator\initializeClassData
initializeClassData( $package, $http, $step, &$persistentData, $tpl)
Definition: ezcontentclasspackagecreator.php:68
eZContentClassPackageCreator\packageInitialState
packageInitialState( $package, &$persistentData)
Definition: ezcontentclasspackagecreator.php:55
eZContentClassPackageCreator\validateClassData
validateClassData( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
Definition: ezcontentclasspackagecreator.php:75
eZContentClass\fetch
static fetch( $id, $asObject=true, $version=eZContentClass::VERSION_STATUS_DEFINED, $user_id=false, $parent_id=null)
Definition: ezcontentclass.php:1116
eZPackageCreationHandler
The class eZPackageCreationHandler does.
Definition: ezpackagecreationhandler.php:19
eZPackageCreationHandler\packageInformationStep
packageInformationStep()
Definition: ezpackagecreationhandler.php:378
eZPackageCreationHandler\packageChangelogStep
packageChangelogStep()
Definition: ezpackagecreationhandler.php:409
eZPackageCreationHandler\createPackage
createPackage(&$package, $http, &$persistentData, &$cleanupFiles, $storePackage=true)
Definition: ezpackagecreationhandler.php:493
eZPackageCreationHandler\packageMaintainerStep
packageMaintainerStep()
Definition: ezpackagecreationhandler.php:393
eZPackage\packageHandler
static packageHandler( $handlerName)
Definition: ezpackage.php:2806
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+.