当前位置: 首页>>代码示例>>PHP>>正文


PHP category::add方法代码示例

本文整理汇总了PHP中category::add方法的典型用法代码示例。如果您正苦于以下问题:PHP category::add方法的具体用法?PHP category::add怎么用?PHP category::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在category的用法示例。


在下文中一共展示了category::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

    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;
开发者ID:stof,项目名称:pearweb,代码行数:31,代码来源:category-manager.php

示例2: category

<?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);
开发者ID:NewMyCMS,项目名称:MyCMS,代码行数:31,代码来源:manage_category.php

示例3: array

$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'] = '';
开发者ID:hcd2008,项目名称:destoon,代码行数:31,代码来源:category.inc.php

示例4: array

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";
}
开发者ID:phpsource,项目名称:web-pecl,代码行数:31,代码来源:addcategories.php


注:本文中的category::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。