function _get_data() { $this->options['amount'] = intval($this->options['amount']); $cache_server =& cache_server(); $key = $this->_get_cache_id(); $data = $cache_server->get($key); if ($data === false) { $gcategory_mod =& bm('gcategory', array('_store_id' => 0)); $gcategories = array(); if (empty($this->options['amount'])) { $gcategories = $gcategory_mod->get_list(-1, true); } else { $gcategory = $gcategory_mod->get_list(0, true); $gcategories = $gcategory; foreach ($gcategory as $val) { $result = $gcategory_mod->get_list($val['cate_id'], true); $result = array_slice($result, 0, $this->options['amount']); $gcategories = array_merge($gcategories, $result); } } import('tree.lib'); $tree = new Tree(); //LLL 商品分类挂件根据语言选择分类字段 $lang2 = get_lang2(); //like fr,sc etc... $gcategories = chg_array2_string($gcategories, 'cate_name', $lang2); $tree->setTree($gcategories, 'cate_id', 'parent_id', 'cate_name'); $data = $tree->getArrayList(0); $cache_server->set($key, $data, $this->_ttl); } return $data; }
function _list_scategory() { $scategory_mod =& m('scategory'); $scategories = $scategory_mod->get_list(-1, true); import('tree.lib'); $tree = new Tree(); $lang2 = get_lang2(); //LLL 获取语言2个字母的代称,如fr, sc, en $scategories = chg_array2_string($scategories, 'cate_name', $lang2); //保留数组第二维字段字符串中指定语言的部分 $tree->setTree($scategories, 'cate_id', 'parent_id', 'cate_name'); return $tree->getArrayList(0); }
function _get_data() { $cache_server =& cache_server(); $key = $this->_get_cache_id(); $data = $cache_server->get($key); if ($data === false) { $recom_mod =& m('recommend'); $data = $recom_mod->get_recommended_goods($this->options['img_recom_id'], $this->_num, true, $this->options['img_cate_id']); //LLL best goods精品推荐中商品名称多语言 $data = chg_array2_string($data, 'goods_name', get_lang2()); $cache_server->set($key, $data, $this->_ttl); } return $data; }
function _get_data() { $cache_server =& cache_server(); $key = $this->_get_cache_id(); $data = $cache_server->get($key); if ($data === false) { $goods_mod =& m('goods'); $data = $goods_mod->find(array('conditions' => "if_show = 1 AND closed = 0", 'order' => 'sales', 'fields' => 'g.goods_id, g.goods_name', 'join' => 'has_goodsstatistics', 'limit' => 10)); //LLL sale list top 10 销售排行多语言 $data = chg_array2_string($data, 'goods_name', get_lang2()); $cache_server->set($key, $data, $this->_ttl); } return $data; }
function _get_data() { $cache_server =& cache_server(); $key = $this->_get_cache_id(); $data = $cache_server->get($key); if ($data === false) { $recom_mod =& m('recommend'); $img_goods_list = $recom_mod->get_recommended_goods($this->options['img_recom_id'], 4, true, $this->options['img_cate_id']); $txt_goods_list = $recom_mod->get_recommended_goods($this->options['txt_recom_id'], 8, true, $this->options['txt_cate_id']); //LLL 商品模块 goods module 1 多语言 $img_goods_list = chg_array2_string($img_goods_list, 'goods_name', get_lang2()); $txt_goods_list = chg_array2_string($txt_goods_list, 'goods_name', get_lang2()); $cache_server->set($key, array('img_goods_list' => $img_goods_list, 'txt_goods_list' => $txt_goods_list), $this->_ttl); } return array('module_name' => $this->options['module_name'], 'bgcolor' => $this->options['bgcolor'], 'keyword_list' => explode(' ', $this->options['keyword_list']), 'ad_image_url' => $this->options['ad_image_url'], 'ad_link_url' => $this->options['ad_link_url'], 'img_goods_list' => $data['img_goods_list'], 'txt_goods_list' => $data['txt_goods_list']); }
function _get_data() { $cache_server =& cache_server(); $key = $this->_get_cache_id(); $data = $cache_server->get($key); if ($data === false) { $recom_mod =& m('recommend'); $img_goods_list = $recom_mod->get_recommended_goods($this->options['img_recom_id'], 3, true, $this->options['img_cate_id']); $txt_goods_list = $recom_mod->get_recommended_goods($this->options['txt_recom_id'], 4, true, $this->options['txt_cate_id']); //LLL 特价商品sale price 多语言 $img_goods_list = chg_array2_string($img_goods_list, 'goods_name', get_lang2()); $txt_goods_list = chg_array2_string($txt_goods_list, 'goods_name', get_lang2()); $cache_server->set($key, array('img_goods_list' => $img_goods_list, 'txt_goods_list' => $txt_goods_list), $this->_ttl); } return array('img_goods_list' => $data['img_goods_list'], 'txt_goods_list' => $data['txt_goods_list']); }
function _get_data() { if (empty($this->options['num']) || intval($this->options['num']) <= 0) { $this->options['num'] = 5; } $cache_server =& cache_server(); $key = $this->_get_cache_id(); $data = $cache_server->get($key); if ($data === false) { $order_goods_mod =& m('ordergoods'); $data = $order_goods_mod->find(array('conditions' => "status = '" . ORDER_FINISHED . "'", 'order' => 'finished_time desc', 'fields' => 'goods_id, goods_name, price, goods_image', 'join' => 'belongs_to_order', 'limit' => $this->options['num'])); //LLL latest sold最新成交多语言 $data = chg_array2_string($data, 'goods_name', get_lang2()); foreach ($data as $key => $goods) { empty($goods['goods_image']) && ($data[$key]['goods_image'] = Conf::get('default_goods_image')); } $cache_server->set($key, $data, $this->_ttl); } return $data; }
function index() { /* 取得商品分类 */ $gcategories = $this->_gcategory_mod->get_list(); //LLL my_category商品名切换语言 $gcategories = chg_array2_string($gcategories, 'cate_name', get_lang2(), true); $tree =& $this->_tree($gcategories); /* 先根排序 */ $sorted_gcategories = array(); $cate_ids = $tree->getChilds(); foreach ($cate_ids as $id) { $sorted_gcategories[] = array_merge($gcategories[$id], array('layer' => $tree->getLayer($id))); } $this->assign('gcategories', $sorted_gcategories); /* 构造映射表(每个结点的父结点对应的行,从1开始) */ $row = array(0 => 0); // cate_id对应的row $map = array(); // parent_id对应的row foreach ($sorted_gcategories as $key => $gcategory) { $row[$gcategory['cate_id']] = $key + 1; $map[] = $row[$gcategory['parent_id']]; } $this->assign('map', ecm_json_encode($map)); /* 当前页面信息 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_category'), 'index.php?app=my_category', LANG::get('gcategory_list')); $this->_curitem('my_category'); $this->_curmenu('gcategory_manage'); $this->assign('page_title', Lang::get('member_center') . ' - ' . Lang::get('my_category')); // $this->import_resource(array( // 'script' => 'jqtreetable.js,inline_edit.js', // 'style' => 'res:jqtreetable.css') // ); $this->import_resource(array('script' => array(array('path' => 'dialog/dialog.js', 'attr' => 'id="dialog_js"'), array('path' => 'jquery.ui/jquery.ui.js', 'attr' => ''), array('path' => 'jqtreetable.js', 'attr' => ''), array('path' => 'jquery.plugins/jquery.validate.js', 'attr' => ''), array('path' => 'utils.js', 'attr' => '')), 'style' => 'jquery.ui/themes/ui-lightness/jquery.ui.css,res:css/jqtreetable.css')); header("Content-Type:text/html;charset=" . CHARSET); $this->display('my_category.index.html'); }
function _get_store_curlocal($cate_id) { $parents = array(); if ($cate_id) { $scategory_mod =& m('scategory'); $scategory_mod->get_parents($parents, $cate_id); } //LLL $parents里面的cate_name部分仅保留对应语言的字符store page中导航栏 $parents = chg_array2_string($parents, 'cate_name', get_lang2()); $curlocal = array(array('text' => LANG::get('all_categories'), 'url' => 'index.php?app=search&act=store')); foreach ($parents as $category) { $curlocal[] = array('text' => $category['cate_name'], 'url' => 'index.php?app=search&act=store&cate_id=' . $category['cate_id']); } unset($curlocal[count($curlocal) - 1]['url']); return $curlocal; }
function index() { /* 取得店铺商品分类 */ $this->assign('sgcategories', $this->_get_sgcategory_options()); /* 搜索条件 */ $conditions = "1 = 1"; if (trim($_GET['keyword'])) { $str = "LIKE '%" . trim($_GET['keyword']) . "%'"; //搜索货号 //$conditions .= " AND (goods_name {$str} OR brand {$str} OR cate_name {$str})"; $conditions .= " AND (goods_name {$str} OR brand {$str} OR cate_name {$str} OR sku {$str})"; } if ($_GET['character']) { switch ($_GET['character']) { case 'show': $conditions .= " AND if_show = 1"; break; case 'hide': $conditions .= " AND if_show = 0"; break; case 'closed': $conditions .= " AND closed = 1"; break; case 'recommended': $conditions .= " AND g.recommended = 1"; break; } } if (intval($_GET['sgcate_id']) > 0) { $cate_mod =& bm('gcategory', array('_store_id' => $this->_store_id)); $cate_ids = $cate_mod->get_descendant(intval($_GET['sgcate_id'])); } else { $cate_ids = 0; } // 标识有没有过滤条件 if ($conditions != '1 = 1') { $this->assign('filtered', 1); } //更新排序 if (isset($_GET['sort']) && isset($_GET['order'])) { $sort = strtolower(trim($_GET['sort'])); $order = strtolower(trim($_GET['order'])); if (!in_array($order, array('asc', 'desc'))) { $sort = 'goods_id'; $order = 'desc'; } } else { $sort = 'goods_id'; $order = 'desc'; } /* 取得商品列表 */ $page = $this->_get_page(); $goods_list = $this->_goods_mod->get_list(array('conditions' => $conditions, 'count' => true, 'order' => "{$sort} {$order}", 'limit' => $page['limit']), $cate_ids); //LLL my_goods商品列表语言处理 $goods_list = chg_array2_string($goods_list, 'goods_name', get_lang2(), true); foreach ($goods_list as $key => $goods) { $goods_list[$key]['cate_name'] = $this->_goods_mod->format_cate_name($goods['cate_name']); } $this->assign('goods_list', $goods_list); $page['item_count'] = $this->_goods_mod->getCount(); $this->_format_page($page); $this->assign('page_info', $page); $this->assign('order', $order); $this->assign('sort', $sort); $this->import_resource(array('script' => array(array('path' => 'dialog/dialog.js', 'attr' => 'id="dialog_js" charset="utf-8"'), array('path' => 'jquery.ui/jquery.ui.js', 'attr' => 'charset="utf-8"'), array('path' => 'jquery.plugins/jquery.validate.js', 'attr' => 'charset="utf-8"'), array('path' => 'utils.js', 'attr' => 'charset="utf-8"')), 'style' => 'jquery.ui/themes/ui-lightness/jquery.ui.css')); /* 当前页面信息 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_goods'), 'index.php?app=my_goods', LANG::get('goods_list')); $this->_curitem('my_goods'); $this->_curmenu('goods_list'); //$this->import_resource(array('script' => 'utils.js')); $this->assign('page_title', Lang::get('member_center') . ' - ' . Lang::get('my_goods')); $this->display('my_goods.index.html'); }
function _get_store_gcategory() { $gcategory_mod =& bm('gcategory', array('_store_id' => $this->_store_id)); $gcategories = $gcategory_mod->get_list(-1, true); //LLL store gcategories里面的cate_name部分仅保留对应语言的字符 frontend.base, store中的商品分类 $gcategories = chg_array2_string($gcategories, 'cate_name', get_lang2()); import('tree.lib'); $tree = new Tree(); $tree->setTree($gcategories, 'cate_id', 'parent_id', 'cate_name'); return $tree->getArrayList(0); }
function _get_scategory_options() { $mod =& m('scategory'); $scategories = $mod->get_list(); //LLL apply_app分类多语言 $scategories = chg_array2_string($scategories, 'cate_name', get_lang2(), true); import('tree.lib'); $tree = new Tree(); $tree->setTree($scategories, 'cate_id', 'parent_id', 'cate_name'); return $tree->getOptions(); }
/** * 取得当前位置 * * @param int $cate_id 分类id */ function _get_curlocal($cate_id) { $parents = array(); if ($cate_id) { $gcategory_mod =& m('gcategory'); $gcategory_mod->get_parents($parents, $cate_id); } $curlocal = array(array('text' => LANG::get('all_categories'), 'url' => 'index.php?app=category')); //LLL $parents里面的cate_name部分仅保留对应语言的字符 goods page中导航栏 $parents = chg_array2_string($parents, 'cate_name', get_lang2()); foreach ($parents as $category) { $curlocal[] = array('text' => $category['cate_name'], 'url' => 'index.php?app=search&cate_id=' . $category['cate_id']); } $curlocal[] = array('text' => LANG::get('goods_detail')); return $curlocal; }
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); }