Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
hf
9 years ago
Commit
47fab2f881734dd3b6ce92e9274717ce7fceaad1
1 parent
43c3427c
do domain merge support old code
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
3 deletions
yohobuy/m.yohobuy.com/application/Bootstrap.php
yohobuy/m.yohobuy.com/application/Bootstrap.php
View file @
47fab2f
...
...
@@ -64,10 +64,39 @@ class Bootstrap extends Bootstrap_Abstract
*/
public
function
_initRoute
(
Dispatcher
$dispatcher
)
{
$config
=
new
Config\Ini
(
APPLICATION_PATH
.
'/configs/routes.ini'
);
if
(
isset
(
$config
->
routes
))
{
$dispatcher
->
getRouter
()
->
addConfig
(
$config
->
routes
);
/* 根据域名的级别,选择对应的模块 */
$hostParts
=
explode
(
'.'
,
$dispatcher
->
getRequest
()
->
getServer
(
'HTTP_HOST'
,
''
));
$level
=
count
(
$hostParts
)
-
1
;
$module
=
'Index'
;
// 三级域名
if
(
$level
===
3
)
{
switch
(
strtolower
(
strval
(
$hostParts
[
0
])))
{
case
'm'
:
case
'new'
:
// 默认
$module
=
'Index'
;
break
;
case
'guang'
:
// 逛
$module
=
'Guang'
;
break
;
case
'list'
:
// 商品列表
$module
=
'Product'
;
break
;
default
:
// 其它(识别为品牌)
$module
=
'Brand'
;
break
;
}
}
$dispatcher
->
getRequest
()
->
module
=
$module
;
/* 根据对应模块的配置,添加相应的路由规则 */
$iniFile
=
APPLICATION_PATH
.
'/configs/routes.'
.
strtolower
(
$module
)
.
'ini'
;
if
(
file_exists
(
$iniFile
))
{
$config
=
new
Config\Ini
(
$iniFile
);
if
(
isset
(
$config
->
routes
))
{
$dispatcher
->
getRouter
()
->
addConfig
(
$config
->
routes
);
}
}
}
/**
...
...
Please
register
or
login
to post a comment