* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Config.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
}
}
+// Default for metadata_dir
+if (getenv('PHP_PEAR_METADATA_DIR')) {
+ define('PEAR_CONFIG_DEFAULT_METADATA_DIR', getenv('PHP_PEAR_METADATA_DIR'));
+} else {
+ define('PEAR_CONFIG_DEFAULT_METADATA_DIR', '');
+}
+
// Default for ext_dir
if (getenv('PHP_PEAR_EXTENSION_DIR')) {
define('PEAR_CONFIG_DEFAULT_EXT_DIR', getenv('PHP_PEAR_EXTENSION_DIR'));
$PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'www');
}
+// Default for man_dir
+if (getenv('PHP_PEAR_MAN_DIR')) {
+ define('PEAR_CONFIG_DEFAULT_MAN_DIR', getenv('PHP_PEAR_MAN_DIR'));
+} else {
+ if (defined('PHP_MANDIR')) { // Added in PHP5.3.7
+ define('PEAR_CONFIG_DEFAULT_MAN_DIR', PHP_MANDIR);
+ } else {
+ define('PEAR_CONFIG_DEFAULT_MAN_DIR', PHP_PREFIX . DIRECTORY_SEPARATOR .
+ 'local' . DIRECTORY_SEPARATOR .'man');
+ }
+}
+
// Default for test_dir
if (getenv('PHP_PEAR_TEST_DIR')) {
define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR'));
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 0.1
*/
'prompt' => 'PEAR www files directory',
'group' => 'File Locations (Advanced)',
),
+ 'man_dir' => array(
+ 'type' => 'directory',
+ 'default' => PEAR_CONFIG_DEFAULT_MAN_DIR,
+ 'doc' => 'directory where unix manual pages are installed',
+ 'prompt' => 'Systems manpage files directory',
+ 'group' => 'File Locations (Advanced)',
+ ),
'test_dir' => array(
'type' => 'directory',
'default' => PEAR_CONFIG_DEFAULT_TEST_DIR,
'prompt' => 'php.ini location',
'group' => 'File Locations (Advanced)',
),
+ 'metadata_dir' => array(
+ 'type' => 'directory',
+ 'default' => PEAR_CONFIG_DEFAULT_METADATA_DIR,
+ 'doc' => 'directory where metadata files are installed (registry, filemap, channels, ...)',
+ 'prompt' => 'PEAR metadata directory',
+ 'group' => 'File Locations (Advanced)',
+ ),
// Maintainers
'username' => array(
'type' => 'string',
*
* @see PEAR_Config::singleton
*/
- function PEAR_Config($user_file = '', $system_file = '', $ftp_file = false,
+ function __construct($user_file = '', $system_file = '', $ftp_file = false,
$strict = true)
{
- $this->PEAR();
+ parent::__construct();
PEAR_Installer_Role::initializeConfig($this);
$sl = DIRECTORY_SEPARATOR;
if (empty($user_file)) {
$this->configuration['default'][$key] = $info['default'];
}
- $this->_registry['default'] = &new PEAR_Registry($this->configuration['default']['php_dir']);
+ $this->_registry['default'] = new PEAR_Registry(
+ $this->configuration['default']['php_dir'], false, false,
+ $this->configuration['default']['metadata_dir']);
$this->_registry['default']->setConfig($this, false);
$this->_regInitialized['default'] = false;
//$GLOBALS['_PEAR_Config_instance'] = &$this;
/**
* Return the default locations of user and system configuration files
- * @static
*/
- function getDefaultConfigFiles()
+ public static function getDefaultConfigFiles()
{
$sl = DIRECTORY_SEPARATOR;
if (OS_WINDOWS) {
*
* @return object an existing or new PEAR_Config instance
*
- * @access public
- *
* @see PEAR_Config::PEAR_Config
*/
- function &singleton($user_file = '', $system_file = '', $strict = true)
+ public static function &singleton($user_file = '', $system_file = '', $strict = true)
{
if (is_object($GLOBALS['_PEAR_Config_instance'])) {
return $GLOBALS['_PEAR_Config_instance'];
}
- $t_conf = &new PEAR_Config($user_file, $system_file, false, $strict);
+ $t_conf = new PEAR_Config($user_file, $system_file, false, $strict);
if ($t_conf->_errorsFound > 0) {
return $t_conf->lastError;
}
$this->configuration[$layer] = $data;
$this->_setupChannels();
if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
- $this->_registry[$layer] = &new PEAR_Registry($phpdir);
+ $this->_registry[$layer] = new PEAR_Registry(
+ $phpdir, false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
} else {
return PEAR::raiseError('PEAR_RemoteInstaller must be installed to use remote config');
}
- $this->_ftp = &new PEAR_FTP;
+ $this->_ftp = new PEAR_FTP;
$this->_ftp->pushErrorHandling(PEAR_ERROR_RETURN);
$e = $this->_ftp->init($path);
if (PEAR::isError($e)) {
$this->_setupChannels();
if (!$this->_noRegistry && ($phpdir = $this->get('php_dir', $layer, 'pear.php.net'))) {
- $this->_registry[$layer] = &new PEAR_Registry($phpdir);
+ $this->_registry[$layer] = new PEAR_Registry(
+ $phpdir, false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
} else {
* @param array
* @param array
* @return array
- * @static
*/
- function arrayMergeRecursive($arr2, $arr1)
+ public static function arrayMergeRecursive($arr2, $arr1)
{
$ret = array();
foreach ($arr2 as $key => $data) {
}
$size = filesize($file);
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
fclose($fp);
$contents = file_get_contents($file);
if (empty($contents)) {
return $this->raiseError('Configuration file "' . $file . '" is empty');
}
- set_magic_quotes_runtime($rt);
-
$version = false;
if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) {
$version = $matches[1];
if ($key == 'preferred_mirror') {
$reg = &$this->getRegistry();
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $channel;
}
if ($key == 'preferred_mirror') {
$reg = &$this->getRegistry();
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $channel;
}
if ($ret !== null) {
$reg = &$this->getRegistry($layer);
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel);
+ $chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $channel;
}
$reg = &$this->getRegistry($layer);
if (is_object($reg)) {
- $chan = &$reg->getChannel($channel ? $channel : 'pear.php.net');
+ $chan = $reg->getChannel($channel ? $channel : 'pear.php.net');
if (PEAR::isError($chan)) {
return false;
}
if ($key == 'php_dir' && !$this->_noRegistry) {
if (!isset($this->_registry[$layer]) ||
$value != $this->_registry[$layer]->install_dir) {
- $this->_registry[$layer] = &new PEAR_Registry($value);
+ $this->_registry[$layer] = new PEAR_Registry($value);
$this->_regInitialized[$layer] = false;
$this->_registry[$layer]->setConfig($this, false);
}
if (!is_object($this->_registry[$layer])) {
if ($phpdir = $this->get('php_dir', $layer, 'pear.php.net')) {
- $this->_registry[$layer] = &new PEAR_Registry($phpdir);
+ $this->_registry[$layer] = new PEAR_Registry(
+ $phpdir, false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
} else {
require_once 'PEAR/REST/' . $version . '.php';
}
- $remote = &new $class($this, $options);
+ $remote = new $class($this, $options);
return $remote;
}
continue;
}
$this->_registry[$layer] =
- &new PEAR_Registry($this->get('php_dir', $layer, 'pear.php.net'));
+ new PEAR_Registry(
+ $this->get('php_dir', $layer, 'pear.php.net'), false, false,
+ $this->get('metadata_dir', $layer, 'pear.php.net'));
$this->_registry[$layer]->setConfig($this, false);
$this->_regInitialized[$layer] = false;
}