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 'pear-database-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('/admin/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('/admin/category-manager.php'); break;
<?php require 'load.php'; //init_sitepath(); $c = new category(); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'add': $e = $c->add($db); break; case 'modify': $e = $c->modify($db); break; /*case 'edit': $e = $c->edit($db); break;*/ /*case 'edit': $e = $c->edit($db); break;*/ case 'delete': if (!isset($_GET['cid'])) { $e = ERROR::err('非法访问!'); break; } $e = $c->_delete($db, $_GET['cid']); break; default: $e = ''; break; } $classes = $c->_list($db, 0);
$menus = array(array('添加分类', '?file=' . $file . '&action=add&mid=' . $mid . '&parentid=' . $parentid), array('管理分类', '?file=' . $file . '&mid=' . $mid), array('分类复制', '?file=' . $file . '&action=copy&mid=' . $mid), array('批量索引', '?file=' . $file . '&action=letters&mid=' . $mid), array('更新地址', '?file=' . $file . '&action=url&mid=' . $mid), array('更新统计', '?file=' . $file . '&action=count&mid=' . $mid), array('更新缓存', '?file=' . $file . '&action=cache&mid=' . $mid)); if (strpos($forward, 'category') === false) { $forward = '?file=' . $file . '&mid=' . $mid . '&parentid=' . $parentid . '&kw=' . urlencode($kw); } switch ($action) { case 'add': if ($submit) { if (!$category['catname']) { msg('分类名不能为空'); } $category['catname'] = trim($category['catname']); $childs = ''; $catids = array(); if (strpos($category['catname'], "\n") === false) { $category['catdir'] = $do->get_catdir($category['catdir']); $do->add($category); $childs .= ',' . $do->catid; $catids[] = $do->catid; } else { $catnames = explode("\n", $category['catname']); foreach ($catnames as $catname) { $catname = trim($catname); if (!$catname) { continue; } $category['catname'] = $catname; $category['catdir'] = ''; $category['letter'] = ''; $category['seo_title'] = ''; $category['seo_keywords'] = ''; $category['seo_description'] = '';
Date and Time;; File System;; HTML;; HTTP;; Images;; Logging;; Mail;; Math;; Networking;; Numbers;; Payment;; PEAR;PEAR infrastructure; Scheduling;; Science;; XML;; XML-RPC;;XML '; $catids = array(); foreach (explode("\n", $categories) as $line) { if (trim($line) == '') { continue; } list($name, $desc, $parent) = explode(";", trim($line)); $params = array('name' => $name, 'desc' => $desc); if (!empty($parent)) { $params['parent'] = $catids[$parent]; } $catid = category::add($params); $catids[$name] = $catid; print "Category: {$name}\n"; }