Пример #1
0
';
            continue;
        } else {
            $item .= 'item' . $val['pid'] . '.add(item' . $val['id'] . ');
';
            continue;
        }
    }
    $tp->set_templatefile('templates/category_add.html');
    $tp->assign('tree', $tree);
    $tp->assign('root', $root);
    $tp->assign('item', $item);
    $tp->assign('option', $option);
    $moduleTemplate = $tp->result();
    $moduleTitle = '添加采集器分类';
} else {
    if (!$_POST['title']) {
        error('分类名称不能为空!');
    }
    !$_POST['orderid'] ? $maxOrderID = $NC->getNodeMaxOrderID($_POST['pid']) : ($maxOrderID = $_POST['orderid']);
    $data['id'] = '';
    $data['pid'] = $_POST['pid'];
    $data['title'] = $_POST['title'];
    $data['orderid'] = $maxOrderID;
    $NC->addCategory($data);
    $catearray = $NC->getCategory();
    $getarray = $NC->getTree($catearray, 0, 0, 'category');
    $NC->doCategoryCache($getarray);
    showloading('?module=listCategory', '分类添加', '分类添加完毕,现在返回分类列表', 1);
    $tpShowBody = false;
}
Пример #2
0
$NDB = new MySQL(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);
$NCA->setCachePath('tmp/');
$NCA->setCacheFile('categoryCache');
$NC->setTable(TB_CATE);
$catData['id'] = 'id';
$catData['pid'] = 'pid';
$catData['orderid'] = 'orderid';
$NC->setField($catData);
$NC->setNDB($NDB);
$NC->setNBS($NBS);
$NC->setNCA($NCA);
if (!$_GET['action']) {
    if (!$_GET['CID']) {
        error('您要编辑哪个分类?');
    }
    $array = $NC->getCategory($_GET['CID']);
    $pid = $array['pid'];
    $pArray = $NC->getCategory($pid);
    $getarray = $NC->readCategoryCache();
    if (!is_array($getarray)) {
        $getarray = array();
    }
    $last = '├─';
    $option = '<option value=0>根目录</option>';
    foreach ($getarray as $key => $val) {
        $itemTemp = str_repeat('│', $val['deep']);
        $pid == $val['id'] ? $selected = ' selected' : ($selected = '');
        $option .= '<option' . $selected . ' value="' . $val['id'] . '">' . $itemTemp . $last . $val['title'] . '</option>
';
    }
    $tp->set_templatefile('templates/category_edit.html');