cvs: pear /PEAR_Frontend_Web WebInstaller.php package.xml /PEAR_Frontend_Web/Command Install.php /PEAR_Frontend_Web/Frontend CLI.php Web.php
/PEAR_Frontend_Web/Frontend/Web config.gif footer.inc.tpl.html header.inc.tpl.html info.gif infoplus.gif package.list.tpl.html pkglist.gif style.css
userDialog.tpl.html
| From: | Christian Dickmann | Date: | Wed, 29 May 2002 13:20:19 +0000 |
| Subject: | cvs: pear /PEAR_Frontend_Web WebInstaller.php package.xml /PEAR_Frontend_Web/Command Install.php /PEAR_Frontend_Web/Frontend CLI.php Web.php /PEAR_Frontend_Web/Frontend/Web config.gif footer.inc.tpl.html header.inc.tpl.html info.gif infoplus.gif package.list.tpl.html pkglist.gif style.css userDialog.tpl.html |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4261@lists.php.net to get a copy of this message | ||
dickmann Wed May 29 09:20:19 2002 EDT
Added files:
/pear/PEAR_Frontend_Web WebInstaller.php package.xml
/pear/PEAR_Frontend_Web/Frontend/Web config.gif footer.inc.tpl.html
infoplus.gif pkglist.gif
style.css
Modified files:
/pear/PEAR_Frontend_Web/Command Install.php
/pear/PEAR_Frontend_Web/Frontend CLI.php Web.php
/pear/PEAR_Frontend_Web/Frontend/Web header.inc.tpl.html info.gif
package.list.tpl.html
userDialog.tpl.html
Log:
improve ErrorHandling. Improve Layout. add package.xml and WebInstaller.php
Index: pear/PEAR_Frontend_Web/Command/Install.php diff -u pear/PEAR_Frontend_Web/Command/Install.php:1.2 pear/PEAR_Frontend_Web/Command/Install.php:1.3 --- pear/PEAR_Frontend_Web/Command/Install.php:1.2 Mon May 27 11:16:03 2002 +++ pear/PEAR_Frontend_Web/Command/Install.php Wed May 29 09:20:09 2002 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Install.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ +// $Id: Install.php,v 1.3 2002/05/29 13:20:09 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; @@ -166,6 +166,7 @@ return $this->raiseError("$command failed"); } } + return true; } function doUninstall($command, $options, $params) Index: pear/PEAR_Frontend_Web/Frontend/CLI.php diff -u pear/PEAR_Frontend_Web/Frontend/CLI.php:1.1 pear/PEAR_Frontend_Web/Frontend/CLI.php:1.2 --- pear/PEAR_Frontend_Web/Frontend/CLI.php:1.1 Mon May 27 11:20:29 2002 +++ pear/PEAR_Frontend_Web/Frontend/CLI.php Wed May 29 09:20:09 2002 @@ -16,7 +16,7 @@ | Author: Stig Sæther Bakken <ssb@fast.no> | +----------------------------------------------------------------------+ - $Id: CLI.php,v 1.1 2002/05/27 15:20:29 dickmann Exp $ + $Id: CLI.php,v 1.2 2002/05/29 13:20:09 dickmann Exp $ */ require_once "PEAR.php"; @@ -103,9 +103,9 @@ } // }}} - // {{{ userDialog(prompt, [type], [default]) + // {{{ _userDialog(prompt, [type], [default]) - function userDialog($prompt, $type = 'text', $default = '') + function _userDialog($prompt, $type = 'text', $default = '') { if ($type == 'password') { system('stty -echo'); @@ -115,6 +115,7 @@ print "[$default] "; } print ": "; + $fp = fopen("php://stdin", "r"); $line = fgets($fp, 2048); fclose($fp); @@ -126,6 +127,21 @@ return $default; } return $line; + } + + // }}} + // {{{ userDialog(command, prompts, [types], [defaults]) + + function userDialog($command, $prompts, $types = array(), $defaults = array()) + { + $result = array(); + foreach($prompts as $key => $prompt) { + $type = ((isset($types[$key])) ? $types[$key] : 'text'); + $default = ((isset($defaults[$key])) ? $defaults[$key] : ''); + $result[] = $this->_userDialog($prompt, $type, $default); + }; + + return $result; } // }}} Index: pear/PEAR_Frontend_Web/Frontend/Web.php diff -u pear/PEAR_Frontend_Web/Frontend/Web.php:1.2 pear/PEAR_Frontend_Web/Frontend/Web.php:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web.php:1.2 Mon May 27 11:20:29 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web.php Wed May 29 09:20:09 2002 @@ -16,7 +16,7 @@ | Author: Christian Dickmann <dickmann@php.net> | +----------------------------------------------------------------------+ - $Id: Web.php,v 1.2 2002/05/27 15:20:29 dickmann Exp $ + $Id: Web.php,v 1.3 2002/05/29 13:20:09 dickmann Exp $ */ require_once "PEAR.php"; @@ -36,6 +36,7 @@ var $tpl; var $table; var $data = array(); + var $_log; var $params = array(); @@ -67,7 +68,10 @@ function displayError($eobj) { - $msg = $eobj->getMessage(); + $msg = ''; + if (trim($this->_log)) + $msg = trim($this->_log)."\n\n"; + $msg .= $eobj->getMessage(); $msg = nl2br($msg); $tpl = new IntegratedTemplate(dirname(__FILE__)."/Web"); @@ -77,8 +81,16 @@ $tpl->setVariable("ImgError", $_SERVER["PHP_SELF"].'?img=error'); $tpl->setVariable("Error", $msg); - if (isset($_GET['command'])) + $command_map = array( + "install" => "list-all", + "uninstall" => "list-all", + "upgrade" => "list-all", + ); + if (isset($_GET['command'])) { + if (isset($command_map[$_GET['command']])) + $_GET['command'] = $command_map[$_GET['command']]; $tpl->setVariable("param", '?command='.$_GET['command']); + }; $tpl->show(); exit; @@ -95,15 +107,6 @@ } // }}} - // {{{ displayHeading(title) - - function displayHeading($title) - { -// print $this->lp.$this->bold($title)."\n"; -// print $this->lp.str_repeat("=", strlen($title))."\n"; - } - - // }}} // {{{ userConfirm(prompt, [default]) function userConfirm($prompt, $default = 'yes') @@ -132,12 +135,13 @@ // }}} - function outputListAll($data) + function _outputListAll($data) { $tpl = new IntegratedTemplate(dirname(__FILE__)."/Web"); $tpl->loadTemplateFile("package.list.tpl.html"); $tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("ImgPEAR", $_SERVER["PHP_SELF"].'?img=pear'); + $tpl->setVariable("Title", 'Install / Upgrade / Remove PEAR Packages'); foreach($data['data'] as $category => $packages) { @@ -147,27 +151,37 @@ $tpl->setVariable("ImgPackage", $_SERVER["PHP_SELF"].'?img=package'); $compare = version_compare($row[1], $row[2]); if (!$row[2]) { - $inst = sprintf('<a href="%s?install=%s"><img src="%s?img=install" border="0"></a>', + $inst = sprintf( + '<a href="%s?command=install&pkg=%s"><img src="%s?img=install" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); $del = ''; } else if ($compare == 1) { - $inst = sprintf('<a href="%s?upgrade=%s"><img src="%s?img=install" border="0"></a>', + $inst = sprintf( + '<a href="%s?command=upgrade&pkg=%s"><img src="%s?img=install" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); - $del = sprintf('<a href="%s?uninstall=%s"><img src="%s?img=uninstall" border="0"></a>', + $del = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); } else { - $del = sprintf('<a href="%s?uninstall=%s"><img src="%s?img=uninstall" border="0"></a>', + $del = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); $inst = ''; }; $info=sprintf('<a href="%s?info=%s#%s"><img src="%s?img=info" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $row[0], $_SERVER["PHP_SELF"]); + $infoExt=sprintf('<a href="%s?info=%s#%s"><img src="%s?img=infoplus" border="0"></a>', + $_SERVER["PHP_SELF"], $row[0], $row[0], $_SERVER["PHP_SELF"]); + + if ($row[0] == 'PEAR') + $del = ''; $tpl->setVariable("Version", $row[1]); $tpl->setVariable("Installed", $row[2]); $tpl->setVariable("Install", $inst); $tpl->setVariable("Delete", $del); $tpl->setVariable("Info", $info); + $tpl->setVariable("InfoExt", $infoExt); $tpl->setVariable("Package", $row[0]); $tpl->setVariable("Summary", nl2br($row[3])); $tpl->parseCurrentBlock(); @@ -185,15 +199,26 @@ { switch ($command) { + case 'config-show': + $prompt = array(); + $default = array(); + foreach($data['data'] as $row) { + $prompt[] = $row[0]; + if ($row[1] != "<not set>") + $default[] = $row[1]; + else + $default[] = ''; + }; + $GLOBALS['_PEAR_Frontend_Web_Config'] = + $this->userDialog($command, $prompt, array(), $default, 'Configuration'); + return true; case 'list-all': - return $this->outputListAll($data); + return $this->_outputListAll($data); case 'install': case 'uninstall': return true; case 'login': - if ($_SERVER["REQUEST_METHOD"] == "POST") - break; - else + if ($_SERVER["REQUEST_METHOD"] != "POST") $this->data[$command] = $data; return true; case 'logout': @@ -207,14 +232,14 @@ return true; } - function userDialog($command, $prompts, $types = array(), $defaults = array()) + function userDialog($command, $prompts, $types = array(), $defaults = array(), $title = '') { if (isset($_GET["command"]) && $_GET["command"]==$command && $_SERVER["REQUEST_METHOD"] == "POST") { $result = array(); foreach($prompts as $prompt) - $result[] = $_POST[$prompt]; + $result[$prompt] = $_POST[$prompt]; return $result; }; @@ -224,6 +249,7 @@ $tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("Command", $command); $tpl->setVariable("Headline", nl2br($this->data[$command])); + $tpl->setVariable("Title", $title); if (is_array($prompts)) { @@ -240,6 +266,11 @@ $tpl->show(); exit; + } + + function log($text) + { + $this->_log .= $text."\n"; } // }}} Index: pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.1 pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.2 --- pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.1 Mon May 27 07:49:35 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html Wed May 29 09:20:09 2002 @@ -1,26 +1,67 @@ -<HTML> -<HEAD> - <TITLE>PEAR Installer</TITLE> -</HEAD> -<BODY topmargin="0" leftmargin="0"> - <TABLE border="0" width="100%" cellspacing="0" cellpadding="0"> - <TR> - <TD bgcolor="#339900" width="110"> - <img src="{ImgPEAR}" border="0"> - </TD> - <TD bgcolor="#339900" width="20"> - - </TD> - <TD bgcolor="#339900"> - <font color="#ffffff" size="4"><b>Install / Upgrade / Remove PEAR Packages</b></font> - </TD> - </TR> - <TR> - <TD bgcolor="#006600" colspan="3"> - <a href="{InstallerURL}?command=login"><font color="white"><b>Login</b></font></a> - <font color="white">|</font> - <a href="{InstallerURL}"><font color="white"><b>PackageList</b></font></a> - </TD> - </TR> - </TABLE> - <br> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> + <title>PEAR :: Installer :: {Title}</title> + <link rel="stylesheet" href="{InstallerURL}?css=style" /> + <meta name="description" content="This is the Web Interface of the PEAR Installer" /> +</head> + +<body topmargin="0" leftmargin="0" + marginheight="0" marginwidth="0" + bgcolor="#ffffff" + text="#000000" + link="#006600" + alink="#cccc00" + vlink="#003300" +> +<a name="TOP" /></a> +<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%"> + <tr bgcolor="#339900"> + <td align="left" width="120"> + <img src="{InstallerURL}?img=pear" vspace="2" hspace="5" alt="PEAR"> + </td> + <td align="left" valign="middle" width="20"> + + </td> + <td align="left" valign="middle"> + <span class="Headline">{Title}</span> + </td> + </tr> + + <tr bgcolor="#003300"><td colspan="3"></td></tr> + + <tr bgcolor="#006600"> + <td align="right" valign="top" colspan="3"> + <br /> + </td> + </tr> + + <tr bgcolor="#003300"><td colspan="3"></td></tr> +</table> + +<table cellpadding="0" cellspacing="0" width="100%"> + <tr valign="top"> + <td bgcolor="#f0f0f0" width="100"> + <table width="200" border="0" cellpadding="4" cellspacing="0"> + <tr valign="top"> + <td style="font-size: 90%" align="center" width="200"> + <br><br> + <a href="{InstallerURL}"> + <img src="{InstallerURL}?img=pkglist" border="0"><br> + Package Management + </a> + <br><br><br> + <a href="{InstallerURL}?command=config-show"> + <img src="{InstallerURL}?img=config" border="0"><br> + Configuration + </a> + + </td> + </tr> + </table> + </td> + <td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td> + <td> + <table width="100%" cellpadding="10" cellspacing="0"> + <tr> + <td valign="top"> Index: pear/PEAR_Frontend_Web/Frontend/Web/info.gif Index: pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.1 pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.2 --- pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.1 Mon May 27 07:49:35 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html Wed May 29 09:20:09 2002 @@ -13,8 +13,39 @@ </TR> </TABLE> <TABLE border="0"> + <TR> + <TD width="50" valign="top"> + </TD> + <TD valign="top"> + + </TD> + <TD width="150" valign="top"> + <b>PackageName</b> + </TD> + <TD width="50" valign="top"> + <b>Local</b> + </TD> + <TD width="50" valign="top"> + <b>Latest</b> + </TD> + <TD valign="top" width="15"> + + </TD> + <TD valign="top" width="18"> + + </TD> + <TD valign="top"> + + </TD> + <TD valign="top"> + + </TD> + <TD width="300" valign="top"> + <b>Description</b> + </TD> + </TR> <!-- BEGIN Row --> - <TR>{x} + <TR> <TD width="50" valign="top"> <a name="{Package}"> </TD> @@ -25,10 +56,10 @@ {Package} </TD> <TD width="50" valign="top"> - {Version} + {Installed} </TD> <TD width="50" valign="top"> - {Installed} + {Version} </TD> <TD valign="top" width="15"> {Install} @@ -37,6 +68,9 @@ {Delete} </TD> <TD valign="top"> + {InfoExt} + </TD> + <TD valign="top"> {Info} </TD> <TD width="300" valign="top"> @@ -46,5 +80,4 @@ <!-- END Row --> </TABLE> <!-- END Category --> -</BODY> -</HTML> \ No newline at end of file +<!-- INCLUDE footer.inc.tpl.html --> Index: pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.2 pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.2 Mon May 27 11:20:29 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html Wed May 29 09:20:09 2002 @@ -8,7 +8,7 @@ <b>{prompt}:</b> </TD> <TD> - <input type="{type}" name="{prompt}" value="{default}"> + <input type="{type}" name="{prompt}" value="{default}" size="50"> </TD> </TR> <!-- END InputField --> Index: pear/PEAR_Frontend_Web/WebInstaller.php +++ pear/PEAR_Frontend_Web/WebInstaller.php <?php require_once 'PEAR.php'; require_once 'PEAR/Config.php'; require_once 'PEAR/Command.php'; // Cient requests an Image/Stylesheet if (isset($_GET["css"])) { $images = array( "style" => "style.css", ); Header("Content-Type: text/css"); readfile(dirname(__FILE__).'/Frontend/Web/'.$images[$_GET["css"]]); exit; }; if (isset($_GET["img"])) { $images = array( "config" => array( "type" => "gif", "file" => "config.gif", ), "pkglist" => array( "type" => "gif", "file" => "pkglist.gif", ), "package" => array( "type" => "jpeg", "file" => "package.jpg", ), "category" => array( "type" => "jpeg", "file" => "category.jpg", ), "install" => array( "type" => "gif", "file" => "install.gif", ), "uninstall" => array( "type" => "gif", "file" => "trash.gif", ), "info" => array( "type" => "gif", "file" => "info.gif", ), "infoplus" => array( "type" => "gif", "file" => "infoplus.gif", ), "pear" => array( "type" => "gif", "file" => "pearsmall.gif", ), "error" => array( "type" => "gif", "file" => "error.gif", ), ); Header("Content-Type: image/".$images[$_GET["img"]]['type']); readfile(dirname(__FILE__).'/Frontend/Web/'.$images[$_GET["img"]]['file']); exit; }; // Init PEAR Installer Code and WebFrontend PEAR_Command::setFrontendType("Web"); $ui = &PEAR_Command::getFrontendObject(); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); $config = &PEAR_Config::singleton($pear_user_config, ''); // $config->store('user'); $verbose = $config->get("verbose"); $cmdopts = array(); $opts = array(); $URL = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; // Handle some diffrent Commands if (isset($_GET["command"])) { switch ($_GET["command"]) { case 'install': case 'uninstall': case 'upgrade': $command = $_GET["command"]; $params = array($_GET["pkg"]); $cmd = PEAR_Command::factory($command, $config); $ok = $cmd->run($command, $opts, $params); if (!$ok) { PEAR::raiseError(''); }; $URL .= '#'.$_GET["pkg"]; Header("Location: ".$URL); exit; case 'config-show': $cmd = PEAR_Command::factory($command, $config); $res = $cmd->run($command, $opts, $params); foreach($GLOBALS['_PEAR_Frontend_Web_Config'] as $var => $value) { $command = 'config-set'; $params = array($var, $value); $cmd = PEAR_Command::factory($command, $config); $res = $cmd->run($command, $opts, $params); }; $URL .= '?command=config-show'; Header("Location: ".$URL); exit; } }; $command = "list-all"; $params = array(); if (isset($_GET["info"])) $params[$_GET["info"]] = 1; $cmd = PEAR_Command::factory($command, $config); $ok = $cmd->run($command, $opts, $params); ?> Index: pear/PEAR_Frontend_Web/package.xml +++ pear/PEAR_Frontend_Web/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "../package.dtd"> <package version="1.0"> <name>PEAR_Frontend_Web</name> <summary>HTML (Web) PEAR Package Manager</summary> <description>Web Interface to the PEAR Package Manager </description> <license>PHP License</license> <maintainers> <maintainer> <user>dickmann</user> <role>lead</role> <name>Christian Dickmann</name> <email>alan@akbkhome.com</email> </maintainer> <maintainer> <user>ssb</user> <role>helper</role> <name>Stig Sæther Bakken</name> <email>stig@php.net</email> </maintainer> </maintainers> <release> <version>0.1</version> <date>2002-05-27</date> <notes>First release</notes> <state>alpha</state> <filelist> <dir name="/" baseinstalldir="PEAR"> <file role="php">WebInstaller.php</file> <dir name="Frontend" baseinstalldir="PEAR/Frontend"> <file role="php">Web.php</file> <dir name="Web" baseinstalldir="PEAR/Frontend/Web"> <file role="php">error.gif</file> <file role="php">pearsmall.gif</file> <file role="php">trash.gif</file> <file role="php">install.gif</file> <file role="php">info.gif</file> <file role="php">infoplus.gif</file> <file role="php">package.jpg</file> <file role="php">category.jpg</file> <file role="php">pkglist.gif</file> <file role="php">config.gif</file> <file role="php">style.css</file> <file role="php">userDialog.tpl.html</file> <file role="php">package.list.tpl.html</file> <file role="php">header.inc.tpl.html</file> <file role="php">footer.inc.tpl.html</file> <file role="php">error.tpl.html</file> </dir> </dir> </dir> </filelist> </release> </package> Index: pear/PEAR_Frontend_Web/Frontend/Web/footer.inc.tpl.html +++ pear/PEAR_Frontend_Web/Frontend/Web/footer.inc.tpl.html </td> </tr> </table> </td> </tr> </table> Index: pear/PEAR_Frontend_Web/Frontend/Web/style.css +++ pear/PEAR_Frontend_Web/Frontend/Web/style.css body, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 90%; } p { font-family: verdana,arial,helvetica,sans-serif; } th.pack { color: #FFFFFF; background: #009933; text-align: right; } th.others { color: #006600; text-align: left; } em { font-weight: bold; font-style: italic; } span.headline { font-family: verdana,arial,helvetica,sans-serif; font-size: 125%; font-weight: bold; color: #ffffff; } newsDate { font-size: 85%; font-style: italic; color: #66cc66; } compact { font-family: arial, helvetica, sans-serif; font-size: 90%; } menuWhite { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; color: #ffffff; } menuBlack { font-family: verdana,arial,helvetica,sans-serif; text-decoration: none; font-weight: bold; font-size: 75%; color: #000000; } sidebar { font-size: 85%; } code, pre, tt { font-family: Courier, "Courier New", monospace; font-size: 90%; } pre.php { border-color: black; border-style: dashed; border-width: 1px; background-color: #eeeeee; padding: 5px; } h1 { font-family: verdana,arial,helvetica,sans-serif; font-size: 140%; font-weight: bold; color: #006600; } h2 { font-family: verdana,arial,helvetica,sans-serif; font-size: 125%; font-weight: bold; color: #006600; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 110%; font-weight: bold; color: #006600; } small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } a.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; text-decoration: none; } tableTitle { font-family: verdana,arial,helvetica,sans-serif; font-weight: bold; } tableExtras { font-family: verdana,arial,helvetica,sans-serif; font-size: 85%; color: #FFFFFF; } input { font-family: verdana,arial,helvetica,sans-serif; } textarea { font-family: verdana,arial,helvetica,sans-serif; } input.small, select.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } textarea.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } form { margin-bottom : 0; }
Index: pear/PEAR_Frontend_Web/Command/Install.php diff -u pear/PEAR_Frontend_Web/Command/Install.php:1.2 pear/PEAR_Frontend_Web/Command/Install.php:1.3 --- pear/PEAR_Frontend_Web/Command/Install.php:1.2 Mon May 27 11:16:03 2002 +++ pear/PEAR_Frontend_Web/Command/Install.php Wed May 29 09:20:09 2002 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Install.php,v 1.2 2002/05/27 15:16:03 dickmann Exp $ +// $Id: Install.php,v 1.3 2002/05/29 13:20:09 dickmann Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Installer.php"; @@ -166,6 +166,7 @@ return $this->raiseError("$command failed"); } } + return true; } function doUninstall($command, $options, $params) Index: pear/PEAR_Frontend_Web/Frontend/CLI.php diff -u pear/PEAR_Frontend_Web/Frontend/CLI.php:1.1 pear/PEAR_Frontend_Web/Frontend/CLI.php:1.2 --- pear/PEAR_Frontend_Web/Frontend/CLI.php:1.1 Mon May 27 11:20:29 2002 +++ pear/PEAR_Frontend_Web/Frontend/CLI.php Wed May 29 09:20:09 2002 @@ -16,7 +16,7 @@ | Author: Stig Sæther Bakken <ssb@fast.no> | +----------------------------------------------------------------------+ - $Id: CLI.php,v 1.1 2002/05/27 15:20:29 dickmann Exp $ + $Id: CLI.php,v 1.2 2002/05/29 13:20:09 dickmann Exp $ */ require_once "PEAR.php"; @@ -103,9 +103,9 @@ } // }}} - // {{{ userDialog(prompt, [type], [default]) + // {{{ _userDialog(prompt, [type], [default]) - function userDialog($prompt, $type = 'text', $default = '') + function _userDialog($prompt, $type = 'text', $default = '') { if ($type == 'password') { system('stty -echo'); @@ -115,6 +115,7 @@ print "[$default] "; } print ": "; + $fp = fopen("php://stdin", "r"); $line = fgets($fp, 2048); fclose($fp); @@ -126,6 +127,21 @@ return $default; } return $line; + } + + // }}} + // {{{ userDialog(command, prompts, [types], [defaults]) + + function userDialog($command, $prompts, $types = array(), $defaults = array()) + { + $result = array(); + foreach($prompts as $key => $prompt) { + $type = ((isset($types[$key])) ? $types[$key] : 'text'); + $default = ((isset($defaults[$key])) ? $defaults[$key] : ''); + $result[] = $this->_userDialog($prompt, $type, $default); + }; + + return $result; } // }}} Index: pear/PEAR_Frontend_Web/Frontend/Web.php diff -u pear/PEAR_Frontend_Web/Frontend/Web.php:1.2 pear/PEAR_Frontend_Web/Frontend/Web.php:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web.php:1.2 Mon May 27 11:20:29 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web.php Wed May 29 09:20:09 2002 @@ -16,7 +16,7 @@ | Author: Christian Dickmann <dickmann@php.net> | +----------------------------------------------------------------------+ - $Id: Web.php,v 1.2 2002/05/27 15:20:29 dickmann Exp $ + $Id: Web.php,v 1.3 2002/05/29 13:20:09 dickmann Exp $ */ require_once "PEAR.php"; @@ -36,6 +36,7 @@ var $tpl; var $table; var $data = array(); + var $_log; var $params = array(); @@ -67,7 +68,10 @@ function displayError($eobj) { - $msg = $eobj->getMessage(); + $msg = ''; + if (trim($this->_log)) + $msg = trim($this->_log)."\n\n"; + $msg .= $eobj->getMessage(); $msg = nl2br($msg); $tpl = new IntegratedTemplate(dirname(__FILE__)."/Web"); @@ -77,8 +81,16 @@ $tpl->setVariable("ImgError", $_SERVER["PHP_SELF"].'?img=error'); $tpl->setVariable("Error", $msg); - if (isset($_GET['command'])) + $command_map = array( + "install" => "list-all", + "uninstall" => "list-all", + "upgrade" => "list-all", + ); + if (isset($_GET['command'])) { + if (isset($command_map[$_GET['command']])) + $_GET['command'] = $command_map[$_GET['command']]; $tpl->setVariable("param", '?command='.$_GET['command']); + }; $tpl->show(); exit; @@ -95,15 +107,6 @@ } // }}} - // {{{ displayHeading(title) - - function displayHeading($title) - { -// print $this->lp.$this->bold($title)."\n"; -// print $this->lp.str_repeat("=", strlen($title))."\n"; - } - - // }}} // {{{ userConfirm(prompt, [default]) function userConfirm($prompt, $default = 'yes') @@ -132,12 +135,13 @@ // }}} - function outputListAll($data) + function _outputListAll($data) { $tpl = new IntegratedTemplate(dirname(__FILE__)."/Web"); $tpl->loadTemplateFile("package.list.tpl.html"); $tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("ImgPEAR", $_SERVER["PHP_SELF"].'?img=pear'); + $tpl->setVariable("Title", 'Install / Upgrade / Remove PEAR Packages'); foreach($data['data'] as $category => $packages) { @@ -147,27 +151,37 @@ $tpl->setVariable("ImgPackage", $_SERVER["PHP_SELF"].'?img=package'); $compare = version_compare($row[1], $row[2]); if (!$row[2]) { - $inst = sprintf('<a href="%s?install=%s"><img src="%s?img=install" border="0"></a>', + $inst = sprintf( + '<a href="%s?command=install&pkg=%s"><img src="%s?img=install" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); $del = ''; } else if ($compare == 1) { - $inst = sprintf('<a href="%s?upgrade=%s"><img src="%s?img=install" border="0"></a>', + $inst = sprintf( + '<a href="%s?command=upgrade&pkg=%s"><img src="%s?img=install" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); - $del = sprintf('<a href="%s?uninstall=%s"><img src="%s?img=uninstall" border="0"></a>', + $del = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); } else { - $del = sprintf('<a href="%s?uninstall=%s"><img src="%s?img=uninstall" border="0"></a>', + $del = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); $inst = ''; }; $info=sprintf('<a href="%s?info=%s#%s"><img src="%s?img=info" border="0"></a>', $_SERVER["PHP_SELF"], $row[0], $row[0], $_SERVER["PHP_SELF"]); + $infoExt=sprintf('<a href="%s?info=%s#%s"><img src="%s?img=infoplus" border="0"></a>', + $_SERVER["PHP_SELF"], $row[0], $row[0], $_SERVER["PHP_SELF"]); + + if ($row[0] == 'PEAR') + $del = ''; $tpl->setVariable("Version", $row[1]); $tpl->setVariable("Installed", $row[2]); $tpl->setVariable("Install", $inst); $tpl->setVariable("Delete", $del); $tpl->setVariable("Info", $info); + $tpl->setVariable("InfoExt", $infoExt); $tpl->setVariable("Package", $row[0]); $tpl->setVariable("Summary", nl2br($row[3])); $tpl->parseCurrentBlock(); @@ -185,15 +199,26 @@ { switch ($command) { + case 'config-show': + $prompt = array(); + $default = array(); + foreach($data['data'] as $row) { + $prompt[] = $row[0]; + if ($row[1] != "<not set>") + $default[] = $row[1]; + else + $default[] = ''; + }; + $GLOBALS['_PEAR_Frontend_Web_Config'] = + $this->userDialog($command, $prompt, array(), $default, 'Configuration'); + return true; case 'list-all': - return $this->outputListAll($data); + return $this->_outputListAll($data); case 'install': case 'uninstall': return true; case 'login': - if ($_SERVER["REQUEST_METHOD"] == "POST") - break; - else + if ($_SERVER["REQUEST_METHOD"] != "POST") $this->data[$command] = $data; return true; case 'logout': @@ -207,14 +232,14 @@ return true; } - function userDialog($command, $prompts, $types = array(), $defaults = array()) + function userDialog($command, $prompts, $types = array(), $defaults = array(), $title = '') { if (isset($_GET["command"]) && $_GET["command"]==$command && $_SERVER["REQUEST_METHOD"] == "POST") { $result = array(); foreach($prompts as $prompt) - $result[] = $_POST[$prompt]; + $result[$prompt] = $_POST[$prompt]; return $result; }; @@ -224,6 +249,7 @@ $tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("Command", $command); $tpl->setVariable("Headline", nl2br($this->data[$command])); + $tpl->setVariable("Title", $title); if (is_array($prompts)) { @@ -240,6 +266,11 @@ $tpl->show(); exit; + } + + function log($text) + { + $this->_log .= $text."\n"; } // }}} Index: pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.1 pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.2 --- pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.1 Mon May 27 07:49:35 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html Wed May 29 09:20:09 2002 @@ -1,26 +1,67 @@ -<HTML> -<HEAD> - <TITLE>PEAR Installer</TITLE> -</HEAD> -<BODY topmargin="0" leftmargin="0"> - <TABLE border="0" width="100%" cellspacing="0" cellpadding="0"> - <TR> - <TD bgcolor="#339900" width="110"> - <img src="{ImgPEAR}" border="0"> - </TD> - <TD bgcolor="#339900" width="20"> - - </TD> - <TD bgcolor="#339900"> - <font color="#ffffff" size="4"><b>Install / Upgrade / Remove PEAR Packages</b></font> - </TD> - </TR> - <TR> - <TD bgcolor="#006600" colspan="3"> - <a href="{InstallerURL}?command=login"><font color="white"><b>Login</b></font></a> - <font color="white">|</font> - <a href="{InstallerURL}"><font color="white"><b>PackageList</b></font></a> - </TD> - </TR> - </TABLE> - <br> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> +<head> + <title>PEAR :: Installer :: {Title}</title> + <link rel="stylesheet" href="{InstallerURL}?css=style" /> + <meta name="description" content="This is the Web Interface of the PEAR Installer" /> +</head> + +<body topmargin="0" leftmargin="0" + marginheight="0" marginwidth="0" + bgcolor="#ffffff" + text="#000000" + link="#006600" + alink="#cccc00" + vlink="#003300" +> +<a name="TOP" /></a> +<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%"> + <tr bgcolor="#339900"> + <td align="left" width="120"> + <img src="{InstallerURL}?img=pear" vspace="2" hspace="5" alt="PEAR"> + </td> + <td align="left" valign="middle" width="20"> + + </td> + <td align="left" valign="middle"> + <span class="Headline">{Title}</span> + </td> + </tr> + + <tr bgcolor="#003300"><td colspan="3"></td></tr> + + <tr bgcolor="#006600"> + <td align="right" valign="top" colspan="3"> + <br /> + </td> + </tr> + + <tr bgcolor="#003300"><td colspan="3"></td></tr> +</table> + +<table cellpadding="0" cellspacing="0" width="100%"> + <tr valign="top"> + <td bgcolor="#f0f0f0" width="100"> + <table width="200" border="0" cellpadding="4" cellspacing="0"> + <tr valign="top"> + <td style="font-size: 90%" align="center" width="200"> + <br><br> + <a href="{InstallerURL}"> + <img src="{InstallerURL}?img=pkglist" border="0"><br> + Package Management + </a> + <br><br><br> + <a href="{InstallerURL}?command=config-show"> + <img src="{InstallerURL}?img=config" border="0"><br> + Configuration + </a> + + </td> + </tr> + </table> + </td> + <td bgcolor="#cccccc" width="1" background="/gifs/checkerboard.gif"></td> + <td> + <table width="100%" cellpadding="10" cellspacing="0"> + <tr> + <td valign="top"> Index: pear/PEAR_Frontend_Web/Frontend/Web/info.gif Index: pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.1 pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.2 --- pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.1 Mon May 27 07:49:35 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html Wed May 29 09:20:09 2002 @@ -13,8 +13,39 @@ </TR> </TABLE> <TABLE border="0"> + <TR> + <TD width="50" valign="top"> + </TD> + <TD valign="top"> + + </TD> + <TD width="150" valign="top"> + <b>PackageName</b> + </TD> + <TD width="50" valign="top"> + <b>Local</b> + </TD> + <TD width="50" valign="top"> + <b>Latest</b> + </TD> + <TD valign="top" width="15"> + + </TD> + <TD valign="top" width="18"> + + </TD> + <TD valign="top"> + + </TD> + <TD valign="top"> + + </TD> + <TD width="300" valign="top"> + <b>Description</b> + </TD> + </TR> <!-- BEGIN Row --> - <TR>{x} + <TR> <TD width="50" valign="top"> <a name="{Package}"> </TD> @@ -25,10 +56,10 @@ {Package} </TD> <TD width="50" valign="top"> - {Version} + {Installed} </TD> <TD width="50" valign="top"> - {Installed} + {Version} </TD> <TD valign="top" width="15"> {Install} @@ -37,6 +68,9 @@ {Delete} </TD> <TD valign="top"> + {InfoExt} + </TD> + <TD valign="top"> {Info} </TD> <TD width="300" valign="top"> @@ -46,5 +80,4 @@ <!-- END Row --> </TABLE> <!-- END Category --> -</BODY> -</HTML> \ No newline at end of file +<!-- INCLUDE footer.inc.tpl.html --> Index: pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.2 pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.2 Mon May 27 11:20:29 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html Wed May 29 09:20:09 2002 @@ -8,7 +8,7 @@ <b>{prompt}:</b> </TD> <TD> - <input type="{type}" name="{prompt}" value="{default}"> + <input type="{type}" name="{prompt}" value="{default}" size="50"> </TD> </TR> <!-- END InputField --> Index: pear/PEAR_Frontend_Web/WebInstaller.php +++ pear/PEAR_Frontend_Web/WebInstaller.php <?php require_once 'PEAR.php'; require_once 'PEAR/Config.php'; require_once 'PEAR/Command.php'; // Cient requests an Image/Stylesheet if (isset($_GET["css"])) { $images = array( "style" => "style.css", ); Header("Content-Type: text/css"); readfile(dirname(__FILE__).'/Frontend/Web/'.$images[$_GET["css"]]); exit; }; if (isset($_GET["img"])) { $images = array( "config" => array( "type" => "gif", "file" => "config.gif", ), "pkglist" => array( "type" => "gif", "file" => "pkglist.gif", ), "package" => array( "type" => "jpeg", "file" => "package.jpg", ), "category" => array( "type" => "jpeg", "file" => "category.jpg", ), "install" => array( "type" => "gif", "file" => "install.gif", ), "uninstall" => array( "type" => "gif", "file" => "trash.gif", ), "info" => array( "type" => "gif", "file" => "info.gif", ), "infoplus" => array( "type" => "gif", "file" => "infoplus.gif", ), "pear" => array( "type" => "gif", "file" => "pearsmall.gif", ), "error" => array( "type" => "gif", "file" => "error.gif", ), ); Header("Content-Type: image/".$images[$_GET["img"]]['type']); readfile(dirname(__FILE__).'/Frontend/Web/'.$images[$_GET["img"]]['file']); exit; }; // Init PEAR Installer Code and WebFrontend PEAR_Command::setFrontendType("Web"); $ui = &PEAR_Command::getFrontendObject(); PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ui, "displayFatalError")); $config = &PEAR_Config::singleton($pear_user_config, ''); // $config->store('user'); $verbose = $config->get("verbose"); $cmdopts = array(); $opts = array(); $URL = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; // Handle some diffrent Commands if (isset($_GET["command"])) { switch ($_GET["command"]) { case 'install': case 'uninstall': case 'upgrade': $command = $_GET["command"]; $params = array($_GET["pkg"]); $cmd = PEAR_Command::factory($command, $config); $ok = $cmd->run($command, $opts, $params); if (!$ok) { PEAR::raiseError(''); }; $URL .= '#'.$_GET["pkg"]; Header("Location: ".$URL); exit; case 'config-show': $cmd = PEAR_Command::factory($command, $config); $res = $cmd->run($command, $opts, $params); foreach($GLOBALS['_PEAR_Frontend_Web_Config'] as $var => $value) { $command = 'config-set'; $params = array($var, $value); $cmd = PEAR_Command::factory($command, $config); $res = $cmd->run($command, $opts, $params); }; $URL .= '?command=config-show'; Header("Location: ".$URL); exit; } }; $command = "list-all"; $params = array(); if (isset($_GET["info"])) $params[$_GET["info"]] = 1; $cmd = PEAR_Command::factory($command, $config); $ok = $cmd->run($command, $opts, $params); ?> Index: pear/PEAR_Frontend_Web/package.xml +++ pear/PEAR_Frontend_Web/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "../package.dtd"> <package version="1.0"> <name>PEAR_Frontend_Web</name> <summary>HTML (Web) PEAR Package Manager</summary> <description>Web Interface to the PEAR Package Manager </description> <license>PHP License</license> <maintainers> <maintainer> <user>dickmann</user> <role>lead</role> <name>Christian Dickmann</name> <email>alan@akbkhome.com</email> </maintainer> <maintainer> <user>ssb</user> <role>helper</role> <name>Stig Sæther Bakken</name> <email>stig@php.net</email> </maintainer> </maintainers> <release> <version>0.1</version> <date>2002-05-27</date> <notes>First release</notes> <state>alpha</state> <filelist> <dir name="/" baseinstalldir="PEAR"> <file role="php">WebInstaller.php</file> <dir name="Frontend" baseinstalldir="PEAR/Frontend"> <file role="php">Web.php</file> <dir name="Web" baseinstalldir="PEAR/Frontend/Web"> <file role="php">error.gif</file> <file role="php">pearsmall.gif</file> <file role="php">trash.gif</file> <file role="php">install.gif</file> <file role="php">info.gif</file> <file role="php">infoplus.gif</file> <file role="php">package.jpg</file> <file role="php">category.jpg</file> <file role="php">pkglist.gif</file> <file role="php">config.gif</file> <file role="php">style.css</file> <file role="php">userDialog.tpl.html</file> <file role="php">package.list.tpl.html</file> <file role="php">header.inc.tpl.html</file> <file role="php">footer.inc.tpl.html</file> <file role="php">error.tpl.html</file> </dir> </dir> </dir> </filelist> </release> </package> Index: pear/PEAR_Frontend_Web/Frontend/Web/footer.inc.tpl.html +++ pear/PEAR_Frontend_Web/Frontend/Web/footer.inc.tpl.html </td> </tr> </table> </td> </tr> </table> Index: pear/PEAR_Frontend_Web/Frontend/Web/style.css +++ pear/PEAR_Frontend_Web/Frontend/Web/style.css body, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 90%; } p { font-family: verdana,arial,helvetica,sans-serif; } th.pack { color: #FFFFFF; background: #009933; text-align: right; } th.others { color: #006600; text-align: left; } em { font-weight: bold; font-style: italic; } span.headline { font-family: verdana,arial,helvetica,sans-serif; font-size: 125%; font-weight: bold; color: #ffffff; } newsDate { font-size: 85%; font-style: italic; color: #66cc66; } compact { font-family: arial, helvetica, sans-serif; font-size: 90%; } menuWhite { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; color: #ffffff; } menuBlack { font-family: verdana,arial,helvetica,sans-serif; text-decoration: none; font-weight: bold; font-size: 75%; color: #000000; } sidebar { font-size: 85%; } code, pre, tt { font-family: Courier, "Courier New", monospace; font-size: 90%; } pre.php { border-color: black; border-style: dashed; border-width: 1px; background-color: #eeeeee; padding: 5px; } h1 { font-family: verdana,arial,helvetica,sans-serif; font-size: 140%; font-weight: bold; color: #006600; } h2 { font-family: verdana,arial,helvetica,sans-serif; font-size: 125%; font-weight: bold; color: #006600; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 110%; font-weight: bold; color: #006600; } small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } a.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; text-decoration: none; } tableTitle { font-family: verdana,arial,helvetica,sans-serif; font-weight: bold; } tableExtras { font-family: verdana,arial,helvetica,sans-serif; font-size: 85%; color: #FFFFFF; } input { font-family: verdana,arial,helvetica,sans-serif; } textarea { font-family: verdana,arial,helvetica,sans-serif; } input.small, select.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } textarea.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } form { margin-bottom : 0; }