PageRenderTime 50ms CodeModel.GetById 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

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