130 lines
3.2 KiB
PHP
Executable File
130 lines
3.2 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @Author: fm453
|
|
* @Date: 2018-04-07 18:02:22
|
|
# @Last modified by: fm453
|
|
# @Last modified time: 2021-09-14T21:23:50+08:00
|
|
* @Email: fm453@lukegzs.com
|
|
*/
|
|
|
|
/**
|
|
* [按风格引导加载模板] 弃用该方案
|
|
* @param [string] $file [文件名]
|
|
* @param [string] $controller [控制器,为空则调用公用文档]
|
|
* @param [string] $action [方法]
|
|
* @param [string] $theme [风格主题,默认为当前整站设定的风格]
|
|
* @param [bool] $iscommon [是否调用的公用文件]
|
|
* @return [string] [返回文件完整绝对路径]
|
|
*/
|
|
function fmFunc_template($file,$controller,$action,$theme=null,$iscommon=null)
|
|
{
|
|
global $_HI;
|
|
$_HI['tplPath'] = Yii::getAlias('@frontend').'/views';
|
|
|
|
$_file = $_HI['tplPath'].'/';
|
|
if($controller){
|
|
$_file .= $controller.'/';
|
|
if($action){
|
|
$_file .= $action.'/';
|
|
}else{
|
|
$_file .= 'index/';
|
|
}
|
|
}elseif($iscommon){
|
|
$_file .= '_common/';
|
|
}
|
|
|
|
if($_HI['os'] != 'web' ){
|
|
$_file .= $_HI['os'].'/';
|
|
}
|
|
$theme = !($theme) ? $_HI['siteStyle'] : $theme;
|
|
if($theme != 'default' ){
|
|
$_file .= $theme.'/';
|
|
}
|
|
|
|
$_file .= $file;
|
|
return $_file;
|
|
}
|
|
|
|
/**
|
|
* [按风格模板取相应视图的资源文件路径] 弃用该方案
|
|
* @param [string] $controller [控制器,为空则调用公用文档]
|
|
* @param [string] $action [方法]
|
|
* @param [string] $theme [风格主题,默认为当前整站设定的风格]
|
|
* @param [bool] $iscommon [是否调用的公用文件]
|
|
* @return [string] [返回文件完整绝对路径]
|
|
*/
|
|
function fmFunc_template_resource($controller,$action,$theme=null)
|
|
{
|
|
global $_HI;
|
|
$_file = Yii::getAlias('@web').'/resource/';
|
|
$_file .= $controller.'-';
|
|
if($action){
|
|
$_file .= $action.'/';
|
|
}else{
|
|
$_file .= 'index/';
|
|
}
|
|
|
|
if($_HI['os'] != 'web' ){
|
|
$_file .= $_HI['os'].'/';
|
|
}
|
|
$theme = !($theme) ? $_HI['siteStyle'] : $theme;
|
|
if($theme != 'default' ){
|
|
$_file .= $theme.'/';
|
|
}
|
|
|
|
$_file .= '';
|
|
return $_file;
|
|
}
|
|
|
|
/**
|
|
* [处理URL]
|
|
* @param [string] $controller [控制器]
|
|
* @param [string] $action [方法]
|
|
* @param [bool] $isAddons [是否追回当前查询参数]
|
|
* @return [type] [格式化后的网址]
|
|
*/
|
|
function fmFunc_url($controller,$action,$isAddons=null)
|
|
{
|
|
global $_HI;
|
|
if(fmFunc_isHttpsUrl()){
|
|
$url = 'https://';
|
|
}else{
|
|
$url = 'http://';
|
|
}
|
|
$url .= $_HI['siteRoot'];
|
|
if(Yii::$app->urlManager->enablePrettyUrl) //开启了URL美化
|
|
{
|
|
if(Yii::$app->urlManager->showScriptName) //显示主入口脚本
|
|
{
|
|
$url .='/index.php';
|
|
}
|
|
|
|
$url .= '/'.$controller;
|
|
$url .= '/'.$action;
|
|
$url .= Yii::$app->urlManager->suffix; //加上自定义后缀
|
|
}
|
|
|
|
if($isAddons)
|
|
{
|
|
$url .= '?'.$_SERVER['QUERY_STRING'];
|
|
}
|
|
|
|
// echo Yii::$app->urlManager->enableStrictParsing;
|
|
// echo Yii::$app->urlManager->routeParam;
|
|
|
|
return $url;
|
|
}
|
|
|
|
//判断是否https协议
|
|
function fmFunc_isHttpsUrl() {
|
|
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
|
|
return true;
|
|
} elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
|
|
return true;
|
|
} elseif ( !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|