Ejemplo n.º 1
0
function part_categories($categories, &$existing_cat, $start_pos)
{
    $start_time = time();
    for ($i = $start_pos; $i < count($categories); $i++) {
        if (!term_exists($categories[$i]->ID, 'product_cat')) {
            //если категория не добавлена в базу
            if ($categories[$i]->ID == 'Order') {
                $parent_id = 0;
            }
            $parent_id = cat_exists($categories[$i]->ID_PARENT, $existing_cat, 'product_cat');
            wp_insert_category(array('cat_name' => $categories[$i]->Description, 'category_nicename' => $categories[$i]->ID, 'category_parent' => $parent_id, 'taxonomy' => 'product_cat'));
        }
        if (time() - $start_time > 20) {
            restart_load_categories($categories, $existing_cat, ++$i);
            break;
        }
    }
}
Ejemplo n.º 2
0
 $cat['cat_desc'] = !empty($_POST['cat_desc']) ? $_POST['cat_desc'] : '';
 $cat['measure_unit'] = !empty($_POST['measure_unit']) ? trim($_POST['measure_unit']) : '';
 $cat['cat_name'] = !empty($_POST['cat_name']) ? trim($_POST['cat_name']) : '';
 $cat['is_show'] = !empty($_POST['is_show']) ? intval($_POST['is_show']) : 0;
 /*by zhou*/
 $cat['is_top_show'] = !empty($_POST['is_top_show']) ? intval($_POST['is_top_show']) : 0;
 $cat['is_top_style'] = !empty($_POST['is_top_style']) ? intval($_POST['is_top_style']) : 0;
 /*by zhou*/
 $cat['show_in_nav'] = !empty($_POST['show_in_nav']) ? intval($_POST['show_in_nav']) : 0;
 $cat['style'] = !empty($_POST['style']) ? trim($_POST['style']) : '';
 $cat['grade'] = !empty($_POST['grade']) ? intval($_POST['grade']) : 0;
 $cat['filter_attr'] = !empty($_POST['filter_attr']) ? implode(',', array_unique(array_diff($_POST['filter_attr'], array(0)))) : 0;
 $cat['cat_recommend'] = !empty($_POST['cat_recommend']) ? $_POST['cat_recommend'] : array();
 /* 判断分类名是否重复 */
 if ($cat['cat_name'] != $old_cat_name) {
     if (cat_exists($cat['cat_name'], $cat['parent_id'], $cat_id)) {
         $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
         sys_msg($_LANG['catname_exist'], 0, $link);
     }
 }
 /* 判断上级目录是否合法 */
 $children = array_keys(cat_list($cat_id, 0, false));
 // 获得当前分类的所有下级分类
 if (in_array($cat['parent_id'], $children)) {
     /* 选定的父类是当前分类或当前分类的下级分类 */
     $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
     sys_msg($_LANG["is_leaf_error"], 0, $link);
 }
 if ($cat['grade'] > 10 || $cat['grade'] < 0) {
     /* 价格区间数超过范围 */
     $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
Ejemplo n.º 3
0
    $smarty->display('setting_second.htm');
} elseif ($_REQUEST['act'] == 'third') {
    admin_priv('goods_manage');
    $good_name = empty($_POST['good_name']) ? '' : $_POST['good_name'];
    $good_number = empty($_POST['good_number']) ? '' : $_POST['good_number'];
    $good_category = empty($_POST['good_category']) ? '' : $_POST['good_category'];
    $good_brand = empty($_POST['good_brand']) ? '' : $_POST['good_brand'];
    $good_price = empty($_POST['good_price']) ? 0 : $_POST['good_price'];
    $good_name = empty($_POST['good_name']) ? '' : $_POST['good_name'];
    $is_best = empty($_POST['is_best']) ? 0 : 1;
    $is_new = empty($_POST['is_new']) ? 0 : 1;
    $is_hot = empty($_POST['is_hot']) ? 0 : 1;
    $good_brief = empty($_POST['good_brief']) ? '' : $_POST['good_brief'];
    $market_price = $good_price * 1.2;
    if (!empty($good_category)) {
        if (cat_exists($good_category, 0)) {
            /* 同级别下不能有重复的分类名称 */
            $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
            sys_msg($_LANG['catname_exist'], 0, $link);
        }
    }
    if (!empty($good_brand)) {
        if (brand_exists($good_brand)) {
            /* 同级别下不能有重复的品牌名称 */
            $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
            sys_msg($_LANG['brand_name_exist'], 0, $link);
        }
    }
    $brand_id = 0;
    if (!empty($good_brand)) {
        $sql = 'INSERT INTO ' . $ecs->table('brand') . " (brand_name, is_show)" . " values('" . $good_brand . "', '1')";
Ejemplo n.º 4
0
function API_EditCategory($post)
{
    /* 加载后台主操作函数 */
    require_once ROOT_PATH . ADMIN_PATH . '/includes/lib_main.php';
    /* 初始化变量 */
    $cat_id = !empty($_POST['cat_id']) ? intval($_POST['cat_id']) : 0;
    $cat['parent_id'] = !empty($_POST['parent_id']) ? intval($_POST['parent_id']) : 0;
    $cat['sort_order'] = !empty($_POST['sort_order']) ? intval($_POST['sort_order']) : 0;
    $cat['keywords'] = !empty($_POST['keywords']) ? trim($_POST['keywords']) : '';
    $cat['cat_desc'] = !empty($_POST['cat_desc']) ? $_POST['cat_desc'] : '';
    $cat['measure_unit'] = !empty($_POST['measure_unit']) ? trim($_POST['measure_unit']) : '';
    $cat['cat_name'] = !empty($_POST['cat_name']) ? trim($_POST['cat_name']) : '';
    $cat['is_show'] = !empty($_POST['is_show']) ? intval($_POST['is_show']) : 0;
    $cat['show_in_nav'] = !empty($_POST['show_in_nav']) ? intval($_POST['show_in_nav']) : 0;
    $cat['style'] = !empty($_POST['style']) ? trim($_POST['style']) : '';
    $cat['grade'] = !empty($_POST['grade']) ? intval($_POST['grade']) : 0;
    $cat['filter_attr'] = !empty($_POST['filter_attr']) ? intval($_POST['filter_attr']) : 0;
    /* 判断上级目录是否合法 */
    $children = array_keys(cat_list($cat_id, 0, false));
    // 获得当前分类的所有下级分类
    if (in_array($cat['parent_id'], $children)) {
        /* 选定的父类是当前分类或当前分类的下级分类 */
        client_show_message(401);
    }
    if ($cat['grade'] > 10 || $cat['grade'] < 0) {
        /* 价格区间数超过范围 */
        client_show_message(402);
    }
    if (cat_exists($cat['cat_name'], $cat['parent_id'], $cat_id)) {
        /* 同级别下不能有重复的分类名称 */
        client_show_message(403);
    }
    $dat = $GLOBALS['db']->getRow("SELECT cat_name, show_in_nav FROM " . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '{$cat_id}'");
    if ($GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('category'), $cat, 'UPDATE', "cat_id='{$cat_id}'")) {
        if ($cat['cat_name'] != $dat['cat_name']) {
            //如果分类名称发生了改变
            $sql = "UPDATE " . $GLOBALS['ecs']->table('nav') . " SET name = '" . $cat['cat_name'] . "' WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'";
            $GLOBALS['db']->query($sql);
        }
        if ($cat['show_in_nav'] != $dat['show_in_nav']) {
            //是否显示于导航栏发生了变化
            if ($cat['show_in_nav'] == 1) {
                //显示
                $nid = $GLOBALS['db']->getOne("SELECT id FROM " . $GLOBALS['ecs']->table('nav') . " WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'");
                if (empty($nid)) {
                    //不存在
                    $vieworder = $GLOBALS['db']->getOne("SELECT max(vieworder) FROM " . $GLOBALS['ecs']->table('nav') . " WHERE type = 'middle'");
                    $vieworder += 2;
                    $uri = build_uri('category', array('cid' => $cat_id), $cat['cat_name']);
                    $sql = "INSERT INTO " . $GLOBALS['ecs']->table('nav') . " (name,ctype,cid,ifshow,vieworder,opennew,url,type) VALUES('" . $cat['cat_name'] . "', 'c', '{$cat_id}','1','{$vieworder}','0', '" . $uri . "','middle')";
                } else {
                    $sql = "UPDATE " . $GLOBALS['ecs']->table('nav') . " SET ifshow = 1 WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'";
                }
                $GLOBALS['db']->query($sql);
            } else {
                //去除
                $GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('nav') . " SET ifshow = 0 WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'");
            }
        }
    }
    /* 更新分類信息成功 */
    clear_cache_files();
    // 清除缓存
    admin_log($_POST['cat_name'], 'edit', 'category');
    // 记录管理员操作
    client_show_message(0, true);
}
Ejemplo n.º 5
0
     $is_exist = $GLOBALS['db']->getOne($sql_select);
     $sql_select = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('packing') . " WHERE packing_desc='{$goods_sn}'";
     $is_exist_package = $GLOBALS['db']->getOne($sql_select);
     if ($is_exist || $is_exist_package) {
         $res['req_msg'] = true;
         $res['message'] = '编号已被使用!';
         $res['timeout'] = 2000;
         die($json->encode($res));
     } else {
         $res['req_msg'] = false;
         die($json->encode($res));
     }
 } elseif ($_REQUEST['act'] == 'add_category') {
     $parent_id = empty($_REQUEST['parent_id']) ? 0 : intval($_REQUEST['parent_id']);
     $category = empty($_REQUEST['cat']) ? '' : trim($_REQUEST['cat']);
     if (cat_exists($category, $parent_id)) {
         $res['code'] = 1;
         $res['message'] = '分类存在';
         die($json->encode($res));
     } else {
         $sql_insert = 'INSERT INTO ' . $ecs->table('category') . '(cat_name, parent_id, is_show)' . " VALUES ( '{$category}', '{$parent_id}', 1)";
         $GLOBALS['db']->query($sql_insert);
         record_operate($sql_insert, 'category');
         $category_id = $GLOBALS['db']->insert_id();
         $res['id'] = $category_id;
         $res['parent_id'] = $parent_id;
         $res['cat'] = $category;
         die($json->encode($res));
     }
 } elseif ($_REQUEST['act'] == 'brand_manage') {
     if (!admin_priv('add_brand', '', false)) {
Ejemplo n.º 6
0
     if ($categories_count == 1) {
         $row = DB()->fetch_row("SELECT COUNT(*) AS forums_count FROM " . BB_FORUMS);
         if ($row['forums_count'] > 0) {
             bb_die($lang['MUST_DELETE_FORUMS']);
         } else {
             $template->assign_var('NOWHERE_TO_MOVE', $lang['NOWHERE_TO_MOVE']);
         }
     }
     $hidden_fields = array('mode' => 'movedelcat', 'from_id' => $cat_id);
     $template->assign_vars(array('TPL_DELETE_FORUM' => true, 'WHAT_TO_DELETE' => htmlCHR($catinfo['cat_title']), 'DELETE_TITLE' => $lang['CATEGORY_DELETE'], 'CAT_FORUM_NAME' => $lang['CATEGORY'], 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_fields), 'S_FORUM_ACTION' => "admin_forums.php", 'MOVE_TO_OPTIONS' => get_list('category', $cat_id, 0), 'S_SUBMIT_VALUE' => $lang['MOVE_AND_DELETE']));
     break;
 case 'movedelcat':
     // Move or delete a category in the DB
     $from_id = (int) $_POST['from_id'];
     $to_id = (int) $_POST['to_id'];
     if ($from_id == $to_id || !cat_exists($from_id) || !cat_exists($to_id)) {
         bb_die('Bad input');
     }
     $order_shear = get_max_forum_order($to_id) + 10;
     DB()->query("\n\t\t\t\tUPDATE " . BB_FORUMS . " SET\n\t\t\t\t\tcat_id = {$to_id},\n\t\t\t\t\tforum_order = forum_order + {$order_shear}\n\t\t\t\tWHERE cat_id = {$from_id}\n\t\t\t");
     DB()->query("DELETE FROM " . BB_CATEGORIES . " WHERE cat_id = {$from_id}");
     renumber_order('forum', $to_id);
     $cat_forums = get_cat_forums();
     $fix = fix_orphan_sf();
     $datastore->update('cat_forums');
     CACHE('bb_cache')->rm();
     $message = $lang['FORUMS_UPDATED'] . '<br /><br />';
     $message .= $fix ? "{$fix}<br /><br />" : '';
     $message .= sprintf($lang['CLICK_RETURN_FORUMADMIN'], '<a href="admin_forums.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');
     bb_die($message);
     break;
Ejemplo n.º 7
0
    $smarty->assign('form_act', 'update');
    //$smarty->assign('cat_select',  cat_list(0, $cat_info['parent_id'], true));
    /*2015-03-18 ccx 代理商显示代理商站点的分类 start */
    $smarty->assign('cat_select', cat_list_ccx(0, $cat_info['parent_id'], true));
    /*2015-03-18 ccx end */
    $smarty->assign('goods_type_list', goods_type_list(0));
    // 取得商品类型
    /* 显示页面 */
    assign_query_info();
    $smarty->display('category_info.htm');
} elseif ($_REQUEST['act'] == 'add_category') {
    $cat['parent_id'] = empty($_REQUEST['parent_id']) ? 0 : intval($_REQUEST['parent_id']);
    $cat['cat_name'] = empty($_REQUEST['cat']) ? '' : json_str_iconv(trim($_REQUEST['cat']));
    $cat['is_show'] = 1;
    $admin_agency_id = admin_agency_id();
    $exist_cat_id = cat_exists($cat['cat_name'], $cat['parent_id']);
    $obj_cat = new class_category();
    //分类存在
    if ($exist_cat_id) {
        if ($obj_cat->exist_add_cat($exist_cat_id, $admin_agency_id, $cat)) {
            make_json_error($_LANG['catname_exist']);
        }
    } else {
        $exist_cat_id = $obj_cat->add_cat($cat);
    }
    $arr = array("parent_id" => $cat['parent_id'], "id" => $exist_cat_id, "cat" => $cat['cat_name']);
    clear_cache_files();
    // 清除缓存
    make_json_result($arr);
}
/*------------------------------------------------------ */