2002-03-22 09:22:28 +00:00
|
|
|
<?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
|
|
|
|
*/
|
2002-03-22 11:59:52 +00:00
|
|
|
function PEAR_Command_Registry(&$ui, &$config)
|
2002-03-22 09:22:28 +00:00
|
|
|
{
|
2002-03-22 11:59:52 +00:00
|
|
|
parent::PEAR_Command_Common($ui, $config);
|
2002-03-22 09:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
// {{{ 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;
|
2002-03-22 11:59:52 +00:00
|
|
|
$this->ui->startTable(
|
|
|
|
array('caption' => 'Installed packages:',
|
|
|
|
'border' => true));
|
2002-03-22 09:22:28 +00:00
|
|
|
foreach ($installed as $package) {
|
|
|
|
if ($i++ % 20 == 0) {
|
2002-03-22 11:59:52 +00:00
|
|
|
$this->ui->tableRow(array('Package', 'Version', 'State'),
|
|
|
|
array('bold' => true));
|
2002-03-22 09:22:28 +00:00
|
|
|
}
|
2002-03-22 12:46:18 +00:00
|
|
|
$this->ui->tableRow(array($package['package'],
|
|
|
|
$package['version'],
|
|
|
|
$package['release_state']));
|
2002-03-22 09:22:28 +00:00
|
|
|
}
|
2002-03-22 11:59:52 +00:00
|
|
|
$this->ui->endTable();
|
2002-03-22 09:22:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($failmsg) {
|
|
|
|
return $this->raiseError($failmsg);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|