PEAR.php \
PEAR/Autoloader.php \
PEAR/Command.php \
+ PEAR/Command/Auth.php \
PEAR/Command/Common.php \
PEAR/Command/Config.php \
PEAR/Command/Install.php \
- PEAR/Command/Login.php \
PEAR/Command/Package.php \
+ PEAR/Command/Registry.php \
PEAR/CommandResponse.php \
- PEAR/CommandUI/CLI.php \
+ PEAR/Frontend/CLI.php \
PEAR/Common.php \
PEAR/Config.php \
PEAR/Dependency.php \
* Which user interface class is being used.
* @var string class name
*/
-$GLOBALS['_PEAR_Command_uiclass'] = 'PEAR_CommandUI_CLI';
+$GLOBALS['_PEAR_Command_uiclass'] = 'PEAR_Frontend_CLI';
/**
* The options accepted by the commands
}
if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
$class = $GLOBALS['_PEAR_Command_commandlist'][$command];
- $obj = &new $class(PEAR_Command::getUIObject(), $config);
+ $obj = &new $class(PEAR_Command::getFrontendObject(), $config);
return $obj;
}
return PEAR::raiseError("unknown command `$command'");
}
- function &getUIObject()
+ function &getFrontendObject()
{
global $_PEAR_Command_uiclass, $_PEAR_Command_uiobject;
if (empty($_PEAR_Command_uiobject)) {
return $_PEAR_Command_uiobject;
}
- function setUIClass($uiclass)
+ function setFrontendClass($uiclass)
{
$GLOBALS['_PEAR_Command_uiclass'] = $uiclass;
$file = str_replace("_", "/", $uiclass) . '.php';
return class_exists(strtolower($uiclass));
}
- function setUIType($uitype)
+ function setFrontendType($uitype)
{
- $uiclass = 'PEAR_CommandUI_' . $uitype;
- return PEAR_Command::setUIClass($uiclass);
+ $uiclass = 'PEAR_Frontend_' . $uitype;
+ return PEAR_Command::setFrontendClass($uiclass);
}
/**
*/
function PEAR_Command_Login(&$ui, &$config)
{
- parent::PEAR_Command_Common($ui);
+ parent::PEAR_Command_Common($ui, $config);
}
// }}}
*
* @param array list of additional parameters
*
- * @return bool TRUE on success, PEAR error on failure
+ * @return bool TRUE on success, FALSE for unknown commands, or
+ * a PEAR error on failure
*
* @access public
*/
$server = $cf->get('master_server');
switch ($command) {
case 'login': {
+ $remote = new PEAR_Remote($cf);
$username = $cf->get('username');
if (empty($username)) {
$username = @$_ENV['USER'];
$cf->set('username', $username);
$password = trim($this->ui->userDialog('Password', 'password'));
$cf->set('password', $password);
- $remote = new PEAR_Remote($cf);
$remote->expectError(401);
$ok = $remote->call('logintest');
$remote->popExpect();
break;
}
default: {
- $failmsg = "unknown command: $command";
- break;
+ return false;
}
}
if ($failmsg) {
function PEAR_Command_Common(&$ui, &$config)
{
parent::PEAR();
- $this->config =& $config;
- $this->ui = $ui;
+ $this->config = &$config;
+ $this->ui = &$ui;
}
function getOptions()
$this->config->get('ext_dir'),
$this->config->get('doc_dir'));
$installer->debug = $this->config->get('verbose');
+
$failmsg = '';
$opts = array();
switch ($command) {
+++ /dev/null
-<?php
-//
-// +----------------------------------------------------------------------+
-// | PHP Version 4 |
-// +----------------------------------------------------------------------+
-// | Copyright (c) 1997-2002 The PHP Group |
-// +----------------------------------------------------------------------+
-// | This source file is subject to version 2.02 of the PHP license, |
-// | that is bundled with this package in the file LICENSE, and is |
-// | available at through the world-wide-web at |
-// | http://www.php.net/license/2_02.txt. |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to |
-// | license@php.net so we can mail you a copy immediately. |
-// +----------------------------------------------------------------------+
-// | Author: Stig Bakken <ssb@fast.no> |
-// +----------------------------------------------------------------------+
-//
-// $Id$
-
-require_once "PEAR/Command/Common.php";
-require_once "PEAR/Registry.php";
-
-/**
- * PEAR commands for managing configuration data.
- *
- */
-class PEAR_Command_List extends PEAR_Command_Common
-{
- // {{{ properties
- // }}}
-
- // {{{ constructor
-
- /**
- * PEAR_Command_Config constructor.
- *
- * @access public
- */
- function PEAR_Command_List(&$ui, &$config)
- {
- parent::PEAR_Command_Common($ui, $config);
- }
-
- // }}}
-
- // {{{ getCommands()
-
- /**
- * Return a list of all the commands defined by this class.
- * @return array list of commands
- * @access public
- */
- function getCommands()
- {
- return array('list');
- }
-
- // }}}
- // {{{ run()
-
- function run($command, $options, $params)
- {
- $reg = new PEAR_Registry(); // XXX Use config here
- $installed = $reg->packageInfo();
- $i = $j = 0;
- ob_start();
- heading("Installed packages:");
- foreach ($installed as $package) {
- if ($i++ % 20 == 0) {
- if ($j++ > 0) {
- print "\n";
- }
- printf("%-20s %-10s %s\n",
- "Package", "Version", "State");
- print str_repeat("-", 75)."\n";
- }
- printf("%-20s %-10s %s\n", $package['package'],
- $package['version'], $package['release_state']);
- }
- $output = ob_get_contents();
- ob_end_clean();
- $lines = explode("\n", $output);
- foreach ($lines as $line) {
- $this->ui->displayLine($line);
- }
- }
-}
-?>
\ No newline at end of file
// {{{ constructor
/**
- * PEAR_Command_Login constructor.
+ * PEAR_Command_Package constructor.
*
* @access public
*/
--- /dev/null
+<?php
+
+require_once 'PEAR/Command/Common.php';
+require_once 'PEAR/Registry.php';
+require_once 'PEAR/Config.php';
+
+class PEAR_Command_Registry extends PEAR_Command_Common
+{
+ // {{{ constructor
+
+ /**
+ * PEAR_Command_Registry constructor.
+ *
+ * @access public
+ */
+ function PEAR_Command_Registry(&$ui)
+ {
+ parent::PEAR_Command_Common($ui);
+ }
+
+ // }}}
+
+ // {{{ getCommands()
+
+ /**
+ * Return a list of all the commands defined by this class.
+ * @return array list of commands
+ * @access public
+ */
+ function getCommands()
+ {
+ return array('list-installed');
+ }
+
+ // }}}
+ // {{{ run()
+
+ /**
+ * Execute the command.
+ *
+ * @param string command name
+ *
+ * @param array option_name => value
+ *
+ * @param array list of additional parameters
+ *
+ * @return bool TRUE on success, FALSE if the command was unknown,
+ * or a PEAR error on failure
+ *
+ * @access public
+ */
+ function run($command, $options, $params)
+ {
+ $failmsg = '';
+ $cf = &PEAR_Config::singleton();
+ switch ($command) {
+ case 'list-installed': {
+ $reg = new PEAR_Registry($cf->get('php_dir'));
+ $installed = $reg->packageInfo();
+ $i = $j = 0;
+ heading("Installed packages:");
+ foreach ($installed as $package) {
+ if ($i++ % 20 == 0) {
+ if ($j++ > 0) {
+ print "\n";
+ }
+ printf("%-20s %-10s %s\n",
+ "Package", "Version", "State");
+ print str_repeat("-", 75)."\n";
+ }
+ printf("%-20s %-10s %s\n", $package['package'],
+ $package['version'], $package['release_state']);
+ }
+ break;
+ }
+ default: {
+ return false;
+ }
+ }
+ if ($failmsg) {
+ return $this->raiseError($failmsg);
+ }
+ return true;
+ }
+
+ // }}}
+
+
+}
+
+?>
\ No newline at end of file
+++ /dev/null
-<?php
-
-require_once "PEAR.php";
-
-class PEAR_CommandUI_CLI extends PEAR
-{
- var $output_mode = 'plain';
- var $output_mode_params = array();
-
- function PEAR_CommandUI_CLI()
- {
- parent::PEAR();
- }
-
- function _PEAR_CommandUI_CLI()
- {
- parent::_PEAR();
- if ($this->output_mode) {
- $this->endOutput();
- }
- }
-
- function displayLine($text)
- {
- print "$text\n";
- }
-
- function userDialog($prompt, $type = 'text', $default = '')
- {
- if ($type == 'password') {
- system('stty -echo');
- }
- print "$prompt ";
- if ($default) {
- print "[$default] ";
- }
- print ": ";
- $fp = fopen("php://stdin", "r");
- $line = fgets($fp, 2048);
- fclose($fp);
- if ($type == 'password') {
- system('stty echo');
- print "\n";
- }
- if ($default && trim($line) == "") {
- return $default;
- }
- return $line;
- }
-
- function userConfirm($prompt, $default = 'yes')
- {
- static $positives = array('y', 'yes', 'on', '1');
- static $negatives = array('n', 'no', 'off', '0');
- print "$prompt [$default] : ";
- $fp = fopen("php://stdin", "r");
- $line = fgets($fp, 2048);
- fclose($fp);
- $answer = strtolower(trim($line));
- if (empty($answer)) {
- $answer = $default;
- }
- if (in_array($answer, $positives)) {
- return true;
- }
- if (in_array($answer, $negatives)) {
- return false;
- }
- if (in_array($default, $positives)) {
- return true;
- }
- return false;
- }
-
- function setOutputMode($mode, $params = array())
- {
- $this->output_mode = $mode;
- $this->output_mode_params = $params;
- }
-
- function startOutput($mode)
- {
- if ($this->output_mode) {
- $this->endOutput();
- }
- switch ($mode) {
- }
- }
-
- function endOutput($mode = null)
- {
- if ($mode === null) {
- $mode = $this->output_mode;
- }
- $this->output_mode = '';
- switch ($mode) {
- }
- }
-}
-
-?>
\ No newline at end of file
--- /dev/null
+<?php
+
+require_once "PEAR.php";
+
+class PEAR_Frontend_CLI extends PEAR
+{
+ var $omode = 'plain';
+ var $params = array();
+
+ function PEAR_Frontend_CLI()
+ {
+ parent::PEAR();
+ }
+
+ function _PEAR_Frontend_CLI()
+ {
+ parent::_PEAR();
+ if ($this->omode) {
+ $this->endOutput();
+ }
+ }
+
+ function displayLine($text)
+ {
+ print "| $text\n";
+ }
+
+ function displayHeading($title)
+ {
+ print "| ".strtoupper($title)."\n";
+ print "| ".str_repeat("=", strlen($title))."\n";
+ }
+
+ function userDialog($prompt, $type = 'text', $default = '')
+ {
+ if ($type == 'password') {
+ system('stty -echo');
+ }
+ print "| $prompt ";
+ if ($default) {
+ print "[$default] ";
+ }
+ print ": ";
+ $fp = fopen("php://stdin", "r");
+ $line = fgets($fp, 2048);
+ fclose($fp);
+ if ($type == 'password') {
+ system('stty echo');
+ print "\n";
+ }
+ if ($default && trim($line) == "") {
+ return $default;
+ }
+ return $line;
+ }
+
+ function userConfirm($prompt, $default = 'yes')
+ {
+ static $positives = array('y', 'yes', 'on', '1');
+ static $negatives = array('n', 'no', 'off', '0');
+ print "| $prompt [$default] : ";
+ $fp = fopen("php://stdin", "r");
+ $line = fgets($fp, 2048);
+ fclose($fp);
+ $answer = strtolower(trim($line));
+ if (empty($answer)) {
+ $answer = $default;
+ }
+ if (in_array($answer, $positives)) {
+ return true;
+ }
+ if (in_array($answer, $negatives)) {
+ return false;
+ }
+ if (in_array($default, $positives)) {
+ return true;
+ }
+ return false;
+ }
+
+ function startTable($params = array())
+ {
+ $this->omode = 'table';
+ $params['table_data'] = array();
+ $params['widest'] = array();
+ $params['ncols'] = 0;
+ $this->params = $params;
+ }
+
+ function tableRow($columns, $rowparams = array(), $colparams = array())
+ {
+ for ($i = 0; $i < sizeof($columns); $i++) {
+ if (!isset($this->params['widest'][$i]) ||
+ strlen($columns[$i] > $this->params['widest'][$i]))
+ {
+ $this->params['widest'][$i] = strlen($columns[$i]);
+ }
+ }
+ if (!isset($this->params['ncols']) ||
+ sizeof($columns) > $this->params['ncols'])
+ {
+ $this->params['ncols'] = sizeof($columns);
+ }
+ $new_row = array(
+ 'data' => $columns,
+ 'rowparams' => $rowparams,
+ 'colparams' => $colparams,
+ );
+ $this->params['table_data'][] = $new_row;
+ }
+
+ function endTable()
+ {
+ $this->omode = '';
+ extract($this->params);
+ if (!empty($caption)) {
+ $this->displayHeading($caption);
+ }
+ if (!isset($width)) {
+ $width = $widest;
+ } else {
+ for ($i = 0; $i < $ncols; $i++) {
+ if (!isset($width[$i])) {
+ $width[$i] = $widest[$i];
+ }
+ }
+ }
+ if (empty($params['border'])) {
+ $cellstart = " ";
+ $rowend = "\n";
+ $padrowend = false;
+ } else {
+ $cellstart = "| ";
+ $rowend = " |\n";
+ $padrowend = true;
+ $borderline = "+";
+ foreach ($width as $w) {
+ $borderline .= str_repeat('-', $w + 2);
+ }
+ }
+ for ($i = 0; $i < sizeof($table_data); $i++) {
+ extract($table_data[$i]);
+ for ($c = 0; $c < sizeof($data); $c++) {
+ $w = $width[$c];
+ $l = strlen($data[$c]);
+ if ($l > $w) {
+ print
+ }
+ }
+ }
+ }
+}
+
+?>
\ No newline at end of file
// {{{ constructor
- function PEAR_Installer($phpdir = PEAR_INSTALL_DIR,
- $extdir = PEAR_EXTENSION_DIR,
- $docdir = null)
+ function PEAR_Installer(&$config)
{
$this->PEAR();
$this->phpdir = $phpdir;
return $this->raiseError("PEAR_Remote: authorization required, please log in first", 401);
}
default:
- return $this->raiseError("PEAR_Remote: unexpected HTTP response: $matches[1] $matches[2]", (int)$matches[1]);
+ return $this->raiseError("PEAR_Remote: unexpected HTTP response", (int)$matches[1], null, null, "$matches[1] $matches[2]");
}
while (trim(fgets($fp, 2048)) != ''); // skip rest of headers
while ($chunk = fread($fp, 10240)) {