[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <11-Aug-2003 18:12:39 amos> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 27 include_once ( 'kernel/common/template.php' ); 28 include_once ( 'kernel/classes/ezpackage.php' ); 29 include_once ( 'kernel/classes/ezpackageinstallationhandler.php' ); 30 include_once ( "lib/ezdb/classes/ezdb.php" ); 31 32 $http =& eZHTTPTool::instance(); 33 34 $module =& $Params['Module']; 35 $packageName =& $Params['PackageName']; 36 $installer = false; 37 $currentItem = 0; 38 $displayStep = false; 39 40 if ( $http->hasSessionVariable( 'eZPackageInstallerData' ) ) 41 { 42 $persistentData = $http->sessionVariable( 'eZPackageInstallerData' ); 43 if ( isset( $persistentData['currentItem'] ) ) 44 $currentItem = $persistentData['currentItem']; 45 $packageName = $persistentData['package_name']; 46 } 47 else 48 { 49 $persistentData = array(); 50 $persistentData['package_name'] = $packageName; 51 $persistentData['currentItem'] = $currentItem; 52 $persistentData['doItemInstall'] = false; 53 $persistentData['error'] = array(); 54 $persistentData['error_default_actions'] = array(); 55 } 56 57 if ( !eZPackage::canUsePolicyFunction( 'install' ) ) 58 return $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 59 60 $package = eZPackage::fetch( $packageName ); 61 if ( !$package ) 62 return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 63 64 $installItemArray = $package->installItemsList( false, eZSys::osType() ); 65 66 $tpl =& templateInit(); 67 68 if ( $module->isCurrentAction( 'SkipPackage' ) ) 69 { 70 $http->removeSessionVariable( 'eZPackageInstallerData' ); 71 return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) ); 72 } 73 elseif ( $module->isCurrentAction( 'InstallPackage' ) ) 74 { 75 $persistentData['doItemInstall'] = true; 76 } 77 elseif ( $module->isCurrentAction( 'HandleError' ) ) 78 { 79 $persistentData['doItemInstall'] = true; 80 81 // Choosing error action 82 if ( $module->hasActionParameter( 'ActionID' ) ) 83 { 84 $choosenAction = $module->actionParameter( 'ActionID' ); 85 86 $persistentData['error']['choosen_action'] = $choosenAction; 87 if ( $module->hasActionParameter( 'RememberAction' ) ) 88 { 89 $errorCode = $persistentData['error']['error_code']; 90 $itemType = $installItemArray[$currentItem]['type']; 91 if ( !isset( $persistentData['error_default_actions'][$itemType] ) ) 92 $persistentData['error_default_actions'][$itemType] = array(); 93 $persistentData['error_default_actions'][$itemType][$errorCode] = $choosenAction; 94 } 95 } 96 elseif ( !isset( $persistentData['error']['error_code'] ) ) 97 { 98 // If this is an unhandled error, we are skipping this item 99 $currentItem++; 100 } 101 } 102 elseif ( $module->isCurrentAction( 'PackageStep' ) && !$persistentData['doItemInstall'] ) 103 { 104 $installItem = $installItemArray[$currentItem]; 105 $installerType = $module->actionParameter( 'InstallerType' ); 106 $installer = eZPackageInstallationHandler::instance( $package, $installerType, $installItem ); 107 $installer->generateStepMap( $package, $persistentData ); 108 $displayStep = true; 109 } 110 elseif ( !$persistentData['doItemInstall'] ) 111 { 112 // Displaying a list of items to install 113 $installElements = array(); 114 foreach ( $installItemArray as $installItem ) 115 { 116 $handler =& eZPackage::packageHandler( $installItem['type'] ); 117 if ( $handler ) 118 { 119 $installElement = $handler->explainInstallItem( $package, $installItem ); 120 if ( $installElement ) 121 { 122 if ( isset( $installElement[0] ) ) 123 $installElements = array_merge( $installElements, $installElement ); 124 else 125 $installElements[] = $installElement; 126 } 127 } 128 } 129 $tpl->setVariable( 'install_elements', $installElements ); 130 131 $templateName = 'design:package/install.tpl'; 132 } 133 134 if ( $persistentData['doItemInstall'] ) 135 { 136 while( $currentItem < count( $installItemArray ) ) 137 { 138 $installItem = $installItemArray[$currentItem]; 139 $installer = eZPackageInstallationHandler::instance( $package, $installItem['type'], $installItem ); 140 141 if ( !$installer || isset( $persistentData['error']['choosen_action'] ) ) 142 { 143 $result = $package->installItem( $installItem, $persistentData ); 144 145 if ( !$result ) 146 { 147 $templateName = "design:package/install_error.tpl"; 148 break; 149 } 150 else 151 { 152 $persistentData['error'] = array(); 153 $currentItem++; 154 } 155 } 156 else 157 { 158 $persistentData['doItemInstall'] = false; 159 $installer->generateStepMap( $package, $persistentData ); 160 $displayStep = true; 161 break; 162 } 163 } 164 } 165 166 //$templateName = 'design:package/install.tpl'; 167 if ( $displayStep ) 168 { 169 $currentStepID = false; 170 if ( $module->hasActionParameter( 'InstallStepID' ) ) 171 $currentStepID = $module->actionParameter( 'InstallStepID' ); 172 $steps =& $installer->stepMap(); 173 if ( !isset( $steps['map'][$currentStepID] ) ) 174 $currentStepID = $steps['first']['id']; 175 $errorList = array(); 176 $hasAdvanced = false; 177 178 $lastStepID = $currentStepID; 179 if ( $module->hasActionParameter( 'NextStep' ) ) 180 { 181 $hasAdvanced = true; 182 $currentStepID = $installer->validateStep( $package, $http, $currentStepID, $steps, $persistentData, $errorList ); 183 if ( $currentStepID != $lastStepID ) 184 { 185 $lastStep =& $steps['map'][$lastStepID]; 186 $installer->commitStep( $package, $http, $lastStep, $persistentData, $tpl ); 187 } 188 } 189 190 if ( $currentStepID ) 191 { 192 $currentStep =& $steps['map'][$currentStepID]; 193 194 $stepTemplate = $installer->stepTemplate( $package, $installItem, $currentStep ); 195 $stepTemplateName = $stepTemplate['name']; 196 $stepTemplatePath = $stepTemplate['path']; 197 198 $installer->initializeStep( $package, $http, $currentStep, $persistentData, $tpl, $module ); 199 200 //if ( $package ) 201 // $persistentData['package_name'] = $package->attribute( 'name' ); 202 203 //$http->setSessionVariable( 'eZPackageInstallerData', $persistentData ); 204 205 $tpl->setVariable( 'installer', $installer ); 206 $tpl->setVariable( 'current_step', $currentStep ); 207 //$tpl->setVariable( 'persistent_data', $persistentData ); 208 $tpl->setVariable( 'error_list', $errorList ); 209 $tpl->setVariable( 'package', $package ); 210 211 $templateName = "$stepTemplatePath/$stepTemplateName"; 212 } 213 else 214 { 215 $persistentData['doItemInstall'] = true; 216 $installItem = $installItemArray[$currentItem]; 217 $result = $package->installItem( $installItem, $persistentData ); 218 if ( !$result ) 219 { 220 $templateName = "design:package/install_error.tpl"; 221 } 222 else 223 { 224 $currentItem++; 225 if ( $currentItem < count( $installItemArray ) ) 226 { 227 $persistentData['error'] = array(); 228 $persistentData['currentItem'] = $currentItem; 229 $http->setSessionVariable( 'eZPackageInstallerData', $persistentData ); 230 return $module->redirectToView( 'install', array( $packageName ) ); 231 } 232 } 233 } 234 } 235 236 // Installation complete (all items are installed) 237 if ( $currentItem >= count( $installItemArray ) ) 238 { 239 $package->setInstalled(); 240 $http->removeSessionVariable( 'eZPackageInstallerData' ); 241 return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) ); 242 } 243 244 $persistentData['currentItem'] = $currentItem; 245 $http->setSessionVariable( 'eZPackageInstallerData', $persistentData ); 246 $tpl->setVariable( 'persistent_data', $persistentData ); 247 $tpl->setVariable( 'package', $package ); 248 249 $Result = array(); 250 $Result['content'] =& $tpl->fetch( $templateName ); 251 $Result['path'] = array( array( 'url' => 'package/list', 252 'text' => ezi18n( 'kernel/package', 'Packages' ) ), 253 array( 'url' => false, 254 'text' => ezi18n( 'kernel/package', 'Install' ) ) ); 255 256 ?>
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 |