Source for file Common.php
Documentation is available at Common.php
* Base class for all installation roles.
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Common.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
* Base class for all installation roles.
* This class allows extensibility of file roles. Packages with complex
* customization can now provide custom file roles along with the possibility of
* adding configuration values to match.
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2006 The PHP Group
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 1.9.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
* Retrieve configuration information about a file role from its XML info
* @param string $role Role Classname, as in "PEAR_Installer_Role_Data"
if (empty ($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) {
return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role];
* This is called for each file to set up the directories and files
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
* @param array attributes from the <file> tag
* @param string file name
* @return array an array consisting of:
* 1 the original, pre-baseinstalldir installation directory
* 2 the final installation directory
* 3 the full path to the final location of the file
* 4 the location of the pre-installation file
if (!$roleInfo['locationconfig']) {
if ($roleInfo['honorsbaseinstall']) {
$dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], $layer,
if (!empty ($atts['baseinstalldir'])) {
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
} elseif ($roleInfo['unusualbaseinstall']) {
$dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'],
$layer, $pkg->getChannel ()) . DIRECTORY_SEPARATOR . $pkg->getPackage ();
if (!empty ($atts['baseinstalldir'])) {
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
$dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'],
$layer, $pkg->getChannel ()) . DIRECTORY_SEPARATOR . $pkg->getPackage ();
if (dirname($file) != '.' && empty ($atts['install-as'])) {
$dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
if (empty ($atts['install-as'])) {
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
$orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
// Clean up the DIRECTORY_SEPARATOR mess
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
list ($dest_dir, $dest_file, $orig_file) = preg_replace(array ('!\\\\+!', '!/!', " !$ds2+!" ),
array (DIRECTORY_SEPARATOR , DIRECTORY_SEPARATOR ,
array ($dest_dir, $dest_file, $orig_file));
return array ($save_destdir, $dest_dir, $dest_file, $orig_file);
* Get the name of the configuration variable that specifies the location of this file
return $roleInfo['locationconfig'];
* Do any unusual setup here
* @param PEAR_PackageFile_v2
* @param array file attributes
* @param string file name
function setup(&$installer, $pkg, $atts, $file)
return $roleInfo['executable'];
return $roleInfo['installable'];
return $roleInfo['phpextension'];
Documentation generated on Wed, 06 Jul 2011 23:30:34 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|