<?php
 class PEAR_Installer_Role_Common { var $config; function PEAR_Installer_Role_Common(&$config) { $this->config = $config; } function getInfo($role) { if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) { return PEAR::raiseError('Unknown Role class: "' . $role . '"'); } return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role]; } function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null) { $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); if (PEAR::isError($roleInfo)) { return $roleInfo; } if (!$roleInfo['locationconfig']) { return false; } if ($roleInfo['honorsbaseinstall']) { $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], $layer, $pkg->getChannel()); 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']; } } else { $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); } else { $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as']; } $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file; $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; list($dest_dir, $dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), array($dest_dir, $dest_file, $orig_file)); return array($save_destdir, $dest_dir, $dest_file, $orig_file); } function getLocationConfig() { $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); if (PEAR::isError($roleInfo)) { return $roleInfo; } return $roleInfo['locationconfig']; } function setup(&$installer, $pkg, $atts, $file) { } function isExecutable() { $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); if (PEAR::isError($roleInfo)) { return $roleInfo; } return $roleInfo['executable']; } function isInstallable() { $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); if (PEAR::isError($roleInfo)) { return $roleInfo; } return $roleInfo['installable']; } function isExtension() { $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); if (PEAR::isError($roleInfo)) { return $roleInfo; } return $roleInfo['phpextension']; } } ?>