function _get_mgcategory_options($parent_id = 0) { $res = array(); $mod =& bm('gcategory', array('_store_id' => 0)); $gcategories = $mod->get_list($parent_id, true); foreach ($gcategories as $gcategory) { //LLL 本店所有商品分类多语言 $res[$gcategory['cate_id']] = get_part_string($gcategory['cate_name'], '', true); } return $res; }
/** * LLL 截取数组第二维字符串中指定语言的部分 * @param $source 在第二维array中包含$key=$thekey(如cate_name)的array,如$gcategories in app->category.app.php中 * @param $thekey the key of which the value to be modified * @param $lang2 形如sc * @return $result the modified $source */ function chg_array2_string($source, $thekey, $lang2, $show_all = false) { foreach ($source as $key => $value) { if (isset($source[$key][$thekey])) { $source[$key][$thekey] = get_part_string($source[$key][$thekey], $lang2, $show_all); } } return $source; }
function _assign_searched_goods($id) { $goods_mod =& bm('goods', array('_store_id' => $id)); $search_name = LANG::get('all_goods'); $conditions = $this->_get_query_conditions(array(array('field' => 'goods_name', 'name' => 'keyword', 'equal' => 'like'))); if ($conditions) { $search_name = sprintf(LANG::get('goods_include'), $_GET['keyword']); $sgcate_id = 0; } else { $sgcate_id = empty($_GET['cate_id']) ? 0 : intval($_GET['cate_id']); } if ($sgcate_id > 0) { $gcategory_mod =& m('gcategory'); $sgcate = $gcategory_mod->get_info($sgcate_id); $search_name = $sgcate['cate_name']; //LLL 提取语言对应字符 $search_name = get_part_string($search_name, get_lang2()); $sgcate_ids = $gcategory_mod->get_descendant($sgcate_id); } else { $sgcate_ids = array(); } /* 排序方式 */ $orders = array('add_time desc' => LANG::get('add_time_desc'), 'price asc' => LANG::get('price_asc'), 'price desc' => LANG::get('price_desc')); $this->assign('orders', $orders); $page = $this->_get_page(16); $goods_list = $goods_mod->get_list(array('conditions' => 'closed = 0 AND if_show = 1' . $conditions, 'count' => true, 'order' => empty($_GET['order']) || !isset($orders[$_GET['order']]) ? 'add_time desc' : $_GET['order'], 'limit' => $page['limit']), $sgcate_ids); foreach ($goods_list as $key => $goods) { empty($goods['default_image']) && ($goods_list[$key]['default_image'] = Conf::get('default_goods_image')); } $this->assign('searched_goods', $goods_list); $page['item_count'] = $goods_mod->getCount(); $this->_format_page($page); $this->assign('page_info', $page); $this->assign('search_name', $search_name); }
function _assign_common_info($id) { /* 取得商品信息 */ $goods = $this->_goods_mod->get_info($id); //LLL 商品名称显示的多语言 $goods['goods_name'] = get_part_string($goods['goods_name'], get_lang2()); if (!$goods || $goods['if_show'] == 0 || $goods['closed'] == 1 || $goods['state'] != 1) { $this->show_warning('goods_not_exist'); return false; } $this->assign('goods', $goods); $this->assign('sales_info', sprintf(LANG::get('sales'), $goods['sales'] ? $goods['sales'] : 0)); $this->assign('comments', sprintf(LANG::get('comments'), $goods['comments'] ? $goods['comments'] : 0)); /* 设置店铺id */ if (!$goods['store_id']) { $this->show_warning('store of goods is empty'); return false; } $this->set_store($goods['store_id']); /* 赋值店铺信息 */ $this->assign('store', $this->get_store_data()); /* 取得浏览历史 */ $this->assign('goods_history', $this->_get_goods_history($id)); /* 默认图片 */ $this->assign('default_image', Conf::get('default_goods_image')); /* 当前位置 */ $this->_curlocal($this->_get_curlocal($goods['cate_id'])); $this->assign('page_title', $goods['goods_name'] . ' - ' . Conf::get('site_title')); $this->import_resource(array('script' => 'jquery.jqzoom.js', 'style' => 'res:jqzoom.css')); return true; }
function edit() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); if (!IS_POST) { /* 是否存在 */ $gcategory = $this->_gcategory_mod->get_info($id); //XXX 还只解决两种语言,多语言有待修改(最好是用javascript) $gcategory['cate_name_it'] = get_part_string($gcategory['cate_name'], 'it', false); $gcategory['cate_name_sc'] = get_part_string($gcategory['cate_name'], 'sc', false); if (!$gcategory) { $this->show_warning('gcategory_empty'); return; } $this->assign('gcategory', $gcategory); $this->assign('parents', $this->_get_options($id)); /* 当前页面信息 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_category'), 'index.php?app=my_category', LANG::get('gcategory_edit')); $this->_curitem('my_category'); $this->_curmenu('edit_category'); $this->assign('page_title', Lang::get('member_center') . Lang::get('my_category')); $this->import_resource(array('script' => 'jquery.plugins/jquery.validate.js')); header("Content-Type:text/html;charset=" . CHARSET); $this->display('my_category.form.html'); } else { $data = array('cate_name' => $_POST['cate_name'], 'parent_id' => $_POST['parent_id'], 'sort_order' => $_POST['sort_order'], 'if_show' => $_POST['if_show']); /* 检查名称是否已存在 */ if (!$this->_gcategory_mod->unique(trim($data['cate_name']), $data['parent_id'], $id)) { $this->show_warning('name_exist'); return; } /* 保存 */ $rows = $this->_gcategory_mod->edit($id, $data); if ($this->_gcategory_mod->has_error()) { $this->show_warning($this->_gcategory_mod->get_error()); return; } $this->pop_warning('ok'); } }