PageRenderTime 32ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/b2b/core/shop/controller/ctl.brand.php

http://phpfor.googlecode.com/
PHP | 126 lines | 110 code | 14 blank | 2 comment | 10 complexity | 8d5cd54fbf0059f1db60d24237cefcc9 MD5 | raw file
  1. <?php
  2. class ctl_brand extends shopPage{
  3. var $seoTag=array('shopname','brand');
  4. function showList($page=1){
  5. $pageLimit = 24;
  6. $oGoods=$this->system->loadModel('goods/brand');
  7. $result=$oGoods->getList('*', '',($page-1)*$pageLimit,$pageLimit,$brandCount);
  8. $this->title = $this->system->getConf('site.brand_index_title');
  9. $this->keyWords = $this->system->getConf('site.brand_index_meta_key_words');
  10. $this->metaDesc = $this->system->getConf('site.brand_index_meta_desc');
  11. $oSearch = $this->system->loadModel('goods/search');
  12. foreach($result as $k=>$v){
  13. $result[$k]['link']=$this->system->mkUrl('gallery','index',array('',$oSearch->encode(array('brand_id'=>array($v['brand_id'])))));
  14. }
  15. $this->path[]=array('title'=>'??');
  16. $this->pagedata['pager'] = array(
  17. 'current'=>$page,
  18. 'total'=>ceil($brandCount/$pageLimit),
  19. 'link'=>$this->system->mkUrl('brand','showList',array(($tmp = time()))),
  20. 'token'=>$tmp);
  21. if($page > $this->pagedata['pager']['total']){
  22. trigger_error('?????',E_USER_NOTICE);
  23. }
  24. $this->pagedata['data'] = $result;
  25. $this->getGlobal($this->seoTag,$this->pagedata,1);
  26. $this->output();
  27. }
  28. function index($brand_id,$page=1) {
  29. $oGoods=$this->system->loadModel('goods/brand');
  30. $obj_product_cat = $this->system->loadModel('goods/productCat');
  31. $argu=array("brand_id","brand_name","brand_url","brand_desc","brand_logo");
  32. $result= $oGoods->getFieldById($brand_id,$argu);
  33. $this->title=$result['brand_name'];
  34. $this->pagedata['data'] = $result;
  35. $this->title = $seo_info['title']?$seo_info['title']:$this->system->getConf('site.brand_list_title');
  36. $this->keyWords = $seo_info['keywords']?$seo_info['keywords']:$this->system->getConf('site.brand_list_meta_key_words');
  37. $this->metaDesc = $seo_info['descript']?$seo_info['descript']:$this->system->getConf('site.brand_list_meta_desc');
  38. $this->path[] = array('title'=>'????','link'=>$this->system->mkUrl('brand','showList'));
  39. $this->path[] = array('title'=>$result['brand_name']);
  40. $view = $obj_product_cat->get_gallery_default_view();
  41. if($view=='index') $view='list';
  42. $this->pagedata['view'] = 'gallery/type/'.$view.'.html';
  43. if($GLOBALS['runtime']['member_lv']){
  44. $filter['mlevel'] = $GLOBALS['runtime']['member_lv'];
  45. }
  46. $filter['brand_id'] = $brand_id;
  47. $filter['marketable'] = 'true';
  48. $objGoods = &$this->system->loadModel('goods/products');
  49. $pageLimit = 20;
  50. $start = ($page-1)*$pageLimit;
  51. $aProduct = $objGoods->getList(null,$filter,$start,$pageLimit,$count);
  52. $aProduct = $this->_checkDealerPurview($aProduct);
  53. $this->pagedata['count'] = $count+0;
  54. if(is_array($aProduct) && count($aProduct) > 0){
  55. $objGoods->getSparePrice($aProduct, $GLOBALS['runtime']['member_lv']);
  56. $objGoods->extend_product_info($aProduct,$GLOBALS['runtime']['member_lv']);
  57. //$setting['mktprice'] = $this->system->getConf('site.market_price');
  58. //edit by zhoulei 2010-10-12 bug:0018965
  59. if($this->system->getConf('site.show_mark_price')){
  60. $setting['mktprice'] = $this->system->getConf('site.market_price');
  61. }else{
  62. $setting['mktprice'] =0;
  63. }
  64. $setting['saveprice'] = $this->system->getConf('site.save_price');
  65. $setting['buytarget'] = $this->system->getConf('site.buy.target');
  66. $this->pagedata['setting'] = $setting;
  67. $this->pagedata['products'] = $aProduct;
  68. $order_str = array("\r\n", "\n", "\r");
  69. foreach($this->pagedata['products'] as $key=>$val){
  70. $this->pagedata['products'][$key]['name'] = trim(str_replace($order_str,"",$this->pagedata['products'][$key]['name']));;
  71. }
  72. }
  73. if($GLOBALS['runtime']['member_lv']<0){
  74. $this->pagedata['LOGIN'] = 'nologin';
  75. }
  76. $this->pagedata['pager'] = array(
  77. 'current'=>$page,
  78. 'total'=>ceil($count/$pageLimit),
  79. 'link'=>$this->system->mkUrl('brand','index',array($brand_id,$tmp=time())),
  80. 'token'=>$tmp);
  81. if($page > $this->pagedata['pager']['total']){
  82. trigger_error(__('?????'),E_USER_NOTICE);
  83. }
  84. $this->getGlobal(array('shopname','brand','goods_amount','brand_intro','brand_kw'),$this->pagedata,0);
  85. $this->output();
  86. }
  87. function get_brand(&$result,$list=0){
  88. if($list){
  89. foreach($result['data'] as $k => $v)
  90. $brandName[]=$v['brand_name'];
  91. return implode(",",$brandName);
  92. }else{
  93. return $result['data']['brand_name'];
  94. }
  95. }
  96. function get_goods_amount(&$result,$list=0){
  97. return $result['count'];
  98. }
  99. function get_brand_intro(&$result,$list=0){
  100. $brand_desc=preg_split('/(<[^<>]+>)/',$result['data']['brand_desc'],-1);
  101. if (strlen($brand_desc)>50)
  102. $brand_desc=substr($brand_desc,0,50);
  103. $brand_intro=strip_tags($result['data']['brand_desc']);
  104. return $brand_intro;
  105. }
  106. function get_brand_kw(&$result,$list=0){
  107. $brand = $this->system->loadModel('goods/brand');
  108. $row=$brand->instance($result['data']['brand_id'],'brand_keywords');
  109. return $row['brand_keywords'];
  110. }
  111. }
  112. ?>