...
|
...
|
@@ -64,7 +64,46 @@ class Bootstrap extends Bootstrap_Abstract |
|
|
*/
|
|
|
public function _initRoute(Dispatcher $dispatcher)
|
|
|
{
|
|
|
$iniFile = APPLICATION_PATH . '/configs/routes.index.ini';
|
|
|
$hostParts = explode('.', $dispatcher->getRequest()->getServer('HTTP_HOST', ''));
|
|
|
$level = count($hostParts) - 1;
|
|
|
|
|
|
/* 根据域名的级别,设置默认的模块、控制器、方法 */
|
|
|
$module = 'Index';
|
|
|
$controller = 'Index';
|
|
|
$action = 'Index';
|
|
|
// 三级域名
|
|
|
if (3 === $level) {
|
|
|
$subDomain = strval($hostParts[0]);
|
|
|
switch (strtolower($subDomain)) {
|
|
|
case 'm': // 老版(到频道选择)
|
|
|
case 'buy': // 测试环境的域名, 以后可去掉
|
|
|
break;
|
|
|
case 'new': // 原新版(到男生首页)
|
|
|
$controller = 'Boys';
|
|
|
break;
|
|
|
case 'search': // 搜索
|
|
|
$controller = 'Search';
|
|
|
$action = 'List';
|
|
|
break;
|
|
|
case 'guang': // 逛
|
|
|
$module = 'Guang';
|
|
|
break;
|
|
|
case 'list': // 商品列表
|
|
|
$module = 'Product';
|
|
|
break;
|
|
|
default: // 其它(识别为品牌)
|
|
|
$module = 'Product';
|
|
|
$action = 'Brand';
|
|
|
$dispatcher->getRequest()->setParam('named', $subDomain);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
$dispatcher->getRequest()->module = $module;
|
|
|
$dispatcher->getRequest()->controller = $controller;
|
|
|
$dispatcher->getRequest()->action = $action;
|
|
|
|
|
|
/* 根据对应模块的配置,添加相应的路由规则 */
|
|
|
$iniFile = APPLICATION_PATH . '/configs/routes.' . strtolower($module) . '.ini';
|
|
|
if (file_exists($iniFile)) {
|
|
|
$config = new Config\Ini($iniFile);
|
|
|
if (isset($config->routes)) {
|
...
|
...
|
|