cvs: pearweb /public_html category-manager.php /public_html/admin category-manager.php index.php /templates category-manager.html
| From: | Martin Jansen | Date: | Mon, 09 Jun 2003 07:47:04 +0000 |
| Subject: | cvs: pearweb /public_html category-manager.php /public_html/admin category-manager.php index.php /templates category-manager.html | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-10790@lists.php.net to get a copy of this message | ||
mj Mon Jun 9 03:47:04 2003 EDT
Added files:
/pearweb/public_html/admin category-manager.php
Removed files:
/pearweb/public_html category-manager.php
Modified files:
/pearweb/templates category-manager.html
/pearweb/public_html/admin index.php
Log:
* Moving the category manager to /admin
Index: pearweb/templates/category-manager.html
diff -u pearweb/templates/category-manager.html:1.1 pearweb/templates/category-manager.html:1.2
--- pearweb/templates/category-manager.html:1.1 Sun Dec 1 13:37:31 2002
+++ pearweb/templates/category-manager.html Mon Jun 9 03:47:04 2003
@@ -1,6 +1,6 @@
<?response_header()?>
-<script language="JavaScript" type="text/javascript"
src="javascript/TreeMenu/TreeMenu.js"></script>
+<script language="JavaScript" type="text/javascript"
src="/javascript/TreeMenu/TreeMenu.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
currentHighlight = null;
Index: pearweb/public_html/admin/index.php
diff -u pearweb/public_html/admin/index.php:1.2 pearweb/public_html/admin/index.php:1.3
--- pearweb/public_html/admin/index.php:1.2 Mon Jun 9 03:42:26 2003
+++ pearweb/public_html/admin/index.php Mon Jun 9 03:47:04 2003
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Authors: Martin Jansen <mj@php.net> |
+----------------------------------------------------------------------+
- $Id: index.php,v 1.2 2003/06/09 07:42:26 mj Exp $
+ $Id: index.php,v 1.3 2003/06/09 07:47:04 mj Exp $
*/
auth_require(true);
@@ -36,6 +36,7 @@
response_header("PEAR Administration");
menu_link("Package maintainers", "package-maintainers.php");
+menu_link("Manage categories", "category-manager.php");
echo hdelim();
// {{{ adding and deleting notes
Index: pearweb/public_html/admin/category-manager.php
+++ pearweb/public_html/admin/category-manager.php
<?php
/*
+----------------------------------------------------------------------+
| PEAR Web site version 1.0 |
+----------------------------------------------------------------------+
| Copyright (c) 2001-2003 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. |
+----------------------------------------------------------------------+
| Authors: Richard Heyes |
+----------------------------------------------------------------------+
$Id: category-manager.php,v 1.1 2003/06/09 07:47:04 mj Exp $
*/
auth_require(true);
/**
* TODO
*
* o Present options of what to do with orphaned packages when
* deleting categories.
*/
$template_dir = dirname(dirname(__FILE__)) . '/../templates/';
/**
* Function to recurse thru the tree adding nodes to treemenu
*/
function parseTree(&$structure, $parent = null)
{
global $dbh;
$parent = is_null($parent) ? 'IS NULL' : '= ' . $parent;
// Get categories
$categories = $dbh->getAll(sprintf('SELECT id, parent, name, description, npackages
'
. 'FROM categories WHERE parent %s ORDER BY name,
id',
$parent
),
null,
DB_FETCHMODE_ASSOC
);
if (count($categories)) {
foreach ($categories as $cat) {
$newNode = &$structure->addItem(new HTML_TreeNode(array('text' =>
htmlspecialchars($cat['name']),
'icon' =>
'folder.gif'),
array('onclick' =>
'category_click(event, this, ' . $cat['id'] . ')')
)
);
parseTree($newNode, $cat['id']);
}
}
}
/**
* Form submitted?
*/
if (!empty($_POST)) {
include_once '../../include/pear-category.php';
switch (@$_POST['action']) {
case 'add':
if (!empty($_POST['catDesc']) AND !empty($_POST['catName'])) {
$result = category::add(array('name' => $_POST['catName'],
'desc' => $_POST['catDesc'],
'parent' =>
!empty($_POST['cat_parent']) ? (int)$_POST['cat_parent'] : null));
$_SESSION['category_manager']['error_msg'] = PEAR::isError($result)
? 'Failed to insert category: ' . $result->message : 'Category added';
} else {
$_SESSION['category_manager']['error_msg'] = 'Please enter a
name and description!';
}
localRedirect('category-manager.php');
break;
case 'update':
if (!empty($_POST['catDesc']) AND !empty($_POST['catName'])) {
$result = category::update((int)$_POST['cat_parent'],
$_POST['catName'], $_POST['catDesc']);
$_SESSION['category_manager']['error_msg'] = PEAR::isError($result)
? 'Failed to insert category: ' . $result->message : 'Category updated';
} else {
$_SESSION['category_manager']['error_msg'] = 'Please enter a
name and description!';
}
localRedirect('category-manager.php');
break;
case 'delete':
if (!empty($_POST['cat_parent'])) {
$result = category::delete($_POST['cat_parent']);
$_SESSION['category_manager']['error_msg'] = PEAR::isError($result)
? 'Failed to delete category: ' . $result->message : 'Category deleted';
} else {
$_SESSION['category_manager']['error_msg'] = 'Please select a
category';
}
localRedirect('category-manager.php');
break;
default:
localRedirect('category-manager.php');
}
}
/**
* Create the menu, set the db to assoc mode
*/
require_once('HTML/TreeMenu.php');
$treeMenu = new HTML_TreeMenu();
/**
* Get the categories
*/
parseTree($treeMenu);
/**
* Template
*/
// Check for any error msg
if (!empty($_SESSION['category_manager']['error_msg'])) {
$message = $_SESSION['category_manager']['error_msg'];
unset($_SESSION['category_manager']['error_msg']);
}
$categories = $dbh->getAll('SELECT id, name, description FROM categories ORDER BY
id', null, DB_FETCHMODE_ASSOC);
$treeMenuPres = new HTML_TreeMenu_DHTML($treeMenu, array('images' =>
'../gifs/TreeMenu', 'defaultClass' => 'treeMenuOff'));
include($template_dir . 'category-manager.html');
?>