|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZStylePackageCreator class 00004 // 00005 // Created on: <14-Dec-2005 12:39:59 ks> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezstylepackagecreator.php 00032 */ 00033 00034 /*! 00035 \ingroup package 00036 \class eZStylePackageCreator ezstylepackagecreator.php 00037 \brief The class eZStylePackageCreator does 00038 00039 */ 00040 00041 //include_once( 'kernel/classes/ezpackagecreationhandler.php' ); 00042 //include_once( 'lib/ezfile/classes/ezdir.php' ); 00043 00044 class eZExtensionPackageCreator extends eZPackageCreationHandler 00045 { 00046 /*! 00047 Constructor 00048 */ 00049 function eZExtensionPackageCreator( $id ) 00050 { 00051 $steps = array(); 00052 $steps[] = array( 'id' => 'extensionname', 00053 'name' => ezi18n( 'kernel/package', 'Select an extension to be exported' ), 00054 'methods' => array( 'initialize' => 'initializeExtensionName', 00055 'load' => 'loadExtensionName', 00056 'validate' => 'validateExtensionName', 00057 'commit' => 'commitExtensionName' ), 00058 'template' => 'extension.tpl' ); 00059 $steps[] = $this->packageInformationStep(); 00060 $steps[] = $this->packageMaintainerStep(); 00061 $steps[] = $this->packageChangelogStep(); 00062 $this->eZPackageCreationHandler( $id, 00063 ezi18n( 'kernel/package', 'Extension export' ), 00064 $steps ); 00065 } 00066 00067 function finalize( &$package, $http, &$persistentData ) 00068 { 00069 $this->createPackage( $package, $http, $persistentData, $cleanupFiles, false ); 00070 00071 $siteINI = eZINI::instance(); 00072 $extensionDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' ); 00073 00074 $fileList = array(); 00075 $sourceDir = $extensionDir . '/' . $persistentData['extensionname']; 00076 $targetDir = $package->path() . '/ezextension'; 00077 00078 eZDir::mkdir( $targetDir, false, true ); 00079 eZDir::copy( $sourceDir, $targetDir ); 00080 00081 eZDir::recursiveList( $targetDir, '', $fileList ); 00082 00083 $doc = new DOMDocument( '1.0', 'utf-8' ); 00084 00085 $packageRoot = $doc->createElement( 'extension' ); 00086 $packageRoot->setAttribute( 'name', $persistentData['extensionname'] ); 00087 00088 foreach( $fileList as $file ) 00089 { 00090 $fileNode = $doc->createElement( 'file' ); 00091 $fileNode->setAttribute( 'name', $file['name'] ); 00092 00093 if ( $file['path'] ) 00094 $fileNode->setAttribute( 'path', $file['path'] ); 00095 00096 $fullPath = $targetDir . $file['path'] . '/' . $file['name']; 00097 $fileNode->setAttribute( 'md5sum', $package->md5sum( $fullPath ) ); 00098 00099 if ( $file['type'] == 'dir' ) 00100 $fileNode->setAttribute( 'type', 'dir' ); 00101 00102 $packageRoot->appendChild( $fileNode ); 00103 unset( $fileNode ); 00104 } 00105 00106 $filename = 'extension-' . $persistentData['extensionname']; 00107 00108 $package->appendInstall( 'ezextension', false, false, true, 00109 $filename, 'ezextension', 00110 array( 'content' => $packageRoot ) ); 00111 $package->appendInstall( 'ezextension', false, false, false, 00112 $filename, 'ezextension', 00113 array( 'content' => false ) ); 00114 00115 $package->setAttribute( 'is_active', true ); 00116 $package->store(); 00117 } 00118 00119 /*! 00120 \reimp 00121 \return \c 'import' 00122 */ 00123 function packageInstallType( $package, &$persistentData ) 00124 { 00125 return 'install'; 00126 } 00127 00128 /*! 00129 \reimp 00130 Returns \c 'stable', site style packages are always stable. 00131 */ 00132 function packageInitialState( $package, &$persistentData ) 00133 { 00134 return 'stable'; 00135 } 00136 00137 /*! 00138 \return \c 'sitestyle'. 00139 */ 00140 function packageType( $package, &$persistentData ) 00141 { 00142 return 'extension'; 00143 } 00144 00145 function initializeExtensionName( $package, $http, $step, &$persistentData, $tpl ) 00146 { 00147 } 00148 00149 function loadExtensionName( $package, $http, $step, &$persistentData, $tpl ) 00150 { 00151 $siteINI = eZINI::instance(); 00152 $extensionDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' ); 00153 $extensionList = eZDir::findSubItems( $extensionDir ); 00154 $tpl->setVariable( 'extension_list', $extensionList ); 00155 } 00156 00157 function validateExtensionName( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList ) 00158 { 00159 if ( !$http->hasPostVariable( 'PackageExtensionName' ) ) 00160 { 00161 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Extension:' ), 00162 'description' => ezi18n( 'kernel/package', 'You must select an extension' ) ); 00163 return false; 00164 } 00165 return true; 00166 } 00167 00168 function commitExtensionName( $package, $http, $step, &$persistentData, $tpl ) 00169 { 00170 $persistentData['extensionname'] = $http->postVariable( 'PackageExtensionName' ); 00171 } 00172 00173 /*! 00174 \reimp 00175 Fetches the selected content classes and generates a name, summary and description from the selection. 00176 */ 00177 function generatePackageInformation( &$packageInformation, $package, $http, $step, &$persistentData ) 00178 { 00179 $extensionName = $persistentData['extensionname']; 00180 00181 if ( $extensionName ) 00182 { 00183 $packageInformation['name'] = $extensionName; 00184 $packageInformation['summary'] = $extensionName . ' extension'; 00185 $packageInformation['description'] = $extensionName . ' eZ Publish extension'; 00186 } 00187 } 00188 } 00189 00190 ?>