cvs: pear /PEAR_Frontend_Web/Command Auth.php Common.php Config.php Install.php Package.php Registry.php Remote.php
| From: | Christian Dickmann | Date: | Mon, 27 May 2002 15:16:03 +0000 |
| Subject: | cvs: pear /PEAR_Frontend_Web/Command Auth.php Common.php Config.php Install.php Package.php Registry.php Remote.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4152@lists.php.net to get a copy of this message | ||
dickmann Mon May 27 11:16:03 2002 EDT
Modified files:
/pear/PEAR_Frontend_Web/Command Auth.php Common.php Config.php
Install.php Package.php
Registry.php Remote.php
Log:
change UI API
Index: pear/PEAR_Frontend_Web/Command/Auth.php diff -u pear/PEAR_Frontend_Web/Command/Auth.php:1.1 pear/PEAR_Frontend_Web/Command/Auth.php:1.2 --- pear/PEAR_Frontend_Web/Command/Auth.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Auth.php Mon May 27 11:16:03 2002 @@ -16,7 +16,7 @@ // | Author: Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Auth.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Auth.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Remote.php"; @@ -87,7 +87,7 @@ if (empty($username)) { $username = @$_ENV['USER']; } - $this->ui->displayLine("Logging in to $server."); + $this->ui->outputData("Logging in to $server.", $command); list($username, $password) = $this->ui->userDialog( $command, @@ -105,10 +105,10 @@ $ok = $remote->call('logintest'); $remote->popExpect(); if ($ok === true) { - $this->ui->displayLine("Logged in."); + $this->ui->outputData("Logged in.", $command); $this->config->store(); } else { - $this->ui->displayLine("Login failed!"); + return $this->raiseError("Login failed!"); } } @@ -130,7 +130,7 @@ function doLogout($command, $options, $params) { $server = $this->config->get('master_server'); - $this->ui->displayLine("Logging out from $server."); + $this->ui->outputData("Logging out from $server.", $command); $this->config->remove('username'); $this->config->remove('password'); $this->config->store(); Index: pear/PEAR_Frontend_Web/Command/Common.php diff -u pear/PEAR_Frontend_Web/Command/Common.php:1.1 pear/PEAR_Frontend_Web/Command/Common.php:1.2 --- pear/PEAR_Frontend_Web/Command/Common.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Common.php Mon May 27 11:16:03 2002 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Common.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR.php"; Index: pear/PEAR_Frontend_Web/Command/Config.php diff -u pear/PEAR_Frontend_Web/Command/Config.php:1.1 pear/PEAR_Frontend_Web/Command/Config.php:1.2 --- pear/PEAR_Frontend_Web/Command/Config.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Config.php Mon May 27 11:16:03 2002 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Config.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Config.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Config.php"; @@ -88,7 +88,7 @@ } $keys = $this->config->getKeys(); sort($keys); - $this->ui->startTable(array('caption' => 'Configuration:')); + $data = array('caption' => 'Configuration:'); foreach ($keys as $key) { $type = $this->config->getType($key); $value = $this->config->get($key, @$params[0]); @@ -104,9 +104,9 @@ } elseif ($value === true) { $value = 'true'; } - $this->ui->tableRow(array($key, $value)); + $data['data'][] = array($key, $value); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } @@ -121,10 +121,10 @@ if (sizeof($params) < 1 || sizeof($params) > 2) { $failmsg .= "config-get expects 1 or 2 parameters"; } elseif (sizeof($params) == 1) { - $this->ui->displayLine("$params[0] = " . $this->config->get($params[0])); + $this->ui->outputData("$params[0] = " . $this->config->get($params[0]), $command); } else { - $this->ui->displayLine("($params[1])$params[0] = " . - $this->config->get($params[0], $params[1])); + $data = "($params[1])$params[0] = " .$this->config->get($params[0], $params[1]); + $this->ui->outputData($data, $command); } return true; } Index: pear/PEAR_Frontend_Web/Command/Install.php diff -u pear/PEAR_Frontend_Web/Command/Install.php:1.1 pear/PEAR_Frontend_Web/Command/Install.php:1.2 --- pear/PEAR_Frontend_Web/Command/Install.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Install.php Mon May 27 11:16:03 2002 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Install.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Install.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; @@ -160,7 +160,7 @@ if (is_array($info)) { if ($this->config->get('verbose') > 0) { $label = "$info[package] $info[version]"; - $this->ui->displayLine("$command ok: $label"); + $this->ui->outputData("$command ok: $label", $command); } } else { return $this->raiseError("$command failed"); @@ -176,7 +176,7 @@ foreach ($params as $pkg) { if ($this->installer->uninstall($pkg, $options)) { if ($this->config->get('verbose') > 0) { - $this->ui->displayLine("uninstall ok"); + $this->ui->outputData("uninstall ok", $command); } } else { return $this->raiseError("uninstall failed"); Index: pear/PEAR_Frontend_Web/Command/Package.php diff -u pear/PEAR_Frontend_Web/Command/Package.php:1.1 pear/PEAR_Frontend_Web/Command/Package.php:1.2 --- pear/PEAR_Frontend_Web/Command/Package.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Package.php Mon May 27 11:16:03 2002 @@ -17,7 +17,7 @@ // | Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Package.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Package.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once 'PEAR/Common.php'; require_once 'PEAR/Command/Common.php'; @@ -127,6 +127,7 @@ List all depencies the package has.' ), ); + var $output; /** * PEAR_Command_Package constructor. @@ -141,15 +142,15 @@ function _displayValidationResults($err, $warn, $strict = false) { foreach ($err as $e) { - $this->ui->displayLine("Error: $e"); + $this->output .= "Error: $e\n"; } foreach ($warn as $w) { - $this->ui->displayLine("Warning: $w"); + $this->output .= "Warning: $w\n"; } - $this->ui->displayLine(sprintf('Validation: %d error(s), %d warning(s)', - sizeof($err), sizeof($warn))); + $this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n", + sizeof($err), sizeof($warn)); if ($strict && sizeof($err) > 0) { - $this->ui->displayLine("Fix these errors and try again."); + $this->output .= "Fix these errors and try again."; return false; } return true; @@ -157,6 +158,7 @@ function doPackage($command, $options, $params) { + $this->output = ''; include_once 'PEAR/Packager.php'; $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; ob_start(); @@ -167,27 +169,30 @@ $err = $warn = array(); $packager->validatePackageInfo($pkginfofile, $err, $warn); if (!$this->_displayValidationResults($err, $warn, true)) { + $this->ui->outputData($this->output, $command); return; } $compress = empty($options['Z']) ? true : false; $result = $packager->Package($pkginfofile, $compress); - $output = ob_get_contents(); + $this->output .= ob_get_contents(); ob_end_clean(); if (PEAR::isError($result)) { + $this->ui->outputData($this->output, $command); return $this->raiseError($result); } // Don't want output, only the package file name just created if (isset($options['n'])) { - $this->ui->displayLine($result); + $this->output .= $result."\n"; return; } $lines = explode("\n", $output); foreach ($lines as $line) { - $this->ui->displayLine($line); + $this->output .= $line."n"; } if (PEAR::isError($result)) { - $this->ui->displayLine("Package failed: ".$result->getMessage()); + $this->output .= "Package failed: ".$result->getMessage(); } + $this->ui->outputData($this->output, $command); return true; } @@ -257,18 +262,20 @@ } } $caption = 'About ' . basename($params[0]); - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); + $data = array( + 'caption' => $caption, + 'border' => true); foreach ($info as $key => $value) { $key = ucwords(str_replace('_', ' ', $key)); - $this->ui->tableRow(array($key, $value), null, array(1 => array('wrap' => 55))); + $data['data'][] = array($key, $value); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } function doPackageValidate($command, $options, $params) { + $this->output = ''; if (sizeof($params) < 1) { $params[0] = "package.xml"; } @@ -289,11 +296,14 @@ } $obj->validatePackageInfo($info, $err, $warn); $this->_displayValidationResults($err, $warn); + $this->ui->outputData($this->output, $command); return true; } function doCvsTag($command, $options, $params) { + $this->output = ''; + $_cmd = $command; if (sizeof($params) < 1) { $help = $this->getHelp($command); return $this->raiseError("$command: missing parameter: $help[0]"); @@ -306,6 +316,7 @@ $err = $warn = array(); $obj->validatePackageInfo($info, $err, $warn); if (!$this->_displayValidationResults($err, $warn, true)) { + $this->ui->outputData($this->output, $command); break; } $version = $info['version']; @@ -330,14 +341,15 @@ foreach ($files as $file) { $command .= ' ' . escapeshellarg($file); } - $this->ui->displayLine("+ $command"); + $this->output .= "+ $command\n"; if (empty($options['n'])) { $fp = popen($command, "r"); while ($line = fgets($fp, 1024)) { - $this->ui->displayLine(rtrim($line)); + $this->output .= rtrim($line)."\n"; } pclose($fp); } + $this->ui->outputData($this->output, $_cmd); return true; } @@ -374,9 +386,11 @@ } if (is_array($info['release_deps'])) { - $this->ui->startTable(array('caption' => 'Dependencies for ' . $info['package'], - 'border' => true)); - $this->ui->tableRow(array("Type", "Name", "Relation", "Version")); + $data = array( + 'caption' => 'Dependencies for ' . $info['package'], + 'border' => true, + 'headline' => array("Type", "Name", "Relation", "Version"), + ); foreach ($info['release_deps'] as $d) { @@ -404,15 +418,15 @@ $version = ''; } - $this->ui->tableRow(array($type, $name, $rel, $version), null, array(1 => array('wrap' => 55))); + $data['data'][] = array($type, $name, $rel, $version); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } // Fallback - $this->ui->displayLine("This package does not have any dependencies."); + $this->ui->outputData("This package does not have any dependencies.", $command); } } ?> Index: pear/PEAR_Frontend_Web/Command/Registry.php diff -u pear/PEAR_Frontend_Web/Command/Registry.php:1.1 pear/PEAR_Frontend_Web/Command/Registry.php:1.2 --- pear/PEAR_Frontend_Web/Command/Registry.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Registry.php Mon May 27 11:16:03 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Registry.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Registry.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Registry.php'; @@ -67,24 +67,20 @@ $installed = $reg->packageInfo(); $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Installed packages:', - 'border' => true)); + $data = array( + 'caption' => 'Installed packages:', + 'border' => true, + 'headline' => array('Package', 'Version', 'State') + ); foreach ($installed as $package) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version', 'State'), - array('bold' => true)); - } - echo $package['package']."\n"; - $this->ui->tableRow(array($package['package'], + $data['data'][] = array($package['package'], $package['version'], - @$package['release_state'])); + @$package['release_state']); } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed)')); + if (count($installed)==0) { + $data = '(no packages installed)'; } - $this->ui->endTable(); + $this->ui->outputData($data, $command); } else { if (file_exists($params[0]) && !is_dir($params[0])) { include_once "PEAR/Common.php"; @@ -109,15 +105,16 @@ } else { $caption = 'Contents of ' . basename($params[0]); } - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); - $this->ui->tableRow($headings, array('bold' => true)); + $data = array( + 'caption' => $caption, + 'border' => true, + 'headline' => $headings); foreach ($list as $file => $att) { if ($installed) { if (empty($att['installed_as'])) { continue; } - $this->ui->tableRow(array($att['role'], $att['installed_as'])); + $data['data'][] = array($att['role'], $att['installed_as']); } else { if (isset($att['baseinstalldir'])) { $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . @@ -144,10 +141,10 @@ } $dest = preg_replace('!/+!', '/', $dest); $file = preg_replace('!/+!', '/', $file); - $this->ui->tableRow(array($file, $dest)); + $data['data'][] = array($file, $dest); } } - $this->ui->endTable(); + $this->ui->outputData($data, $command); } Index: pear/PEAR_Frontend_Web/Command/Remote.php diff -u pear/PEAR_Frontend_Web/Command/Remote.php:1.1 pear/PEAR_Frontend_Web/Command/Remote.php:1.2 --- pear/PEAR_Frontend_Web/Command/Remote.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Remote.php Mon May 27 11:16:03 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Remote.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Remote.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Common.php'; @@ -114,22 +114,18 @@ return $this->raiseError($available); } $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Available packages:', - 'border' => true)); -// print_r($available); + $data = array( + 'caption' => 'Available packages:', + 'border' => true, + 'headline' => array('Package', 'Version'), + ); foreach ($available as $name => $info) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version'), - array('bold' => true)); - } - $this->ui->tableRow(array($name, $info['stable'])); + $data['data'][] = array($name, $info['stable']); } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); + if (count($available)==0) { + $data = '(no packages installed yet)'; } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } @@ -148,6 +144,7 @@ $data = array( 'caption' => 'All packages:', 'border' => true, + 'headline' => array('Package', 'Latest', 'Local'), ); foreach ($available as $name => $info) { @@ -159,9 +156,8 @@ $data['data'][$info['category']][] = array( $name, $info['stable'], - $info['category'], - $desc, $installed['version'], + $desc, ); } $this->ui->outputData($data, $command); @@ -190,7 +186,7 @@ return $this->raiseError($saved); } $fname = basename($saved); - $this->ui->displayLine("File $fname downloaded ($this->bytes_downloaded bytes)"); + $this->ui->outputData("File $fname downloaded ($this->bytes_downloaded bytes)", $command); return true; } @@ -226,10 +222,11 @@ } $reg = new PEAR_Registry($this->config->get('php_dir')); $inst = array_flip($reg->listPackages()); - $this->ui->startTable(array('caption' => $caption, - 'border' => 1)); - $this->ui->tableRow(array('Package', 'Version', 'Size'), - array('bold' => true)); + $data = array( + 'caption' => $caption, + 'border' => 1, + 'headline' => array('Package', 'Version', 'Size'), + ); foreach ($latest as $package => $info) { if (!isset($inst[$package])) { // skip packages we don't have installed @@ -250,9 +247,9 @@ } else { $fs = " -"; // XXX center instead } - $this->ui->tableRow(array($package, $version, $fs)); + $data['data'][] = array($package, $version, $fs); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; }
Index: pear/PEAR_Frontend_Web/Command/Auth.php diff -u pear/PEAR_Frontend_Web/Command/Auth.php:1.1 pear/PEAR_Frontend_Web/Command/Auth.php:1.2 --- pear/PEAR_Frontend_Web/Command/Auth.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Auth.php Mon May 27 11:16:03 2002 @@ -16,7 +16,7 @@ // | Author: Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Auth.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Auth.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Remote.php"; @@ -87,7 +87,7 @@ if (empty($username)) { $username = @$_ENV['USER']; } - $this->ui->displayLine("Logging in to $server."); + $this->ui->outputData("Logging in to $server.", $command); list($username, $password) = $this->ui->userDialog( $command, @@ -105,10 +105,10 @@ $ok = $remote->call('logintest'); $remote->popExpect(); if ($ok === true) { - $this->ui->displayLine("Logged in."); + $this->ui->outputData("Logged in.", $command); $this->config->store(); } else { - $this->ui->displayLine("Login failed!"); + return $this->raiseError("Login failed!"); } } @@ -130,7 +130,7 @@ function doLogout($command, $options, $params) { $server = $this->config->get('master_server'); - $this->ui->displayLine("Logging out from $server."); + $this->ui->outputData("Logging out from $server.", $command); $this->config->remove('username'); $this->config->remove('password'); $this->config->store(); Index: pear/PEAR_Frontend_Web/Command/Common.php diff -u pear/PEAR_Frontend_Web/Command/Common.php:1.1 pear/PEAR_Frontend_Web/Command/Common.php:1.2 --- pear/PEAR_Frontend_Web/Command/Common.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Common.php Mon May 27 11:16:03 2002 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Common.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR.php"; Index: pear/PEAR_Frontend_Web/Command/Config.php diff -u pear/PEAR_Frontend_Web/Command/Config.php:1.1 pear/PEAR_Frontend_Web/Command/Config.php:1.2 --- pear/PEAR_Frontend_Web/Command/Config.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Config.php Mon May 27 11:16:03 2002 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Config.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Config.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Config.php"; @@ -88,7 +88,7 @@ } $keys = $this->config->getKeys(); sort($keys); - $this->ui->startTable(array('caption' => 'Configuration:')); + $data = array('caption' => 'Configuration:'); foreach ($keys as $key) { $type = $this->config->getType($key); $value = $this->config->get($key, @$params[0]); @@ -104,9 +104,9 @@ } elseif ($value === true) { $value = 'true'; } - $this->ui->tableRow(array($key, $value)); + $data['data'][] = array($key, $value); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } @@ -121,10 +121,10 @@ if (sizeof($params) < 1 || sizeof($params) > 2) { $failmsg .= "config-get expects 1 or 2 parameters"; } elseif (sizeof($params) == 1) { - $this->ui->displayLine("$params[0] = " . $this->config->get($params[0])); + $this->ui->outputData("$params[0] = " . $this->config->get($params[0]), $command); } else { - $this->ui->displayLine("($params[1])$params[0] = " . - $this->config->get($params[0], $params[1])); + $data = "($params[1])$params[0] = " .$this->config->get($params[0], $params[1]); + $this->ui->outputData($data, $command); } return true; } Index: pear/PEAR_Frontend_Web/Command/Install.php diff -u pear/PEAR_Frontend_Web/Command/Install.php:1.1 pear/PEAR_Frontend_Web/Command/Install.php:1.2 --- pear/PEAR_Frontend_Web/Command/Install.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Install.php Mon May 27 11:16:03 2002 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Install.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Install.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; @@ -160,7 +160,7 @@ if (is_array($info)) { if ($this->config->get('verbose') > 0) { $label = "$info[package] $info[version]"; - $this->ui->displayLine("$command ok: $label"); + $this->ui->outputData("$command ok: $label", $command); } } else { return $this->raiseError("$command failed"); @@ -176,7 +176,7 @@ foreach ($params as $pkg) { if ($this->installer->uninstall($pkg, $options)) { if ($this->config->get('verbose') > 0) { - $this->ui->displayLine("uninstall ok"); + $this->ui->outputData("uninstall ok", $command); } } else { return $this->raiseError("uninstall failed"); Index: pear/PEAR_Frontend_Web/Command/Package.php diff -u pear/PEAR_Frontend_Web/Command/Package.php:1.1 pear/PEAR_Frontend_Web/Command/Package.php:1.2 --- pear/PEAR_Frontend_Web/Command/Package.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Package.php Mon May 27 11:16:03 2002 @@ -17,7 +17,7 @@ // | Martin Jansen <mj@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Package.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Package.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once 'PEAR/Common.php'; require_once 'PEAR/Command/Common.php'; @@ -127,6 +127,7 @@ List all depencies the package has.' ), ); + var $output; /** * PEAR_Command_Package constructor. @@ -141,15 +142,15 @@ function _displayValidationResults($err, $warn, $strict = false) { foreach ($err as $e) { - $this->ui->displayLine("Error: $e"); + $this->output .= "Error: $e\n"; } foreach ($warn as $w) { - $this->ui->displayLine("Warning: $w"); + $this->output .= "Warning: $w\n"; } - $this->ui->displayLine(sprintf('Validation: %d error(s), %d warning(s)', - sizeof($err), sizeof($warn))); + $this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n", + sizeof($err), sizeof($warn)); if ($strict && sizeof($err) > 0) { - $this->ui->displayLine("Fix these errors and try again."); + $this->output .= "Fix these errors and try again."; return false; } return true; @@ -157,6 +158,7 @@ function doPackage($command, $options, $params) { + $this->output = ''; include_once 'PEAR/Packager.php'; $pkginfofile = isset($params[0]) ? $params[0] : 'package.xml'; ob_start(); @@ -167,27 +169,30 @@ $err = $warn = array(); $packager->validatePackageInfo($pkginfofile, $err, $warn); if (!$this->_displayValidationResults($err, $warn, true)) { + $this->ui->outputData($this->output, $command); return; } $compress = empty($options['Z']) ? true : false; $result = $packager->Package($pkginfofile, $compress); - $output = ob_get_contents(); + $this->output .= ob_get_contents(); ob_end_clean(); if (PEAR::isError($result)) { + $this->ui->outputData($this->output, $command); return $this->raiseError($result); } // Don't want output, only the package file name just created if (isset($options['n'])) { - $this->ui->displayLine($result); + $this->output .= $result."\n"; return; } $lines = explode("\n", $output); foreach ($lines as $line) { - $this->ui->displayLine($line); + $this->output .= $line."n"; } if (PEAR::isError($result)) { - $this->ui->displayLine("Package failed: ".$result->getMessage()); + $this->output .= "Package failed: ".$result->getMessage(); } + $this->ui->outputData($this->output, $command); return true; } @@ -257,18 +262,20 @@ } } $caption = 'About ' . basename($params[0]); - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); + $data = array( + 'caption' => $caption, + 'border' => true); foreach ($info as $key => $value) { $key = ucwords(str_replace('_', ' ', $key)); - $this->ui->tableRow(array($key, $value), null, array(1 => array('wrap' => 55))); + $data['data'][] = array($key, $value); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } function doPackageValidate($command, $options, $params) { + $this->output = ''; if (sizeof($params) < 1) { $params[0] = "package.xml"; } @@ -289,11 +296,14 @@ } $obj->validatePackageInfo($info, $err, $warn); $this->_displayValidationResults($err, $warn); + $this->ui->outputData($this->output, $command); return true; } function doCvsTag($command, $options, $params) { + $this->output = ''; + $_cmd = $command; if (sizeof($params) < 1) { $help = $this->getHelp($command); return $this->raiseError("$command: missing parameter: $help[0]"); @@ -306,6 +316,7 @@ $err = $warn = array(); $obj->validatePackageInfo($info, $err, $warn); if (!$this->_displayValidationResults($err, $warn, true)) { + $this->ui->outputData($this->output, $command); break; } $version = $info['version']; @@ -330,14 +341,15 @@ foreach ($files as $file) { $command .= ' ' . escapeshellarg($file); } - $this->ui->displayLine("+ $command"); + $this->output .= "+ $command\n"; if (empty($options['n'])) { $fp = popen($command, "r"); while ($line = fgets($fp, 1024)) { - $this->ui->displayLine(rtrim($line)); + $this->output .= rtrim($line)."\n"; } pclose($fp); } + $this->ui->outputData($this->output, $_cmd); return true; } @@ -374,9 +386,11 @@ } if (is_array($info['release_deps'])) { - $this->ui->startTable(array('caption' => 'Dependencies for ' . $info['package'], - 'border' => true)); - $this->ui->tableRow(array("Type", "Name", "Relation", "Version")); + $data = array( + 'caption' => 'Dependencies for ' . $info['package'], + 'border' => true, + 'headline' => array("Type", "Name", "Relation", "Version"), + ); foreach ($info['release_deps'] as $d) { @@ -404,15 +418,15 @@ $version = ''; } - $this->ui->tableRow(array($type, $name, $rel, $version), null, array(1 => array('wrap' => 55))); + $data['data'][] = array($type, $name, $rel, $version); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } // Fallback - $this->ui->displayLine("This package does not have any dependencies."); + $this->ui->outputData("This package does not have any dependencies.", $command); } } ?> Index: pear/PEAR_Frontend_Web/Command/Registry.php diff -u pear/PEAR_Frontend_Web/Command/Registry.php:1.1 pear/PEAR_Frontend_Web/Command/Registry.php:1.2 --- pear/PEAR_Frontend_Web/Command/Registry.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Registry.php Mon May 27 11:16:03 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Registry.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Registry.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Registry.php'; @@ -67,24 +67,20 @@ $installed = $reg->packageInfo(); $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Installed packages:', - 'border' => true)); + $data = array( + 'caption' => 'Installed packages:', + 'border' => true, + 'headline' => array('Package', 'Version', 'State') + ); foreach ($installed as $package) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version', 'State'), - array('bold' => true)); - } - echo $package['package']."\n"; - $this->ui->tableRow(array($package['package'], + $data['data'][] = array($package['package'], $package['version'], - @$package['release_state'])); + @$package['release_state']); } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed)')); + if (count($installed)==0) { + $data = '(no packages installed)'; } - $this->ui->endTable(); + $this->ui->outputData($data, $command); } else { if (file_exists($params[0]) && !is_dir($params[0])) { include_once "PEAR/Common.php"; @@ -109,15 +105,16 @@ } else { $caption = 'Contents of ' . basename($params[0]); } - $this->ui->startTable(array('caption' => $caption, - 'border' => true)); - $this->ui->tableRow($headings, array('bold' => true)); + $data = array( + 'caption' => $caption, + 'border' => true, + 'headline' => $headings); foreach ($list as $file => $att) { if ($installed) { if (empty($att['installed_as'])) { continue; } - $this->ui->tableRow(array($att['role'], $att['installed_as'])); + $data['data'][] = array($att['role'], $att['installed_as']); } else { if (isset($att['baseinstalldir'])) { $dest = $att['baseinstalldir'] . DIRECTORY_SEPARATOR . @@ -144,10 +141,10 @@ } $dest = preg_replace('!/+!', '/', $dest); $file = preg_replace('!/+!', '/', $file); - $this->ui->tableRow(array($file, $dest)); + $data['data'][] = array($file, $dest); } } - $this->ui->endTable(); + $this->ui->outputData($data, $command); } Index: pear/PEAR_Frontend_Web/Command/Remote.php diff -u pear/PEAR_Frontend_Web/Command/Remote.php:1.1 pear/PEAR_Frontend_Web/Command/Remote.php:1.2 --- pear/PEAR_Frontend_Web/Command/Remote.php:1.1 Mon May 27 07:52:36 2002 +++ pear/PEAR_Frontend_Web/Command/Remote.php Mon May 27 11:16:03 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Remote.php,v 1.1 2002/05/27 11:52:36 dickmann Exp $ +// $Id: Remote.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Common.php'; @@ -114,22 +114,18 @@ return $this->raiseError($available); } $i = $j = 0; - $this->ui->startTable( - array('caption' => 'Available packages:', - 'border' => true)); -// print_r($available); + $data = array( + 'caption' => 'Available packages:', + 'border' => true, + 'headline' => array('Package', 'Version'), + ); foreach ($available as $name => $info) { - if ($i++ % 20 == 0) { - $this->ui->tableRow( - array('Package', 'Version'), - array('bold' => true)); - } - $this->ui->tableRow(array($name, $info['stable'])); + $data['data'][] = array($name, $info['stable']); } - if ($i == 0) { - $this->ui->tableRow(array('(no packages installed yet)')); + if (count($available)==0) { + $data = '(no packages installed yet)'; } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; } @@ -148,6 +144,7 @@ $data = array( 'caption' => 'All packages:', 'border' => true, + 'headline' => array('Package', 'Latest', 'Local'), ); foreach ($available as $name => $info) { @@ -159,9 +156,8 @@ $data['data'][$info['category']][] = array( $name, $info['stable'], - $info['category'], - $desc, $installed['version'], + $desc, ); } $this->ui->outputData($data, $command); @@ -190,7 +186,7 @@ return $this->raiseError($saved); } $fname = basename($saved); - $this->ui->displayLine("File $fname downloaded ($this->bytes_downloaded bytes)"); + $this->ui->outputData("File $fname downloaded ($this->bytes_downloaded bytes)", $command); return true; } @@ -226,10 +222,11 @@ } $reg = new PEAR_Registry($this->config->get('php_dir')); $inst = array_flip($reg->listPackages()); - $this->ui->startTable(array('caption' => $caption, - 'border' => 1)); - $this->ui->tableRow(array('Package', 'Version', 'Size'), - array('bold' => true)); + $data = array( + 'caption' => $caption, + 'border' => 1, + 'headline' => array('Package', 'Version', 'Size'), + ); foreach ($latest as $package => $info) { if (!isset($inst[$package])) { // skip packages we don't have installed @@ -250,9 +247,9 @@ } else { $fs = " -"; // XXX center instead } - $this->ui->tableRow(array($package, $version, $fs)); + $data['data'][] = array($package, $version, $fs); } - $this->ui->endTable(); + $this->ui->outputData($data, $command); return true; }