refactor(autoload): migrate theme classes to Composer PSR-4
Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
This commit is contained in:
1 parent
8f349b40fb
commit
aaf458af1c
404 files changed
+13602
-7705
No files matched your search
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
namespace AKSRT\Admin\Schema;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class SchemaForum {
|
||||
|
||||
public static function build(): array {
|
||||
return [
|
||||
'domain' => 'forum',
|
||||
'title' => '社区&论坛',
|
||||
'sections' => [
|
||||
'basic' => SchemaForumBasic::build(),
|
||||
'names' => SchemaForumNames::build(),
|
||||
'homepage' => SchemaForumHomepage::build(),
|
||||
'board_page' => SchemaForumBoardPage::build(),
|
||||
'post_page' => SchemaForumPostPage::build(),
|
||||
'reply' => SchemaForumReply::build(),
|
||||
'permissions' => SchemaForumPermissions::build(),
|
||||
'upload' => SchemaForumUpload::build(),
|
||||
'credits' => SchemaForumCredits::build(),
|
||||
'other' => SchemaForumOther::build(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// §8.1 Capability matrix schema builder
|
||||
// ================================================================
|
||||
|
||||
/**
|
||||
* Build groups for the capabilities section from cap_definitions().
|
||||
*
|
||||
* Each capability becomes a group with role columns as fields.
|
||||
* Grouped by prefix: user_, new_post_, comment_.
|
||||
*/
|
||||
private static function build_cap_matrix_groups(): array {
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$defs = \AKSRT\Settings\Settings::cap_definitions();
|
||||
$cols = \AKSRT\Settings\Settings::cap_role_columns();
|
||||
|
||||
$col_labels = [
|
||||
'all' => __('所有人', 'aksrt'),
|
||||
'logged' => __('已登录', 'aksrt'),
|
||||
'level' => __('等级≥', 'aksrt'),
|
||||
'vip' => __('VIP≥', 'aksrt'),
|
||||
'auth' => __('已认证', 'aksrt'),
|
||||
'moderator' => __('版主', 'aksrt'),
|
||||
'plate_author' => __('超级版主', 'aksrt'),
|
||||
'cat_moderator' => __('分区版主', 'aksrt'),
|
||||
];
|
||||
|
||||
// Group caps by prefix
|
||||
$buckets = [
|
||||
'user' => ['title' => __('用户管理', 'aksrt'), 'caps' => []],
|
||||
'post' => ['title' => __('投稿权限', 'aksrt'), 'caps' => []],
|
||||
'comment' => ['title' => __('评论权限', 'aksrt'), 'caps' => []],
|
||||
];
|
||||
|
||||
foreach ($defs as $cap_id => $def) {
|
||||
if (str_starts_with($cap_id, 'comment_')) {
|
||||
$buckets['comment']['caps'][$cap_id] = $def;
|
||||
} elseif (str_starts_with($cap_id, 'new_post_')) {
|
||||
$buckets['post']['caps'][$cap_id] = $def;
|
||||
} else {
|
||||
$buckets['user']['caps'][$cap_id] = $def;
|
||||
}
|
||||
}
|
||||
|
||||
$groups = [];
|
||||
foreach ($buckets as $bucket_key => $bucket) {
|
||||
if (empty($bucket['caps'])) continue;
|
||||
|
||||
$fields = [];
|
||||
foreach ($bucket['caps'] as $cap_id => $def) {
|
||||
$excludes = $def['exclude_roles'] ?? [];
|
||||
$only_roles = $def['roles'] ?? null;
|
||||
$defaults = $def['default'] ?? [];
|
||||
|
||||
// Each cap gets one field per role column
|
||||
foreach ($cols as $col) {
|
||||
if (in_array($col, $excludes, true)) continue;
|
||||
if ($only_roles !== null && !in_array($col, $only_roles, true)
|
||||
&& !in_array($col, ['all', 'logged', 'level', 'vip', 'auth'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$field_key = 'user_caps.' . $cap_id . '.' . $col;
|
||||
$is_spinner = in_array($col, ['level', 'vip'], true);
|
||||
|
||||
$field = [
|
||||
'key' => $field_key,
|
||||
'label' => $def['label'] . ' — ' . ($col_labels[$col] ?? $col),
|
||||
'type' => $is_spinner ? 'number' : 'switch',
|
||||
'default' => $defaults[$col] ?? ($is_spinner ? -1 : false),
|
||||
'cap_id' => $cap_id,
|
||||
'cap_col' => $col,
|
||||
];
|
||||
|
||||
if ($is_spinner) {
|
||||
$field['min'] = -1;
|
||||
$field['max'] = $col === 'level' ? 10 : 2;
|
||||
$field['help'] = __('-1 = 不限', 'aksrt');
|
||||
}
|
||||
|
||||
$fields[] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
$groups[] = [
|
||||
'key' => 'cap_' . $bucket_key,
|
||||
'title' => $bucket['title'],
|
||||
'fields' => $fields,
|
||||
];
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user