cvs: pear /PEAR_Frontend_Web WebInstaller.php package.xml /PEAR_Frontend_Web/Frontend Web.php /PEAR_Frontend_Web/Frontend/Web dhtml.css dhtml.js
error.tpl.html header.inc.tpl.html nodhtml.js package.info.tpl.html package.list.tpl.html pkgsearch.png style.css userDialog.tpl.html
| From: | Christian Dickmann | Date: | Sat, 01 Jun 2002 19:01:02 +0000 |
| Subject: | cvs: pear /PEAR_Frontend_Web WebInstaller.php package.xml /PEAR_Frontend_Web/Frontend Web.php /PEAR_Frontend_Web/Frontend/Web dhtml.css dhtml.js error.tpl.html header.inc.tpl.html nodhtml.js package.info.tpl.html package.list.tpl.html pkgsearch.png style.css userDialog.tpl.html |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4339@lists.php.net to get a copy of this message | ||
dickmann Sat Jun 1 15:01:02 2002 EDT
Added files:
/pear/PEAR_Frontend_Web/Frontend/Web dhtml.css dhtml.js nodhtml.js
package.info.tpl.html
pkgsearch.png
Modified files:
/pear/PEAR_Frontend_Web WebInstaller.php package.xml
/pear/PEAR_Frontend_Web/Frontend Web.php
/pear/PEAR_Frontend_Web/Frontend/Web error.tpl.html
header.inc.tpl.html
package.list.tpl.html
style.css userDialog.tpl.html
Log:
use DHTML for IE 5+. add 'pear remote-info' (package details). add 'pear
search' (package search). improve layout. code cleanup
Index: pear/PEAR_Frontend_Web/WebInstaller.php diff -u pear/PEAR_Frontend_Web/WebInstaller.php:1.2 pear/PEAR_Frontend_Web/WebInstaller.php:1.3 --- pear/PEAR_Frontend_Web/WebInstaller.php:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/WebInstaller.php Sat Jun 1 15:00:57 2002 @@ -9,11 +9,22 @@ { $images = array( "style" => "style.css", + "dhtml" => "dhtml.css", ); Header("Content-Type: text/css"); readfile(dirname(__FILE__).'/Frontend/Web/'.$images[$_GET["css"]]); exit; }; + if (isset($_GET["js"])) + { + $js = array( + "dhtml" => "dhtml.js", + "nodhtml" => "nodhtml.js", + ); + Header("Content-Type: text/js"); + readfile(dirname(__FILE__).'/Frontend/Web/'.$js[$_GET["js"]]); + exit; + }; if (isset($_GET["img"])) { $images = array( @@ -33,6 +44,10 @@ "type" => "png", "file" => "pkglist.png", ), + "pkgsearch" => array( + "type" => "png", + "file" => "pkgsearch.png", + ), "package" => array( "type" => "jpeg", "file" => "package.jpg", @@ -103,6 +118,30 @@ $URL .= '#'.$_GET["pkg"]; Header("Location: ".$URL); + exit; + case 'remote-info': + $command = $_GET["command"]; + $params = array($_GET["pkg"]); + $cmd = PEAR_Command::factory($command, $config); + $ok = $cmd->run($command, $opts, $params); + + if (!$ok) { + PEAR::raiseError(''); + }; + exit; + case 'search': + list($name, $description) = $ui->userDialog('search', + array('Package Name', 'Package Info'), + array(), array(), 'Package Search', 'pkgsearch'); + + $command = $_GET["command"]; + $params = array($name, $description); + $cmd = PEAR_Command::factory($command, $config); + $ok = $cmd->run($command, $opts, $params); + + if (!$ok) { + PEAR::raiseError(''); + }; exit; case 'config-show': $cmd = PEAR_Command::factory($command, $config); Index: pear/PEAR_Frontend_Web/package.xml diff -u pear/PEAR_Frontend_Web/package.xml:1.2 pear/PEAR_Frontend_Web/package.xml:1.3 --- pear/PEAR_Frontend_Web/package.xml:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/package.xml Sat Jun 1 15:00:57 2002 @@ -31,6 +31,7 @@ <dir name="Frontend" baseinstalldir="PEAR/Frontend"> <file role="php">Web.php</file> <dir name="Web" baseinstalldir="PEAR/Frontend/Web"> + <!-- Images --> <file role="php">error.gif</file> <file role="php">pearsmall.gif</file> <file role="php">trash.gif</file> @@ -39,13 +40,24 @@ <file role="php">infoplus.gif</file> <file role="php">package.jpg</file> <file role="php">category.jpg</file> - <file role="php">pkglist.png</file> <file role="php">config.gif</file> <file role="php">login.gif</file> <file role="php">logout.gif</file> + <file role="php">pkglist.png</file> + <file role="php">pkgsearch.png</file> + + <!-- CSS --> <file role="php">style.css</file> + <file role="php">dhtml.css</file> + + <!-- JS --> + <file role="php">dhtml.js</file> + <file role="php">nodhtml.js</file> + + <!-- TEMPLATES --> <file role="php">userDialog.tpl.html</file> <file role="php">package.list.tpl.html</file> + <file role="php">package.info.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> Index: pear/PEAR_Frontend_Web/Frontend/Web.php diff -u pear/PEAR_Frontend_Web/Frontend/Web.php:1.4 pear/PEAR_Frontend_Web/Frontend/Web.php:1.5 --- pear/PEAR_Frontend_Web/Frontend/Web.php:1.4 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web.php Sat Jun 1 15:01:00 2002 @@ -16,11 +16,12 @@ | Author: Christian Dickmann <dickmann@php.net> | +----------------------------------------------------------------------+ - $Id: Web.php,v 1.4 2002/05/29 22:26:05 dickmann Exp $ + $Id: Web.php,v 1.5 2002/06/01 19:01:00 dickmann Exp $ */ require_once "PEAR.php"; require_once "HTML/IT.php"; +require_once "Net/UserAgent/Detect.php"; class PEAR_Frontend_Web extends PEAR { @@ -65,7 +66,7 @@ // }}} // {{{ displayError(eobj) - function initTemplate($file, $title = '', $icon = '') + function initTemplate($file, $title = '', $icon = '', $useDHTML = true) { $tpl = new IntegratedTemplate(dirname(__FILE__)."/Web"); $tpl->loadTemplateFile($file); @@ -76,21 +77,44 @@ if ($icon) { $tpl->setCurrentBlock("TitleBlock"); + $tpl->setVariable("_InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("_Title", $title); $tpl->setVariable("_Icon", $icon); + $tpl->parseCurrentBlock(); }; + $tpl->setCurrentBlock(); + + if ($useDHTML && Net_UserAgent_Detect::getBrowser('ie5up') == 'ie5up') + $dhtml = true; + else + $dhtml = false; + + if ($dhtml) + { + $tpl->setVariable("JS", 'dhtml'); + $css = '<link rel="stylesheet" href="'.$_SERVER['PHP_SELF'].'?css=dhtml" />'; + $tpl->setVariable("DHTMLcss", $css); + } else { + $tpl->setVariable("JS", 'nodhtml'); + }; + return $tpl; } - function displayError($eobj) + function displayError($eobj, $title = 'Error', $img = 'error') { $msg = ''; if (trim($GLOBALS['_PEAR_Frontend_Web_log'])) $msg = trim($GLOBALS['_PEAR_Frontend_Web_log'])."\n\n"; - $msg .= trim($eobj->getMessage()); + + if (PEAR::isError($eobj)) + $msg .= trim($eobj->getMessage()); + else + $msg .= trim($eobj); + $msg = nl2br($msg."\n"); - $tpl = $this->initTemplate("error.tpl.html", "Error", 'error'); + $tpl = $this->initTemplate("error.tpl.html", $title, $img); $tpl->setVariable("Error", $msg); $command_map = array( @@ -112,9 +136,9 @@ // }}} // {{{ displayFatalError(eobj) - function displayFatalError($eobj) + function displayFatalError($eobj, $title = 'Error', $img = 'error') { - $this->displayError($eobj); + $this->displayError($eobj, $title, $img); exit(1); } @@ -147,9 +171,9 @@ // }}} - function _outputListAll($data) + function _outputListAll($data, $title = 'Install / Upgrade / Remove PEAR Packages', $img = 'pkglist', $useDHTML = true) { - $tpl = $this->initTemplate("package.list.tpl.html", 'Install / Upgrade / Remove PEAR Packages', 'pkglist'); + $tpl = $this->initTemplate("package.list.tpl.html", $title, $img, $useDHTML); foreach($data['data'] as $category => $packages) { @@ -176,10 +200,10 @@ $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); $inst = ''; }; - $info=sprintf('<a href="%s?info=%s#%s"><img src="%s?img=info" border="0" alt="info"></a>', - $_SERVER["PHP_SELF"], $row[0], $row[0], $_SERVER["PHP_SELF"]); - $infoExt=sprintf('<a href="%s?pacid=%s"><img src="%s?img=infoplus" border="0" alt="extended info"></a>', - 'http://pear.php.net/package-info.php', $row[4], $_SERVER["PHP_SELF"]); + $info=sprintf('<a href="%s?command=remote-info&pkg=%s"><img src="%s?img=info" border="0" alt="info"></a>', + $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); + $infoExt=sprintf('<a href="%s?package=%s"><img src="%s?img=infoplus" border="0" alt="extended info"></a>', + 'http://pear.php.net/package-info.php', $row[0], $_SERVER["PHP_SELF"]); if ($row[0] == 'PEAR' || $row[0] == 'Archive_Tar') $del = ''; @@ -203,6 +227,68 @@ } + function _outputPackageInfo($data) + { + $tpl = $this->initTemplate("package.info.tpl.html", 'Package Management :: '.$data['name'], 'pkglist'); + + $tpl->setVariable("Latest", $data['stable']); + $tpl->setVariable("Installed", $data['installed']); + $tpl->setVariable("Package", $data['name']); + $tpl->setVariable("Licence", $data['licence']); + $tpl->setVariable("Category", $data['category']); + $tpl->setVariable("Summary", nl2br($data['summary'])); + $tpl->setVariable("Description", nl2br($data['description'])); + + $compare = version_compare($data['stable'], $data['installed']); + if (!$data['installed']) { + $opt_img_1 = sprintf( + '<a href="%s?command=install&pkg=%s"><img src="%s?img=install" border="0" alt="install"></a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_1 = sprintf( + '<a href="%s?command=install&pkg=%s" class="green">Install</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_img_2 = ''; + } else if ($compare == 1) { + $opt_img_1 = sprintf( + '<a href="%s?command=upgrade&pkg=%s"><img src="%s?img=install" border="0" alt="upgrade"></a><br>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_1 = sprintf( + '<a href="%s?command=upgrade&pkg=%s" class="green">Upgrade</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_img_2 = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0" alt="uninstall"></a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_2 = sprintf( + '<a href="%s?command=uninstall&pkg=%s" class="green">Delete</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + } else { + $opt_img_1 = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0" alt="uninstall"></a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_1 = sprintf( + '<a href="%s?command=uninstall&pkg=%s" class="green">Delete</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_img_2 = ''; + }; + + if ($opt_img_1) + { + $tpl->setVariable("Opt_Img_1", $opt_img_1); + $tpl->setVariable("Opt_Text_1", $opt_text_1); + }; + if ($opt_img_2) + { + $tpl->setVariable("Opt_Img_2", $opt_img_2); + $tpl->setVariable("Opt_Text_2", $opt_text_2); + }; + + $tpl->show(); + + + + + } + function outputData($data, $command) { switch ($command) @@ -210,18 +296,22 @@ 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[] = ''; + foreach($data['data'] as $group) { + foreach($group as $row) { + $prompt[$row[1]] = $row[0]; + $default[$row[1]] = $row[2]; + }; }; + $title = 'Configuration :: '.$GLOBALS['pear_user_config']; $GLOBALS['_PEAR_Frontend_Web_Config'] = - $this->userDialog($command, $prompt, array(), $default, 'Configuration', 'config'); + $this->userDialog($command, $prompt, array(), $default, $title, 'config'); return true; case 'list-all': return $this->_outputListAll($data); + case 'search': + return $this->_outputListAll($data, 'Package Search :: Result', 'pkgsearch', false); + case 'remote-info': + return $this->_outputPackageInfo($data); case 'install': case 'uninstall': return true; @@ -230,7 +320,7 @@ $this->data[$command] = $data; return true; case 'logout': - PEAR::raiseError($data); + $this->displayError($data, 'Logout', 'logout'); break; case 'package': echo $data; @@ -248,8 +338,8 @@ && $_SERVER["REQUEST_METHOD"] == "POST") { $result = array(); - foreach($prompts as $prompt) - $result[$prompt] = $_POST[$prompt]; + foreach($prompts as $key => $prompt) + $result[$key] = $_POST[$key]; return $result; }; @@ -259,13 +349,24 @@ if (is_array($prompts)) { + $maxlen = 0; + foreach($prompts as $key => $prompt) + { + if (strlen($prompt) > $maxlen) { + $maxlen = strlen($prompt); + }; + }; + foreach($prompts as $key => $prompt) { $tpl->setCurrentBlock("InputField"); $type = (isset($types[$key]) ? $types[$key] : 'text'); $tpl->setVariable("prompt", $prompt); + $tpl->setVariable("name", $key); $tpl->setVariable("default", $defaults[$key]); $tpl->setVariable("type", $type); + if ($maxlen > 25) + $tpl->setVariable("width", 'width="275"'); $tpl->parseCurrentBlock(); }; }; Index: pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html:1.2 pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html Sat Jun 1 15:01:01 2002 @@ -6,9 +6,8 @@ <TD> {Error} <br> - <a href="{InstallerURL}{param}">Back</a> + <a href="{InstallerURL}{param}" class="green">Back</a> </TD> </TR> </TABLE> -</BODY> -</HTML> \ No newline at end of file +<!-- INCLUDE footer.inc.tpl.html --> Index: pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.3 pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.4 --- pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.3 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html Sat Jun 1 15:01:01 2002 @@ -3,6 +3,8 @@ <head> <title>PEAR :: Installer :: {Title}</title> <link rel="stylesheet" href="{InstallerURL}?css=style" /> + {DHTMLcss} + <script language="javascript" src="{InstallerURL}?js={JS}"></script> <meta name="description" content="This is the Web Interface of the PEAR Installer" /> </head> @@ -51,6 +53,11 @@ Package Management </a> <br><br><br> + <a href="{InstallerURL}?command=search"> + <img src="{InstallerURL}?img=pkgsearch" border="0" alt="Package Search"><br> + Package Search + </a> + <br><br><br> <a href="{InstallerURL}?command=config-show"> <img src="{InstallerURL}?img=config" border="0" alt="Configuration"><br> Configuration @@ -81,7 +88,7 @@ <TD valign="middle" width="10"> </TD> <TD valign="middle"> - <img src="{InstallerURL}?img={_Icon}" border="0" alt="{_Icon}"> + <img src="{_InstallerURL}?img={_Icon}" border="0" alt="{_Icon}"> </TD> <TD valign="middle" width="5"> </TD> Index: pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.2 pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.2 Wed May 29 09:20:09 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html Sat Jun 1 15:01:01 2002 @@ -1,18 +1,18 @@ <!-- INCLUDE header.inc.tpl.html --> <!-- BEGIN Category --> - <TABLE border="0"> + <TABLE border="0" onClick="expandCategory('__{categoryName}');" class="DHTML_Category_Expand" > <TR> <TD width="20"> </TD> <TD> - <img src="{ImgCategory}" border="0"> + <img src="{ImgCategory}" border="0" alt="{categoryName}"> </TD> <TD> <b>{categoryName}</b> </TD> </TR> </TABLE> - <TABLE border="0"> + <TABLE border="0" id="__{categoryName}" class="DHTML_Category"> <TR> <TD width="50" valign="top"> </TD> Index: pear/PEAR_Frontend_Web/Frontend/Web/style.css diff -u pear/PEAR_Frontend_Web/Frontend/Web/style.css:1.2 pear/PEAR_Frontend_Web/Frontend/Web/style.css:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/style.css:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/style.css Sat Jun 1 15:01:01 2002 @@ -1,4 +1,4 @@ -a:normal { +a { color:#000000; text-decoration: none; } @@ -15,6 +15,23 @@ text-decoration: underline; } +a.green { + color:#006600; + text-decoration: none; +} +a.green:visited { + color:#006600; + text-decoration: none; +} +a.green:active { + color:#006600; + text-decoration: none; +} +a.green:hover { + color:#006600; + text-decoration: underline; +} + body, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 90%; @@ -29,6 +46,11 @@ background: #009933; text-align: right; } + +td.package_info_title { + color: #006600; + font-weight: bold; +} th.others { color: #006600; Index: pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.3 pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.4 --- pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.3 Wed May 29 09:20:09 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html Sat Jun 1 15:01:01 2002 @@ -4,11 +4,11 @@ <TABLE border="0"> <!-- BEGIN InputField --> <TR> - <TD> + <TD {width} valign="top"> <b>{prompt}:</b> </TD> - <TD> - <input type="{type}" name="{prompt}" value="{default}" size="50"> + <TD valign="top"> + <input type="{type}" name="{name}" value="{default}" size="50"> </TD> </TR> <!-- END InputField --> Index: pear/PEAR_Frontend_Web/Frontend/Web/dhtml.css +++ pear/PEAR_Frontend_Web/Frontend/Web/dhtml.css table.DHTML_Category { display: none; } table.DHTML_Category_Expand { cursor: hand; } Index: pear/PEAR_Frontend_Web/Frontend/Web/dhtml.js +++ pear/PEAR_Frontend_Web/Frontend/Web/dhtml.js function expandCategory(name) { document.all[name].style.display = (document.all[name].style.display == 'inline' ? 'none' : 'inline'); } Index: pear/PEAR_Frontend_Web/Frontend/Web/nodhtml.js +++ pear/PEAR_Frontend_Web/Frontend/Web/nodhtml.js function expandCategory(name) { } Index: pear/PEAR_Frontend_Web/Frontend/Web/package.info.tpl.html +++ pear/PEAR_Frontend_Web/Frontend/Web/package.info.tpl.html <!-- INCLUDE header.inc.tpl.html --> <TABLE border="0"> <TR> <TD width="10" valign="top" rowspan="6"> </TD> <TD width="100" valign="top" class="package_info_title"> Package </TD> <TD width="300" valign="top"> {Package} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Installed </TD> <TD width="300" valign="top"> {Installed} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Latest </TD> <TD width="300" valign="top"> {Latest} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Summary </TD> <TD width="300" valign="top"> {Summary} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Description </TD> <TD width="300" valign="top"> {Description} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Options </TD> <TD width="300" valign="top"> <TABLE border="0" cellspacing="0" cellpadding="0"> <TR> <TD align="center"> {Opt_Img_1} </TD> <TD width="5"> </TD> <TD valign="middle"> {Opt_Text_1} </TD> </TR> <TR> <TD height="4"></TD> </TR> <TR> <TD align="center"> {Opt_Img_2} </TD> <TD width="5"> </TD> <TD valign="middle"> {Opt_Text_2} </TD> </TR> </TABLE> </TD> </TR> </TABLE> <!-- INCLUDE footer.inc.tpl.html -->
Index: pear/PEAR_Frontend_Web/WebInstaller.php diff -u pear/PEAR_Frontend_Web/WebInstaller.php:1.2 pear/PEAR_Frontend_Web/WebInstaller.php:1.3 --- pear/PEAR_Frontend_Web/WebInstaller.php:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/WebInstaller.php Sat Jun 1 15:00:57 2002 @@ -9,11 +9,22 @@ { $images = array( "style" => "style.css", + "dhtml" => "dhtml.css", ); Header("Content-Type: text/css"); readfile(dirname(__FILE__).'/Frontend/Web/'.$images[$_GET["css"]]); exit; }; + if (isset($_GET["js"])) + { + $js = array( + "dhtml" => "dhtml.js", + "nodhtml" => "nodhtml.js", + ); + Header("Content-Type: text/js"); + readfile(dirname(__FILE__).'/Frontend/Web/'.$js[$_GET["js"]]); + exit; + }; if (isset($_GET["img"])) { $images = array( @@ -33,6 +44,10 @@ "type" => "png", "file" => "pkglist.png", ), + "pkgsearch" => array( + "type" => "png", + "file" => "pkgsearch.png", + ), "package" => array( "type" => "jpeg", "file" => "package.jpg", @@ -103,6 +118,30 @@ $URL .= '#'.$_GET["pkg"]; Header("Location: ".$URL); + exit; + case 'remote-info': + $command = $_GET["command"]; + $params = array($_GET["pkg"]); + $cmd = PEAR_Command::factory($command, $config); + $ok = $cmd->run($command, $opts, $params); + + if (!$ok) { + PEAR::raiseError(''); + }; + exit; + case 'search': + list($name, $description) = $ui->userDialog('search', + array('Package Name', 'Package Info'), + array(), array(), 'Package Search', 'pkgsearch'); + + $command = $_GET["command"]; + $params = array($name, $description); + $cmd = PEAR_Command::factory($command, $config); + $ok = $cmd->run($command, $opts, $params); + + if (!$ok) { + PEAR::raiseError(''); + }; exit; case 'config-show': $cmd = PEAR_Command::factory($command, $config); Index: pear/PEAR_Frontend_Web/package.xml diff -u pear/PEAR_Frontend_Web/package.xml:1.2 pear/PEAR_Frontend_Web/package.xml:1.3 --- pear/PEAR_Frontend_Web/package.xml:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/package.xml Sat Jun 1 15:00:57 2002 @@ -31,6 +31,7 @@ <dir name="Frontend" baseinstalldir="PEAR/Frontend"> <file role="php">Web.php</file> <dir name="Web" baseinstalldir="PEAR/Frontend/Web"> + <!-- Images --> <file role="php">error.gif</file> <file role="php">pearsmall.gif</file> <file role="php">trash.gif</file> @@ -39,13 +40,24 @@ <file role="php">infoplus.gif</file> <file role="php">package.jpg</file> <file role="php">category.jpg</file> - <file role="php">pkglist.png</file> <file role="php">config.gif</file> <file role="php">login.gif</file> <file role="php">logout.gif</file> + <file role="php">pkglist.png</file> + <file role="php">pkgsearch.png</file> + + <!-- CSS --> <file role="php">style.css</file> + <file role="php">dhtml.css</file> + + <!-- JS --> + <file role="php">dhtml.js</file> + <file role="php">nodhtml.js</file> + + <!-- TEMPLATES --> <file role="php">userDialog.tpl.html</file> <file role="php">package.list.tpl.html</file> + <file role="php">package.info.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> Index: pear/PEAR_Frontend_Web/Frontend/Web.php diff -u pear/PEAR_Frontend_Web/Frontend/Web.php:1.4 pear/PEAR_Frontend_Web/Frontend/Web.php:1.5 --- pear/PEAR_Frontend_Web/Frontend/Web.php:1.4 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web.php Sat Jun 1 15:01:00 2002 @@ -16,11 +16,12 @@ | Author: Christian Dickmann <dickmann@php.net> | +----------------------------------------------------------------------+ - $Id: Web.php,v 1.4 2002/05/29 22:26:05 dickmann Exp $ + $Id: Web.php,v 1.5 2002/06/01 19:01:00 dickmann Exp $ */ require_once "PEAR.php"; require_once "HTML/IT.php"; +require_once "Net/UserAgent/Detect.php"; class PEAR_Frontend_Web extends PEAR { @@ -65,7 +66,7 @@ // }}} // {{{ displayError(eobj) - function initTemplate($file, $title = '', $icon = '') + function initTemplate($file, $title = '', $icon = '', $useDHTML = true) { $tpl = new IntegratedTemplate(dirname(__FILE__)."/Web"); $tpl->loadTemplateFile($file); @@ -76,21 +77,44 @@ if ($icon) { $tpl->setCurrentBlock("TitleBlock"); + $tpl->setVariable("_InstallerURL", $_SERVER["PHP_SELF"]); $tpl->setVariable("_Title", $title); $tpl->setVariable("_Icon", $icon); + $tpl->parseCurrentBlock(); }; + $tpl->setCurrentBlock(); + + if ($useDHTML && Net_UserAgent_Detect::getBrowser('ie5up') == 'ie5up') + $dhtml = true; + else + $dhtml = false; + + if ($dhtml) + { + $tpl->setVariable("JS", 'dhtml'); + $css = '<link rel="stylesheet" href="'.$_SERVER['PHP_SELF'].'?css=dhtml" />'; + $tpl->setVariable("DHTMLcss", $css); + } else { + $tpl->setVariable("JS", 'nodhtml'); + }; + return $tpl; } - function displayError($eobj) + function displayError($eobj, $title = 'Error', $img = 'error') { $msg = ''; if (trim($GLOBALS['_PEAR_Frontend_Web_log'])) $msg = trim($GLOBALS['_PEAR_Frontend_Web_log'])."\n\n"; - $msg .= trim($eobj->getMessage()); + + if (PEAR::isError($eobj)) + $msg .= trim($eobj->getMessage()); + else + $msg .= trim($eobj); + $msg = nl2br($msg."\n"); - $tpl = $this->initTemplate("error.tpl.html", "Error", 'error'); + $tpl = $this->initTemplate("error.tpl.html", $title, $img); $tpl->setVariable("Error", $msg); $command_map = array( @@ -112,9 +136,9 @@ // }}} // {{{ displayFatalError(eobj) - function displayFatalError($eobj) + function displayFatalError($eobj, $title = 'Error', $img = 'error') { - $this->displayError($eobj); + $this->displayError($eobj, $title, $img); exit(1); } @@ -147,9 +171,9 @@ // }}} - function _outputListAll($data) + function _outputListAll($data, $title = 'Install / Upgrade / Remove PEAR Packages', $img = 'pkglist', $useDHTML = true) { - $tpl = $this->initTemplate("package.list.tpl.html", 'Install / Upgrade / Remove PEAR Packages', 'pkglist'); + $tpl = $this->initTemplate("package.list.tpl.html", $title, $img, $useDHTML); foreach($data['data'] as $category => $packages) { @@ -176,10 +200,10 @@ $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); $inst = ''; }; - $info=sprintf('<a href="%s?info=%s#%s"><img src="%s?img=info" border="0" alt="info"></a>', - $_SERVER["PHP_SELF"], $row[0], $row[0], $_SERVER["PHP_SELF"]); - $infoExt=sprintf('<a href="%s?pacid=%s"><img src="%s?img=infoplus" border="0" alt="extended info"></a>', - 'http://pear.php.net/package-info.php', $row[4], $_SERVER["PHP_SELF"]); + $info=sprintf('<a href="%s?command=remote-info&pkg=%s"><img src="%s?img=info" border="0" alt="info"></a>', + $_SERVER["PHP_SELF"], $row[0], $_SERVER["PHP_SELF"]); + $infoExt=sprintf('<a href="%s?package=%s"><img src="%s?img=infoplus" border="0" alt="extended info"></a>', + 'http://pear.php.net/package-info.php', $row[0], $_SERVER["PHP_SELF"]); if ($row[0] == 'PEAR' || $row[0] == 'Archive_Tar') $del = ''; @@ -203,6 +227,68 @@ } + function _outputPackageInfo($data) + { + $tpl = $this->initTemplate("package.info.tpl.html", 'Package Management :: '.$data['name'], 'pkglist'); + + $tpl->setVariable("Latest", $data['stable']); + $tpl->setVariable("Installed", $data['installed']); + $tpl->setVariable("Package", $data['name']); + $tpl->setVariable("Licence", $data['licence']); + $tpl->setVariable("Category", $data['category']); + $tpl->setVariable("Summary", nl2br($data['summary'])); + $tpl->setVariable("Description", nl2br($data['description'])); + + $compare = version_compare($data['stable'], $data['installed']); + if (!$data['installed']) { + $opt_img_1 = sprintf( + '<a href="%s?command=install&pkg=%s"><img src="%s?img=install" border="0" alt="install"></a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_1 = sprintf( + '<a href="%s?command=install&pkg=%s" class="green">Install</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_img_2 = ''; + } else if ($compare == 1) { + $opt_img_1 = sprintf( + '<a href="%s?command=upgrade&pkg=%s"><img src="%s?img=install" border="0" alt="upgrade"></a><br>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_1 = sprintf( + '<a href="%s?command=upgrade&pkg=%s" class="green">Upgrade</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_img_2 = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0" alt="uninstall"></a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_2 = sprintf( + '<a href="%s?command=uninstall&pkg=%s" class="green">Delete</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + } else { + $opt_img_1 = sprintf( + '<a href="%s?command=uninstall&pkg=%s"><img src="%s?img=uninstall" border="0" alt="uninstall"></a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_text_1 = sprintf( + '<a href="%s?command=uninstall&pkg=%s" class="green">Delete</a>', + $_SERVER["PHP_SELF"], $data['name'], $_SERVER["PHP_SELF"]); + $opt_img_2 = ''; + }; + + if ($opt_img_1) + { + $tpl->setVariable("Opt_Img_1", $opt_img_1); + $tpl->setVariable("Opt_Text_1", $opt_text_1); + }; + if ($opt_img_2) + { + $tpl->setVariable("Opt_Img_2", $opt_img_2); + $tpl->setVariable("Opt_Text_2", $opt_text_2); + }; + + $tpl->show(); + + + + + } + function outputData($data, $command) { switch ($command) @@ -210,18 +296,22 @@ 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[] = ''; + foreach($data['data'] as $group) { + foreach($group as $row) { + $prompt[$row[1]] = $row[0]; + $default[$row[1]] = $row[2]; + }; }; + $title = 'Configuration :: '.$GLOBALS['pear_user_config']; $GLOBALS['_PEAR_Frontend_Web_Config'] = - $this->userDialog($command, $prompt, array(), $default, 'Configuration', 'config'); + $this->userDialog($command, $prompt, array(), $default, $title, 'config'); return true; case 'list-all': return $this->_outputListAll($data); + case 'search': + return $this->_outputListAll($data, 'Package Search :: Result', 'pkgsearch', false); + case 'remote-info': + return $this->_outputPackageInfo($data); case 'install': case 'uninstall': return true; @@ -230,7 +320,7 @@ $this->data[$command] = $data; return true; case 'logout': - PEAR::raiseError($data); + $this->displayError($data, 'Logout', 'logout'); break; case 'package': echo $data; @@ -248,8 +338,8 @@ && $_SERVER["REQUEST_METHOD"] == "POST") { $result = array(); - foreach($prompts as $prompt) - $result[$prompt] = $_POST[$prompt]; + foreach($prompts as $key => $prompt) + $result[$key] = $_POST[$key]; return $result; }; @@ -259,13 +349,24 @@ if (is_array($prompts)) { + $maxlen = 0; + foreach($prompts as $key => $prompt) + { + if (strlen($prompt) > $maxlen) { + $maxlen = strlen($prompt); + }; + }; + foreach($prompts as $key => $prompt) { $tpl->setCurrentBlock("InputField"); $type = (isset($types[$key]) ? $types[$key] : 'text'); $tpl->setVariable("prompt", $prompt); + $tpl->setVariable("name", $key); $tpl->setVariable("default", $defaults[$key]); $tpl->setVariable("type", $type); + if ($maxlen > 25) + $tpl->setVariable("width", 'width="275"'); $tpl->parseCurrentBlock(); }; }; Index: pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html:1.2 pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/error.tpl.html Sat Jun 1 15:01:01 2002 @@ -6,9 +6,8 @@ <TD> {Error} <br> - <a href="{InstallerURL}{param}">Back</a> + <a href="{InstallerURL}{param}" class="green">Back</a> </TD> </TR> </TABLE> -</BODY> -</HTML> \ No newline at end of file +<!-- INCLUDE footer.inc.tpl.html --> Index: pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.3 pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.4 --- pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html:1.3 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/header.inc.tpl.html Sat Jun 1 15:01:01 2002 @@ -3,6 +3,8 @@ <head> <title>PEAR :: Installer :: {Title}</title> <link rel="stylesheet" href="{InstallerURL}?css=style" /> + {DHTMLcss} + <script language="javascript" src="{InstallerURL}?js={JS}"></script> <meta name="description" content="This is the Web Interface of the PEAR Installer" /> </head> @@ -51,6 +53,11 @@ Package Management </a> <br><br><br> + <a href="{InstallerURL}?command=search"> + <img src="{InstallerURL}?img=pkgsearch" border="0" alt="Package Search"><br> + Package Search + </a> + <br><br><br> <a href="{InstallerURL}?command=config-show"> <img src="{InstallerURL}?img=config" border="0" alt="Configuration"><br> Configuration @@ -81,7 +88,7 @@ <TD valign="middle" width="10"> </TD> <TD valign="middle"> - <img src="{InstallerURL}?img={_Icon}" border="0" alt="{_Icon}"> + <img src="{_InstallerURL}?img={_Icon}" border="0" alt="{_Icon}"> </TD> <TD valign="middle" width="5"> </TD> Index: pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.2 pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html:1.2 Wed May 29 09:20:09 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/package.list.tpl.html Sat Jun 1 15:01:01 2002 @@ -1,18 +1,18 @@ <!-- INCLUDE header.inc.tpl.html --> <!-- BEGIN Category --> - <TABLE border="0"> + <TABLE border="0" onClick="expandCategory('__{categoryName}');" class="DHTML_Category_Expand" > <TR> <TD width="20"> </TD> <TD> - <img src="{ImgCategory}" border="0"> + <img src="{ImgCategory}" border="0" alt="{categoryName}"> </TD> <TD> <b>{categoryName}</b> </TD> </TR> </TABLE> - <TABLE border="0"> + <TABLE border="0" id="__{categoryName}" class="DHTML_Category"> <TR> <TD width="50" valign="top"> </TD> Index: pear/PEAR_Frontend_Web/Frontend/Web/style.css diff -u pear/PEAR_Frontend_Web/Frontend/Web/style.css:1.2 pear/PEAR_Frontend_Web/Frontend/Web/style.css:1.3 --- pear/PEAR_Frontend_Web/Frontend/Web/style.css:1.2 Wed May 29 18:26:05 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/style.css Sat Jun 1 15:01:01 2002 @@ -1,4 +1,4 @@ -a:normal { +a { color:#000000; text-decoration: none; } @@ -15,6 +15,23 @@ text-decoration: underline; } +a.green { + color:#006600; + text-decoration: none; +} +a.green:visited { + color:#006600; + text-decoration: none; +} +a.green:active { + color:#006600; + text-decoration: none; +} +a.green:hover { + color:#006600; + text-decoration: underline; +} + body, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 90%; @@ -29,6 +46,11 @@ background: #009933; text-align: right; } + +td.package_info_title { + color: #006600; + font-weight: bold; +} th.others { color: #006600; Index: pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html diff -u pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.3 pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.4 --- pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html:1.3 Wed May 29 09:20:09 2002 +++ pear/PEAR_Frontend_Web/Frontend/Web/userDialog.tpl.html Sat Jun 1 15:01:01 2002 @@ -4,11 +4,11 @@ <TABLE border="0"> <!-- BEGIN InputField --> <TR> - <TD> + <TD {width} valign="top"> <b>{prompt}:</b> </TD> - <TD> - <input type="{type}" name="{prompt}" value="{default}" size="50"> + <TD valign="top"> + <input type="{type}" name="{name}" value="{default}" size="50"> </TD> </TR> <!-- END InputField --> Index: pear/PEAR_Frontend_Web/Frontend/Web/dhtml.css +++ pear/PEAR_Frontend_Web/Frontend/Web/dhtml.css table.DHTML_Category { display: none; } table.DHTML_Category_Expand { cursor: hand; } Index: pear/PEAR_Frontend_Web/Frontend/Web/dhtml.js +++ pear/PEAR_Frontend_Web/Frontend/Web/dhtml.js function expandCategory(name) { document.all[name].style.display = (document.all[name].style.display == 'inline' ? 'none' : 'inline'); } Index: pear/PEAR_Frontend_Web/Frontend/Web/nodhtml.js +++ pear/PEAR_Frontend_Web/Frontend/Web/nodhtml.js function expandCategory(name) { } Index: pear/PEAR_Frontend_Web/Frontend/Web/package.info.tpl.html +++ pear/PEAR_Frontend_Web/Frontend/Web/package.info.tpl.html <!-- INCLUDE header.inc.tpl.html --> <TABLE border="0"> <TR> <TD width="10" valign="top" rowspan="6"> </TD> <TD width="100" valign="top" class="package_info_title"> Package </TD> <TD width="300" valign="top"> {Package} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Installed </TD> <TD width="300" valign="top"> {Installed} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Latest </TD> <TD width="300" valign="top"> {Latest} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Summary </TD> <TD width="300" valign="top"> {Summary} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Description </TD> <TD width="300" valign="top"> {Description} </TD> </TR> <TR> <TD width="100" valign="top" class="package_info_title"> Options </TD> <TD width="300" valign="top"> <TABLE border="0" cellspacing="0" cellpadding="0"> <TR> <TD align="center"> {Opt_Img_1} </TD> <TD width="5"> </TD> <TD valign="middle"> {Opt_Text_1} </TD> </TR> <TR> <TD height="4"></TD> </TR> <TR> <TD align="center"> {Opt_Img_2} </TD> <TD width="5"> </TD> <TD valign="middle"> {Opt_Text_2} </TD> </TR> </TABLE> </TD> </TR> </TABLE> <!-- INCLUDE footer.inc.tpl.html -->