fix awful indentation in i18n files of option pages

This commit is contained in:
printempw 2017-01-17 22:16:03 +08:00
parent db15ff2314
commit a0494ce3d0
6 changed files with 246 additions and 225 deletions

View File

@ -89,13 +89,12 @@ class AdminController extends Controller
$signIn = Option::form('sign_in', OptionForm::AUTO_DETECT, function($form) $signIn = Option::form('sign_in', OptionForm::AUTO_DETECT, function($form)
{ {
$form->group('sign_score') $form->group('sign_score')
->text('sign_score_from')->addon(trans('options.sign_score.addon1')) ->text('sign_score_from')->addon(trans('options.sign_in.sign_score.addon1'))
->text('sign_score_to')->addon(trans('options.sign_score.addon2')); ->text('sign_score_to')->addon(trans('options.sign_in.sign_score.addon2'));
$form->group('sign_gap_time')->text('sign_gap_time')->addon(OptionForm::AUTO_DETECT); $form->group('sign_gap_time')->text('sign_gap_time')->addon();
$form->checkbox('sign_after_zero')->label(OptionForm::AUTO_DETECT) $form->checkbox('sign_after_zero')->label()->hint();
->hint(OptionForm::AUTO_DETECT);
})->handle(function() { })->handle(function() {
$sign_score = $_POST['sign_score_from'].','.$_POST['sign_score_to']; $sign_score = $_POST['sign_score_from'].','.$_POST['sign_score_to'];
Option::set('sign_score', $sign_score); Option::set('sign_score', $sign_score);
@ -116,27 +115,27 @@ class AdminController extends Controller
{ {
$form->text('site_name'); $form->text('site_name');
$form->text('site_description'); $form->text('site_description');
$form->text('site_url')->hint(OptionForm::AUTO_DETECT); $form->text('site_url')->hint();
$form->checkbox('user_can_register')->label(OptionForm::AUTO_DETECT); $form->checkbox('user_can_register')->label();
$form->text('regs_per_ip'); $form->text('regs_per_ip');
$form->group('max_upload_file_size') $form->group('max_upload_file_size')
->text('max_upload_file_size')->addon('KB') ->text('max_upload_file_size')->addon('KB')
->hint(trans('options.max_upload_file_size.hint', ['size' => ini_get('upload_max_filesize')])); ->hint(trans('options.general.max_upload_file_size.hint', ['size' => ini_get('upload_max_filesize')]));
$form->checkbox('allow_chinese_playername')->label(OptionForm::AUTO_DETECT); $form->checkbox('allow_chinese_playername')->label();
$form->select('api_type') $form->select('api_type')
->option('0', 'CustomSkinLoader API') ->option('0', 'CustomSkinLoader API')
->option('1', 'UniversalSkinAPI'); ->option('1', 'UniversalSkinAPI');
$form->checkbox('auto_del_invalid_texture')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT); $form->checkbox('auto_del_invalid_texture')->label()->hint();
$form->textarea('comment_script')->rows(6)->description(OptionForm::AUTO_DETECT); $form->textarea('comment_script')->rows(6)->description();
$form->checkbox('allow_sending_statistic')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT); $form->checkbox('allow_sending_statistics')->label()->hint();
})->handle(function() { })->handle(function() {
if (substr($_POST['site_url'], -1) == "/") if (substr($_POST['site_url'], -1) == "/")
@ -145,21 +144,21 @@ class AdminController extends Controller
$announ = Option::form('announ', OptionForm::AUTO_DETECT, function($form) $announ = Option::form('announ', OptionForm::AUTO_DETECT, function($form)
{ {
$form->textarea('announcement')->description(OptionForm::AUTO_DETECT); $form->textarea('announcement')->rows(10)->description();
})->renderWithOutTable()->handle(); })->renderWithOutTable()->handle();
$cache = Option::form('cache', OptionForm::AUTO_DETECT, function($form) $resources = Option::form('resources', OptionForm::AUTO_DETECT, function($form)
{ {
$form->checkbox('force_ssl')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT); $form->checkbox('force_ssl')->label()->hint();
$form->checkbox('auto_detect_asset_url')->label(OptionForm::AUTO_DETECT)->description(OptionForm::AUTO_DETECT); $form->checkbox('auto_detect_asset_url')->label()->description();
$form->checkbox('return_200_when_notfound')->label(OptionForm::AUTO_DETECT); $form->checkbox('return_200_when_notfound')->label()->description();
$form->text('cache_expire_time')->hint(OptionForm::AUTO_DETECT); $form->text('cache_expire_time')->hint(OptionForm::AUTO_DETECT);
})->type('warning')->hint(OptionForm::AUTO_DETECT)->handle(); })->type('warning')->hint(OptionForm::AUTO_DETECT)->handle();
return view('admin.options')->with('forms', compact('general', 'cache', 'announ')); return view('admin.options')->with('forms', compact('general', 'resources', 'announ'));
} }
/** /**

View File

@ -67,13 +67,15 @@ class OptionForm
throw new BadMethodCallException("Method [$method] does not exist on option form."); throw new BadMethodCallException("Method [$method] does not exist on option form.");
} }
// assign name for option item
if (!isset($params[1]) || Arr::get($params, 1) == OptionForm::AUTO_DETECT) { if (!isset($params[1]) || Arr::get($params, 1) == OptionForm::AUTO_DETECT) {
$params[1] = Arr::get(trans("options.$params[0]"), 'title', trans("options.$params[0]")); $params[1] = Arr::get(trans("options.$this->id.$params[0]"), 'title', trans("options.$this->id.$params[0]"));
} }
$class = new ReflectionClass('App\Services\OptionForm'.Str::title($method)); $class = new ReflectionClass('App\Services\OptionForm'.Str::title($method));
// use ReflectionClass to create a new OptionFormItem instance // use ReflectionClass to create a new OptionFormItem instance
$item = $class->newInstanceArgs($params); $item = $class->newInstanceArgs($params);
$item->setParentId($this->id);
$this->items[] = $item; $this->items[] = $item;
return $item; return $item;
@ -98,7 +100,7 @@ class OptionForm
* @param array $info * @param array $info
* @return $this * @return $this
*/ */
public function hint($hintContent) public function hint($hintContent = self::AUTO_DETECT)
{ {
if ($hintContent == self::AUTO_DETECT) { if ($hintContent == self::AUTO_DETECT) {
$hintContent = trans("options.$this->id.hint"); $hintContent = trans("options.$this->id.hint");
@ -384,12 +386,21 @@ class OptionFormItem
public $description; public $description;
protected $parentId;
public function __construct($id, $name = null) public function __construct($id, $name = null)
{ {
$this->id = $id; $this->id = $id;
$this->name = $name; $this->name = $name;
} }
public function setParentId($id)
{
$this->parentId = $id;
return $this;
}
public function value($value) public function value($value)
{ {
$this->value = $value; $this->value = $value;
@ -397,10 +408,10 @@ class OptionFormItem
return $this; return $this;
} }
public function hint($hintContent) public function hint($hintContent = OptionForm::AUTO_DETECT)
{ {
if ($hintContent == OptionForm::AUTO_DETECT) { if ($hintContent == OptionForm::AUTO_DETECT) {
$hintContent = trans("options.$this->id.hint"); $hintContent = trans("options.$this->parentId.$this->id.hint");
} }
$this->hint = view('vendor.option-form.hint')->with('hint', $hintContent)->render(); $this->hint = view('vendor.option-form.hint')->with('hint', $hintContent)->render();
@ -415,10 +426,10 @@ class OptionFormItem
return $this; return $this;
} }
public function description($description) public function description($description = OptionForm::AUTO_DETECT)
{ {
if ($description == OptionForm::AUTO_DETECT) { if ($description == OptionForm::AUTO_DETECT) {
$description = trans("options.$this->id.description"); $description = trans("options.$this->parentId.$this->id.description");
} }
$this->description = $description; $this->description = $description;
@ -454,10 +465,10 @@ class OptionFormCheckbox extends OptionFormItem
{ {
protected $label; protected $label;
public function label($label) public function label($label = OptionForm::AUTO_DETECT)
{ {
if ($label == OptionForm::AUTO_DETECT) { if ($label == OptionForm::AUTO_DETECT) {
$label = trans("options.$this->id.label"); $label = trans("options.$this->parentId.$this->id.label");
} }
$this->label = $label; $this->label = $label;
@ -531,10 +542,10 @@ class OptionFormGroup extends OptionFormItem
return $this; return $this;
} }
public function addon($value) public function addon($value = OptionForm::AUTO_DETECT)
{ {
if ($value == OptionForm::AUTO_DETECT) { if ($value == OptionForm::AUTO_DETECT) {
$value = trans("options.$this->id.addon"); $value = trans("options.$this->parentId.$this->id.addon");
} }
$this->items[] = ['type' => 'addon', 'id' => null, 'value' => $value]; $this->items[] = ['type' => 'addon', 'id' => null, 'value' => $value];

View File

@ -3,7 +3,7 @@
* @Author: printempw * @Author: printempw
* @Date: 2016-07-29 11:53:11 * @Date: 2016-07-29 11:53:11
* @Last Modified by: printempw * @Last Modified by: printempw
* @Last Modified time: 2017-01-14 22:05:22 * @Last Modified time: 2017-01-17 21:47:29
*/ */
return [ return [
@ -20,7 +20,7 @@ return [
'custom_js' => '', 'custom_js' => '',
'allow_chinese_playername' => 'true', 'allow_chinese_playername' => 'true',
'comment_script' => '', 'comment_script' => '',
'allow_sending_statistic' => 'true', 'allow_sending_statistics' => 'true',
'user_initial_score' => '1000', 'user_initial_score' => '1000',
'sign_gap_time' => '24', 'sign_gap_time' => '24',
'sign_score' => '10,100', 'sign_score' => '10,100',

View File

@ -2,6 +2,7 @@ option-saved: Option Saved.
homepage: homepage:
title: Homepage title: Homepage
home_pic_url: home_pic_url:
title: Picture URL at Homepage title: Picture URL at Homepage
hint: Path relative to homepage or full URL. hint: Path relative to homepage or full URL.
@ -21,11 +22,13 @@ customJsCss:
message: | message: |
The contents will be attached to &lt;style&gt; and &lt;script&gt; tags.<br> The contents will be attached to &lt;style&gt; and &lt;script&gt; tags.<br>
- Here are some useful examples: <a href="https://github.com/printempw/blessing-skin-server/wiki/Examples-of-custom-CSS-JavaScript">Examples of Custom CSS JavaScript @GitHub WiKi</a> - Here are some useful examples: <a href="https://github.com/printempw/blessing-skin-server/wiki/Examples-of-custom-CSS-JavaScript">Examples of Custom CSS JavaScript @GitHub WiKi</a>
custom_css: CSS custom_css: CSS
custom_js: JavaScript custom_js: JavaScript
rate: rate:
title: About Scores title: About Scores
score_per_storage: score_per_storage:
title: Storage title: Storage
addon: scores = 1 KB addon: scores = 1 KB
@ -46,6 +49,7 @@ user_initial_score: User Initial Score
sign_in: sign_in:
title: Signing In title: Signing In
sign_score: sign_score:
title: Score Granted title: Score Granted
addon1: scores ~ addon1: scores ~
@ -55,11 +59,12 @@ sign_gap_time:
addon: hours addon: hours
sign_after_zero: sign_after_zero:
title: Time title: Time
label: Can sign in after 0 everyday label: Users can sign in after 0 everyday.
hint: The above option will be ignored if this is checked. hint: The above option will be ignored if this is checked.
general: general:
title: General Options title: General Options
site_name: Site Name site_name: Site Name
site_description: Site Description site_description: Site Description
site_url: site_url:
@ -67,52 +72,56 @@ site_url:
hint: Begin with http(s)://, nerver ends with slash hint: Begin with http(s)://, nerver ends with slash
user_can_register: user_can_register:
title: Open Registration title: Open Registration
label: Everyone is allowed to register label: Everyone is allowed to register.
regs_per_ip: Max accounts of one IP regs_per_ip: Max accounts of one IP
max_upload_file_size: max_upload_file_size:
title: Max Upload Size title: Max Upload Size
hint: "Limit of PHP in php.ini: :size" hint: "Limit of PHP in php.ini: :size"
allow_chinese_playername: allow_chinese_playername:
title: Player Name title: Player Name
label: Allow chinese player names label: Allow chinese player names.
api_type: Prefered JSON API api_type: Prefered JSON API
auto_del_invalid_texture: auto_del_invalid_texture:
title: Invalid Textures title: Invalid Textures
label: Delete invalid textures from skinlib automatically. label: Delete invalid textures automatically.
hint: Delete textures records whose file no longer exists automatically. hint: Delete textures records whose file no longer exists from skinlib.
comment_script: comment_script:
title: Comment Script title: Comment Script
description: Placeholders are available in comment scripts. <code>{tid}</code> will be replaced with texture id, <code>{name}</code> will be replaced with texture name, <code>{url}</code> will be replaced with current URL. description: Placeholders are available in comment scripts. <code>{tid}</code> will be replaced with texture id, <code>{name}</code> will be replaced with texture name, <code>{url}</code> will be replaced with current URL.
allow_sending_statistic: allow_sending_statistics:
title: Statistics title: Statistics
label: Send usage statistics anonymously. label: Send usage statistics anonymously.
hint: Information about privacy will nerver be sent. hint: Information about privacy will nerver be sent.
announ: announ:
title: Site Announcement title: Announcement
announcement: announcement:
description: Styling with Markdown is supported. description: Styling with Markdown is supported.
cache: resources:
title: Resource Files title: Resource Files
hint: Please adjust these options when CDN cache is on hint: Please adjust these options when CDN cache is on
force_ssl: force_ssl:
title: Force SSL title: Force SSL
label: Force to use HTTPS protocol to load resources label: Use HTTPS protocol to load resources forcely.
hint: Check SSL available before turning on hint: Check SSL available before turning on
auto_detect_asset_url: auto_detect_asset_url:
title: Assets URL title: Assets URL
label: Determine assets url automatically label: Determine assets url automatically.
description: Load asset files according to current URL. The site url will be used if this is not enabled. Please unable this if requests don't go through CDN. description: Load asset files according to current URL. The site url will be used if this is not enabled. Please unable this if requests don't go through CDN.
return_200_when_notfound: return_200_when_notfound:
title: HTTP Response Code title: HTTP Response Code
label: Return 200 instead of 404 when requesting un-existent player label: Return 200 instead of 404 when requesting un-existent player.
description: If your CDN doesn't cache 404 pages, please turn this on. A flood of requests to un-existent players will greatly slow down the site.
cache_expire_time: cache_expire_time:
title: Cache Exipre Time title: Cache Exipre Time
hint: In seconds, 86400 = one day, 31536000 = one year hint: In seconds, 86400 = one day, 31536000 = one year
update: update:
title: Check Update title: Check Update
check_update: check_update:
title: Check Update title: Check Update
label: Check update automatically and notify me. label: Check update automatically and notify me.

View File

@ -2,6 +2,7 @@ option-saved: 设置已保存。
homepage: homepage:
title: 首页配置 title: 首页配置
home_pic_url: home_pic_url:
title: 首页图片地址 title: 首页图片地址
hint: 相对于首页的路径或者完整的 URL hint: 相对于首页的路径或者完整的 URL
@ -21,11 +22,13 @@ customJsCss:
message: | message: |
内容将会被追加至每个页面的 &lt;style&gt; 和 &lt;script&gt; 标签中。<br> 内容将会被追加至每个页面的 &lt;style&gt; 和 &lt;script&gt; 标签中。<br>
- 这里有一些有用的示例:<a href="https://github.com/printempw/blessing-skin-server/wiki/Examples-of-custom-CSS-JavaScript">「自定义 CSS JavaScript」功能的一些实例@GitHub WiKi</a> - 这里有一些有用的示例:<a href="https://github.com/printempw/blessing-skin-server/wiki/Examples-of-custom-CSS-JavaScript">「自定义 CSS JavaScript」功能的一些实例@GitHub WiKi</a>
custom_css: CSS custom_css: CSS
custom_js: JavaScript custom_js: JavaScript
rate: rate:
title: 积分换算 title: 积分换算
score_per_storage: score_per_storage:
title: 存储 title: 存储
addon: 积分 = 1 KB addon: 积分 = 1 KB
@ -46,6 +49,7 @@ user_initial_score: 新用户默认积分
sign_in: sign_in:
title: 签到配置 title: 签到配置
sign_score: sign_score:
title: 签到获得积分 title: 签到获得积分
addon1: 积分 ~ addon1: 积分 ~
@ -60,6 +64,7 @@ sign_after_zero:
general: general:
title: 常规选项 title: 常规选项
site_name: 站点标题 site_name: 站点标题
site_description: 站点描述 site_description: 站点描述
site_url: site_url:
@ -83,19 +88,21 @@ auto_del_invalid_texture:
comment_script: comment_script:
title: 评论代码 title: 评论代码
description: 评论代码内可使用占位符,<code>{tid}</code> 将会被自动替换为材质的 id<code>{name}</code> 会被替换为材质名称,<code>{url}</code> 会被替换为当前页面地址。 description: 评论代码内可使用占位符,<code>{tid}</code> 将会被自动替换为材质的 id<code>{name}</code> 会被替换为材质名称,<code>{url}</code> 会被替换为当前页面地址。
allow_sending_statistic: allow_sending_statistics:
title: 统计信息 title: 统计信息
label: 发送程序使用情况统计信息以帮助开发 label: 发送程序使用情况统计信息以帮助开发
hint: 隐私信息不会被收集 hint: 隐私信息不会被收集
announ: announ:
title: 站点公告 title: 站点公告
announcement: announcement:
description: 可使用 Markdown 进行排版 description: 可使用 Markdown 进行排版
cache: resources:
title: 资源文件配置 title: 资源文件配置
hint: 如果启用了 CDN 缓存请适当修改这些配置 hint: 如果启用了 CDN 缓存请适当修改这些配置
force_ssl: force_ssl:
title: 强制 SSL title: 强制 SSL
label: 强制使用 HTTPS 协议加载资源 label: 强制使用 HTTPS 协议加载资源
@ -107,12 +114,14 @@ auto_detect_asset_url:
return_200_when_notfound: return_200_when_notfound:
title: HTTP 响应码 title: HTTP 响应码
label: 请求不存在的角色时返回 200 而不是 404 label: 请求不存在的角色时返回 200 而不是 404
description: 如果你的 CDN 不缓存 404 页面,请打开此项。否则大量对不存在角色的 Profile 请求会加重站点负载。
cache_expire_time: cache_expire_time:
title: 缓存失效时间 title: 缓存失效时间
hint: 秒数86400 = 一天31536000 = 一年 hint: 秒数86400 = 一天31536000 = 一年
update: update:
title: 更新选项 title: 更新选项
check_update: check_update:
title: 检查更新 title: 检查更新
label: 自动检查更新并提示 label: 自动检查更新并提示

View File

@ -25,7 +25,7 @@
<div class="col-md-6"> <div class="col-md-6">
{!! $forms['announ']->render() !!} {!! $forms['announ']->render() !!}
{!! $forms['cache']->render() !!} {!! $forms['resources']->render() !!}
</div> </div>
</div> </div>
@ -34,10 +34,3 @@
</div><!-- /.content-wrapper --> </div><!-- /.content-wrapper -->
@endsection @endsection
@section('style')
<style type="text/css">
.box-body > textarea { height: 200px; }
.description { margin: 7px 0 0 0; color: #555; }
</style>
@endsection