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