00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 include_once( 'kernel/classes/ezpackagecreationhandler.php' );
00042
00043 class eZContentClassPackageCreator extends eZPackageCreationHandler
00044 {
00045
00046
00047
00048 function eZContentClassPackageCreator( $id )
00049 {
00050 $steps = array();
00051 $steps[] = array( 'id' => 'class',
00052 'name' => ezi18n( 'kernel/package', 'Content classes to include' ),
00053 'methods' => array( 'initialize' => 'initializeClassData',
00054 'validate' => 'validateClassData',
00055 'commit' => 'commitClassData' ),
00056 'template' => 'class.tpl' );
00057 $steps[] = $this->packageInformationStep();
00058 $steps[] = $this->packageMaintainerStep();
00059 $steps[] = $this->packageChangelogStep();
00060 $this->eZPackageCreationHandler( $id,
00061 ezi18n( 'kernel/package', 'Content class export' ),
00062 $steps );
00063 }
00064
00065
00066
00067
00068
00069 function finalize( &$package, &$http, &$persistentData )
00070 {
00071 $this->createPackage( $package, $http, $persistentData, $cleanupFiles );
00072
00073 $classHandler = eZPackage::packageHandler( 'ezcontentclass' );
00074 $classList = $persistentData['classlist'];
00075 foreach ( $classList as $classID )
00076 {
00077 $classHandler->addClass( $package, $classID );
00078 }
00079 $package->setAttribute( 'is_active', true );
00080 $package->store();
00081 }
00082
00083
00084
00085
00086
00087 function packageInitialState( &$package, &$persistentData )
00088 {
00089 return 'stable';
00090 }
00091
00092
00093
00094
00095 function packageType( &$package, &$persistentData )
00096 {
00097 return 'contentclass';
00098 }
00099
00100 function initializeClassData( &$package, &$http, $step, &$persistentData, &$tpl )
00101 {
00102 }
00103
00104
00105
00106
00107 function validateClassData( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
00108 {
00109 $classList = array();
00110 if ( $http->hasPostVariable( 'ClassList' ) )
00111 $classList = $http->postVariable( 'ClassList' );
00112
00113 $persistentData['classlist'] = $classList;
00114
00115 $result = true;
00116 if ( count( $classList ) == 0 )
00117 {
00118 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Class list' ),
00119 'description' => ezi18n( 'kernel/package', 'You must select at least one class for inclusion' ) );
00120 $result = false;
00121 }
00122 return $result;
00123 }
00124
00125 function commitClassData( &$package, &$http, $step, &$persistentData, &$tpl )
00126 {
00127 }
00128
00129
00130
00131
00132
00133 function generatePackageInformation( &$packageInformation, &$package, &$http, $step, &$persistentData )
00134 {
00135 $classList = $persistentData['classlist'];
00136
00137 if ( count( $classList ) == 1 )
00138 {
00139 $classID = $classList[0];
00140 $class = eZContentClass::fetch( $classID );
00141 if ( $class )
00142 {
00143 $packageInformation['name'] = $class->attribute( 'name' );
00144 $packageInformation['summary'] = 'Export of content class ' . $class->attribute( 'name' );
00145 $packageInformation['description'] = 'This package contains an exported definition of the content class ' . $class->attribute( 'name' ) . ' which can be imported to another eZ publish site';
00146 }
00147 }
00148 else if ( count( $classList ) > 1 )
00149 {
00150 $classNames = array();
00151 foreach ( $classList as $classID )
00152 {
00153 $class = eZContentClass::fetch( $classID );
00154 if ( $class )
00155 {
00156 $classNames[] = $class->attribute( 'name' );
00157 }
00158 }
00159 $packageInformation['name'] = count( $classList ) . ' Classes';
00160 $packageInformation['summary'] = 'Export of ' . count( $classList ) . ' content classes';
00161 $description = 'This package contains exported definitions of the following content classes:' . "\n";
00162 foreach ( $classNames as $className )
00163 {
00164 $description .= '- ' . $className . "\n";
00165 }
00166 $packageInformation['description'] = $description;
00167 }
00168 }
00169 }
00170
00171 ?>