Skip to content

Commit abda216

Browse files
committed
新增:富文本编辑器文档导入支持直接粘贴 Markdown 格式
1 parent 0786c22 commit abda216

File tree

76 files changed

+2387
-2202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2387
-2202
lines changed

module/Cms/Admin/Controller/BackupController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use ModStart\Core\Util\FileUtil;
1616
use ModStart\Core\Util\SerializeUtil;
1717
use ModStart\Module\ModuleManager;
18+
use Module\Cms\Util\CmsBackupUtil;
1819

1920
class BackupController extends Controller
2021
{
@@ -51,8 +52,6 @@ public function index()
5152
FileUtil::write($savePath, SerializeUtil::jsonEncodePretty($backup));
5253
return Response::generateSuccess('备份成功');
5354
}
54-
return view('module::Cms.View.admin.backup.index', [
55-
'configs' => modstart_config()->all(),
56-
]);
55+
return view('module::Cms.View.admin.backup.index');
5756
}
5857
}

module/Cms/Admin/Controller/RestoreController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ public function submit()
5353
CmsBackupUtil::restoreBackup($data);
5454
return Response::generateSuccess('恢复成功');
5555
}
56-
}
56+
}

module/Cms/Util/CmsBackupUtil.php

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use ModStart\Core\Dao\ModelManageUtil;
88
use ModStart\Core\Dao\ModelUtil;
99
use ModStart\Core\Exception\BizException;
10+
use ModStart\Core\Util\ArrayUtil;
1011
use ModStart\Core\Util\FileUtil;
1112
use ModStart\Module\ModuleManager;
1213
use Module\Cms\Provider\Theme\CmsThemeProvider;
@@ -31,16 +32,20 @@ public static function listBackups()
3132
if (empty($json['config'])) {
3233
$json['config'] = [];
3334
}
35+
$moduleInfo = ModuleManager::getModuleBasic($theme->name());
3436
$results[] = [
3537
'module' => $theme->name(),
38+
'moduleInfo' => $moduleInfo,
3639
'root' => 'module/' . $theme->name() . '/Backup',
3740
'filename' => $file['filename'],
41+
'filemtime' => filemtime($file['pathname']),
3842
'size' => $file['size'],
3943
'tables' => array_keys($json['structure']),
4044
'config' => $json['config'],
4145
];
4246
}
4347
}
48+
$results = ArrayUtil::sortByKey($results, 'filemtime', 'desc');
4449
return $results;
4550
}
4651

@@ -50,7 +55,7 @@ public static function restoreBackup($backup)
5055
BizException::throwsIf('备份文件损坏', empty($backup['backup']));
5156
$tableBackupBatch = '_del_' . date('Ymd_His_');
5257
foreach ($backup['structure'] as $table => $structure) {
53-
if (!self::isCmsTable($table)) {
58+
if (!self::isCmsTable($table) && !self::isCmsBackupTable($table)) {
5459
continue;
5560
}
5661
if (ModelManageUtil::hasTable($table)) {
@@ -60,7 +65,7 @@ public static function restoreBackup($backup)
6065
ModelManageUtil::statement($structure);
6166
}
6267
foreach ($backup['backup'] as $table => $data) {
63-
if (!self::isCmsTable($table)) {
68+
if (!self::isCmsTable($table) && !self::isCmsBackupTable($table)) {
6469
continue;
6570
}
6671
ModelUtil::insertAll($table, $data, false);
@@ -73,6 +78,65 @@ public static function restoreBackup($backup)
7378
}
7479
}
7580

81+
public static function mergeConfigTitle(&$configs)
82+
{
83+
$titleMap = [
84+
'/^Cms_/' => 'CMS配置',
85+
'/^CmsTheme.*?/' => '主题配置',
86+
];
87+
foreach ($configs as $k => $v) {
88+
foreach ($titleMap as $pattern => $title) {
89+
if (preg_match($pattern, $v['key'])) {
90+
$configs[$k]['title'] = $title;
91+
break;
92+
}
93+
}
94+
}
95+
}
96+
97+
public static function mergeTableTitle(&$tables)
98+
{
99+
$titleMap = [
100+
'/^banner$/' => '通用轮播',
101+
'/^partner$/' => '友情链接',
102+
'/^nav$/' => '通用导航',
103+
'/^content_block$/' => '内容区块',
104+
'/^cms_model$/' => 'CMS模型',
105+
'/^cms_model_field$/' => 'CMS模型字段',
106+
'/^cms_cat$/' => 'CMS栏目',
107+
'/^cms_content$/' => 'CMS内容主表',
108+
'/^cms_m_.*?$/' => 'CMS内容副表',
109+
];
110+
foreach ($tables as $k => $v) {
111+
foreach ($titleMap as $pattern => $title) {
112+
if (preg_match($pattern, $v['name'])) {
113+
$tables[$k]['title'] = $title;
114+
break;
115+
}
116+
}
117+
}
118+
}
119+
120+
public static function listBackupConfigs()
121+
{
122+
$configs = modstart_config()->all();
123+
$buildIns = [
124+
'/^Cms_/',
125+
'/^CmsTheme.*?/',
126+
];
127+
$configs = array_filter($configs, function ($o) use ($buildIns) {
128+
foreach ($buildIns as $pattern) {
129+
if (preg_match($pattern, $o['key'])) {
130+
return true;
131+
}
132+
}
133+
return false;
134+
});
135+
CmsBackupUtil::mergeConfigTitle($configs);
136+
$configs = ArrayUtil::sortByKey($configs, 'key');
137+
return array_values($configs);
138+
}
139+
76140
public static function listBackupTables()
77141
{
78142
$tables = ModelManageUtil::listTables();
@@ -101,7 +165,20 @@ public static function listBackupTables()
101165
];
102166
}
103167
}
104-
return $tables;
168+
self::mergeTableTitle($tables);
169+
$tables = ArrayUtil::sortByKey($tables, 'name');
170+
return array_values($tables);
171+
}
172+
173+
public static function isCmsBackupTable($table)
174+
{
175+
$tables = [
176+
'banner',
177+
'partner',
178+
'nav',
179+
'content_block',
180+
];
181+
return in_array($table, $tables);
105182
}
106183

107184
public static function isCmsTable($table)

module/Cms/View/admin/backup/index.blade.php

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,6 @@
1818
<div class="body">
1919
<form action="{{\ModStart\Core\Input\Request::currentPageUrl()}}" data-ajax-form method="post">
2020
<div class="ub-form">
21-
<div class="line">
22-
<div class="label">备份CMS表</div>
23-
<div class="field">
24-
@foreach(\Module\Cms\Util\CmsBackupUtil::listBackupTables() as $table)
25-
<label class="tw-font-mono tw-block">
26-
<input type="checkbox" style="vertical-align:middle;" name="table[]"
27-
value="{{$table['name']}}"
28-
@if($table['checked']) checked @endif
29-
/>
30-
{{$table['name']}}
31-
</label>
32-
@endforeach
33-
</div>
34-
</div>
35-
<div class="line">
36-
<div class="label">备份配置</div>
37-
<div class="field">
38-
@foreach($configs as $c)
39-
<label class="tw-font-mono tw-inline-block" style="min-width:15rem;">
40-
<input type="checkbox" style="vertical-align:middle;" name="config[]"
41-
value="{{$c['key']}}"
42-
/>
43-
{{$c['key']}}
44-
</label>
45-
@endforeach
46-
</div>
47-
</div>
4821
<div class="line">
4922
<div class="label">
5023
备份保存目录
@@ -82,6 +55,55 @@
8255
</div>
8356
</div>
8457
</div>
58+
<div class="line">
59+
<div class="label">备份数据表</div>
60+
<div class="field">
61+
@foreach(\Module\Cms\Util\CmsBackupUtil::listBackupTables() as $table)
62+
<label class="tw-font-mono tw-block">
63+
<input type="checkbox" style="vertical-align:middle;" name="table[]"
64+
value="{{$table['name']}}"
65+
@if($table['checked']) checked @endif
66+
/>
67+
{{$table['name']}}
68+
@if(!empty($table['title']))
69+
<span class="ub-text-muted">
70+
{{$table['title']}}
71+
</span>
72+
@endif
73+
</label>
74+
@endforeach
75+
</div>
76+
</div>
77+
<div class="line">
78+
<div class="label">
79+
备份配置
80+
<br>
81+
<a href="javascript:;" class="ub-text-muted"
82+
data-tip-popover="点击显示配置项的值"
83+
onclick="$('[data-config-item]').next().toggle();">
84+
<i class="iconfont icon-eye"></i>
85+
</a>
86+
</div>
87+
<div class="field">
88+
@foreach(\Module\Cms\Util\CmsBackupUtil::listBackupConfigs() as $c)
89+
<label data-config-item class="tw-font-mono tw-inline-block tw-bg-white"
90+
style="min-width:20rem;">
91+
<input type="checkbox" style="vertical-align:middle;" name="config[]"
92+
value="{{$c['key']}}"
93+
/>
94+
{{$c['key']}}
95+
@if(!empty($c['title']))
96+
<span class="ub-text-muted">
97+
{{$c['title']}}
98+
</span>
99+
@endif
100+
</label>
101+
<div class="tw--mt-12" style="display:none;">
102+
<pre class="tw-bg-gray-100 tw-pt-10">{{$c['value']}}</pre>
103+
</div>
104+
@endforeach
105+
</div>
106+
</div>
85107
<div class="line">
86108
<div class="label">&nbsp;</div>
87109
<div class="field">

module/Cms/View/admin/restore/index.blade.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
<table class="ub-table">
2020
<thead>
2121
<tr>
22-
<th class="ub-text-truncate">模块</th>
23-
<th>名称</th>
22+
<th class="ub-text-truncate">备份</th>
2423
<th>
2524
数据表
2625
<a href="javascript:;" class="ub-text-muted"
@@ -54,8 +53,19 @@
5453
@endif
5554
@foreach($backups as $backup)
5655
<tr>
57-
<td class="tw-font-mono ub-text-truncate">{{$backup['module']}}</td>
58-
<td class="tw-font-mono ub-text-truncate">{{$backup['filename']}}</td>
56+
<td class="tw-font-mono ub-text-truncate">
57+
<div class="ub-text-bold">
58+
<span>
59+
{{$backup['moduleInfo']['title']}}
60+
</span>
61+
<span class="ub-text-sm">
62+
{{$backup['module']}}
63+
</span>
64+
</div>
65+
<div>
66+
名称:{{$backup['filename']}}
67+
</div>
68+
</td>
5969
<td class="tw-font-mono">
6070
@foreach($backup['tables'] as $table)
6171
<span class="ub-tag tw-mb-1 ub-text-sm">{{$table}}</span>

module/Cms/View/pc/cms/detail/cases.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242

4343
<div class="ub-container margin-bottom">
44-
@if(!\MCms::canVisitCat($cat))
44+
@if(!MCms::canVisitCat($cat))
4545
<div class="ub-alert danger">
4646
<i class="iconfont icon-warning"></i>
4747
您没有权限访问该栏目内容

module/Cms/View/pc/cms/detail/default.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
@endif
6262
</div>
6363
</div>
64-
@if(!\MCms::canVisitCat($cat))
64+
@if(!MCms::canVisitCat($cat))
6565
<div class="ub-alert danger">
6666
<i class="iconfont icon-warning"></i>
6767
您没有权限访问该栏目
@@ -84,7 +84,7 @@
8484
</div>
8585
</div>
8686
<div class="body ub-list-items">
87-
@foreach(\MCms::latestContentByCat($cat['id']) as $a)
87+
@foreach(MCms::latestContentByCat($cat['id']) as $a)
8888
<a class="item-c" href="{{$a['_url']}}">{{$a['title']}}</a>
8989
@endforeach
9090
</div>

module/Cms/View/pc/cms/detail/job.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div class="col-md-9">
4343

4444
<div class="ub-panel" style="padding:1rem;">
45-
@if(!\MCms::canVisitCat($cat))
45+
@if(!MCms::canVisitCat($cat))
4646
<div class="ub-alert danger">
4747
<i class="iconfont icon-warning"></i>
4848
您没有权限访问该栏目内容
@@ -138,7 +138,7 @@
138138
</div>
139139
</div>
140140
<div class="body ub-list-items">
141-
@foreach(\MCms::latestContentByCat($cat['id']) as $a)
141+
@foreach(MCms::latestContentByCat($cat['id']) as $a)
142142
<a class="item-c" href="{{$a['_url']}}">{{$a['title']}}</a>
143143
@endforeach
144144
</div>

module/Cms/View/pc/cms/detail/news.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<div class="row">
4848
<div class="col-md-9">
4949

50-
@if(!\MCms::canVisitCat($cat))
50+
@if(!MCms::canVisitCat($cat))
5151
<div class="ub-alert danger">
5252
<i class="iconfont icon-warning"></i>
5353
您没有权限访问该栏目内容
@@ -127,7 +127,7 @@
127127
</div>
128128
</div>
129129
<div class="body ub-list-items">
130-
@foreach(\MCms::latestContentByCat($cat['id']) as $a)
130+
@foreach(MCms::latestContentByCat($cat['id']) as $a)
131131
<a class="item-c" href="{{$a['_url']}}">{{$a['title']}}</a>
132132
@endforeach
133133
</div>

module/Cms/View/pc/cms/detail/product.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<div class="ub-container">
4444

45-
@if(\MCms::canVisitCat($cat))
45+
@if(MCms::canVisitCat($cat))
4646
<div class="ub-article-a margin-bottom">
4747
<div class="row">
4848
<div class="col-md-4">
@@ -76,7 +76,7 @@
7676

7777
<div class="row">
7878
<div class="col-md-9">
79-
@if(!\MCms::canVisitCat($cat))
79+
@if(!MCms::canVisitCat($cat))
8080
<div class="ub-alert danger">
8181
<i class="iconfont icon-warning"></i>
8282
您没有权限访问该栏目内容

0 commit comments

Comments
 (0)