|
@@ -12,133 +12,7 @@
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
require_once (BASE_ROOT_PATH . '/helper/util_helper.php');
|
|
|
-
|
|
|
-
|
|
|
-class block_filter
|
|
|
-{
|
|
|
- private $mSpecialId;
|
|
|
- private $mItems;
|
|
|
- private $mType;
|
|
|
-
|
|
|
- public function __construct($block_type,$special_id,$items)
|
|
|
- {
|
|
|
- $this->mItems = $items;
|
|
|
- $this->mType = $block_type;
|
|
|
- $this->mSpecialId = $special_id;
|
|
|
- }
|
|
|
-
|
|
|
- public function filter()
|
|
|
- {
|
|
|
- if($this->mType == 'adv_list' || $this->mType == 'home3' || $this->mType == 'home5' || $this->mType == 'home6' || $this->mType == 'home7' || $this->mType == 'goods') {
|
|
|
- return $this->normal();
|
|
|
- }
|
|
|
- elseif ($this->mType == 'home1') {
|
|
|
- return $this->home1();
|
|
|
- }
|
|
|
- elseif($this->mType == 'home2' || $this->mType == 'home4') {
|
|
|
- return $this->home2();
|
|
|
- }
|
|
|
-
|
|
|
- return $this->mItems;
|
|
|
- }
|
|
|
-
|
|
|
- private function home1()
|
|
|
- {
|
|
|
- if(empty($this->mItems['show_type']))
|
|
|
- {
|
|
|
- $this->calc_show($this->mItems['type'],$this->mItems['data'],$this->mItems['image'],$show_type,$show_data);
|
|
|
- $this->mItems['show_type'] = $show_type;
|
|
|
- $this->mItems['show_data'] = $show_data;
|
|
|
- }
|
|
|
- }
|
|
|
- private function home2()
|
|
|
- {
|
|
|
- if(empty($this->mItems['rectangle1_show_type']))
|
|
|
- {
|
|
|
- $this->calc_show($this->mItems['rectangle1_type'],$this->mItems['rectangle1_data'],$this->mItems['rectangle1_image'],$show_type,$show_data);
|
|
|
- $this->mItems['rectangle1_show_type'] = $show_type;
|
|
|
- $this->mItems['rectangle1_show_data'] = $show_data;
|
|
|
- }
|
|
|
-
|
|
|
- if(empty($this->mItems['rectangle2_show_type']))
|
|
|
- {
|
|
|
- $this->calc_show($this->mItems['rectangle2_type'],$this->mItems['rectangle2_data'],$this->mItems['rectangle2_image'],$show_type,$show_data);
|
|
|
- $this->mItems['rectangle2_show_type'] = $show_type;
|
|
|
- $this->mItems['rectangle2_show_data'] = $show_data;
|
|
|
- }
|
|
|
- if(empty($this->mItems['square_show_type']))
|
|
|
- {
|
|
|
- $this->calc_show($this->mItems['square_type'],$this->mItems['square_data'],$this->mItems['square_image'],$show_type,$show_data);
|
|
|
- $this->mItems['square_show_type'] = $show_type;
|
|
|
- $this->mItems['square_show_data'] = $show_data;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private function calc_show($data_type,$data,$image,&$show_type,&$show_data)
|
|
|
- {
|
|
|
- if($data_type == 'goods') {
|
|
|
- $show_type = 'goods';
|
|
|
- $show_data = $data;
|
|
|
- }
|
|
|
- elseif($data_type == 'innerurl') {
|
|
|
- $show_type = 'webview';
|
|
|
- $show_data = $data;
|
|
|
- }
|
|
|
- elseif($data_type == 'video') {
|
|
|
- $show_type = 'video';
|
|
|
- $show_data = $data;
|
|
|
- }
|
|
|
- else {
|
|
|
- $show_type = 'image';
|
|
|
- $show_data = $image;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private function normal()
|
|
|
- {
|
|
|
- $items = [];
|
|
|
- foreach ($this->mItems['item'] as $image => &$item)
|
|
|
- {
|
|
|
- if($this->to_local($image) == true) {
|
|
|
- $item['image'] = $image;
|
|
|
- }
|
|
|
-
|
|
|
- if(empty($item['show_type']))
|
|
|
- {
|
|
|
- $this->calc_show($item['type'],$item['data'],$item['image'],$show_type,$show_data);
|
|
|
- $item['show_type'] = $show_type;
|
|
|
- $item['show_data'] = $show_data;
|
|
|
- }
|
|
|
- $items[$image] = $item;
|
|
|
- }
|
|
|
- return array('item' => $items);
|
|
|
- }
|
|
|
-
|
|
|
- private function to_local(&$image)
|
|
|
- {
|
|
|
- if(util::start_with($image,BASE_SITE_URL))
|
|
|
- {
|
|
|
- $prefix = 's' . $this->mSpecialId;
|
|
|
-
|
|
|
- $dest_dir = BASE_ROOT_PATH.DS.DIR_UPLOAD.DS.ATTACH_MOBILE . DS . 'special' . DS . $prefix;
|
|
|
- if(file_exists($dest_dir) == false) {
|
|
|
- mkdir($dest_dir);
|
|
|
- }
|
|
|
- $length = strlen(BASE_SITE_URL);
|
|
|
- $src = BASE_ROOT_PATH . substr($image, $length, strlen($image) - $length);
|
|
|
-
|
|
|
- $info = pathinfo($src);
|
|
|
- $dest_name = $prefix . '_' . md5_file($src) . '.' .$info['extension'];
|
|
|
- copy($src,$dest_dir . DS . $dest_name);
|
|
|
- $image = $dest_name;
|
|
|
-
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/special/block_filter.php');
|
|
|
|
|
|
class mb_specialControl extends SystemControl
|
|
|
{
|
|
@@ -151,6 +25,19 @@ class mb_specialControl extends SystemControl
|
|
|
parent::__construct();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //升级专题数据
|
|
|
+ public function upgradeOp()
|
|
|
+ {
|
|
|
+ $mod_mb_special = Model('mb_special_item');
|
|
|
+ $items = $mod_mb_special->where(array('item_type' => 'goods'))->field('*')->limit(false)->select();
|
|
|
+
|
|
|
+ foreach ($items as $item) {
|
|
|
+ $filter = new block_filter($item['item_type'],$item['special_id'],unserialize($item['item_data']));
|
|
|
+ $item_data = $filter->filter();
|
|
|
+ $result = $mod_mb_special->editMbSpecialItemByID($item_data, $item['item_id'], $item['special_id']);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 专题列表
|
|
|
*/
|