/** * ZE2 Constructor * * @since 1.8.0 */ function __construct() { $this->opts = array('php-dir' => array('short' => 'pd', 'desc' => 'PEAR directory', 'default' => '', 'min' => 0, 'max' => 1), 'usr-cfg' => array('short' => 'uc', 'desc' => 'User Configuration File', 'default' => '', 'min' => 0, 'max' => 1), 'sys-cfg' => array('short' => 'sc', 'desc' => 'System Configuration File', 'default' => '', 'min' => 0, 'max' => 1), 'http-proxy' => array('short' => 'hp', 'desc' => 'HTTP Proxy Server Address', 'default' => '', 'min' => 0, 'max' => 1), 'all' => array('short' => 'a', 'desc' => 'Display informations for installed packages', 'default' => PEAR_INFO_ALL, 'min' => 0, 'max' => 1), 'allchannels' => array('short' => 'A', 'desc' => 'List packages from all channels, ' . 'not just the default one', 'max' => 0), 'channel' => array('short' => 'c', 'desc' => 'Specify which channel', 'default' => '', 'min' => 0, 'max' => 1), 'version' => array('short' => 'V', 'desc' => 'Print version information', 'max' => 0), 'help' => array('short' => 'h', 'desc' => 'Show this help', 'max' => 0)); $this->args =& Console_Getargs::factory($this->opts); if (PEAR::isError($this->args)) { if ($this->args->getCode() === CONSOLE_GETARGS_HELP) { $this->error = ''; } else { $this->error = $this->args->getMessage(); } return; } $options = array('channels' => array('pear.php.net'), 'resume' => PEAR_INFO_ALL); // php-dir if ($this->args->isDefined('pd')) { $pear_dir = $this->args->getValue('pd'); } else { $pear_dir = ''; } // usr-cfg if ($this->args->isDefined('uc')) { $user_file = $this->args->getValue('uc'); if (!file_exists($user_file)) { $this->error = 'Failed opening PEAR user configuration file "' . $user_file . '". Please check your spelling and try again.'; return; } } else { $user_file = ''; } // sys-cfg if ($this->args->isDefined('sc')) { $system_file = $this->args->getValue('sc'); if (!file_exists($system_file)) { $this->error = 'Failed opening PEAR system configuration file "' . $system_file . '". Please check your spelling and try again.'; return; } } else { $system_file = ''; } // http-proxy if ($this->args->isDefined('hp')) { $proxy = $this->args->getValue('hp'); $res = PEAR_Info::setProxy($proxy); if ($res === false) { $this->error = 'Failed define Proxy Server Address.' . ' Please check your spelling and try again.'; return; } } // all if ($this->args->isDefined('a')) { $a = $this->args->getValue('a'); if (is_numeric($a)) { $options['resume'] = intval($a); } else { $this->error = "No valid 'resume' option for argument all." . ' Please check your spelling and try again.'; return; } } // allchannels $A = $this->args->getValue('A'); if (isset($A)) { $options['channels'] = array(); } // channel if ($this->args->isDefined('c')) { $chan = $this->args->getValue('c'); if (is_string($chan)) { $options['channels'] = explode(',', $chan); } else { $this->error = 'No valid channel list provided.' . ' Please check your spelling and try again.'; return; } } // version $V = $this->args->getValue('V'); if (isset($V)) { $this->error = 'PEAR_Info (cli) version 1.9.2' . ' (http://pear.php.net/package/PEAR_Info)'; return; } parent::__construct($pear_dir, $user_file, $system_file, $options); }