| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZContentObjectPackageCreator class 4 // 5 // Created on: <09-Mar-2004 12:39:59 kk> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezcontentobjectpackagecreator.php 30 */ 31 32 /*! 33 \ingroup package 34 \class eZContentObjectPackageCreator ezcontentclasspackagecreator.php 35 \brief A package creator for content objects 36 */ 37 38 include_once ( 'kernel/classes/ezpackagecreationhandler.php' ); 39 40 class eZContentObjectPackageCreator extends eZPackageCreationHandler 41 { 42 /*! 43 \reimp 44 */ 45 function eZContentObjectPackageCreator( $id ) 46 { 47 $steps = array(); 48 $steps[] = array( 'id' => 'object', 49 'name' => ezi18n( 'kernel/package', 'Content objects to include' ), 50 'methods' => array( 'initialize' => 'initializeObjectList', 51 'load' => 'loadObjectList', 52 'validate' => 'validateObjectList' ), 53 'template' => 'object_select.tpl' ); 54 $steps[] = array( 'id' => 'object_limits', 55 'name' => ezi18n( 'kernel/package', 'Content object limits' ), 56 'methods' => array( 'initialize' => 'initializeObjectLimits', 57 'load' => 'loadObjectLimits', 58 'validate' => 'validateObjectLimits' ), 59 'template' => 'object_limit.tpl' ); 60 $steps[] = $this->packageInformationStep(); 61 $steps[] = $this->packageMaintainerStep(); 62 $steps[] = $this->packageChangelogStep(); 63 $this->eZPackageCreationHandler( $id, 64 ezi18n( 'kernel/package', 'Content object export' ), 65 $steps ); 66 } 67 68 /*! 69 \reimp 70 Creates the package and adds the selected content classes. 71 */ 72 function finalize( &$package, &$http, &$persistentData ) 73 { 74 $this->createPackage( $package, $http, $persistentData, $cleanupFiles ); 75 76 $objectHandler = eZPackage::packageHandler( 'ezcontentobject' ); 77 $nodeList = $persistentData['node_list']; 78 $options = $persistentData['object_options']; 79 80 foreach( $nodeList as $nodeInfo ) 81 { 82 $objectHandler->addNode( $nodeInfo['id'], $nodeInfo['type'] == 'subtree' ); 83 } 84 $objectHandler->generatePackage( $package, $options ); 85 86 $package->setAttribute( 'is_active', true ); 87 $package->store(); 88 } 89 90 /*! 91 \reimp 92 Returns \c 'stable', content class packages are always stable. 93 */ 94 function packageInitialState( &$package, &$persistentData ) 95 { 96 return 'stable'; 97 } 98 99 /*! 100 \return \c 'contentclass'. 101 */ 102 function packageType( &$package, &$persistentData ) 103 { 104 return 'contentobject'; 105 } 106 107 function initializeObjectList( &$package, &$http, $step, &$persistentData, &$tpl ) 108 { 109 $persistentData['node_list'] = array(); 110 } 111 112 function loadObjectList( &$package, &$http, $step, &$persistentData, &$tpl, &$module ) 113 { 114 if ( $http->hasPostVariable( 'AddSubtree' ) ) 115 { 116 include_once ( 'kernel/classes/ezcontentbrowse.php' ); 117 eZContentBrowse::browse( array( 'action_name' => 'FindLimitationSubtree', 118 'description_template' => 'design:package/creators/ezcontentobject/browse_subtree.tpl', 119 'from_page' => '/package/create', 120 'persistent_data' => array( 'PackageStep' => $http->postVariable( 'PackageStep' ), 121 'CreatorItemID' => $http->postVariable( 'CreatorItemID' ), 122 'CreatorStepID' => $http->postVariable( 'CreatorStepID' ), 123 'Subtree' => 1 ) ), 124 $module ); 125 } 126 else if ( $http->hasPostVariable( 'AddNode' ) ) 127 { 128 include_once ( 'kernel/classes/ezcontentbrowse.php' ); 129 eZContentBrowse::browse( array( 'action_name' => 'FindLimitationNode', 130 'description_template' => 'design:package/creators/ezcontentobject/browse_node.tpl', 131 'from_page' => '/package/create', 132 'persistent_data' => array( 'PackageStep' => $http->postVariable( 'PackageStep' ), 133 'CreatorItemID' => $http->postVariable( 'CreatorItemID' ), 134 'CreatorStepID' => $http->postVariable( 'CreatorStepID' ), 135 'Node' => 1) ), 136 $module ); 137 } 138 else if( $http->hasPostVariable( 'RemoveSelected' ) ) 139 { 140 foreach ( array_keys( $persistentData['node_list'] ) as $key ) 141 { 142 if ( in_array( $persistentData['node_list'][$key]['id'], $http->postVariable( 'DeleteIDArray' ) ) ) 143 { 144 unset( $persistentData['node_list'][$key] ); 145 } 146 } 147 } 148 else if( $http->hasPostVariable( 'SelectedNodeIDArray' ) && !$http->hasPostVariable( 'BrowseCancelButton' ) ) 149 { 150 if ( $http->hasPostVariable( 'Subtree' ) && 151 $http->hasPostVariable( 'Subtree' ) == 1 ) 152 { 153 foreach( $http->postVariable( 'SelectedNodeIDArray' ) as $nodeID ) 154 { 155 $persistentData['node_list'][] = array( 'id' => $nodeID, 156 'type' => 'subtree' ); 157 } 158 } 159 else if ( $http->hasPostVariable( 'Node' ) && 160 $http->hasPostVariable( 'Node' ) == 1 ) 161 { 162 foreach( $http->postVariable( 'SelectedNodeIDArray' ) as $nodeID ) 163 { 164 $persistentData['node_list'][] = array( 'id' => $nodeID, 165 'type' => 'node' ); 166 } 167 } 168 } 169 170 $tpl->setVariable( 'node_list', $persistentData['node_list'] ); 171 } 172 173 /*! 174 Checks if at least one content class has been selected. 175 */ 176 function validateObjectList( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList ) 177 { 178 if ( count( $persistentData['node_list'] ) == 0 ) 179 { 180 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Selected nodes' ), 181 'description' => ezi18n( 'kernel/package', 'You must select one or more node(s)/subtree(s) for export.' ) ); 182 return false; 183 } 184 185 return true; 186 } 187 188 function initializeObjectLimits( &$package, &$http, $step, &$persistentData, &$tpl ) 189 { 190 $persistentData['object_options'] = array( 'include_classes' => 1, 191 'include_templates' => 1, 192 'site_access_array' => array(), 193 'versions' => 'current', 194 'language_array' => array(), 195 'node_assignment' => 'selected', 196 'related_objects' => 'selected', 197 'embed_objects' => 'selected' ); 198 199 include_once ( 'lib/ezutils/classes/ezini.php' ); 200 $ini =& eZINI::instance(); 201 $persistentData['object_options']['site_access_array'] = array( $ini->variable( 'SiteSettings', 'DefaultAccess' ) ); 202 203 include_once ( 'kernel/classes/ezcontentobject.php' ); 204 $availableLanguages = eZContentObject::translationList(); 205 foreach ( $availableLanguages as $language ) 206 { 207 $persistentData['object_options']['language_array'][] = $language->attribute( 'locale_code' ); 208 } 209 } 210 211 function loadObjectLimits( &$package, &$http, $step, &$persistentData, &$tpl, &$module ) 212 { 213 include_once ( 'lib/ezutils/classes/ezini.php' ); 214 $ini =& eZINI::instance(); 215 $availableSiteAccesses = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' ); 216 217 include_once ( 'kernel/classes/ezcontentobject.php' ); 218 $availableLanguages = eZContentObject::translationList(); 219 $availableLanguageArray = array(); 220 foreach ( $availableLanguages as $language ) 221 { 222 $availableLanguageArray[] = array( 'name' => $language->attribute( 'language_name' ), 223 'locale' => $language->attribute( 'locale_code' ) ); 224 } 225 226 $tpl->setVariable( 'available_site_accesses', $availableSiteAccesses ); 227 $tpl->setVariable( 'available_languages', $availableLanguageArray ); 228 $tpl->setVariable( 'options', $persistentData['object_options'] ); 229 } 230 231 /*! 232 Checks if at least one content class has been selected. 233 */ 234 function validateObjectLimits( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList ) 235 { 236 $options =& $persistentData['object_options']; 237 238 $options['include_classes'] = $http->hasPostVariable( 'IncludeClasses' ) ? $http->postVariable( 'IncludeClasses' ) : false; 239 $options['include_templates'] = $http->hasPostVariable( 'IncludeTemplates' ) ? $http->postVariable( 'IncludeTemplates' ) : false; 240 $options['site_access_array'] = $http->postVariable( 'SiteAccesses' ); 241 $options['versions'] = $http->postVariable( 'VersionExport' ); 242 $options['language_array'] = $http->postVariable( 'Languages' ); 243 $options['node_assignment'] = $http->postVariable( 'NodeAssignment' ); 244 $options['related_objects'] = $http->postVariable( 'RelatedObjects' ); 245 $options['minimal_template_set'] = $http->hasPostVariable( 'MinimalTemplateSet' ) ? $http->postVariable( 'MinimalTemplateSet' ) : false; 246 247 $result = true; 248 if ( count( $persistentData['object_options']['language_array'] ) == 0 ) 249 { 250 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Selected nodes' ), 251 'description' => ezi18n( 'kernel/package', 'You must choose one or more languages.' ) ); 252 $result = false; 253 } 254 255 if ( $persistentData['object_options']['include_templates'] && 256 count( $persistentData['object_options']['site_access_array'] ) == 0 ) 257 { 258 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Selected nodes' ), 259 'description' => ezi18n( 'kernel/package', 'You must choose one or more site access.' ) ); 260 $result = false; 261 } 262 263 return $result; 264 } 265 266 /*! 267 \reimp 268 Fetches the selected content classes and generates a name, summary and description from the selection. 269 */ 270 function generatePackageInformation( &$packageInformation, &$package, &$http, $step, &$persistentData ) 271 { 272 $nodeList = $persistentData['node_list']; 273 $options = $persistentData['object_options']; 274 $nodeCount = 0; 275 $description = 'This package contains the following nodes :' . "\n"; 276 $nodeNames = array(); 277 foreach( $nodeList as $nodeInfo ) 278 { 279 $contentNode = eZContentObjectTreeNode::fetch( $nodeInfo['id'] ); 280 $description .= $contentNode->attribute( 'name' ) . ' - ' . $nodeInfo['type'] . "\n"; 281 $nodeNames[] = trim( $contentNode->attribute( 'name' ) ); 282 if ( $nodeInfo['type'] == 'node' ) 283 { 284 ++$nodeCount; 285 } 286 else if ( $nodeInfo['type'] == 'subtree' ) 287 { 288 $nodeCount += $contentNode->subTreeCount(); 289 } 290 } 291 292 $packageInformation['name'] = implode( ',', $nodeNames ); 293 $packageInformation['summary'] = implode( ', ', $nodeNames ); 294 $packageInformation['description'] = $description; 295 } 296 297 } 298 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |