Esempio n. 1
0
 /**
  * 多终端适配
  * @param  [type] &$config [系统配置]
  * @return [type]          [description]
  */
 private static function multiple_device(&$config)
 {
     $template = $config['template'];
     $_device = iPHP::PG('device');
     if ($_device) {
         /**
          * 判断指定设备
          * @var [type]
          */
         foreach ((array) $template['device'] as $key => $device) {
             if ($device['tpl'] && ($device['ua'] == $_device || $device['name'] == $_device)) {
                 $device_name = $device['name'];
                 $device_tpl = $device['tpl'];
                 $domain = $device['domain'];
                 break;
             }
         }
     }
     /**
      * 无指定设备 判断USER_AGENT
      */
     if (empty($device_tpl)) {
         foreach ((array) $template['device'] as $key => $device) {
             if ($device['tpl'] && self::device_agent($device['ua'])) {
                 $device_name = $device['name'];
                 $device_tpl = $device['tpl'];
                 $domain = $device['domain'];
                 break;
             }
         }
     }
     iPHP::$mobile = false;
     if ($device_tpl) {
         //设备模板
         $def_tpl = $device_tpl;
     } else {
         //检查是否移动设备
         if (self::device_agent($template['mobile']['agent'])) {
             iPHP::$mobile = true;
             $mobile_tpl = $template['mobile']['tpl'];
             $device_name = 'mobile';
             $def_tpl = $mobile_tpl;
             $domain = $template['mobile']['domain'];
         }
     }
     if (empty($def_tpl)) {
         $device_name = 'desktop';
         $def_tpl = $template['desktop']['tpl'];
         $domain = false;
     }
     define('iPHP_ROUTER_URL', $config['router']['URL']);
     $domain && ($config['router'] = str_replace($config['router']['URL'], $domain, $config['router']));
     define('iPHP_DEFAULT_TPL', $def_tpl);
     define('iPHP_MOBILE_TPL', $mobile_tpl);
     define('iPHP_DEVICE', $device_name);
     define('iPHP_HOST', $config['router']['URL']);
     header("Access-Control-Allow-Origin: " . iPHP_HOST);
     header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');
 }
Esempio n. 2
0
 private static function multiple_device(&$config)
 {
     $template = $config['template'];
     foreach ((array) $template['device'] as $key => $device) {
         if ($device['tpl'] && self::device_agent($device['ua'])) {
             $device_name = $device['name'];
             $device_tpl = $device['tpl'];
             $domain = $device['domain'];
             break;
         }
     }
     iPHP::$mobile = false;
     //检查是否移动设备
     if (self::device_agent($template['mobile']['agent'])) {
         iPHP::$mobile = true;
         $mobile_tpl = $template['mobile']['tpl'];
         $domain = $template['mobile']['domain'];
     }
     if ($device_tpl) {
         //设备模板
         $def_tpl = $device_tpl;
     } else {
         if (iPHP::$mobile) {
             //没有设置设备模板 但是移动设备
             $device_name = 'mobile';
             $def_tpl = $mobile_tpl;
         }
     }
     if (empty($def_tpl)) {
         $device_name = 'desktop';
         $def_tpl = $template['desktop']['tpl'];
         $domain = false;
     }
     $domain && ($config['router'] = str_replace($config['router']['URL'], $domain, $config['router']));
     define('iPHP_DEFAULT_TPL', $def_tpl);
     define('iPHP_MOBILE_TPL', $mobile_tpl);
     define('iPHP_DEVICE', $device_name);
     define('iPHP_HOST', $config['router']['URL']);
     header("Access-Control-Allow-Origin: " . iPHP_HOST);
     header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');
 }