|
@@ -122,6 +122,29 @@ class mb_specialModel extends Model
|
|
|
return $this->_getMbSpecialItemList($condition);
|
|
|
}
|
|
|
|
|
|
+ private function gen_tabs($tab_words)
|
|
|
+ {
|
|
|
+ if(empty($tab_words)) return false;
|
|
|
+
|
|
|
+ $result = [];
|
|
|
+ $items = preg_split("/#/",$tab_words);
|
|
|
+ foreach ($items as $item)
|
|
|
+ {
|
|
|
+ $values = explode(":",$item);
|
|
|
+ $item_id = intval($values[0]);
|
|
|
+
|
|
|
+ if(count($values) != 2 || $item_id <= 0) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ $result[$item_id] = ['pos' => 0,'title' => trim($values[1])];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return empty($result) ? false : $result;
|
|
|
+ }
|
|
|
+ private function format_tabs($tabs) {
|
|
|
+
|
|
|
+ }
|
|
|
public function getMbSpecialItemUsableListByID($special_id)
|
|
|
{
|
|
|
$prefix = 'mb_special';
|
|
@@ -137,22 +160,31 @@ class mb_specialModel extends Model
|
|
|
$condition['item_usable'] = self::SPECIAL_ITEM_USABLE;
|
|
|
$item_list = $this->_getMbSpecialItemList($condition);
|
|
|
|
|
|
- $spinfo = $this->getMbSpecialByID($special_id,'from_user');
|
|
|
+ $spinfo = $this->getMbSpecialByID($special_id,'from_user,tabs');
|
|
|
$from_user = $spinfo['from_user'] == 1 ? true : false;
|
|
|
+ $tabs = $this->gen_tabs($spinfo['tabs']);
|
|
|
|
|
|
+ $item_sort = 0;
|
|
|
$blocks = [];
|
|
|
foreach ($item_list as $value)
|
|
|
{
|
|
|
$block = [];
|
|
|
+
|
|
|
$block['item_type'] = $value['item_type'];
|
|
|
$block['bg_image'] = $value['bg_image'];
|
|
|
$block['bg_type'] = $value['bg_type'];
|
|
|
$block['bg_data'] = $value['bg_data'];
|
|
|
$has_margin = intval($value['has_margin']);
|
|
|
$block['has_margin']= $has_margin === 0 ? false : true;
|
|
|
+ $item_id = intval($value['item_id']);
|
|
|
|
|
|
- $item_type = $value['item_type'];
|
|
|
+ if($tabs != false && array_key_exists($item_id,$tabs)) {
|
|
|
+ $tabs[$item_id]['pos'] = $item_sort;
|
|
|
+ }
|
|
|
+ $block['item_sort'] = $item_sort;
|
|
|
+ $item_sort++;
|
|
|
|
|
|
+ $item_type = $value['item_type'];
|
|
|
if($item_type == 'divider') {
|
|
|
$blocks[] = $block;
|
|
|
continue;
|
|
@@ -183,8 +215,16 @@ class mb_specialModel extends Model
|
|
|
|
|
|
$blocks[] = $block;
|
|
|
}
|
|
|
-
|
|
|
- $cache = array('blocks' => $blocks);
|
|
|
+ if($tabs == false) {
|
|
|
+ $tab_items = [];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $tab_items = [];
|
|
|
+ foreach ($tabs as $key => $val) {
|
|
|
+ $tab_items[] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $cache = array('blocks' => $blocks,'tabs' => $tab_items);
|
|
|
wcache($special_id, array('special' => serialize($cache)), $prefix);
|
|
|
return $cache;
|
|
|
}
|