[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZStylePackageCreator class 4 // 5 // Created on: <14-Dec-2005 12:39:59 ks> 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 ezstylepackagecreator.php 30 */ 31 32 /*! 33 \ingroup package 34 \class eZStylePackageCreator ezstylepackagecreator.php 35 \brief The class eZStylePackageCreator does 36 37 */ 38 39 include_once ( 'kernel/classes/ezpackagecreationhandler.php' ); 40 include_once ( 'lib/ezfile/classes/ezdir.php' ); 41 42 class eZExtensionPackageCreator extends eZPackageCreationHandler 43 { 44 /*! 45 Constructor 46 */ 47 function eZExtensionPackageCreator( $id ) 48 { 49 $steps = array(); 50 $steps[] = array( 'id' => 'extensionname', 51 'name' => ezi18n( 'kernel/package', 'Select an extension to be exported' ), 52 'methods' => array( 'initialize' => 'initializeExtensionName', 53 'load' => 'loadExtensionName', 54 'validate' => 'validateExtensionName', 55 'commit' => 'commitExtensionName' ), 56 'template' => 'extension.tpl' ); 57 $steps[] = $this->packageInformationStep(); 58 $steps[] = $this->packageMaintainerStep(); 59 $steps[] = $this->packageChangelogStep(); 60 $this->eZPackageCreationHandler( $id, 61 ezi18n( 'kernel/package', 'Extension export' ), 62 $steps ); 63 } 64 65 function finalize( &$package, &$http, &$persistentData ) 66 { 67 $this->createPackage( $package, $http, $persistentData, $cleanupFiles, false ); 68 69 $siteINI = eZINI::instance(); 70 $extensionDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' ); 71 72 $fileList = array(); 73 $sourceDir = $extensionDir . '/' . $persistentData['extensionname']; 74 $targetDir = $package->path() . '/ezextension'; 75 76 eZDir::mkdir( $targetDir, false, true ); 77 eZDir::copy( $sourceDir, $targetDir ); 78 79 eZDir::recursiveList( $targetDir, '', $fileList ); 80 81 $doc = new eZDOMDocument; 82 83 $packageRoot =& $doc->createElement( 'extension' ); 84 $packageRoot->setAttribute( 'name', $persistentData['extensionname'] ); 85 86 foreach( $fileList as $file ) 87 { 88 $fileNode =& $doc->createElement( 'file' ); 89 $fileNode->setAttribute( 'name', $file['name'] ); 90 91 if ( $file['path'] ) 92 $fileNode->setAttribute( 'path', $file['path'] ); 93 94 $fullPath = $targetDir . $file['path'] . '/' . $file['name']; 95 //$fileNode->setAttribute( 'full-path', $fullPath ); 96 $fileNode->setAttribute( 'md5sum', $package->md5sum( $fullPath ) ); 97 98 if ( $file['type'] == 'dir' ) 99 $fileNode->setAttribute( 'type', 'dir' ); 100 101 $packageRoot->appendChild( $fileNode ); 102 unset( $fileNode ); 103 } 104 105 $filename = 'extension-' . $persistentData['extensionname']; 106 107 $package->appendInstall( 'ezextension', false, false, true, 108 $filename, 'ezextension', 109 array( 'content' => $packageRoot ) ); 110 $package->appendInstall( 'ezextension', false, false, false, 111 $filename, 'ezextension', 112 array( 'content' => false ) ); 113 114 $package->setAttribute( 'is_active', true ); 115 $package->store(); 116 } 117 118 /*! 119 \reimp 120 \return \c 'import' 121 */ 122 function packageInstallType( &$package, &$persistentData ) 123 { 124 return 'install'; 125 } 126 127 /*! 128 \reimp 129 Returns \c 'stable', site style packages are always stable. 130 */ 131 function packageInitialState( &$package, &$persistentData ) 132 { 133 return 'stable'; 134 } 135 136 /*! 137 \return \c 'sitestyle'. 138 */ 139 function packageType( &$package, &$persistentData ) 140 { 141 return 'extension'; 142 } 143 144 function initializeExtensionName( &$package, &$http, $step, &$persistentData, &$tpl ) 145 { 146 } 147 148 function loadExtensionName( &$package, &$http, $step, &$persistentData, &$tpl ) 149 { 150 $siteINI = eZINI::instance(); 151 $extensionDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' ); 152 $extensionList = eZDir::findSubItems( $extensionDir ); 153 $tpl->setVariable( 'extension_list', $extensionList ); 154 } 155 156 function validateExtensionName( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList ) 157 { 158 if ( !$http->hasPostVariable( 'PackageExtensionName' ) ) 159 { 160 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Extension:' ), 161 'description' => ezi18n( 'kernel/package', 'You must select an extension' ) ); 162 return false; 163 } 164 return true; 165 } 166 167 function commitExtensionName( &$package, &$http, $step, &$persistentData, &$tpl ) 168 { 169 $persistentData['extensionname'] = $http->postVariable( 'PackageExtensionName' ); 170 } 171 172 /*! 173 \reimp 174 Fetches the selected content classes and generates a name, summary and description from the selection. 175 */ 176 function generatePackageInformation( &$packageInformation, &$package, &$http, $step, &$persistentData ) 177 { 178 $extensionName = $persistentData['extensionname']; 179 180 if ( $extensionName ) 181 { 182 $packageInformation['name'] = $extensionName; 183 $packageInformation['summary'] = $extensionName . ' extension'; 184 $packageInformation['description'] = $extensionName . ' eZ publish extension'; 185 } 186 } 187 } 188 189 ?>
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 |