作者 魏强
1 个管道 的构建 失败 耗费 4 秒

online

正在显示 25 个修改的文件 包含 1295 行增加796 行删除
... ... @@ -17,6 +17,78 @@ class IndexController extends HomeBaseController
{
$data=json_decode(Db::name('information')->where('id',1)->find()['banner'],true);
$this->assign('banner',$data);
if($this->isMobile()){
$this->redirect('portal/company/companyIntroduce');
}else{
return $this->fetch(':index');
}
}
function isMobile()
{
// 如果有HTTP_X_WAP_PROFILE则一定是移动设备
if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
{
return true;
}
// 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息
if (isset ($_SERVER['HTTP_VIA']))
{
// 找不到为flase,否则为true
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
// 脑残法,判断手机发送的客户端标志,兼容性有待提高
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array ('nokia',
'sony',
'ericsson',
'mot',
'samsung',
'htc',
'sgh',
'lg',
'sharp',
'sie-',
'philips',
'panasonic',
'alcatel',
'lenovo',
'iphone',
'ipod',
'blackberry',
'meizu',
'android',
'netfront',
'symbian',
'ucweb',
'windowsce',
'palm',
'operamini',
'operamobi',
'openwave',
'nexusone',
'cldc',
'midp',
'wap',
'mobile'
);
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
{
return true;
}
}
// 协议法,因为有可能不准确,放到最后判断
if (isset ($_SERVER['HTTP_ACCEPT']))
{
// 如果只支持wml并且不支持html那一定是移动设备
// 如果支持wml和html但是wml在html之前则是移动设备
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html'))))
{
return true;
}
}
return false;
}
}
... ...
... ... @@ -8,9 +8,9 @@
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li ><a href="{:url('AdminAbout/about')}">专业团队</a></li>
<li ><a href="{:url('AdminAbout/add3')}">添加专业团队</a></li>
<li class="active"><a href="javascript:;">编辑专业团队</a></li>
<li ><a href="{:url('AdminAbout/about')}">公司介绍</a></li>
<li ><a href="{:url('AdminAbout/add3')}">添加公司介绍</a></li>
<li class="active"><a href="javascript:;">编辑公司介绍</a></li>
</ul>
<form action="{:url('AdminAbout/editPost3')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
... ...
... ... @@ -20,7 +20,7 @@
<th width="50">ID</th>
<th>图片</th>
<th>内容</th>
<th>操作</th>
<th width="100">操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
... ...
... ... @@ -15,7 +15,7 @@
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<input type="hidden" name="type" id="type" value="1">
<input type="hidden" name="type" id="type" value="2">
<tr>
<th>缩略图</th>
<td>
... ...
... ... @@ -15,7 +15,7 @@
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<input type="hidden" name="type" id="type" value="1">
<input type="hidden" name="type" id="type" value="3">
<tr>
<th>缩略图</th>
<td>
... ...
... ... @@ -22,7 +22,7 @@
<th>缩略图</th>
<th>简介</th>
<th>创建时间</th>
<th>操作</th>
<th width="100">操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
... ...
... ... @@ -22,7 +22,7 @@
<th>缩略图</th>
<th>简介</th>
<th>创建时间</th>
<th>操作</th>
<th width="100">操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
... ...
... ... @@ -22,7 +22,7 @@
<th>缩略图</th>
<th>简介</th>
<th>创建时间</th>
<th>操作</th>
<th width="100">操作</th>
</tr>
</thead>
<foreach name="list" item="vo">
... ...
... ... @@ -155,5 +155,17 @@
$(this).addClass("companylistactive");
$(this).siblings(".companylist").removeClass("companylistactive")
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -12,6 +12,9 @@
.aboutcompanyname a{
color:#171717;
}
/*body{*/
/*height:100%;*/
/*}*/
</style>
</head>
... ... @@ -162,5 +165,20 @@ color:#333; " target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin={$list.qq}&s
$(".wxcodeimg").click(function(){
$(".codeimg").css("display","block")
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -112,9 +112,10 @@
<div id="page" class="page_div"></div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/cookie.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/bootstrap.min.js"></script>
... ... @@ -129,17 +130,31 @@
})
//分页
$("#page").paging({
pageNo:1,
totalPage: 10,
totalSize: 300,
callback: function(num) {
alert(num)
}
})
// $("#page").paging({
// pageNo:1,
// totalPage: 10,
// totalSize: 300,
// callback: function(num) {
// alert(num)
// }
// })
// $(".thumbnail").click(function(){
// window.location.href="{:url('portal/company/peopleDetail')}"
// })
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -14,6 +14,12 @@
.aboutcompanyname a{
color:#171717;
}
.slidebanner {
margin-bottom: 50px;
}
.footer{
position: unset;
}
</style>
</head>
... ... @@ -109,16 +115,16 @@
<div class="swiper-slide"><a href="{:url('portal/company/peopleDetail',array('id'=>$vo.id))}"><img src="{:cmf_get_image_preview_url($vo.picture);}" ></a></div>
</foreach>
</div>
<div class="swiper-button-prev swiper-button-black"></div>
<div class="swiper-button-next swiper-button-black"></div>
<div class="swiper-button-prev swiper-button-black peoplepre"></div>
<div class="swiper-button-next swiper-button-black peopleback"></div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
... ... @@ -149,5 +155,18 @@
prevEl: '.swiper-button-prev',
},
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
$("body").css("height","100%")
}else{
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -14,6 +14,12 @@
.aboutcompanyname a{
color:#171717;
}
.footer{
position: unset;
}
.swiper-wrapper{
padding-bottom: 40px;
}
</style>
</head>
... ... @@ -115,12 +121,12 @@
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/swiper.min.js"></script>
... ... @@ -149,5 +155,18 @@
prevEl: '.swiper-button-prev',
},
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
$("body").css("height","100%")
}else{
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -15,103 +15,108 @@
</style>
</head>
<body>
<nav id="common-nav" class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img class="navbar-logo" src="__TMPL__/public/assets/images/img/dfsd@2x.png">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="{:url('portal/index/index')}" >首页</a>
</li>
<li>
<a href="{:url('portal/company/companyIntroduce')}" class="navactive">
关于公司
</a>
<nav id="common-nav" class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img class="navbar-logo" src="__TMPL__/public/assets/images/img/dfsd@2x.png">
</a>
</div>
</li>
<li>
<a href="{:url('portal/companyProject/personalCompanyProject')}" >
公司项目
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="{:url('portal/index/index')}" >首页</a>
</li>
<li>
<a href="{:url('portal/company/companyIntroduce')}" class="navactive">
关于公司
</a>
</li>
<li>
<a href="{:url('portal/companyProject/personalCompanyProject')}" >
公司项目
</a>
</li>
<li>
<a href="{:url('portal/companyNews/industry')}" >
新闻动态
</a>
</li>
<li>
<a href="{:url('portal/companyService/townPlan')}" >
公司服务
</a>
</li>
<li>
<a href="{:url('portal/invitePeople/viewOfPeople')}">
招贤纳士
</a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="headimg">
<img src="__TMPL__/public/assets/images/img/gdfsgdfgd@2x.png" alt="">
</div>
<div class="container secnav">
<div class="row aboutcompanyname">
<div class="col-md-2 col-sm-2 col-xs-6 about" >关于</div>
<div class="col-md-2 col-sm-2 col-xs-6 company">公司</div>
<a href="{:url('portal/company/companyIntroduce')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist" >公司介绍</div></a>
<a href="{:url('portal/company/professionalTeam')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist companylistactive">专业团队</div></a>
<a href="{:url('portal/company/managerTeam')}"><div class="col-md-2 col-sm-2 col-xs-3 companylist">管理团队</div></a>
<a href="{:url('portal/company/connectUs')}"><div class="col-md-2 col-sm-2 col-xs-3 companylist">联系我们</div></a>
</div>
</div>
<div class="container containertext">
</a>
</li>
<li>
<a href="{:url('portal/companyNews/industry')}" >
新闻动态
</a>
</li>
<li>
<a href="{:url('portal/companyService/townPlan')}" >
公司服务
</a>
<div class="row presidentlist">
<foreach name="list" item="vo">
<div class="col-md-3 col-xs-12 col-sm-6">
<a href="{:url('portal/company/peopleDetail2',array('id'=>$vo.id))}" style="text-decoration:none;">
<div class="thumbnail teamthumbinal">
<img src="{:cmf_get_image_preview_url($vo.picture);}" alt="...">
<div class="caption">
<p class="professioname">{$vo.name}</p>
<p class="professioname">{$vo.job}</p>
</li>
<li>
<a href="{:url('portal/invitePeople/viewOfPeople')}">
招贤纳士
</div>
</div>
</a>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="headimg">
<img src="__TMPL__/public/assets/images/img/gdfsgdfgd@2x.png" alt="">
</div>
<div class="container secnav">
<div class="row aboutcompanyname">
<div class="col-md-2 col-sm-2 col-xs-6 about" >关于</div>
<div class="col-md-2 col-sm-2 col-xs-6 company">公司</div>
<a href="{:url('portal/company/companyIntroduce')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist" >公司介绍</div></a>
<a href="{:url('portal/company/professionalTeam')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist companylistactive">专业团队</div></a>
<a href="{:url('portal/company/managerTeam')}"><div class="col-md-2 col-sm-2 col-xs-3 companylist">管理团队</div></a>
<a href="{:url('portal/company/connectUs')}"><div class="col-md-2 col-sm-2 col-xs-3 companylist">联系我们</div></a>
</div>
</div>
<div class="container containertext">
</div>
</foreach>
</div>
<div id="page" class="page_div"></div>
<div class="row presidentlist">
<foreach name="list" item="vo">
<div class="col-md-3 col-xs-12 col-sm-6">
<a href="{:url('portal/company/peopleDetail2',array('id'=>$vo.id))}" style="text-decoration:none;">
<div class="thumbnail teamthumbinal">
<img src="{:cmf_get_image_preview_url($vo.picture);}" alt="...">
<div class="caption">
<p class="professioname">{$vo.name}</p>
<p class="professioname">{$vo.job}</p>
</div>
</div>
</a>
</div>
</foreach>
</div>
<div id="page" class="page_div"></div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/cookie.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/bootstrap.min.js"></script>
... ... @@ -128,13 +133,26 @@
window.location.href='peopledetail.html'
})
//分页
$("#page").paging({
pageNo:1,
totalPage: 10,
totalSize: 300,
callback: function(num) {
alert(num)
}
})
// $("#page").paging({
// pageNo:1,
// totalPage: 10,
// totalSize: 300,
// callback: function(num) {
// alert(num)
// }
// })
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -71,8 +71,8 @@
</nav>
<div class="position">
<ul class="positionlist">
<li class="aboutposition"><a href="">当前位置:</a></li>
<a href="{:url('portal/companyNews/industry')}"><li class="aboutposition">新闻动态</li></a><span class="iconfont icon-jiantou rightrow"></span>
<a href=""><li class="aboutposition">当前位置:</li></a>
<a href="{:url('portal/companyNews/industry')}" style="margin-left: 5px"><li class="aboutposition">新闻动态</li></a><span class="iconfont icon-jiantou rightrow"></span>
<a href="{:url('portal/companyNews/industry',array('type'=>$list.type))}"> <li class="aboutposition aboutpositionname">
<switch name="list.type">
<case value="1">行业动态</case>
... ... @@ -103,9 +103,39 @@
</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</body>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/bootstrap.min.js"></script>
<script>
window.onresize = function () {
// document.title = client().width + " "+ client().height;
var wi=$(window).width();
// alert(wi)
if(wi<968){
$(".companynewsdetailtext p span").css("font-size","18px")
}else{
$(".companynewsdetailtext p span").css("font-size","23px")
}
}
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
$("body").css("height","100%")
}else{
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -80,8 +80,8 @@
<div class="row aboutcompanyname">
<div class="col-md-2 col-sm-2 col-xs-6 invitepeople" >新闻</div>
<div class="col-md-2 col-sm-2 col-xs-6 company">动态</div>
<a href="{:url('portal/companyNews/industry',array('type'=>1))}"><div class="col-md-2 col-sm-2 col-xs-4 companylist <eq name="type" value="1">companylistactive</eq>" >行业动态</div></a>
<a href="{:url('portal/companyNews/industry',array('type'=>2))}"><div class="col-md-2 col-sm-2 col-xs-4 companylist <eq name="type" value="2">companylistactive</eq>" >公司新闻</div></a>
<a href="{:url('portal/companyNews/industry',array('type'=>2))}"><div class="col-md-2 col-sm-2 col-xs-4 companylist <eq name="type" value="2">companylistactive</eq>" >行业动态</div></a>
<a href="{:url('portal/companyNews/industry',array('type'=>1))}"><div class="col-md-2 col-sm-2 col-xs-4 companylist <eq name="type" value="1">companylistactive</eq>" >公司新闻</div></a>
<a href="{:url('portal/companyNews/industry',array('type'=>3))}"><div class="col-md-2 col-sm-2 col-xs-4 companylist <eq name="type" value="3">companylistactive</eq>" >文化交流</div></a>
</div>
</div>
... ... @@ -92,6 +92,7 @@
<div class="col-md-12 companynewsitem">
<p class="year">{:date('Y',$vo.create_time);}</p>
<p class="month">{:date('m/d',$vo.create_time);}</p>
<a href="{:url('portal/companyNews/companyNewDetail',array('id'=>$vo.id))}">
<div class="row companynewstext">
<if condition="$key/2==0">
<div class="col-md-5 col-sm-12 col-xs-12">
... ... @@ -101,19 +102,23 @@
</div>
</div>
<div class="col-md-7 col-sm-12 col-xs-12">
<a href="{:url('portal/companyNews/companyNewDetail',array('id'=>$vo.id))}">
<div class="companynewsimg">
<a href="{:url('portal/companyNews/companyNewDetail',array('id'=>$vo.id))}">
<img src="{:cmf_get_image_preview_url($vo.thumbnail)}" alt="">
</a>
</div>
</a>
</div>
<else />
<div class="col-md-7 col-sm-12 col-xs-12">
<div class="companynewsimg">
<a href="{:url('portal/companyNews/companyNewDetail',array('id'=>$vo.id))}">
<img src="{:cmf_get_image_preview_url($vo.thumbnail)}" alt="">
</a>
</div>
</div>
<div class="col-md-5 col-sm-12 col-xs-12">
<p class="landscapename">{$vo.title}</p>
... ... @@ -123,6 +128,8 @@
</div>
</if>
</div>
</a>
</div>
</foreach>
</div>
... ... @@ -137,9 +144,9 @@
<!--<div id="page" class="page_div"></div>-->
<div class="pagination">{$page|default=''}</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/paging.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/bootstrap.min.js"></script>
... ... @@ -162,5 +169,19 @@
alert(num)
}
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -75,7 +75,7 @@
<div class="position">
<ul class="positionlist">
<li class="aboutposition"><a href="">当前位置:</a></li>
<li class="aboutposition"><a href="">公司项目</a></li><span class="iconfont icon-jiantou rightrow"></span>
<li class="aboutposition"><a href="{:url('portal/companyProject/personalCompanyProject',array('id'=>$list.cid))}">公司项目</a></li><span class="iconfont icon-jiantou rightrow"></span>
<a href="{:url('portal/companyProject/personalCompanyProject',array('id'=>$list.cid))}"><li class="aboutposition aboutpositionname">{$list.cname}</li></a>
</ul>
</div>
... ... @@ -153,14 +153,14 @@
</div>
</foreach>
</div>
<div class="swiper-button-prev swiper-button-black"></div>
<div class="swiper-button-next swiper-button-black"></div>
<div class="swiper-button-prev swiper-button-black prerow"></div>
<div class="swiper-button-next swiper-button-black backrow"></div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/swiper.min.js"></script>
... ... @@ -188,5 +188,18 @@
prevEl: '.swiper-button-prev',
},
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
$("body").css("height","100%")
}else{
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -80,13 +80,18 @@
</div>
<div class="container secnav">
<div class="row aboutcompanyname">
<div class="col-md-2 col-sm-2 col-xs-6 about">公司</div>
<div class="col-md-2 col-sm-2 col-xs-6 company">项目</div>
<foreach name="category" item="vo">
<a href="{:url('portal/companyProject/personalCompanyProject',array('id'=>$vo.id))}">
<div class="col-md-2 col-sm-2 col-xs-3 companylist <eq name="select" value="$vo.id">companylistactive</eq>">{$vo.name}</div>
</a>
</foreach>
<div class="col-md-4 col=sm-4 col-xs-12 servicetitle">
<div class="col-md-6 col-sm-6 col-xs-6 about">公司</div>
<div class="col-md-6col-sm-6 col-xs-6 company">项目</div>
</div>
<div class="col-md-8 col-sm-8 col-xs-12 servicebox">
<foreach name="category" item="vo">
<a href="{:url('portal/companyProject/personalCompanyProject',array('id'=>$vo.id))}">
<div class="col-md-2 col-sm-2 col-xs-3 companylist <eq name="select" value="$vo.id">companylistactive</eq>">{$vo.name}</div>
</a>
</foreach>
</div>
<!--<div class="col-md-2 col-sm-2 col-xs-3 companylist " ><a href="production.html">作品集</a></div>-->
</div>
... ... @@ -167,5 +172,19 @@ color:#333; " href="{:url('portal/companyProject/companyProjectDetail',array('id
}
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -80,12 +80,12 @@
</div>
<div class="container secnav">
<div class="row aboutcompanyname">
<div class="col-md-4 col=sm-4 col-xs-6 servicetitle">
<div class="col-md-4 col=sm-4 col-xs-12 servicetitle">
<div class="col-md-6 col-sm-6 col-xs-6 companyservice ">公司</div>
<div class="col-md-6 col-sm-6 col-xs-6 company">服务</div>
</div>
<div class="col-md-8 col-sm-8 col-xs-8 servicebox">
<div class="col-md-8 col-sm-8 col-xs-12 servicebox">
<foreach name="category" item="vo">
<a href="{:url('portal/companyService/townPlan',array('id'=>$vo.id))}">
<div class="col-md-2 col-sm-4 col-xs-4 companylistitem <eq name="select" value="$vo.id">companylistactive</eq>">{$vo.name}</div>
... ... @@ -101,7 +101,7 @@
<foreach name="list" item="vo">
<div class="row landscapedesigntext">
<div class="col-md-6 col-sm-12 col-xs-12">
<div class="col-md-6 col-sm-12 col-xs-12 servicecontentbox">
<div class="landscapeimg">
<img src="{:cmf_get_image_preview_url($vo.thumbnail)}" alt="">
</div>
... ... @@ -115,10 +115,10 @@
</div>
</foreach>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
</div>
</div>
<div class="footer">版权所有© 渝ICP备18005497号-1</div>
<script type="text/javascript" src="__TMPL__/public/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/paging.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/js/bootstrap.min.js"></script>
... ... @@ -131,5 +131,19 @@
$(this).addClass("companylistactive");
$(this).siblings(".companylist").removeClass("companylistactive")
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -99,12 +99,12 @@
<notempty name="$list['0']">
<div class="col-md-6 col-xs-12 col-sm-6 peopleactivitylist">
<div class="row peopleactivetyitem">
<div class="col-md-8 col-sm-8 col-xs-8">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="peopleactivityimg">
<img src="{:cmf_get_image_preview_url($list[$it*2]['thumbnail'])}" alt="">
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<p class="peopleactivitydate">{:date('Y.m.d',$list[$it*2]['time'])}</p>
<p class="peopleactivityname">{$list[$it*2]['name']}</p>
<p class="peopleactivitynum1 num">{$it*4+1}</p>
... ... @@ -115,12 +115,12 @@
<notempty name="$list['1']">
<div class="col-md-6 col-xs-12 col-sm-6 peopleactivitylist">
<div class="row peopleactivetyitem">
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<p class="peopleactivitydate">{:date('Y.m.d',$list[$it*2+1]['time'])}</p>
<p class="peopleactivityname">{$list[$it*2+1]['name']}</p>
<p class="peopleactivitynum2 num">{$it*4+2}</p>
</div>
<div class="col-md-8 col-sm-8 col-xs-8">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="peopleactivityimg">
<img src="{:cmf_get_image_preview_url($list[$it*2+1]['thumbnail'])}" alt="">
</div>
... ... @@ -132,12 +132,12 @@
<div class="col-md-6 col-xs-12 col-sm-6 peopleactivitylist">
<div class="row peopleactivetyitem">
<div class="col-md-8 col-sm-8 col-xs-8">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="peopleactivityimg">
<img src="{:cmf_get_image_preview_url($list[$it*2+2]['thumbnail'])}" alt="">
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<p class="peopleactivitynum3 num">{$it*4+3}</p>
<p class="peopleactivitydate">{:date('Y.m.d',$list[$it*2+2]['time'])}</p>
<p class="peopleactivityname">{$list[$it*2+2]['name']}</p>
... ... @@ -150,13 +150,13 @@
<notempty name="$list['3']">
<div class="col-md-6 col-xs-12 col-sm-6 peopleactivitylist">
<div class="row peopleactivetyitem">
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<p class="peopleactivitynum4 num">{$it*4+4}</p>
<p class="peopleactivitydate">{:date('Y.m.d',$list[$it*2+3]['time'])}</p>
<p class="peopleactivityname">{$list[$it*2+3]['name']}</p>
</div>
<div class="col-md-8 col-sm-8 col-xs-8">
<div class="col-md-8 col-sm-8 col-xs-12">
<div class="peopleactivityimg">
<img src="{:cmf_get_image_preview_url($list[$it*2+3]['thumbnail'])}" alt="">
</div>
... ... @@ -201,5 +201,18 @@
alert(num)
}
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -88,24 +88,17 @@
</div>
</div>
<div class="container containertext">
<div class="row aboutcompanyname">
<div class="col-md-2 col-sm-2 col-xs-6 invitepeople" >招贤</div>
<div class="col-md-2 col-sm-2 col-xs-6 company">纳士</div>
<a href="{:url('portal/invitePeople/viewOfPeople')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist " >人才观</div></a>
<a href="{:url('portal/invitePeople/peopleActivity')}"><div class="col-md-2 col-sm-2 col-xs-3 companylist " >员工活动</div></a>
<a href="{:url('portal/invitePeople/schoolRequire')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist companylistactive" >校园招聘</div></a>
<a href="{:url('portal/invitePeople/socialRequire')}"> <div class="col-md-2 col-sm-2 col-xs-3 companylist " >社会招聘</div></a>
</div>
<for start="0" end="$count" step="1" name="it">
<notempty name="list[$it*2]">
<div class="row requiresociallist">
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="socialrequireimg">
<img src="{:cmf_get_image_preview_url($list[$it*2]['thumbnail'])}" alt="">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<div class="col-md-6 col-sm-6 col-xs-12">
<p class="workname">招聘职位:{$list[$it*2]['name']}</p>
<div>
<p>职位要求</p>
... ... @@ -127,14 +120,14 @@
</div>
</notempty>
<notempty name="list[$it*2+1]">
<div class="row requiresociallist" style="margin-left: 100px">
<div class="col-md-2 col-sm-2 col-xs-2">
<div class="row requiresociallist requiresociallistsec" >
<div class="col-md-2 col-sm-2 col-xs-12">
<p class="socialrequireimgnumwordtwo">0{$it*2+2}</p>
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<div class="col-md-6 col-sm-6 col-xs-12">
<p class="workname">招聘职位:{$list[$it*2+1]['name']}</p>
<div>
<p>职位要求</p>
... ... @@ -148,7 +141,7 @@
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="socialrequireimg">
<img src="{:cmf_get_image_preview_url($list[$it*2+1]['thumbnail'])}" alt="">
</div>
... ... @@ -183,5 +176,18 @@
alert(num)
}
})
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -92,12 +92,12 @@
<for start="0" end="$count" step="1" name="it">
<notempty name="list[$it*3]">
<div class="row requiresociallist">
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="socialrequireimg">
<img src="{:cmf_get_image_preview_url($list[$it*3]['thumbnail'])}" alt="">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<div class="col-md-6 col-sm-6 col-xs-12">
<p class="workname">招聘职位:{$list[$it*3]['name']}</p>
<div>
<p>职位要求</p>
... ... @@ -119,14 +119,14 @@
</div>
</notempty>
<notempty name="list[$it*3+1]">
<div class="row requiresociallist" style="margin-left: 100px">
<div class="col-md-2 col-sm-2 col-xs-2">
<div class="row requiresociallist">
<div class="col-md-2 col-sm-2 col-xs-12">
<p class="socialrequireimgnumwordtwo">0{$it*3+2}</p>
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<div class="col-md-6 col-sm-6 col-xs-12">
<p class="workname">招聘职位:{$list[$it*3+1]['name']}</p>
<div>
<p>职位要求</p>
... ... @@ -140,7 +140,7 @@
</div>
</div>
<div class="col-md-4 col-sm-4 col-xs-4">
<div class="col-md-4 col-sm-4 col-xs-12">
<div class="socialrequireimg">
<img src="{:cmf_get_image_preview_url($list[$it*3+1]['thumbnail'])}" alt="">
</div>
... ... @@ -166,13 +166,26 @@
})
//分页
$("#page").paging({
pageNo:1,
totalPage: 10,
totalSize: 300,
callback: function(num) {
alert(num)
}
})
// $("#page").paging({
// pageNo:1,
// totalPage: 10,
// totalSize: 300,
// callback: function(num) {
// alert(num)
// }
// })
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
$("body").css("height","100%")
}else{
$("body").css("height","auto")
$("body").css("position","relative")
}
</script>
</html>
... ...
... ... @@ -154,5 +154,31 @@
$(".two").css("margin-top","80px")
}
}
var width=$(window).width();
if(width<968){
$(".viewcompanyintro").css("margin-top","45px")
}else{
$(".three").css("margin-top","160px")
$(".two").css("margin-top","80px")
}
var height=$(window).height();
var bodyheight=$("body").height();
console.log(height);
console.log(bodyheight)
if(height>bodyheight){
console.log(111)
$("body").css("height","100%")
}else{
console.log(222)
$("body").css("height","auto")
$("body").css("position","relative")
}
// if(height>){
//
// }
</script>
</html>
... ...
... ... @@ -3,9 +3,18 @@
padding: 0;
margin: 0;
}
/*
* 外面盒子样式---自己定义
*/
body,html{
/*height:auto;*/
}
body{
/*position:relative*/
}
.pagination{
margin-bottom:30px;
}
/*
* 外面盒子样式---自己定义
*/
.page_div {
width:90%;
... ... @@ -58,7 +67,14 @@
margin: 0 5px;
}
/***************************************/
.navbar-toggle{
background:#8EC63F ;
opacity: 0.4;
}
.navbar-inverse .navbar-toggle:hover {
background:#8EC63F ;
opacity: 0.4;
}
.navbar-right{
width:85%;
}
... ... @@ -66,7 +82,7 @@
padding: 0 14px;
}
.navbar-inverse {
background:rgba(255,255,255,0.5);
background:rgba(255,255,255,0.8);
box-shadow:0px 4px 8px 0px rgba(78,78,78,0.1);
border:none;
}
... ... @@ -88,15 +104,16 @@
.navbar-inverse .navbar-toggle {
border:none ;
}
.navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover{
background:transparent;
}
/*.navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover{*/
/*background:transparent;*/
/*}*/
.navbar-header{
border:none;
}
.navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
border: none;
background:rgba(255,255,255,0.5);
}
/*@media (min-width: 1200px) {*/
/*.container {*/
... ... @@ -157,7 +174,10 @@
.indexcourael{
bottom:55px;
}
.positionlist a{
color:#999999;
font-size: 18px;
}
/*关于公司*/
... ... @@ -256,9 +276,15 @@
}
.professioname{
text-align: center;
font-size: 18px;
font-size: 17px;
color:#333333;
margin-bottom: 0;
width:121px;
margin: 0 auto;
margin-bottom: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
... ... @@ -290,6 +316,7 @@
margin-top: 0;
box-shadow:0px 2px 40px 0px rgba(51,51,51,0.11);
border-radius:10px;
margin-bottom: 50px;
}
.companyintro .thumbnail{
margin-bottom: 0;
... ... @@ -331,6 +358,7 @@
.viewofpeoplelist{
margin-top:37px ;
padding-bottom: 50px;
}
.viewofpeopletext{
box-shadow:0px 0px 50px 0px rgba(51,51,51,0.06);
... ... @@ -372,10 +400,11 @@
}
.aboutposition a{
text-decoration: none;
color:#999999
color:#999999;
font-size: 18px;
}
.aboutpositionname{
margin-left:20px ;
/*margin-left:20px ;*/
}
.peopletailimg{
width:40%;
... ... @@ -462,20 +491,23 @@
text-align: center;
}
.companyprojectinfo{
padding: 30px 27px;
background:rgba(255,255,255,1);
box-shadow:0px 2px 40px 0px rgba(51,51,51,0.11);
border-radius:6px;
}
.landscapeimg{
height:320px;
border-radius:10px;
}
.landscapeimg img{
width:100%;
height:100%;
border-radius:10px;
}
.lanscapetext p{
margin: 0;
}
.landscapedesigntext{
margin-top: 80px;
... ... @@ -483,6 +515,7 @@
box-shadow:0px 2px 40px 0px rgba(51,51,51,0.11);
border-radius:10px;
padding: 20px;
margin-bottom: 50px;
}
.lanscapetext{
color:#333333;
... ... @@ -580,11 +613,13 @@
}
.companynewsimg{
width:100%;
/*height:174px;*/
height:250px;
border-radius:10px;
}
.companynewsimg img{
width:100%;
height:100%;
border-radius:10px;
}
.year{
color:#333333;
... ... @@ -719,6 +754,7 @@
color:#171717;
font-size: 18px;
font-weight: bold;
text-align: center;
}
.peopleactivitydate{
margin-top: 30px;
... ... @@ -748,6 +784,7 @@
padding: 10px 10px;
box-sizing: border-box;
margin: 0 auto;
margin-bottom: 50px;
}
.peopleactivitylist{
margin-top: 20px;
... ... @@ -780,12 +817,12 @@
}
.swiper-button-next, .swiper-container-rtl .swiper-button-prev{
position:absolute;
top:73%;
top:65%;
left:95%;
}
.swiper-button-next, .swiper-button-prev{
top:73%;
top:65%;
}
.personalthumbinal{
border-radius:6px 6px 0px 0px;
... ... @@ -813,9 +850,14 @@
margin-top: 50px;
}
.projectpersonalname,.projectpersonalnamesec{
overflow: hidden;
}
.personalitemtitle{
width:42%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
float:left;
margin-bottom: 0;
}
... ... @@ -844,7 +886,7 @@
}
.companytailtext{
width:80%;
width:70%;
background:rgba(255,255,255,1);
box-shadow:0px -1px 10px 0px #E8E2E4;
border-radius:16px;
... ... @@ -891,8 +933,8 @@
}
.footer{
position: absolute;
margin-top: 150px;
/*bottom:0;*/
/*margin-top: 230px;*/
bottom:0;
left:0;
right:0;
color:#000;
... ... @@ -951,9 +993,13 @@
top:-40px;
left:-75%;
}
.requiresociallistsec{
margin-left: 100px;
}
.requiresociallist{
width:90%;
margin: 40px auto 0;
margin-bottom: 50px;
}
.workname{
color:#171717;
... ... @@ -1016,6 +1062,7 @@
}
.introducetextitem{
height:405px;
}
@media (min-width: 1903px){
.containertext {
... ... @@ -1043,9 +1090,12 @@
.company{
font-size: 18px;
}
.companylist{
.companylist,.companylistitem{
font-size: 13px;
}
.companylistactive{
font-size: 15px;
}
.companyintro:nth-child(2n){
margin-top:0 ;
}
... ... @@ -1106,18 +1156,128 @@
}
.footer{
position: unset;
margin-top: 180px;
margin-top: 35px;
color:#000;
font-size: 12px;
text-align: center;
}
.aboutposition a{
font-size: 12px;
}
.peopletailinfo{
padding: 30px 17px;
}
.peopletailtext{
font-size: 18px;
}
.swiper-button-next, .swiper-container-rtl .swiper-button-prev {
position: absolute;
top: 54%;
left: 90%;
}
.swiper-button-prev{
top:60%;
left:0;
background-size: 50% 50%;
}
.peopletailname{
font-size: 24px;
}
.socialrequireimgnumword {
color: #666666;
font-size: 20px;
font-weight: bold;
text-align: center;
position: absolute;
top: -12px;
right: -10%;
}
.socialrequireimgnumwordtwo {
color: #666666;
font-size: 20px;
font-weight: bold;
text-align: center;
position: absolute;
top: -18px;
left: -5%;
}
.about,.invitepeople,.companyservice{
height: 50px;
line-height: 50px;
font-size: 20px;
}
.company {
height: 50px;
line-height: 50px;
}
.prerow,.backrow{
top:41%;
/*width:100px;*/
/*height:100px;*/
background-size: 50% 50%;
}
.headimg{
height:210px;
}
.companytailtext{
margin-top: 20px;
}
.companynewsdetailname{
font-size: 23px;
}
.companynewsdetailtext p span{
font-size: 18px;
}
.servicecontentbox{
padding: 0;
}
.landscapeimg {
height: 270px;
}
.companytailtext{
padding-left: 10px;
padding-right: 10px;
}
.workname{
font-size: 21px;
}
.companytailtext{
width:90%;
}
.viewofpeoplelist{
padding-bottom: 0;
}
.viewofpeoplelist{
margin-top: 0;
}
.peoplepre,.peopleback{
top:78%;
background-size: 50% 50%;
}
}
@media screen and (max-width: 750px){
.swiper-button-next, .swiper-container-rtl .swiper-button-prev {
position: absolute;
top: 69%;
top: 60%;
left: 90%;
/*width:50%;*/
background-size: 50% 50%;
}
.prerow,.backrow{
top:53%;
background-size: 50% 50%;
}
.peoplepre,.peopleback{
top:78%;
background-size: 50% 50%;
}
}
@media screen and (max-width: 320px){
... ... @@ -1125,12 +1285,19 @@
font-size: 12px;
}
.company{
font-size: 12px;
font-size: 25px;
}
.companylist{
font-size: 12px;
}
.companyservice{
font-size: 12px;
font-size: 25px;
}
.prerow,.backrow{
top:25%;
}
.peoplepre,.peopleback{
top:78%;
background-size: 50% 50%;
}
}
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think;
use think\exception\ClassNotFoundException;
use think\exception\HttpException;
use think\exception\HttpResponseException;
use think\exception\RouteNotFoundException;
/**
* App 应用管理
* @author liu21st <liu21st@gmail.com>
*/
class App
{
/**
* @var bool 是否初始化过
*/
protected static $init = false;
/**
* @var string 当前模块路径
*/
public static $modulePath;
/**
* @var bool 应用调试模式
*/
public static $debug = true;
/**
* @var string 应用类库命名空间
*/
public static $namespace = 'app';
/**
* @var bool 应用类库后缀
*/
public static $suffix = false;
/**
* @var bool 应用路由检测
*/
protected static $routeCheck;
/**
* @var bool 严格路由检测
*/
protected static $routeMust;
protected static $dispatch;
protected static $file = [];
/**
* 执行应用程序
* @access public
* @param Request $request Request对象
* @return Response
* @throws Exception
*/
public static function run(Request $request = null)
{
is_null($request) && $request = Request::instance();
try {
$config = self::initCommon();
if (defined('BIND_MODULE')) {
// 模块/控制器绑定
BIND_MODULE && Route::bind(BIND_MODULE);
} elseif ($config['auto_bind_module']) {
// 入口自动绑定
$name = pathinfo($request->baseFile(), PATHINFO_FILENAME);
if ($name && 'index' != $name && is_dir(APP_PATH . $name)) {
Route::bind($name);
}
}
$request->filter($config['default_filter']);
// 默认语言
Lang::range($config['default_lang']);
if ($config['lang_switch_on']) {
// 开启多语言机制 检测当前语言
Lang::detect();
}
$request->langset(Lang::range());
// 加载系统语言包
Lang::load([
THINK_PATH . 'lang' . DS . $request->langset() . EXT,
APP_PATH . 'lang' . DS . $request->langset() . EXT,
]);
// 获取应用调度信息
$dispatch = self::$dispatch;
if (empty($dispatch)) {
// 进行URL路由检测
$dispatch = self::routeCheck($request, $config);
}
// 记录当前调度信息
$request->dispatch($dispatch);
// 记录路由和请求信息
if (self::$debug) {
Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info');
Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info');
}
// 监听app_begin
Hook::listen('app_begin', $dispatch);
// 请求缓存检查
$request->cache($config['request_cache'], $config['request_cache_expire'], $config['request_cache_except']);
$data = self::exec($dispatch, $config);
} catch (HttpResponseException $exception) {
$data = $exception->getResponse();
}
// 清空类的实例化
Loader::clearInstance();
// 输出数据到客户端
if ($data instanceof Response) {
$response = $data;
} elseif (!is_null($data)) {
// 默认自动识别响应输出类型
$isAjax = $request->isAjax();
$type = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
$response = Response::create($data, $type);
} else {
$response = Response::create();
}
// 监听app_end
Hook::listen('app_end', $response);
return $response;
}
/**
* 设置当前请求的调度信息
* @access public
* @param array|string $dispatch 调度信息
* @param string $type 调度类型
* @return void
*/
public static function dispatch($dispatch, $type = 'module')
{
self::$dispatch = ['type' => $type, $type => $dispatch];
}
/**
* 执行函数或者闭包方法 支持参数调用
* @access public
* @param string|array|\Closure $function 函数或者闭包
* @param array $vars 变量
* @return mixed
*/
public static function invokeFunction($function, $vars = [])
{
$reflect = new \ReflectionFunction($function);
$args = self::bindParams($reflect, $vars);
// 记录执行信息
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info');
return $reflect->invokeArgs($args);
}
/**
* 调用反射执行类的方法 支持参数绑定
* @access public
* @param string|array $method 方法
* @param array $vars 变量
* @return mixed
*/
public static function invokeMethod($method, $vars = [])
{
if (is_array($method)) {
$class = is_object($method[0]) ? $method[0] : self::invokeClass($method[0]);
$reflect = new \ReflectionMethod($class, $method[1]);
} else {
// 静态方法
$reflect = new \ReflectionMethod($method);
}
$args = self::bindParams($reflect, $vars);
self::$debug && Log::record('[ RUN ] ' . $reflect->class . '->' . $reflect->name . '[ ' . $reflect->getFileName() . ' ]', 'info');
return $reflect->invokeArgs(isset($class) ? $class : null, $args);
}
/**
* 调用反射执行类的实例化 支持依赖注入
* @access public
* @param string $class 类名
* @param array $vars 变量
* @return mixed
*/
public static function invokeClass($class, $vars = [])
{
$reflect = new \ReflectionClass($class);
$constructor = $reflect->getConstructor();
if ($constructor) {
$args = self::bindParams($constructor, $vars);
} else {
$args = [];
}
return $reflect->newInstanceArgs($args);
}
/**
* 绑定参数
* @access private
* @param \ReflectionMethod|\ReflectionFunction $reflect 反射类
* @param array $vars 变量
* @return array
*/
private static function bindParams($reflect, $vars = [])
{
if (empty($vars)) {
// 自动获取请求变量
if (Config::get('url_param_type')) {
$vars = Request::instance()->route();
} else {
$vars = Request::instance()->param();
}
}
$args = [];
if ($reflect->getNumberOfParameters() > 0) {
// 判断数组类型 数字数组时按顺序绑定参数
reset($vars);
$type = key($vars) === 0 ? 1 : 0;
$params = $reflect->getParameters();
foreach ($params as $param) {
$args[] = self::getParamValue($param, $vars, $type);
}
}
return $args;
}
/**
* 获取参数值
* @access private
* @param \ReflectionParameter $param
* @param array $vars 变量
* @param string $type
* @return array
*/
private static function getParamValue($param, &$vars, $type)
{
$name = $param->getName();
$class = $param->getClass();
if ($class) {
$className = $class->getName();
$bind = Request::instance()->$name;
if ($bind instanceof $className) {
$result = $bind;
} else {
if (method_exists($className, 'invoke')) {
$method = new \ReflectionMethod($className, 'invoke');
if ($method->isPublic() && $method->isStatic()) {
return $className::invoke(Request::instance());
}
}
$result = method_exists($className, 'instance') ? $className::instance() : new $className;
}
} elseif (1 == $type && !empty($vars)) {
$result = array_shift($vars);
} elseif (0 == $type && isset($vars[$name])) {
$result = $vars[$name];
} elseif ($param->isDefaultValueAvailable()) {
$result = $param->getDefaultValue();
} else {
throw new \InvalidArgumentException('method param miss:' . $name);
}
return $result;
}
protected static function exec($dispatch, $config)
{
switch ($dispatch['type']) {
case 'redirect':
// 执行重定向跳转
$data = Response::create($dispatch['url'], 'redirect')->code($dispatch['status']);
break;
case 'module':
// 模块/控制器/操作
$data = self::module($dispatch['module'], $config, isset($dispatch['convert']) ? $dispatch['convert'] : null);
break;
case 'controller':
// 执行控制器操作
$vars = array_merge(Request::instance()->param(), $dispatch['var']);
$data = Loader::action($dispatch['controller'], $vars, $config['url_controller_layer'], $config['controller_suffix']);
break;
case 'method':
// 执行回调方法
$vars = array_merge(Request::instance()->param(), $dispatch['var']);
$data = self::invokeMethod($dispatch['method'], $vars);
break;
case 'function':
// 执行闭包
$data = self::invokeFunction($dispatch['function']);
break;
case 'response':
$data = $dispatch['response'];
break;
default:
throw new \InvalidArgumentException('dispatch type not support');
}
return $data;
}
/**
* 执行模块
* @access public
* @param array $result 模块/控制器/操作
* @param array $config 配置参数
* @param bool $convert 是否自动转换控制器和操作名
* @return mixed
*/
public static function module($result, $config, $convert = null)
{
if (is_string($result)) {
$result = explode('/', $result);
}
$request = Request::instance();
if ($config['app_multi_module']) {
// 多模块部署
$module = strip_tags(strtolower($result[0] ?: $config['default_module']));
$bind = Route::getBind('module');
$available = false;
if ($bind) {
// 绑定模块
list($bindModule) = explode('/', $bind);
if (empty($result[0])) {
$module = $bindModule;
$available = true;
} elseif ($module == $bindModule) {
$available = true;
}
} elseif (!in_array($module, $config['deny_module_list']) && is_dir(APP_PATH . $module)) {
$available = true;
}
// 模块初始化
if ($module && $available) {
// 初始化模块
$request->module($module);
$config = self::init($module);
// 模块请求缓存检查
$request->cache($config['request_cache'], $config['request_cache_expire'], $config['request_cache_except']);
} else {
throw new HttpException(404, 'module not exists:' . $module);
}
} else {
// 单一模块部署
$module = '';
$request->module($module);
}
// 当前模块路径
App::$modulePath = APP_PATH . ($module ? $module . DS : '');
// 是否自动转换控制器和操作名
$convert = is_bool($convert) ? $convert : $config['url_convert'];
// 获取控制器名
$controller = strip_tags($result[1] ?: $config['default_controller']);
$controller = $convert ? strtolower($controller) : $controller;
// 获取操作名
$actionName = strip_tags($result[2] ?: $config['default_action']);
$actionName = $convert ? strtolower($actionName) : $actionName;
// 设置当前请求的控制器、操作
$request->controller(Loader::parseName($controller, 1))->action($actionName);
// 监听module_init
Hook::listen('module_init', $request);
try {
$instance = Loader::controller($controller, $config['url_controller_layer'], $config['controller_suffix'], $config['empty_controller']);
} catch (ClassNotFoundException $e) {
throw new HttpException(404, 'controller not exists:' . $e->getClass());
}
// 获取当前操作名
$action = $actionName . $config['action_suffix'];
$vars = [];
if (is_callable([$instance, $action])) {
// 执行操作方法
$call = [$instance, $action];
} elseif (is_callable([$instance, '_empty'])) {
// 空操作
$call = [$instance, '_empty'];
$vars = [$actionName];
} else {
// 操作不存在
throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()');
}
Hook::listen('action_begin', $call);
return self::invokeMethod($call, $vars);
}
/**
* 初始化应用
*/
public static function initCommon()
{
if (empty(self::$init)) {
if (defined('APP_NAMESPACE')) {
self::$namespace = APP_NAMESPACE;
}
Loader::addNamespace(self::$namespace, APP_PATH);
// 初始化应用
$config = self::init();
self::$suffix = $config['class_suffix'];
// 应用调试模式
self::$debug = Env::get('app_debug', Config::get('app_debug'));
if (!self::$debug) {
ini_set('display_errors', 'Off');
} elseif (!IS_CLI) {
//重新申请一块比较大的buffer
if (ob_get_level() > 0) {
$output = ob_get_clean();
}
ob_start();
if (!empty($output)) {
echo $output;
}
}
if (!empty($config['root_namespace'])) {
Loader::addNamespace($config['root_namespace']);
}
// 加载额外文件
if (!empty($config['extra_file_list'])) {
foreach ($config['extra_file_list'] as $file) {
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
if (is_file($file) && !isset(self::$file[$file])) {
include $file;
self::$file[$file] = true;
}
}
}
// 设置系统时区
date_default_timezone_set($config['default_timezone']);
// 监听app_init
Hook::listen('app_init');
self::$init = true;
}
return Config::get();
}
/**
* 初始化应用或模块
* @access public
* @param string $module 模块名
* @return array
*/
private static function init($module = '')
{
// 定位模块目录
$module = $module ? $module . DS : '';
// 加载初始化文件
if (is_file(APP_PATH . $module . 'init' . EXT)) {
include APP_PATH . $module . 'init' . EXT;
} elseif (is_file(RUNTIME_PATH . $module . 'init' . EXT)) {
include RUNTIME_PATH . $module . 'init' . EXT;
} else {
$path = APP_PATH . $module;
// 加载模块配置
$config = Config::load(CONF_PATH . $module . 'config' . CONF_EXT);
// 读取数据库配置文件
$filename = CONF_PATH . $module . 'database' . CONF_EXT;
Config::load($filename, 'database');
// 读取扩展配置文件
if (is_dir(CONF_PATH . $module . 'extra')) {
$dir = CONF_PATH . $module . 'extra';
$files = scandir($dir);
foreach ($files as $file) {
if ('.' . pathinfo($file, PATHINFO_EXTENSION) === CONF_EXT) {
$filename = $dir . DS . $file;
Config::load($filename, pathinfo($file, PATHINFO_FILENAME));
}
}
}
// 加载应用状态配置
if ($config['app_status']) {
$config = Config::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT);
}
// 加载行为扩展文件
if (is_file(CONF_PATH . $module . 'tags' . EXT)) {
Hook::import(include CONF_PATH . $module . 'tags' . EXT);
}
// 加载公共文件
if (is_file($path . 'common' . EXT)) {
include $path . 'common' . EXT;
}
// 加载当前模块语言包
if ($module) {
Lang::load($path . 'lang' . DS . Request::instance()->langset() . EXT);
}
}
return Config::get();
}
/**
* URL路由检测(根据PATH_INFO)
* @access public
* @param \think\Request $request
* @param array $config
* @return array
* @throws \think\Exception
*/
public static function routeCheck($request, array $config)
{
$path = $request->path();
$depr = $config['pathinfo_depr'];
$result = false;
// 路由检测
$check = !is_null(self::$routeCheck) ? self::$routeCheck : $config['url_route_on'];
if ($check) {
// 开启路由
if (is_file(RUNTIME_PATH . 'route.php')) {
// 读取路由缓存
$rules = include RUNTIME_PATH . 'route.php';
if (is_array($rules)) {
Route::rules($rules);
}
} else {
$files = $config['route_config_file'];
foreach ($files as $file) {
if (is_file(CONF_PATH . $file . CONF_EXT)) {
// 导入路由配置
$rules = include CONF_PATH . $file . CONF_EXT;
if (is_array($rules)) {
Route::import($rules);
}
}
}
}
// 路由检测(根据路由定义返回不同的URL调度)
$result = Route::check($request, $path, $depr, $config['url_domain_deploy']);
$must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must'];
if ($must && false === $result) {
// 路由无效
throw new RouteNotFoundException();
}
}
if (false === $result) {
// 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索
$result = Route::parseUrl($path, $depr, $config['controller_auto_search']);
}
return $result;
}
/**
* 设置应用的路由检测机制
* @access public
* @param bool $route 是否需要检测路由
* @param bool $must 是否强制检测路由
* @return void
*/
public static function route($route, $must = false)
{
self::$routeCheck = $route;
self::$routeMust = $must;
}
}
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think;
use think\exception\ClassNotFoundException;
use think\exception\HttpException;
use think\exception\HttpResponseException;
use think\exception\RouteNotFoundException;
/**
* App 应用管理
* @author liu21st <liu21st@gmail.com>
*/
class App
{
/**
* @var bool 是否初始化过
*/
protected static $init = false;
/**
* @var string 当前模块路径
*/
public static $modulePath;
/**
* @var bool 应用调试模式
*/
public static $debug = true;
/**
* @var string 应用类库命名空间
*/
public static $namespace = 'app';
/**
* @var bool 应用类库后缀
*/
public static $suffix = false;
/**
* @var bool 应用路由检测
*/
protected static $routeCheck;
/**
* @var bool 严格路由检测
*/
protected static $routeMust;
protected static $dispatch;
protected static $file = [];
/**
* 执行应用程序
* @access public
* @param Request $request Request对象
* @return Response
* @throws Exception
*/
public static function run(Request $request = null)
{
is_null($request) && $request = Request::instance();
try {
$config = self::initCommon();
if (defined('BIND_MODULE')) {
// 模块/控制器绑定
BIND_MODULE && Route::bind(BIND_MODULE);
} elseif ($config['auto_bind_module']) {
// 入口自动绑定
$name = pathinfo($request->baseFile(), PATHINFO_FILENAME);
if ($name && 'index' != $name && is_dir(APP_PATH . $name)) {
Route::bind($name);
}
}
$request->filter($config['default_filter']);
// 默认语言
Lang::range($config['default_lang']);
if ($config['lang_switch_on']) {
// 开启多语言机制 检测当前语言
Lang::detect();
}
$request->langset(Lang::range());
// 加载系统语言包
Lang::load([
THINK_PATH . 'lang' . DS . $request->langset() . EXT,
APP_PATH . 'lang' . DS . $request->langset() . EXT,
]);
// 获取应用调度信息
$dispatch = self::$dispatch;
if (empty($dispatch)) {
// 进行URL路由检测
$dispatch = self::routeCheck($request, $config);
}
// 记录当前调度信息
$request->dispatch($dispatch);
// 记录路由和请求信息
if (self::$debug) {
Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info');
Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info');
}
// 监听app_begin
Hook::listen('app_begin', $dispatch);
// 请求缓存检查
$request->cache($config['request_cache'], $config['request_cache_expire'], $config['request_cache_except']);
$data = self::exec($dispatch, $config);
} catch (HttpResponseException $exception) {
$data = $exception->getResponse();
}
// 清空类的实例化
Loader::clearInstance();
// 输出数据到客户端
if ($data instanceof Response) {
$response = $data;
} elseif (!is_null($data)) {
// 默认自动识别响应输出类型
$isAjax = $request->isAjax();
$type = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
$response = Response::create($data, $type);
} else {
$response = Response::create();
}
// 监听app_end
Hook::listen('app_end', $response);
return $response;
}
/**
* 设置当前请求的调度信息
* @access public
* @param array|string $dispatch 调度信息
* @param string $type 调度类型
* @return void
*/
public static function dispatch($dispatch, $type = 'module')
{
self::$dispatch = ['type' => $type, $type => $dispatch];
}
/**
* 执行函数或者闭包方法 支持参数调用
* @access public
* @param string|array|\Closure $function 函数或者闭包
* @param array $vars 变量
* @return mixed
*/
public static function invokeFunction($function, $vars = [])
{
$reflect = new \ReflectionFunction($function);
$args = self::bindParams($reflect, $vars);
// 记录执行信息
self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info');
return $reflect->invokeArgs($args);
}
/**
* 调用反射执行类的方法 支持参数绑定
* @access public
* @param string|array $method 方法
* @param array $vars 变量
* @return mixed
*/
public static function invokeMethod($method, $vars = [])
{
if (is_array($method)) {
$class = is_object($method[0]) ? $method[0] : self::invokeClass($method[0]);
$reflect = new \ReflectionMethod($class, $method[1]);
} else {
// 静态方法
$reflect = new \ReflectionMethod($method);
}
$args = self::bindParams($reflect, $vars);
self::$debug && Log::record('[ RUN ] ' . $reflect->class . '->' . $reflect->name . '[ ' . $reflect->getFileName() . ' ]', 'info');
return $reflect->invokeArgs(isset($class) ? $class : null, $args);
}
/**
* 调用反射执行类的实例化 支持依赖注入
* @access public
* @param string $class 类名
* @param array $vars 变量
* @return mixed
*/
public static function invokeClass($class, $vars = [])
{
$reflect = new \ReflectionClass($class);
$constructor = $reflect->getConstructor();
if ($constructor) {
$args = self::bindParams($constructor, $vars);
} else {
$args = [];
}
return $reflect->newInstanceArgs($args);
}
/**
* 绑定参数
* @access private
* @param \ReflectionMethod|\ReflectionFunction $reflect 反射类
* @param array $vars 变量
* @return array
*/
private static function bindParams($reflect, $vars = [])
{
if (empty($vars)) {
// 自动获取请求变量
if (Config::get('url_param_type')) {
$vars = Request::instance()->route();
} else {
$vars = Request::instance()->param();
}
}
$args = [];
if ($reflect->getNumberOfParameters() > 0) {
// 判断数组类型 数字数组时按顺序绑定参数
reset($vars);
$type = key($vars) === 0 ? 1 : 0;
$params = $reflect->getParameters();
foreach ($params as $param) {
$args[] = self::getParamValue($param, $vars, $type);
}
}
return $args;
}
/**
* 获取参数值
* @access private
* @param \ReflectionParameter $param
* @param array $vars 变量
* @param string $type
* @return array
*/
private static function getParamValue($param, &$vars, $type)
{
$name = $param->getName();
$class = $param->getClass();
if ($class) {
$className = $class->getName();
$bind = Request::instance()->$name;
if ($bind instanceof $className) {
$result = $bind;
} else {
if (method_exists($className, 'invoke')) {
$method = new \ReflectionMethod($className, 'invoke');
if ($method->isPublic() && $method->isStatic()) {
return $className::invoke(Request::instance());
}
}
$result = method_exists($className, 'instance') ? $className::instance() : new $className;
}
} elseif (1 == $type && !empty($vars)) {
$result = array_shift($vars);
} elseif (0 == $type && isset($vars[$name])) {
$result = $vars[$name];
} elseif ($param->isDefaultValueAvailable()) {
$result = $param->getDefaultValue();
} else {
throw new \InvalidArgumentException('method param miss:' . $name);
}
return $result;
}
protected static function exec($dispatch, $config)
{
switch ($dispatch['type']) {
case 'redirect':
// 执行重定向跳转
$data = Response::create($dispatch['url'], 'redirect')->code($dispatch['status']);
break;
case 'module':
// 模块/控制器/操作
$data = self::module($dispatch['module'], $config, isset($dispatch['convert']) ? $dispatch['convert'] : null);
break;
case 'controller':
// 执行控制器操作
$vars = array_merge(Request::instance()->param(), $dispatch['var']);
$data = Loader::action($dispatch['controller'], $vars, $config['url_controller_layer'], $config['controller_suffix']);
break;
case 'method':
// 执行回调方法
$vars = array_merge(Request::instance()->param(), $dispatch['var']);
$data = self::invokeMethod($dispatch['method'], $vars);
break;
case 'function':
// 执行闭包
$data = self::invokeFunction($dispatch['function']);
break;
case 'response':
$data = $dispatch['response'];
break;
default:
throw new \InvalidArgumentException('dispatch type not support');
}
return $data;
}
/**
* 执行模块
* @access public
* @param array $result 模块/控制器/操作
* @param array $config 配置参数
* @param bool $convert 是否自动转换控制器和操作名
* @return mixed
*/
public static function module($result, $config, $convert = null)
{
if (is_string($result)) {
$result = explode('/', $result);
}
$request = Request::instance();
if ($config['app_multi_module']) {
// 多模块部署
$module = strip_tags(strtolower($result[0] ?: $config['default_module']));
$bind = Route::getBind('module');
$available = false;
if ($bind) {
// 绑定模块
list($bindModule) = explode('/', $bind);
if (empty($result[0])) {
$module = $bindModule;
$available = true;
} elseif ($module == $bindModule) {
$available = true;
}
} elseif (!in_array($module, $config['deny_module_list']) && is_dir(APP_PATH . $module)) {
$available = true;
}
// 模块初始化
if ($module && $available) {
// 初始化模块
$request->module($module);
$config = self::init($module);
// 模块请求缓存检查
$request->cache($config['request_cache'], $config['request_cache_expire'], $config['request_cache_except']);
} else {
throw new HttpException(404, 'module not exists:' . $module);
}
} else {
// 单一模块部署
$module = '';
$request->module($module);
}
// 当前模块路径
App::$modulePath = APP_PATH . ($module ? $module . DS : '');
// 是否自动转换控制器和操作名
$convert = is_bool($convert) ? $convert : $config['url_convert'];
// 获取控制器名
$controller = strip_tags($result[1] ?: $config['default_controller']);
$controller = $convert ? strtolower($controller) : $controller;
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
// 获取操作名
$actionName = strip_tags($result[2] ?: $config['default_action']);
$actionName = $convert ? strtolower($actionName) : $actionName;
// 设置当前请求的控制器、操作
$request->controller(Loader::parseName($controller, 1))->action($actionName);
// 监听module_init
Hook::listen('module_init', $request);
try {
$instance = Loader::controller($controller, $config['url_controller_layer'], $config['controller_suffix'], $config['empty_controller']);
} catch (ClassNotFoundException $e) {
throw new HttpException(404, 'controller not exists:' . $e->getClass());
}
// 获取当前操作名
$action = $actionName . $config['action_suffix'];
$vars = [];
if (is_callable([$instance, $action])) {
// 执行操作方法
$call = [$instance, $action];
} elseif (is_callable([$instance, '_empty'])) {
// 空操作
$call = [$instance, '_empty'];
$vars = [$actionName];
} else {
// 操作不存在
throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()');
}
Hook::listen('action_begin', $call);
return self::invokeMethod($call, $vars);
}
/**
* 初始化应用
*/
public static function initCommon()
{
if (empty(self::$init)) {
if (defined('APP_NAMESPACE')) {
self::$namespace = APP_NAMESPACE;
}
Loader::addNamespace(self::$namespace, APP_PATH);
// 初始化应用
$config = self::init();
self::$suffix = $config['class_suffix'];
// 应用调试模式
self::$debug = Env::get('app_debug', Config::get('app_debug'));
if (!self::$debug) {
ini_set('display_errors', 'Off');
} elseif (!IS_CLI) {
//重新申请一块比较大的buffer
if (ob_get_level() > 0) {
$output = ob_get_clean();
}
ob_start();
if (!empty($output)) {
echo $output;
}
}
if (!empty($config['root_namespace'])) {
Loader::addNamespace($config['root_namespace']);
}
// 加载额外文件
if (!empty($config['extra_file_list'])) {
foreach ($config['extra_file_list'] as $file) {
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
if (is_file($file) && !isset(self::$file[$file])) {
include $file;
self::$file[$file] = true;
}
}
}
// 设置系统时区
date_default_timezone_set($config['default_timezone']);
// 监听app_init
Hook::listen('app_init');
self::$init = true;
}
return Config::get();
}
/**
* 初始化应用或模块
* @access public
* @param string $module 模块名
* @return array
*/
private static function init($module = '')
{
// 定位模块目录
$module = $module ? $module . DS : '';
// 加载初始化文件
if (is_file(APP_PATH . $module . 'init' . EXT)) {
include APP_PATH . $module . 'init' . EXT;
} elseif (is_file(RUNTIME_PATH . $module . 'init' . EXT)) {
include RUNTIME_PATH . $module . 'init' . EXT;
} else {
$path = APP_PATH . $module;
// 加载模块配置
$config = Config::load(CONF_PATH . $module . 'config' . CONF_EXT);
// 读取数据库配置文件
$filename = CONF_PATH . $module . 'database' . CONF_EXT;
Config::load($filename, 'database');
// 读取扩展配置文件
if (is_dir(CONF_PATH . $module . 'extra')) {
$dir = CONF_PATH . $module . 'extra';
$files = scandir($dir);
foreach ($files as $file) {
if ('.' . pathinfo($file, PATHINFO_EXTENSION) === CONF_EXT) {
$filename = $dir . DS . $file;
Config::load($filename, pathinfo($file, PATHINFO_FILENAME));
}
}
}
// 加载应用状态配置
if ($config['app_status']) {
$config = Config::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT);
}
// 加载行为扩展文件
if (is_file(CONF_PATH . $module . 'tags' . EXT)) {
Hook::import(include CONF_PATH . $module . 'tags' . EXT);
}
// 加载公共文件
if (is_file($path . 'common' . EXT)) {
include $path . 'common' . EXT;
}
// 加载当前模块语言包
if ($module) {
Lang::load($path . 'lang' . DS . Request::instance()->langset() . EXT);
}
}
return Config::get();
}
/**
* URL路由检测(根据PATH_INFO)
* @access public
* @param \think\Request $request
* @param array $config
* @return array
* @throws \think\Exception
*/
public static function routeCheck($request, array $config)
{
$path = $request->path();
$depr = $config['pathinfo_depr'];
$result = false;
// 路由检测
$check = !is_null(self::$routeCheck) ? self::$routeCheck : $config['url_route_on'];
if ($check) {
// 开启路由
if (is_file(RUNTIME_PATH . 'route.php')) {
// 读取路由缓存
$rules = include RUNTIME_PATH . 'route.php';
if (is_array($rules)) {
Route::rules($rules);
}
} else {
$files = $config['route_config_file'];
foreach ($files as $file) {
if (is_file(CONF_PATH . $file . CONF_EXT)) {
// 导入路由配置
$rules = include CONF_PATH . $file . CONF_EXT;
if (is_array($rules)) {
Route::import($rules);
}
}
}
}
// 路由检测(根据路由定义返回不同的URL调度)
$result = Route::check($request, $path, $depr, $config['url_domain_deploy']);
$must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must'];
if ($must && false === $result) {
// 路由无效
throw new RouteNotFoundException();
}
}
if (false === $result) {
// 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索
$result = Route::parseUrl($path, $depr, $config['controller_auto_search']);
}
return $result;
}
/**
* 设置应用的路由检测机制
* @access public
* @param bool $route 是否需要检测路由
* @param bool $must 是否强制检测路由
* @return void
*/
public static function route($route, $must = false)
{
self::$routeCheck = $route;
self::$routeMust = $must;
}
}
... ...