00001 <?php 00002 // 00003 // Definition of eZPackageHandler class 00004 // 00005 // Created on: <01-Aug-2003 17:11:07 amos> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ publish 00009 // SOFTWARE RELEASE: 3.9.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 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 ezpackagehandler.php 00032 */ 00033 00034 /*! 00035 \class eZPackageHandler ezpackagehandler.php 00036 \brief The class eZPackageHandler does 00037 00038 */ 00039 00040 class eZPackageHandler 00041 { 00042 /*! 00043 Constructor 00044 */ 00045 function eZPackageHandler( $handlerType, $parameters = array() ) 00046 { 00047 $parameters = array_merge( array( 'extract-install-content' => false ), 00048 $parameters ); 00049 $this->ExtractInstallContent = $parameters['extract-install-content']; 00050 $this->HandlerType = $handlerType; 00051 } 00052 00053 /*! 00054 \virtual 00055 \return true if the content of the install item should be extracted 00056 from disk before the install() function is called. 00057 */ 00058 function extractInstallContent() 00059 { 00060 return $this->ExtractInstallContent; 00061 } 00062 00063 /*! 00064 \pure 00065 Installs the package item 00066 */ 00067 function install( &$package, $installType, $parameters, 00068 $name, $os, $filename, $subdirectory, 00069 &$content, &$installParameters, &$installData ) 00070 { 00071 } 00072 00073 /*! 00074 \pure 00075 Uninstalls the package item 00076 */ 00077 function uninstall( &$package, $installType, $parameters, 00078 $name, $os, $filename, $subdirectory, 00079 $installParameters, &$installData ) 00080 { 00081 } 00082 00083 /*! 00084 \return the name of the type this handler works for. 00085 */ 00086 function handlerType() 00087 { 00088 return $this->HandlerType; 00089 } 00090 00091 /*! 00092 \virtual 00093 Resets all data in the handler so that it's ready to handle a new package. 00094 */ 00095 function reset() 00096 { 00097 } 00098 00099 /*! 00100 \pure 00101 Returns an explanation (human readable) for the install item \a $installItem. 00102 The explanation is an array with the following items. 00103 - description - Textual description of what will be installed 00104 00105 \note This must be implemented for package handlers. 00106 */ 00107 function explainInstallItem( &$package, $installItem ) 00108 { 00109 } 00110 00111 /*! 00112 \pure 00113 Adds items defined in \a $parameters to the package \a $package. 00114 */ 00115 function add( $packageType, &$package, $parameters ) 00116 { 00117 } 00118 00119 /*! 00120 \pure 00121 Called when command line parameters must be handled by the package handler. 00122 This function must return an array with values which can easily be used in the add() function. 00123 \param $packageType The type that was specified when using the add command, 00124 which is either the name of this handler or an alias for it. 00125 \param $package The package object. 00126 \param $cli Command line interface object, can be used to output errors etc. 00127 \param $arguments An array with string values taken from the command line after the add command. 00128 */ 00129 function handleAddParameters( $packageType, &$package, &$cli, $arguments ) 00130 { 00131 } 00132 00133 // /*! 00134 // \pure 00135 // Inteprets the parameters defined in \a $parameters and adds items to \a $package. 00136 // */ 00137 // function handle( &$package, $parameters ) 00138 // { 00139 // } 00140 00141 /*! 00142 \pure 00143 Fills in extra information on the dependency node \a $dependencyNode which is 00144 specific to the current handler. 00145 \param $package The current package. 00146 \param $dependencyItem Contains all variables for the dependency 00147 \param $dependencySection The section for the dependency, can be \c 'provide', \c 'require', \c 'obsolete' or \c 'conflict' 00148 */ 00149 function createDependencyNode( &$package, &$dependencyNode, $dependencyItem, $dependencySection ) 00150 { 00151 } 00152 00153 /*! 00154 \pure 00155 Parses the XML node \c $dependencyNode and fills in extra information not handled 00156 by the package parser. 00157 \param $package The current package. 00158 \param $dependencyParameters Reference to an array with must be filled with specific data for the current handler. 00159 \param $dependencySection The section for the dependency, can be \c 'provide', \c 'require', \c 'obsolete' or \c 'conflict' 00160 */ 00161 function parseDependencyNode( &$package, &$dependencyNode, &$dependencyParameters, $dependencySection ) 00162 { 00163 } 00164 00165 /*! 00166 \virtual 00167 Creates a text specific for the dependency item \a $dependencyItem and returns it. 00168 \param $package The current package. 00169 \param $dependencyItem Associative array with dependency values. 00170 \param $dependencySection The section for the dependency, can be \c 'provide', \c 'require', \c 'obsolete' or \c 'conflict' 00171 \return \c false if no special text is required. 00172 */ 00173 function createDependencyText( &$package, $dependencyItem, $dependencySection ) 00174 { 00175 } 00176 00177 /*! 00178 \pure 00179 Fills in extra information on the install node \a $installNode which is 00180 specific to the current handler. 00181 \param $package The current package. 00182 \param $installItem Contains all variables for the install 00183 \param $installType The type of install, can be \c 'install' or \c 'uninstall' 00184 */ 00185 function createInstallNode( &$package, &$installNode, $installItem, $installType ) 00186 { 00187 } 00188 00189 /*! 00190 \pure 00191 Parses the XML node \c $installNode and fills in extra information not handled 00192 by the package parser. 00193 \param $package The current package. 00194 \param $installParameters Reference to an array which must be filled with specific data for the current handler. 00195 \param $isInstall Is \c true if this is an install node, \c false if it is an uninstall node 00196 */ 00197 function parseInstallNode( &$package, &$installNode, &$installParameters, $isInstall ) 00198 { 00199 } 00200 00201 /*! 00202 Helper function to process install errors. 00203 Decides to skip current element or not when cycling thru elements 00204 Also skips element where error has occured if action is not choosen 00205 */ 00206 00207 function isErrorElement( $elementID, &$installParameters ) 00208 { 00209 if ( $elementID == $installParameters['error']['element_id'] ) 00210 { 00211 // If action not set - skip this element 00212 if ( !isset( $installParameters['error']['choosen_action'] ) ) 00213 { 00214 $installParameters['error'] = array(); 00215 return false; 00216 } 00217 return true; 00218 } 00219 return false; 00220 00221 } 00222 00223 /*! 00224 Helper function to process install errors. 00225 \return choosen action code. 00226 If $resetError is false, array should be manually reset in handler. 00227 */ 00228 00229 function errorChoosenAction( $errorCode, &$installParameters, $description = false, $handlerType = false, $resetError = true ) 00230 { 00231 if ( isset( $installParameters['non-interactive'] ) && $installParameters['non-interactive'] ) 00232 { 00233 if ( $description ) 00234 { 00235 eZDebug::writeNotice( $description, 'Package installation conflict' ); 00236 } 00237 return EZ_PACKAGE_NON_INTERACTIVE; 00238 } 00239 00240 if ( !$handlerType ) 00241 $handlerType = $this->HandlerType; 00242 00243 if ( isset( $installParameters['error_default_actions'][$handlerType][$errorCode] ) ) 00244 { 00245 if ( $resetError && count( $installParameters['error'] ) ) 00246 $installParameters['error'] = array(); 00247 return $installParameters['error_default_actions'][$handlerType][$errorCode]; 00248 } 00249 00250 if ( isset( $installParameters['error']['error_code'] ) && 00251 $installParameters['error']['error_code'] == $errorCode ) 00252 { 00253 if ( isset( $installParameters['error']['choosen_action'] ) ) 00254 { 00255 $choosenAction = $installParameters['error']['choosen_action']; 00256 if ( $resetError ) 00257 $installParameters['error'] = array(); 00258 return $choosenAction; 00259 } 00260 } 00261 return false; 00262 } 00263 00264 } 00265 00266 ?>
1.6.3