ComposerUpdate 增加多语言支持

This commit is contained in:
Anyon 2019-12-30 14:45:12 +08:00
parent 16e8738ee7
commit c5955f7880
12 changed files with 291 additions and 30 deletions

View File

@ -155,4 +155,220 @@
.layui-layout.layui-layout-left-hide [data-target-menu-type] { .layui-layout.layui-layout-left-hide [data-target-menu-type] {
display: none; display: none;
} }
/* 通用分页 */
.pagination-container {
line-height: 40px;
}
.pagination-container > span {
color: #666;
font-size: 9pt;
}
.pagination-container > ul {
float: right;
display: inline-block;
margin: 0;
padding: 0;
}
.pagination-container > ul > li {
z-index: 1;
display: inline-block;
}
.pagination-container > ul > li.active {
z-index: 2;
}
.pagination-container > ul > li.active > span {
color: #fff;
border-color: #098;
padding-right: 1px;
background: #009688 !important;
}
.pagination-container > ul > li > a,
.pagination-container > ul > li > span {
color: #333;
width: 33px;
height: 30px;
border: 1px solid #dcdcdc;
display: inline-block;
margin-left: -1px;
text-align: center;
line-height: 28px;
}
.pagination-container > ul > li > span {
background: #dcdcdc;
cursor: default;
}
.pagination-container > ul > li > a:hover {
background: #dcdcdc;
border-color: #dcdcdc;
}
/** 手机盒子及微信菜单 */
.mobile-preview {
width: 317px;
height: 580px;
position: relative;
background: url(../img/wechat/mobile_head.png) no-repeat 0 0;
}
.mobile-preview .mobile-header {
color: #fff;
width: auto;
margin: 0 30px;
overflow: hidden;
font-size: 15px;
padding-top: 30px;
text-align: center;
white-space: nowrap;
text-overflow: ellipsis;
word-wrap: normal;
user-select: none;
pointer-events: none;
-moz-user-select: none;
-webkit-user-select: none;
-webkit-pointer-events: none;
}
.mobile-preview .mobile-body {
top: 60px;
left: 0;
right: 0;
bottom: 0;
position: absolute;
border: 1px solid #ccc;
background: #f5f5f5;
}
.mobile-preview .mobile-body iframe {
width: 100%;
height: 100%;
}
.mobile-preview .mobile-footer {
left: 0;
right: 0;
bottom: 0;
margin: 0;
position: absolute;
padding-left: 43px;
border: 1px solid #ccc;
list-style-type: none;
background: url(../img/wechat/mobile_foot.png) no-repeat 0 0;
}
.mobile-preview .mobile-footer li {
float: left;
width: 33.33%;
position: relative;
text-align: center;
line-height: 50px;
}
.mobile-preview .mobile-footer li a {
width: auto;
display: block;
overflow: hidden;
border: 1px solid hsla(0, 0%, 100%, 0);
border-left: 1px solid #e7e7eb;
margin-top: -1px;
margin-bottom: -1px;
color: #616161;
white-space: nowrap;
text-decoration: none;
text-overflow: ellipsis;
word-wrap: normal;
}
.mobile-preview .mobile-footer li a:hover {
background: rgba(0, 0, 0, 0.02);
}
.mobile-preview .mobile-footer li a.active {
border: 1px solid #44b549 !important;
box-shadow: 0 0 1px #44b549;
}
.mobile-preview .mobile-footer li a span:before {
width: 1px;
height: 1px;
content: '';
display: inline-block;
}
.mobile-preview .mobile-footer li > .close {
top: 1px;
right: 1px;
width: 18px;
height: 18px;
display: none;
cursor: pointer;
position: absolute;
text-align: center;
line-height: 18px;
}
.mobile-preview .mobile-footer li:hover > .close {
display: inline-block;
}
.mobile-preview .mobile-footer li:hover > .close:hover {
color: #fff !important;
background: #999 !important;
}
.mobile-preview .mobile-footer .icon-add {
width: 14px;
height: 14px;
border-bottom: none !important;
background: url(../img/wechat/index.png) 0 0 no-repeat;
}
.mobile-preview .mobile-footer .icon-add,
.mobile-preview .mobile-footer .icon-sub {
display: inline-block;
vertical-align: middle;
}
.mobile-preview .mobile-footer .icon-sub {
width: 7px;
height: 7px;
margin-right: 2px;
background: url(../img/wechat/index.png) 0 -3pc no-repeat;
}
.mobile-preview .mobile-footer .sub-menu {
width: 100%;
bottom: 60px;
margin: -1px;
display: block;
position: absolute;
border: 1px solid #d0d0d0;
background-color: #fafafa;
}
.mobile-preview .mobile-footer .sub-menu ul,
.mobile-preview .mobile-footer .sub-menu ul li {
float: none;
padding: 0;
z-index: 11;
display: block;
width: 100%;
}
.mobile-preview .mobile-footer .sub-menu ul li a {
padding: 0 5px;
border: 1px solid hsla(0, 0%, 100%, 0);
}
.mobile-preview .mobile-footer .sub-menu ul li a.bottom-border {
margin: -1px -1px 0;
border-bottom: 1px solid #e7e7eb;
}
.mobile-preview .mobile-footer .sub-menu ul li:last-child a.bottom-border {
border-bottom-color: #fff;
}
.mobile-preview .mobile-footer .arrow {
left: 50%;
position: absolute;
margin-left: -6px;
}
.mobile-preview .mobile-footer .arrow_in,
.mobile-preview .mobile-footer .arrow_out {
width: 0;
height: 0;
z-index: 10;
display: inline-block;
border: 6px dashed transparent;
border-bottom-width: 0;
border-top-style: solid;
}
.mobile-preview .mobile-footer .arrow_in {
z-index: 3;
bottom: -5px;
border-top-color: #fafafa;
}
.mobile-preview .mobile-footer .arrow_out {
z-index: 2;
bottom: -6px;
border-top-color: #d0d0d0;
}
/*# sourceMappingURL=console.layout.css.map */ /*# sourceMappingURL=console.layout.css.map */

View File

@ -1 +1 @@
{"version":3,"sources":["console.layout.less"],"names":[],"mappings":";AACA,aACE;EACE,SAAA;EACA,SAAA;EACA,cAAA;;AAJJ,aAOE;EACE,SAAA;EACA,SAAA;EACA,cAAA;;AAVJ,aAOE,cAKE;EACE,gBAAA;;AAbN,aAOE,cAKE,cAGE;EACE,kBAAA;;AAhBR,aAOE,cAKE,cAOE;EACE,YAAA;EACA,YAAA;EACA,iBAAA;EACA,0CAAA;EACA,gBAAA;;;AAOR;EACE,YAAA;EACA,mBAAA;;AAFF,aAIE;EAEE,uCAAA;EACA,2CAAA;;AAPJ,aAUE;AAVF,aAWE;EACE,UAAA;;AAZJ,aAeE;EACE,WAAA;EACA,YAAA;EACA,YAAA;EACA,eAAA;EACA,iBAAA;EACA,2CAAA;EACA,4CAAA;;AAtBJ,aAeE,YASE;EACE,cAAA;EACA,gBAAA;;AA1BN,aA8BE;EACE,YAAA;EACA,iBAAA;;AAEA,aAJF,gBAIG;EACC,mBAAA;;AAnCN,aA8BE,gBAQE;EACE,WAAA;;AAvCN,aA8BE,gBAYE;EACE,SAAA;EACA,UAAA;EACA,YAAA;EACA,iBAAA;;AA9CN,aA8BE,gBAYE,iBAME;EACE,mBAAA;;AAGF,aAtBJ,gBAYE,iBAUG,WAAY;EACX,gBAAA;;AAGF,aA1BJ,gBAYE,iBAcG,WAAY,IAAI;EACf,WAAA;;AAzDR,aA8BE,gBAYE,iBAkBE,GAAG;EACD,UAAA;EACA,WAAA;EACA,kBAAA;EACA,6BAAA;;AAhER,aAqEE;AArEF,aAqEkB,gBAAe;EAC7B,aAAA;;AAtEJ,aAyEE,oBACE,KAAK;EACH,0CAAA;EACA,wCAAA;;;AAMN,aAEE,cACE;EACE,aAAA;;AAJN,aAEE,cAKE;EACE,WAAA;;AARN,aAEE,cASE;EACE,2CAAA;;AAZN,aAEE,cASE,gBAGE;EACE,YAAA;EACA,cAAA;EACA,iBAAA;EACA,WAAA;;AAEA,aAlBN,cASE,gBAGE,EAMG;EACC,iCAAA;;AArBV,aAEE,cAwBE;EACE,mBAAA;;AA3BN,aAEE,cA4BE,oBAAoB;EAClB,uBAAA;EACA,iBAAA;;AAIJ,aAAC,uBACC;EACE,UAAA;;AAFJ,aAAC,uBAKC,cACE;EACE,aAAA;;AAPN,aAAC,uBAKC,cAKE,gBACE;EACE,UAAA;;AAZR,aAAC,uBAKC,cAKE,gBAKE;EACE,aAAA;;AAhBR,aAAC,uBAKC,cAKE,gBASE;EACE,qBAAA;EACA,UAAA;;AArBR,aAAC,uBAKC,cAKE,gBAcE;EACE,UAAA;EACA,yBAAA;EACA,oCAAA;;AAIJ,aA/BH,uBAKC;AALF,aAAC,uBAKC,cA0BK;AA/BP,aAAC,uBAKC,cA0BsB;EAClB,WAAA;EACA,kBAAA;;AAjCN,aAAC,uBAqCC,wBAAwB;EACtB,qBAAA;EACA,mBAAmB,cAAnB;EACA,WAAW,cAAX;EACA,eAAe,cAAf;;AAIJ,aAAC,uBACC;EACE,OAAA;;AAFJ,aAAC,uBAKC;EACE,aAAA;;AANJ,aAAC,uBASC;EACE,aAAA","file":"console.layout.css"} {"version":3,"sources":["console.layout.less"],"names":[],"mappings":";AACA,aACE;EACE,SAAA;EACA,SAAA;EACA,cAAA;;AAJJ,aAO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;EACA,yDAAA;;AA9HN,eAuCE,eA0FE;EACE,WAAA;EACA,YAAA;EACA,YAAA;EACA,cAAA;EACA,kBAAA;EACA,yBAAA;EACA,yBAAA;;AAxIN,eAuCE,eA0FE,UASE;AA1IN,eAuCE,eA0FE,UASM,GAAG;EACL,WAAA;EACA,UAAA;EACA,WAAA;EACA,cAAA;EACA,WAAA;;AA/IR,eAuCE,eA0FE,UAiBE,GAAG,GACD;EACE,cAAA;EACA,sCAAA;;AAEA,eAhHR,eA0FE,UAiBE,GAAG,GACD,EAIG;EACC,mBAAA;EACA,gCAAA;;AAIJ,eAtHN,eA0FE,UAiBE,GAAG,GAWA,WAAY,EAAC;EACZ,yBAAA;;AA9JV,eAuCE,eA4HE;EACE,SAAA;EACA,kBAAA;EACA,iBAAA;;AAtKN,eAuCE,eAkIE;AAzKJ,eAuCE,eAkIa;EACT,QAAA;EACA,SAAA;EACA,WAAA;EACA,qBAAA;EACA,8BAAA;EACA,sBAAA;EACA,uBAAA;;AAhLN,eAuCE,eA4IE;EACE,UAAA;EACA,YAAA;EACA,yBAAA;;AAtLN,eAuCE,eAkJE;EACE,UAAA;EACA,YAAA;EACA,yBAAA","file":"console.layout.css"}

View File

@ -401,12 +401,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "80a2dd413f62f0915afbb7be7ac43b8c8bd742d3" "reference": "294304e62f54fcafbd5983386bf02abdd43af0ff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/80a2dd413f62f0915afbb7be7ac43b8c8bd742d3", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/294304e62f54fcafbd5983386bf02abdd43af0ff",
"reference": "80a2dd413f62f0915afbb7be7ac43b8c8bd742d3", "reference": "294304e62f54fcafbd5983386bf02abdd43af0ff",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -426,7 +426,7 @@
"qiniu/php-sdk": "^7.2", "qiniu/php-sdk": "^7.2",
"topthink/framework": "5.1.*" "topthink/framework": "5.1.*"
}, },
"time": "2019-12-17T10:41:31+00:00", "time": "2019-12-30T06:33:48+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {

View File

@ -59,7 +59,7 @@ abstract class Controller extends \stdClass
* 表单CSRF验证失败提示消息 * 表单CSRF验证失败提示消息
* @var string * @var string
*/ */
public $csrf_message = '表单令牌验证失败,请刷新页面再试!'; public $csrf_message = '';
/** /**
* Controller constructor. * Controller constructor.
@ -114,6 +114,9 @@ abstract class Controller extends \stdClass
*/ */
protected function initialize() protected function initialize()
{ {
if (empty($this->csrf_message)) {
$this->csrf_message = lang('think_library_csrf_error');
}
} }
/** /**

View File

@ -15,15 +15,14 @@
use library\service\TokenService; use library\service\TokenService;
use library\tools\Crypt; use library\tools\Crypt;
use library\tools\Csrf;
use library\tools\Data; use library\tools\Data;
use library\tools\Emoji; use library\tools\Emoji;
use library\tools\Http; use library\tools\Http;
use library\tools\Node;
use think\Console; use think\Console;
use think\Db; use think\Db;
use think\db\Query; use think\db\Query;
use think\facade\Cache; use think\facade\Cache;
use think\facade\Lang;
use think\facade\Middleware; use think\facade\Middleware;
use think\Request; use think\Request;
@ -271,6 +270,11 @@ if (class_exists('think\Console')) {
]); ]);
} }
// 加载对应的语言包
if (Lang::range() === 'zh-cn') {
Lang::load(__DIR__ . '/lang/zh-cn.php', 'zh-cn');
}
// 动态加载模块配置 // 动态加载模块配置
if (function_exists('think\__include_file')) { if (function_exists('think\__include_file')) {
$root = rtrim(str_replace('\\', '/', env('app_path')), '/'); $root = rtrim(str_replace('\\', '/', env('app_path')), '/');

View File

@ -123,8 +123,9 @@ class Local extends File
{ {
if ($this->has($name, $safe) && is_string($file = $this->path($name, $safe))) { if ($this->has($name, $safe) && is_string($file = $this->path($name, $safe))) {
return ['file' => $file, 'hash' => md5_file($file), 'url' => $this->base($name), 'key' => "upload/{$name}"]; return ['file' => $file, 'hash' => md5_file($file), 'url' => $this->base($name), 'key' => "upload/{$name}"];
} else {
return null;
} }
return null;
} }
/** /**
@ -137,8 +138,9 @@ class Local extends File
{ {
if ($this->has($name, $safe) && is_string($file = $this->path($name, $safe))) { if ($this->has($name, $safe) && is_string($file = $this->path($name, $safe))) {
return @unlink($file); return @unlink($file);
} else {
return true;
} }
return true;
} }
} }

View File

@ -78,9 +78,9 @@ class DeleteHelper extends Helper
} }
// 回复前端结果 // 回复前端结果
if ($result !== false) { if ($result !== false) {
$this->controller->success('数据删除成功!', ''); $this->controller->success(lang('think_library_delete_success'), '');
} else { } else {
$this->controller->error('数据删除失败, 请稍候再试!'); $this->controller->error(lang('think_library_delete_error'));
} }
} }
} }

View File

@ -62,7 +62,7 @@ class FormHelper extends Helper
* @param string $field 指定数据主键 * @param string $field 指定数据主键
* @param array $where 额外更新条件 * @param array $where 额外更新条件
* @param array $data 表单扩展数据 * @param array $data 表单扩展数据
* @return array|boolean * @return array|mixed
* @throws \think\Exception * @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
@ -84,8 +84,9 @@ class FormHelper extends Helper
$data = array_merge($data, $this->data); $data = array_merge($data, $this->data);
if (false !== $this->controller->callback('_form_filter', $data)) { if (false !== $this->controller->callback('_form_filter', $data)) {
return $this->controller->fetch($this->template, ['vo' => $data]); return $this->controller->fetch($this->template, ['vo' => $data]);
} else {
return $data;
} }
return $data;
} }
// POST请求, 数据自动存库处理 // POST请求, 数据自动存库处理
if ($this->app->request->isPost()) { if ($this->app->request->isPost()) {
@ -93,8 +94,11 @@ class FormHelper extends Helper
if (false !== $this->controller->callback('_form_filter', $data, $this->where)) { if (false !== $this->controller->callback('_form_filter', $data, $this->where)) {
$result = data_save($this->query, $data, $this->field, $this->where); $result = data_save($this->query, $data, $this->field, $this->where);
if (false !== $this->controller->callback('_form_result', $result, $data)) { if (false !== $this->controller->callback('_form_result', $result, $data)) {
if ($result !== false) $this->controller->success('恭喜, 数据保存成功!', ''); if ($result !== false) {
$this->controller->error('数据保存失败, 请稍候再试!'); $this->controller->success(lang('think_library_form_success'), '');
} else {
$this->controller->error(lang('think_library_form_error'));
}
} }
return $result; return $result;
} }

View File

@ -57,7 +57,7 @@ class PageHelper extends Helper
* @param boolean $display 是否渲染模板 * @param boolean $display 是否渲染模板
* @param boolean $total 集合分页记录数 * @param boolean $total 集合分页记录数
* @param integer $limit 集合每页记录数 * @param integer $limit 集合每页记录数
* @return array * @return array|mixed
* @throws \think\Exception * @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
@ -90,17 +90,19 @@ class PageHelper extends Helper
$url = url('@admin') . '#' . $this->controller->request->baseUrl() . '?' . urldecode(http_build_query($query)); $url = url('@admin') . '#' . $this->controller->request->baseUrl() . '?' . urldecode(http_build_query($query));
array_push($rows, "<option data-num='{$num}' value='{$url}' {$selected}>{$num}</option>"); array_push($rows, "<option data-num='{$num}' value='{$url}' {$selected}>{$num}</option>");
} }
$select = "<select onchange='location.href=this.options[this.selectedIndex].value' data-auto-none>" . join('', $rows) . "</select>"; $selects = "<select onchange='location.href=this.options[this.selectedIndex].value' data-auto-none>" . join('', $rows) . "</select>";
$html = "<div class='pagination-container nowrap'><span>共 {$page->total()} 条记录,每页显示 {$select} 条,共 {$page->lastPage()} 页当前显示第 {$page->currentPage()} 页。</span>{$page->render()}</div>"; $pagetext = lang('think_library_page_html', [$page->total(), $selects, $page->lastPage(), $page->currentPage()]);
$this->controller->assign('pagehtml', preg_replace('|href="(.*?)"|', 'data-open="$1" onclick="return false" href="$1"', $html)); $pagehtml = "<div class='pagination-container nowrap'><span>{$pagetext}</span>{$page->render()}</div>";
$this->controller->assign('pagehtml', preg_replace('|href="(.*?)"|', 'data-open="$1" onclick="return false" href="$1"', $pagehtml));
$result = ['page' => ['limit' => intval($limit), 'total' => intval($page->total()), 'pages' => intval($page->lastPage()), 'current' => intval($page->currentPage())], 'list' => $page->items()]; $result = ['page' => ['limit' => intval($limit), 'total' => intval($page->total()), 'pages' => intval($page->lastPage()), 'current' => intval($page->currentPage())], 'list' => $page->items()];
} else { } else {
$result = ['list' => $this->query->select()]; $result = ['list' => $this->query->select()];
} }
if (false !== $this->controller->callback('_page_filter', $result['list']) && $this->display) { if (false !== $this->controller->callback('_page_filter', $result['list']) && $this->display) {
return $this->controller->fetch('', $result); return $this->controller->fetch('', $result);
} else {
return $result;
} }
return $result;
} }
/** /**
@ -116,19 +118,20 @@ class PageHelper extends Helper
if (preg_match('/^_\d{1,}$/', $key) && preg_match('/^\d{1,}$/', $value)) { if (preg_match('/^_\d{1,}$/', $key) && preg_match('/^\d{1,}$/', $value)) {
list($where, $update) = [['id' => trim($key, '_')], ['sort' => $value]]; list($where, $update) = [['id' => trim($key, '_')], ['sort' => $value]];
if (false === Db::table($this->query->getTable())->where($where)->update($update)) { if (false === Db::table($this->query->getTable())->where($where)->update($update)) {
return $this->controller->error('排序失败, 请稍候再试!'); return $this->controller->error(lang('think_library_sort_error'));
} }
} }
} }
return $this->controller->success('排序成功, 正在刷新页面!', ''); return $this->controller->success(lang('think_library_sort_success'), '');
case 'sort': case 'sort':
$where = $this->controller->request->post(); $where = $this->controller->request->post();
$sort = intval($this->controller->request->post('sort')); $sort = intval($this->controller->request->post('sort'));
unset($where['action'], $where['sort']); unset($where['action'], $where['sort']);
if (Db::table($this->query->getTable())->where($where)->update(['sort' => $sort]) !== false) { if (Db::table($this->query->getTable())->where($where)->update(['sort' => $sort]) !== false) {
return $this->controller->success('排序参数修改成功!', ''); return $this->controller->success(lang('think_library_sort_success'), '');
} else {
return $this->controller->error(lang('think_library_sort_error'));
} }
return $this->controller->error('排序参数修改失败,请稍候再试!');
} }
} }

View File

@ -82,9 +82,9 @@ class SaveHelper extends Helper
} }
// 回复前端结果 // 回复前端结果
if ($result !== false) { if ($result !== false) {
$this->controller->success('数据更新成功!', ''); $this->controller->success(lang('think_library_save_success'), '');
} else { } else {
$this->controller->error('数据更新失败, 请稍候再试!'); $this->controller->error(lang('think_library_save_error'));
} }
} }
} }

View File

@ -0,0 +1,29 @@
<?php
// +----------------------------------------------------------------------
// | Library for ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/zoujingli/ThinkLibrary
// | github 仓库地址 https://github.com/zoujingli/ThinkLibrary
// +----------------------------------------------------------------------
return [
'think_library_not_auth' => '抱歉,没有访问该操作的权限!',
'think_library_not_login' => '抱歉,需要登录获取访问权限!',
'think_library_delete_success' => '恭喜, 数据删除成功!',
'think_library_delete_error' => '抱歉,数据删除失败, 请稍候再试!',
'think_library_form_success' => '恭喜, 数据保存成功!',
'think_library_form_error' => '抱歉,数据保存失败, 请稍候再试!',
'think_library_save_success' => '恭喜,数据更新成功!',
'think_library_save_error' => '抱歉,数据更新失败, 请稍候再试!',
'think_library_sort_success' => '恭喜,列表排序成功!',
'think_library_sort_error' => '抱歉,列表排序失败,请稍候再试!',
'think_library_page_html' => '共 %s 条记录,每页显示 %s 条,共 %s 页当前显示第 %s 页。',
'think_library_csrf_error' => '表单令牌验证失败,请刷新页面再试!',
];

View File

@ -49,7 +49,7 @@ class NodeService extends Service
$prefix = $this->request->module(); $prefix = $this->request->module();
$middle = '\\' . $this->nameTolower($this->app->request->controller()); $middle = '\\' . $this->nameTolower($this->app->request->controller());
$suffix = ($type === 'controller') ? '' : ('\\' . $this->app->request->action()); $suffix = ($type === 'controller') ? '' : ('\\' . $this->app->request->action());
return strtr($prefix . $middle . $suffix, '\\', '/'); return strtolower(strtr($prefix . $middle . $suffix, '\\', '/'));
} }
/** /**
@ -61,10 +61,10 @@ class NodeService extends Service
{ {
if (empty($node)) return $this->getCurrent(); if (empty($node)) return $this->getCurrent();
if (count($attrs = explode('/', $node)) === 1) { if (count($attrs = explode('/', $node)) === 1) {
return $this->getCurrent('controller') . "/{$node}"; return strtolower($this->getCurrent('controller') . "/{$node}");
} else { } else {
$attrs[1] = $this->nameTolower($attrs[1]); $attrs[1] = $this->nameTolower($attrs[1]);
return join('/', $attrs); return strtolower(join('/', $attrs));
} }
} }