cvs: pearweb /public_html category-manager.php

From: Date: Thu, 08 Aug 2002 14:02:00 +0000
Subject: cvs: pearweb /public_html category-manager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-5630@lists.php.net to get a copy of this message
cox Thu Aug 8 10:02:00 2002 EDT Modified files: /pearweb/public_html category-manager.php Log: Fix and reorder the code of the category manager Index: pearweb/public_html/category-manager.php diff -u pearweb/public_html/category-manager.php:1.9 pearweb/public_html/category-manager.php:1.10 --- pearweb/public_html/category-manager.php:1.9 Sun Jun 9 18:48:50 2002 +++ pearweb/public_html/category-manager.php Thu Aug 8 10:01:59 2002 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: category-manager.php,v 1.9 2002/06/09 22:48:50 richard Exp $ + $Id: category-manager.php,v 1.10 2002/08/08 14:01:59 cox Exp $ */ // manage categories @@ -28,33 +28,34 @@ $catid = (isset($catid)) ? (int) $catid : null; // ** expected -if (empty($catid)) { - $name = 'Top Level'; - $parent = 0; -} else { - if (isset($insert)) { +do { + // insert new category + if (!empty($newcatname) && !empty($newcatdesc)) { $data = array( - 'name' => $catname, - 'desc' => $catdesc, + 'name' => $newcatname, + 'desc' => $newcatdesc, 'parent' => $catid); if (PEAR::isError(category::add($data))) { $message = "Error while saving category"; } else { $message = "Successfully saved new category."; } - } elseif (isset($remove)) { - // XXXX TODO: implement remove categories } - $row = $dbh->getRow("SELECT name, parent FROM categories - WHERE id = $catid", DB_FETCHMODE_ASSOC); - extract($row); -} + if (empty($catid)) { + $name = 'Top Level'; + $parent = 0; + } else { + $row = $dbh->getRow("SELECT name, parent FROM categories + WHERE id = $catid", DB_FETCHMODE_ASSOC); + extract($row); + } +} while (false); if (isset($message)) { echo "<b><font color=\"#FF0000\">" . $message . "</font></b><br /><br />\n"; } ?> -<form action="<?php echo $GLOBALS['PHP_SELF'] . "?catid=$catid&insert=1"; ?>" method="post"> +<form action="<?php echo $GLOBALS['PHP_SELF'] . "?catid=$catid"; ?>" method="post"> <table border="0" cellpadding="2" cellspacing="1" width="100%"> <tr> <td rowspan="4" width="30%"><?php print get_categories_menu('tree');?></td> @@ -66,19 +67,12 @@ <?php $bb = new Borderbox("Insert new sub-category under: " . $name, "90%", "", 2, true); -$bb->plainRow("Name", "<input type=\"text\" name=\"catname\" size=\"15\" />"); -$bb->plainRow("Summary", "<input type=\"text\" name=\"catdesc\" size=\"40\" />"); +$bb->plainRow("Name", "<input type=\"text\" name=\"newcatname\" size=\"15\" />"); +$bb->plainRow("Summary", "<input type=\"text\" name=\"newcatdesc\" size=\"40\" />"); $bb->plainRow("<input type=\"submit\" name=\"action\" value=\"Insert\" />"); $bb->end(); - -if (isset($catid)) { - echo "<br /><br />\n"; - echo make_link($_SERVER['PHP_SELF'] . "?remove=" . $name, "Delete") . " category " . $name . "<br />\n"; - echo "<font color=\"red\">(Warning: This will delete <b>all</b> subcategories and <b>all</b> packages!)</font><br /><br />\n"; - print_link("/packages.php?catpid=" . $catid . "&catname=" . $name, "List"); - echo ' all packages from this category.</b>'; -} ?> +?> </tr> </table> </form>

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