Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentobjectpackagecreator.php
Go to the documentation of this file.
1 <?php
17 class eZContentObjectPackageCreator extends eZPackageCreationHandler
18 {
19 public function __construct( $id )
20 {
21 $steps = array();
22 $steps[] = array( 'id' => 'object',
23 'name' => ezpI18n::tr( 'kernel/package', 'Content objects to include' ),
24 'methods' => array( 'initialize' => 'initializeObjectList',
25 'load' => 'loadObjectList',
26 'validate' => 'validateObjectList' ),
27 'template' => 'object_select.tpl' );
28 $steps[] = array( 'id' => 'object_limits',
29 'name' => ezpI18n::tr( 'kernel/package', 'Content object limits' ),
30 'methods' => array( 'initialize' => 'initializeObjectLimits',
31 'load' => 'loadObjectLimits',
32 'validate' => 'validateObjectLimits' ),
33 'template' => 'object_limit.tpl' );
34 $steps[] = $this->packageInformationStep();
35 $steps[] = $this->packageMaintainerStep();
36 $steps[] = $this->packageChangelogStep();
37 parent::__construct( $id, ezpI18n::tr( 'kernel/package', 'Content object export' ), $steps );
38 }
39
43 function finalize( &$package, $http, &$persistentData )
44 {
45 $this->createPackage( $package, $http, $persistentData, $cleanupFiles );
46
47 $objectHandler = eZPackage::packageHandler( 'ezcontentobject' );
48 $nodeList = $persistentData['node_list'];
49 $options = $persistentData['object_options'];
50
51 foreach( $nodeList as $nodeInfo )
52 {
53 $objectHandler->addNode( $nodeInfo['id'], $nodeInfo['type'] == 'subtree' );
54 }
55 $objectHandler->generatePackage( $package, $options );
56
57 $package->setAttribute( 'is_active', true );
58 $package->store();
59 }
60
64 function packageInitialState( $package, &$persistentData )
65 {
66 return 'stable';
67 }
68
72 function packageType( $package, &$persistentData )
73 {
74 return 'contentobject';
75 }
76
77 function initializeObjectList( $package, $http, $step, &$persistentData, $tpl )
78 {
79 $persistentData['node_list'] = array();
80 }
81
82 function loadObjectList( $package, $http, $step, &$persistentData, $tpl, &$module )
83 {
84 if ( $http->hasPostVariable( 'AddSubtree' ) )
85 {
86 eZContentBrowse::browse( array( 'action_name' => 'FindLimitationSubtree',
87 'description_template' => 'design:package/creators/ezcontentobject/browse_subtree.tpl',
88 'from_page' => '/package/create',
89 'persistent_data' => array( 'PackageStep' => $http->postVariable( 'PackageStep' ),
90 'CreatorItemID' => $http->postVariable( 'CreatorItemID' ),
91 'CreatorStepID' => $http->postVariable( 'CreatorStepID' ),
92 'Subtree' => 1 ) ),
93 $module );
94 }
95 else if ( $http->hasPostVariable( 'AddNode' ) )
96 {
97 eZContentBrowse::browse( array( 'action_name' => 'FindLimitationNode',
98 'description_template' => 'design:package/creators/ezcontentobject/browse_node.tpl',
99 'from_page' => '/package/create',
100 'persistent_data' => array( 'PackageStep' => $http->postVariable( 'PackageStep' ),
101 'CreatorItemID' => $http->postVariable( 'CreatorItemID' ),
102 'CreatorStepID' => $http->postVariable( 'CreatorStepID' ),
103 'Node' => 1) ),
104 $module );
105 }
106 else if( $http->hasPostVariable( 'RemoveSelected' ) )
107 {
108 foreach ( array_keys( $persistentData['node_list'] ) as $key )
109 {
110 if ( in_array( $persistentData['node_list'][$key]['id'], $http->postVariable( 'DeleteIDArray' ) ) )
111 {
112 unset( $persistentData['node_list'][$key] );
113 }
114 }
115 }
116 else if( $http->hasPostVariable( 'SelectedNodeIDArray' ) && !$http->hasPostVariable( 'BrowseCancelButton' ) )
117 {
118 if ( $http->hasPostVariable( 'Subtree' ) &&
119 $http->hasPostVariable( 'Subtree' ) == 1 )
120 {
121 foreach( $http->postVariable( 'SelectedNodeIDArray' ) as $nodeID )
122 {
123 $persistentData['node_list'][] = array( 'id' => $nodeID,
124 'type' => 'subtree' );
125 }
126 }
127 else if ( $http->hasPostVariable( 'Node' ) &&
128 $http->hasPostVariable( 'Node' ) == 1 )
129 {
130 foreach( $http->postVariable( 'SelectedNodeIDArray' ) as $nodeID )
131 {
132 $persistentData['node_list'][] = array( 'id' => $nodeID,
133 'type' => 'node' );
134 }
135 }
136 }
137
138 $tpl->setVariable( 'node_list', $persistentData['node_list'] );
139 }
140
144 function validateObjectList( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
145 {
146 if ( count( $persistentData['node_list'] ) == 0 )
147 {
148 $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
149 'description' => ezpI18n::tr( 'kernel/package', 'You must select one or more node(s)/subtree(s) for export.' ) );
150 return false;
151 }
152
153 return true;
154 }
155
156 function initializeObjectLimits( $package, $http, $step, &$persistentData, $tpl )
157 {
158 $persistentData['object_options'] = array( 'include_classes' => 1,
159 'include_templates' => 1,
160 'site_access_array' => array(),
161 'versions' => 'current',
162 'language_array' => array(),
163 'node_assignment' => 'selected',
164 'related_objects' => 'selected',
165 'embed_objects' => 'selected' );
166
167 $ini = eZINI::instance();
168 $persistentData['object_options']['site_access_array'] = array( $ini->variable( 'SiteSettings', 'DefaultAccess' ) );
169
170 $availableLanguages = eZContentObject::translationList();
171 foreach ( $availableLanguages as $language )
172 {
173 $persistentData['object_options']['language_array'][] = $language->attribute( 'locale_code' );
174 }
175 }
176
177 function loadObjectLimits( $package, $http, $step, &$persistentData, $tpl, &$module )
178 {
179 $ini = eZINI::instance();
180 $availableSiteAccesses = $ini->variable( 'SiteAccessSettings', 'RelatedSiteAccessList' );
181
182 $availableLanguages = eZContentObject::translationList();
183 $availableLanguageArray = array();
184 foreach ( $availableLanguages as $language )
185 {
186 $availableLanguageArray[] = array( 'name' => $language->attribute( 'language_name' ),
187 'locale' => $language->attribute( 'locale_code' ) );
188 }
189
190 $tpl->setVariable( 'available_site_accesses', $availableSiteAccesses );
191 $tpl->setVariable( 'available_languages', $availableLanguageArray );
192 $tpl->setVariable( 'options', $persistentData['object_options'] );
193 }
194
198 function validateObjectLimits( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
199 {
200 $options =& $persistentData['object_options'];
201
202 $options['include_classes'] = $http->hasPostVariable( 'IncludeClasses' ) ? $http->postVariable( 'IncludeClasses' ) : false;
203 $options['include_templates'] = $http->hasPostVariable( 'IncludeTemplates' ) ? $http->postVariable( 'IncludeTemplates' ) : false;
204 $options['site_access_array'] = $http->postVariable( 'SiteAccesses' );
205 $options['versions'] = $http->postVariable( 'VersionExport' );
206 $options['language_array'] = $http->postVariable( 'Languages' );
207 $options['node_assignment'] = $http->postVariable( 'NodeAssignment' );
208 $options['related_objects'] = $http->postVariable( 'RelatedObjects' );
209 $options['minimal_template_set'] = $http->hasPostVariable( 'MinimalTemplateSet' ) ? $http->postVariable( 'MinimalTemplateSet' ) : false;
210
211 $result = true;
212 if ( count( $persistentData['object_options']['language_array'] ) == 0 )
213 {
214 $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
215 'description' => ezpI18n::tr( 'kernel/package', 'You must choose one or more languages.' ) );
216 $result = false;
217 }
218
219 if ( $persistentData['object_options']['include_templates'] &&
220 count( $persistentData['object_options']['site_access_array'] ) == 0 )
221 {
222 $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Selected nodes' ),
223 'description' => ezpI18n::tr( 'kernel/package', 'You must choose one or more site access.' ) );
224 $result = false;
225 }
226
227 return $result;
228 }
229
233 function generatePackageInformation( &$packageInformation, $package, $http, $step, &$persistentData )
234 {
235 $nodeList = $persistentData['node_list'];
236 $options = $persistentData['object_options'];
237 $nodeCount = 0;
238 $description = 'This package contains the following nodes :' . "\n";
239 $nodeNames = array();
240 foreach( $nodeList as $nodeInfo )
241 {
242 $contentNode = eZContentObjectTreeNode::fetch( $nodeInfo['id'] );
243 $description .= $contentNode->attribute( 'name' ) . ' - ' . $nodeInfo['type'] . "\n";
244 $nodeNames[] = trim( $contentNode->attribute( 'name' ) );
245 if ( $nodeInfo['type'] == 'node' )
246 {
247 ++$nodeCount;
248 }
249 else if ( $nodeInfo['type'] == 'subtree' )
250 {
251 $nodeCount += $contentNode->subTreeCount();
252 }
253 }
254
255 $packageInformation['name'] = implode( ',', $nodeNames );
256 $packageInformation['summary'] = implode( ', ', $nodeNames );
257 $packageInformation['description'] = $description;
258 }
259
260 }
261 ?>
eZContentBrowse\browse
static browse( $parameters=array(), &$module)
Definition: ezcontentbrowse.php:89
eZContentObjectPackageCreator
A package creator for content objects.
Definition: ezcontentobjectpackagecreator.php:18
eZContentObjectPackageCreator\loadObjectList
loadObjectList( $package, $http, $step, &$persistentData, $tpl, &$module)
Definition: ezcontentobjectpackagecreator.php:82
eZContentObjectPackageCreator\loadObjectLimits
loadObjectLimits( $package, $http, $step, &$persistentData, $tpl, &$module)
Definition: ezcontentobjectpackagecreator.php:177
eZContentObjectPackageCreator\initializeObjectLimits
initializeObjectLimits( $package, $http, $step, &$persistentData, $tpl)
Definition: ezcontentobjectpackagecreator.php:156
eZContentObjectPackageCreator\validateObjectList
validateObjectList( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
Definition: ezcontentobjectpackagecreator.php:144
eZContentObjectPackageCreator\generatePackageInformation
generatePackageInformation(&$packageInformation, $package, $http, $step, &$persistentData)
Definition: ezcontentobjectpackagecreator.php:233
eZContentObjectPackageCreator\initializeObjectList
initializeObjectList( $package, $http, $step, &$persistentData, $tpl)
Definition: ezcontentobjectpackagecreator.php:77
eZContentObjectPackageCreator\packageType
packageType( $package, &$persistentData)
Definition: ezcontentobjectpackagecreator.php:72
eZContentObjectPackageCreator\__construct
__construct( $id)
Definition: ezcontentobjectpackagecreator.php:19
eZContentObjectPackageCreator\validateObjectLimits
validateObjectLimits( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
Definition: ezcontentobjectpackagecreator.php:198
eZContentObjectPackageCreator\finalize
finalize(&$package, $http, &$persistentData)
Definition: ezcontentobjectpackagecreator.php:43
eZContentObjectPackageCreator\packageInitialState
packageInitialState( $package, &$persistentData)
Definition: ezcontentobjectpackagecreator.php:64
eZContentObjectTreeNode\fetch
static fetch( $nodeID=false, $lang=false, $asObject=true, $conditions=false)
Definition: ezcontentobjecttreenode.php:3058
eZContentObject\translationList
static translationList()
Definition: ezcontentobject.php:5404
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+.