123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/2/27
- * Time: 上午9:57
- */
- function comp_tab($left,$right)
- {
- $t_l = intval($left['sort']);
- $t_r = intval($right['sort']);
- if($t_l > $t_r) {
- return 1;
- } elseif($t_l == $t_r) {
- return 0;
- } else {
- return -1;
- }
- }
- class index_tab
- {
- private static $stInstance = null;
- private $mTabs;
- const mb_home_tab_id = 123;
- public function __construct()
- {
- $this->mTabs = [];
- }
- public static function instance() {
- if(self::$stInstance == null) {
- self::$stInstance = new index_tab();
- }
- return self::$stInstance;
- }
- public function tabs()
- {
- if($_SESSION['is_lasted'] || $_SESSION['client_type'] == 'ajax')
- {
- if(StatesHelper::fetch_state('tags')) {
- $this->init();
- }
- return $this->mTabs;
- }
- else {
- global $config;
- return $config['old_tabs'];
- }
- }
- private function init()
- {
- Log::record("init tags data.",Log::INFO);
- $this->mTabs = [];
- $mod_webcode = Model('web_code');
- $tabs = $mod_webcode->get_cache(self::mb_home_tab_id);
- if($tabs == null || empty($tabs)) {
- $tabs[] = array('special_id' => 0,'name' => '首页', 'sort' => 0);
- }
- uasort($tabs,'comp_tab');
- foreach ($tabs as $key => $val) {
- $this->mTabs[] = array('special_id' => $val['special_id'],'name' => $val['name']);
- }
- }
- }
|