mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
* add -G option to "pear" for php-gtk frontend
* added Gtk stub (only creates window right now) * added command descriptions
This commit is contained in:
parent
9dece79266
commit
b14c2f9185
@ -94,25 +94,29 @@ PEAR_FILES = \
|
||||
# Net/Socket.php \
|
||||
# Schedule/At.php \
|
||||
|
||||
PEAR_PACKAGES=\
|
||||
Net_Socket-1.0.tgz
|
||||
|
||||
#PEARCMD=$(top_builddir)/sapi/cli/php $(builddir)/scripts/pear
|
||||
#
|
||||
#install-pear-installer: $(top_builddir)/sapi/cli/php
|
||||
# version=`grep '<version>' $(srcdir)/package-pear.xml|head -1|cut -d\> -f2|cut -d\< -f1`; \
|
||||
# if $(PEARCMD) shell-test PEAR; then
|
||||
# if ! $(PEARCMD) shell-test PEAR $$version; then \
|
||||
# $(PEARCMD) upgrade package-pear.xml; \
|
||||
# fi; \
|
||||
# else; \
|
||||
# $(PEARCMD) install package-pear.xml; \
|
||||
# fi
|
||||
|
||||
install-pear:
|
||||
@if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \
|
||||
for i in $(PEAR_SUBDIRS); do \
|
||||
$(mkinstalldirs) $(INSTALL_ROOT)$(peardir)/$$i; \
|
||||
done; \
|
||||
for dir in PEAR/CommandUI; do \
|
||||
test -d $(INSTALL_ROOT)$(peardir)/$$dir && rm -rf $(INSTALL_ROOT)$(peardir)/$$dir; \
|
||||
done; \
|
||||
for i in $(PEAR_FILES); do \
|
||||
echo "Installing $$i"; \
|
||||
dir=`echo $$i|sed 's%[^/][^/]*$$%%'`; \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i $(INSTALL_ROOT)$(peardir)/$$dir; \
|
||||
done; \
|
||||
rm -f $(INSTALL_ROOT)$(peardir)/PEAR/Command/Login.php; \
|
||||
rm -f $(INSTALL_ROOT)$(peardir)/PEAR/CommandUI/CLI.php; \
|
||||
rm -f $(INSTALL_ROOT)$(peardir)/PEAR/CommandResponse.php; \
|
||||
rm -f $(INSTALL_ROOT)$(peardir)/PEAR/Uploader.php; \
|
||||
else \
|
||||
|
@ -197,8 +197,9 @@ class PEAR_Command
|
||||
include_once $file;
|
||||
// List of commands
|
||||
$implements = call_user_func(array($class, "getCommands"));
|
||||
foreach ($implements as $command) {
|
||||
foreach ($implements as $command => $desc) {
|
||||
$GLOBALS['_PEAR_Command_commandlist'][$command] = $class;
|
||||
$GLOBALS['_PEAR_Command_commanddesc'][$command] = $desc;
|
||||
}
|
||||
// List of options accepted
|
||||
$cmdopts = array_merge($cmdopts, call_user_func(array($class, "getOptions")));
|
||||
@ -239,6 +240,20 @@ class PEAR_Command
|
||||
return $GLOBALS['_PEAR_Command_commandopts'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description for a command.
|
||||
*
|
||||
* @param string $command Name of the command
|
||||
*
|
||||
* @return string command description
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function getDescription($command)
|
||||
{
|
||||
return @$GLOBALS['_PEAR_Command_commanddesc'][$command];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get help for command.
|
||||
*
|
||||
|
@ -51,7 +51,8 @@ class PEAR_Command_Auth extends PEAR_Command_Common
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
return array('login', 'logout');
|
||||
return array('login' => 'Log In',
|
||||
'logout' => 'Log Out');
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
@ -55,7 +55,9 @@ class PEAR_Command_Config extends PEAR_Command_Common
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
return array('config-show', 'config-get', 'config-set');
|
||||
return array('config-show' => 'Show All Settings',
|
||||
'config-get' => 'Show One Setting',
|
||||
'config-set' => 'Change Setting');
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
@ -51,7 +51,9 @@ class PEAR_Command_Install extends PEAR_Command_Common
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
return array('install', 'uninstall', 'upgrade');
|
||||
return array('install' => 'Install Package',
|
||||
'uninstall' => 'Uninstall Package',
|
||||
'upgrade' => 'Upgrade Package');
|
||||
}
|
||||
|
||||
function getHelp($command)
|
||||
|
@ -67,11 +67,11 @@ class PEAR_Command_Package extends PEAR_Command_Common
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
return array('package',
|
||||
'package-info',
|
||||
'package-list',
|
||||
'package-validate',
|
||||
'cvstag');
|
||||
return array('package' => 'Build Package',
|
||||
'package-info' => 'Show Package Info',
|
||||
'package-list' => 'List Files in Package',
|
||||
'package-validate' => 'Validate Package',
|
||||
'cvstag' => 'Set CVS Release Tag');
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
@ -48,7 +48,8 @@ class PEAR_Command_Registry extends PEAR_Command_Common
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
return array('list-installed', 'shell-test');
|
||||
return array('list-installed' => 'List Installed Packages',
|
||||
'shell-test' => 'Shell Script Test');
|
||||
}
|
||||
|
||||
function getHelp($command)
|
||||
|
@ -48,10 +48,10 @@ class PEAR_Command_Remote extends PEAR_Command_Common
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
return array('remote-package-info',
|
||||
'list-upgrades',
|
||||
'list-remote-packages',
|
||||
'download');
|
||||
return array('remote-package-info' => 'Information About Remote Package',
|
||||
'list-upgrades' => 'List Available Upgrades',
|
||||
'list-remote-packages' => 'List Remote Packages',
|
||||
'download' => 'Download Package');
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
133
pear/PEAR/Frontend/Gtk.php
Normal file
133
pear/PEAR/Frontend/Gtk.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?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 Sæther Bakken <ssb@fast.no> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
require_once "PEAR.php";
|
||||
|
||||
class PEAR_Frontend_Gtk extends PEAR
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* What type of user interface this frontend is for.
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $type = 'Gtk';
|
||||
|
||||
var $omode = 'plain';
|
||||
var $params = array();
|
||||
var $window = null;
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
function PEAR_Frontend_Gtk()
|
||||
{
|
||||
parent::PEAR();
|
||||
if (!extension_loaded('php_gtk')) {
|
||||
dl('php_gtk.' . (OS_WINDOWS ? 'dll' : 'so'));
|
||||
}
|
||||
$this->window = &new GtkWindow();
|
||||
$this->window->set_title('PEAR Installer');
|
||||
$this->window->set_usize((gdk::screen_width()/3), (gdk::screen_height()/3));
|
||||
$this->window->show_all();
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ displayLine(text)
|
||||
|
||||
function displayLine($text)
|
||||
{
|
||||
}
|
||||
|
||||
function display($text)
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayError(eobj)
|
||||
|
||||
function displayError($eobj)
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayFatalError(eobj)
|
||||
|
||||
function displayFatalError($eobj)
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayHeading(title)
|
||||
|
||||
function displayHeading($title)
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ userDialog(prompt, [type], [default])
|
||||
|
||||
function userDialog($prompt, $type = 'text', $default = '')
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ userConfirm(prompt, [default])
|
||||
|
||||
function userConfirm($prompt, $default = 'yes')
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ startTable([params])
|
||||
|
||||
function startTable($params = array())
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ tableRow(columns, [rowparams], [colparams])
|
||||
|
||||
function tableRow($columns, $rowparams = array(), $colparams = array())
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ endTable()
|
||||
|
||||
function endTable()
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ bold($text)
|
||||
|
||||
function bold($text)
|
||||
{
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
@ -50,6 +50,7 @@
|
||||
<file role="php" name="Dependency.php"/>
|
||||
<dir name="Frontend">
|
||||
<file role="php" name="CLI.php"/>
|
||||
<file role="php" name="Gtk.php"/>
|
||||
</dir>
|
||||
<file role="php" name="Installer.php"/>
|
||||
<file role="php" name="Packager.php"/>
|
||||
|
@ -33,19 +33,27 @@ require_once 'Console/Getopt.php';
|
||||
PEAR_Command::setFrontendType('CLI');
|
||||
$all_commands = PEAR_Command::getCommands();
|
||||
$cmd_options = PEAR_Command::getOptions();
|
||||
$ui = &PEAR_Command::getFrontendObject();
|
||||
$progname = basename(__FILE__);
|
||||
|
||||
// XXX change Getopt to use raiseError() ?
|
||||
$argv = Console_Getopt::readPHPArgv();
|
||||
$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sSqu:v" . $cmd_options);
|
||||
$options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:v" . $cmd_options);
|
||||
if (PEAR::isError($options)) {
|
||||
usage($options);
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
|
||||
$opts = $options[0];
|
||||
|
||||
$fetype = 'CLI';
|
||||
foreach ($opts as $opt) {
|
||||
if ($opt[0] == 'G') {
|
||||
$fetype = 'Gtk';
|
||||
}
|
||||
}
|
||||
PEAR_Command::setFrontendType($fetype);
|
||||
$ui = &PEAR_Command::getFrontendObject();
|
||||
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError"));
|
||||
|
||||
$pear_user_config = '';
|
||||
$pear_system_config = '';
|
||||
$store_user_config = false;
|
||||
@ -114,19 +122,23 @@ if (empty($command) && ($store_user_config || $store_system_config)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($all_commands[$command]) || $command == 'help') {
|
||||
usage(null, @$options[1][2]);
|
||||
}
|
||||
|
||||
$cmd = PEAR_Command::factory($command, $config);
|
||||
if (PEAR::isError($cmd)) {
|
||||
die($cmd->getMessage());
|
||||
}
|
||||
|
||||
$cmdargs = array_slice($options[1], 2);
|
||||
$ok = $cmd->run($command, $cmdopts, $cmdargs);
|
||||
if ($ok === false) {
|
||||
PEAR::raiseError("unknown command `$command'");
|
||||
if ($fetype == 'Gtk') {
|
||||
Gtk::main();
|
||||
} else {
|
||||
if (empty($all_commands[$command]) || $command == 'help') {
|
||||
usage(null, @$options[1][2]);
|
||||
}
|
||||
|
||||
$cmd = PEAR_Command::factory($command, $config);
|
||||
if (PEAR::isError($cmd)) {
|
||||
die($cmd->getMessage());
|
||||
}
|
||||
|
||||
$cmdargs = array_slice($options[1], 2);
|
||||
$ok = $cmd->run($command, $cmdopts, $cmdargs);
|
||||
if ($ok === false) {
|
||||
PEAR::raiseError("unknown command `$command'");
|
||||
}
|
||||
}
|
||||
|
||||
// {{{ usage()
|
||||
@ -148,9 +160,14 @@ function usage($error = null, $helpsubject = null)
|
||||
"Usage: $progname [options] command [command-options] <parameters>\n".
|
||||
"Type \"$progname help options\" to list all options.\n".
|
||||
"Type \"$progname help <command>\" to get the help for the specified command.\n".
|
||||
"Commands:\n " . implode("\n ", array_keys($all_commands));
|
||||
"Commands:\n";
|
||||
$maxlen = max(array_map("strlen", $all_commands));
|
||||
$formatstr = "%-{$maxlen}s %s\n";
|
||||
foreach ($all_commands as $cmd => $class) {
|
||||
$put .= sprintf($formatstr, $cmd, PEAR_Command::getDescription($cmd));
|
||||
}
|
||||
}
|
||||
fputs($stderr, "$put\n\n");
|
||||
fputs($stderr, "$put\n");
|
||||
fclose($stderr);
|
||||
exit;
|
||||
}
|
||||
@ -167,6 +184,7 @@ function cmdHelp($command)
|
||||
" -C file find system configuration in `file'\n".
|
||||
" -d foo=bar set user config variable `foo' to `bar'\n".
|
||||
" -D foo=bar set system config variable `foo' to `bar'\n".
|
||||
" -G start in graphical (Gtk) mode\n".
|
||||
" -s store user configuration\n".
|
||||
" -S store system configuration\n".
|
||||
" -u foo unset `foo' in the user configuration\n".
|
||||
|
Loading…
Reference in New Issue
Block a user