upgrade_helper.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/3/14
  6. * Time: 下午3:38
  7. */
  8. require_once (BASE_ROOT_PATH . '/helper/special/block_filter.php');
  9. class upgrade_helper extends block_filter
  10. {
  11. public function __construct($block_type, $special_id, $items)
  12. {
  13. parent::__construct($block_type, $special_id, $items);
  14. }
  15. public function filter()
  16. {
  17. if($this->mItems == false) {
  18. return false;
  19. }
  20. if ($this->mType == 'goods' || $this->mType == 'home7')
  21. {
  22. $ids = [];
  23. foreach ($this->mItems['item'] as $goods_id)
  24. {
  25. if(is_array($goods_id)) {
  26. return $this->mItems;
  27. }
  28. $ids[] = intval($goods_id);
  29. }
  30. return $this->goods($ids);
  31. }
  32. elseif($this->mType == 'home1') {
  33. return $this->home1();
  34. }
  35. elseif($this->mType == 'home2' || $this->mType == 'home4') {
  36. return $this->home2();
  37. }
  38. elseif($this->mType == 'adv_list' || $this->mType == 'home3' || $this->mType == 'home5' || $this->mType == 'home6') {
  39. return $this->normal();
  40. }
  41. else {
  42. return false;
  43. }
  44. }
  45. private function goods($ids)
  46. {
  47. $model_goods = Model('goods');
  48. $items = $model_goods->getGoodsList(array('goods_id' => array('in',$ids)),'goods_id,goods_name,goods_image');
  49. $result = [];
  50. foreach ($items as $item)
  51. {
  52. $val = [];
  53. $image = cthumb($item['goods_image'],360);
  54. if($this->to_local($image) == true) {
  55. $val['image'] = $image;
  56. } else {
  57. continue;
  58. }
  59. $val['title'] = $item['goods_name'];
  60. $val['type'] = 'goods';
  61. $val['data'] = $item['goods_id'];
  62. if($this->mType == 'goods') {
  63. $val['show_type'] = 'goods';
  64. }
  65. elseif($this->mType == 'goods_simple') {
  66. $val['show_type'] = 'goods_simple';
  67. }
  68. else {
  69. $val['show_type'] = 'goods_top';
  70. }
  71. $val['show_data'] = $val['data'];
  72. $result[$image] = $val;
  73. }
  74. if(empty($result)) {
  75. return false;
  76. } else {
  77. return array('item' => $result);
  78. }
  79. }
  80. }