cvs: pearweb /public_html packages.php

From: Date: Sat, 01 Sep 2001 17:07:53 +0000
Subject: cvs: pearweb /public_html packages.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-730@lists.php.net to get a copy of this message
cox Sat Sep 1 13:07:53 2001 EDT Modified files: /pearweb/public_html packages.php Log: rewrite of the packages/categories browser Index: pearweb/public_html/packages.php diff -u pearweb/public_html/packages.php:1.7 pearweb/public_html/packages.php:1.8 --- pearweb/public_html/packages.php:1.7 Wed Aug 15 14:47:52 2001 +++ pearweb/public_html/packages.php Sat Sep 1 13:07:53 2001 @@ -1,63 +1,61 @@ <?php - +require 'HTML/Table.php'; response_header("PEAR :: Packages"); -if (empty($domain)) { - $package_where = "packages.parent IS NULL"; - $package_title = "Package Browser"; +// expected url vars: catpid (category parent id), catname +$catpid = (isset($catpid)) ? (int) $catpid : null; +// ** expected + +if (empty($catpid)) { + $category_where = "categories.parent IS NULL"; + $category_title = "Package Browser: Top Level Categories"; } else { - $package_where = "packages.parent = '$domain'"; - $package_title = "Package Browser: $domain"; + $category_where = "categories.parent = $catpid"; + $category_title = "Package Browser: " . urldecode($catname); } -$sth = $dbh->query("SELECT packages.name, packages.leftvisit, packages.rightvisit, packages.virtual, releases.version FROM packages LEFT JOIN releases ON packages.name = releases.package WHERE $package_where"); +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$dbh->setFetchmode(DB_FETCHMODE_ASSOC); -//$sth = $dbh->query("SELECT * FROM packages WHERE $package_where"); +// 1) Show categories of this level +echo '<table border="0" width="100%"><tr><td>'; -print "<h2>$package_title</h2>\n"; +$sth = $dbh->query("SELECT * from categories WHERE $category_where"); -border_box_start(array("Package", "Stable", "Sub-packages")); -$i = 0; -while ($sth->fetchInto($row, DB_FETCHMODE_ASSOC) === DB_OK) { - if (++$i % 2) { - $bg1 = "#ffffff"; - $bg2 = "#f0f0f0"; - } else { - $bg1 = "#f0f0f0"; - $bg2 = "#e0e0e0"; - } - print " <tr>\n"; +$table = new HTML_Table('border="1" cellpadding="1" cellspacing="1" width="90%" align="center"'); +$nrow = 0; +while ($sth->fetchInto($row)) { extract($row); - if ($leftvisit && $rightvisit) { - $lv = $leftvisit + 1; - $num = ($rightvisit - $leftvisit - 1) / 2; - //$num = $dbh->getOne("SELECT COUNT(name) FROM packages WHERE leftvisit BETWEEN $lv AND $rightvisit"); - } else { - $num = 0; - } - print " <td bgcolor=\"$bg1\">"; - if ($placeholder) { - print "$name"; - } else { - print "<a href=\"pkginfo.php?package=$name\">$name</a>"; - } - print "</td>\n <td bgcolor=\"$bg2\">"; - if ($version) { - print "<a href=\"pkginfo.php?package=$name&release=$version\">"; - print "$version</a>"; - } else { - print "&nbsp;"; + if (!$npackages) { + //continue; // XXXX Uncomment me to only show categories with packages + } // XXXX change me with elseif + if ($nrow == 0) { + $table->addRow(array("Categories", "Sub.<br>categories", "Num.<br>Packages", "Summary"), + null, 'TH'); } - print "</td>\n <td bgcolor=\"$bg1\">"; - if ($num > 0) { - print "$num <a href=\"$PHP_SELF?domain=$name\">sub-packages</a>"; - } else { - print "&nbsp;"; + $bg = ($nrow++ % 2) ? '#f0f0f0' : '#e0e0e0'; + $childs = ($rightvisit - $leftvisit - 1) / 2; + if (!$childs) { + $childs = '0'; } - print "</td>\n </tr>\n"; + $name = "<a href=\"$PHP_SELF?catpid=$id&catname=".urlencode($name)."\">$name</a>"; + + $table->addRow(array($name, $childs, $npackages, $summary)); + $table->setCellAttributes($nrow, 0, "width=\"20%\" bgcolor=\"$bg\""); + $table->setCellAttributes($nrow, 1, "width=\"10%\" bgcolor=\"$bg\" align=\"center\""); + $table->setCellAttributes($nrow, 2, "width=\"10%\" bgcolor=\"$bg\" align=\"center\""); + $table->setCellAttributes($nrow, 3, "width=\"60%\" bgcolor=\"$bg\""); +} +if ($nrow == 0) { + echo "<center><p>No sub-categories in this level yet</p></center>"; } -border_box_end(); +echo $table->toHTML(); +echo '</td></tr></table><br><hr width="60%">'; -response_footer(); +// 2) Show packages of this level +echo '<table border="0" width="100%"><tr><td>'; +echo "<center><p>No packages in this level yet</p></center>"; +echo '</td></tr></table>'; -?> +response_footer(); +?> \ No newline at end of file

« previous php.pear.cvs (#730) next »