本文整理匯總了PHP中iPHP::mobile方法的典型用法代碼示例。如果您正苦於以下問題:PHP iPHP::mobile方法的具體用法?PHP iPHP::mobile怎麽用?PHP iPHP::mobile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iPHP
的用法示例。
在下文中一共展示了iPHP::mobile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: multiple_device
/**
* 多終端適配
* @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');
}
示例2: multiple_device
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');
}