/b2b/core/shop/controller/ctl.brand.php
PHP | 126 lines | 110 code | 14 blank | 2 comment | 10 complexity | 8d5cd54fbf0059f1db60d24237cefcc9 MD5 | raw file
- <?php
- class ctl_brand extends shopPage{
- var $seoTag=array('shopname','brand');
- function showList($page=1){
- $pageLimit = 24;
- $oGoods=$this->system->loadModel('goods/brand');
- $result=$oGoods->getList('*', '',($page-1)*$pageLimit,$pageLimit,$brandCount);
- $this->title = $this->system->getConf('site.brand_index_title');
- $this->keyWords = $this->system->getConf('site.brand_index_meta_key_words');
- $this->metaDesc = $this->system->getConf('site.brand_index_meta_desc');
- $oSearch = $this->system->loadModel('goods/search');
- foreach($result as $k=>$v){
- $result[$k]['link']=$this->system->mkUrl('gallery','index',array('',$oSearch->encode(array('brand_id'=>array($v['brand_id'])))));
- }
- $this->path[]=array('title'=>'??');
- $this->pagedata['pager'] = array(
- 'current'=>$page,
- 'total'=>ceil($brandCount/$pageLimit),
- 'link'=>$this->system->mkUrl('brand','showList',array(($tmp = time()))),
- 'token'=>$tmp);
- if($page > $this->pagedata['pager']['total']){
- trigger_error('?????',E_USER_NOTICE);
- }
- $this->pagedata['data'] = $result;
- $this->getGlobal($this->seoTag,$this->pagedata,1);
- $this->output();
- }
- function index($brand_id,$page=1) {
-
- $oGoods=$this->system->loadModel('goods/brand');
- $obj_product_cat = $this->system->loadModel('goods/productCat');
- $argu=array("brand_id","brand_name","brand_url","brand_desc","brand_logo");
- $result= $oGoods->getFieldById($brand_id,$argu);
- $this->title=$result['brand_name'];
- $this->pagedata['data'] = $result;
- $this->title = $seo_info['title']?$seo_info['title']:$this->system->getConf('site.brand_list_title');
- $this->keyWords = $seo_info['keywords']?$seo_info['keywords']:$this->system->getConf('site.brand_list_meta_key_words');
- $this->metaDesc = $seo_info['descript']?$seo_info['descript']:$this->system->getConf('site.brand_list_meta_desc');
-
- $this->path[] = array('title'=>'????','link'=>$this->system->mkUrl('brand','showList'));
- $this->path[] = array('title'=>$result['brand_name']);
-
- $view = $obj_product_cat->get_gallery_default_view();
- if($view=='index') $view='list';
- $this->pagedata['view'] = 'gallery/type/'.$view.'.html';
- if($GLOBALS['runtime']['member_lv']){
- $filter['mlevel'] = $GLOBALS['runtime']['member_lv'];
- }
- $filter['brand_id'] = $brand_id;
- $filter['marketable'] = 'true';
-
- $objGoods = &$this->system->loadModel('goods/products');
- $pageLimit = 20;
- $start = ($page-1)*$pageLimit;
- $aProduct = $objGoods->getList(null,$filter,$start,$pageLimit,$count);
- $aProduct = $this->_checkDealerPurview($aProduct);
- $this->pagedata['count'] = $count+0;
- if(is_array($aProduct) && count($aProduct) > 0){
- $objGoods->getSparePrice($aProduct, $GLOBALS['runtime']['member_lv']);
- $objGoods->extend_product_info($aProduct,$GLOBALS['runtime']['member_lv']);
- //$setting['mktprice'] = $this->system->getConf('site.market_price');
- //edit by zhoulei 2010-10-12 bug:0018965
- if($this->system->getConf('site.show_mark_price')){
- $setting['mktprice'] = $this->system->getConf('site.market_price');
- }else{
- $setting['mktprice'] =0;
- }
-
- $setting['saveprice'] = $this->system->getConf('site.save_price');
- $setting['buytarget'] = $this->system->getConf('site.buy.target');
- $this->pagedata['setting'] = $setting;
- $this->pagedata['products'] = $aProduct;
- $order_str = array("\r\n", "\n", "\r");
- foreach($this->pagedata['products'] as $key=>$val){
- $this->pagedata['products'][$key]['name'] = trim(str_replace($order_str,"",$this->pagedata['products'][$key]['name']));;
- }
- }
-
- if($GLOBALS['runtime']['member_lv']<0){
- $this->pagedata['LOGIN'] = 'nologin';
- }
- $this->pagedata['pager'] = array(
- 'current'=>$page,
- 'total'=>ceil($count/$pageLimit),
- 'link'=>$this->system->mkUrl('brand','index',array($brand_id,$tmp=time())),
- 'token'=>$tmp);
- if($page > $this->pagedata['pager']['total']){
- trigger_error(__('?????'),E_USER_NOTICE);
- }
-
- $this->getGlobal(array('shopname','brand','goods_amount','brand_intro','brand_kw'),$this->pagedata,0);
- $this->output();
- }
- function get_brand(&$result,$list=0){
- if($list){
- foreach($result['data'] as $k => $v)
- $brandName[]=$v['brand_name'];
- return implode(",",$brandName);
- }else{
- return $result['data']['brand_name'];
- }
- }
- function get_goods_amount(&$result,$list=0){
- return $result['count'];
- }
- function get_brand_intro(&$result,$list=0){
- $brand_desc=preg_split('/(<[^<>]+>)/',$result['data']['brand_desc'],-1);
- if (strlen($brand_desc)>50)
- $brand_desc=substr($brand_desc,0,50);
- $brand_intro=strip_tags($result['data']['brand_desc']);
- return $brand_intro;
- }
- function get_brand_kw(&$result,$list=0){
- $brand = $this->system->loadModel('goods/brand');
- $row=$brand->instance($result['data']['brand_id'],'brand_keywords');
- return $row['brand_keywords'];
- }
- }
- ?>