Match the reference layouts for the remaining forum routes: plate pages get the blurred header card, moderator row and the affix tab bar with per-tab filtering, topping posts and moderator-only pending/trash tabs; post pages get the article shell with breadcrumbs, cover, meta row, vote box, tag row and footer actions; compose pages get the reference editor plus settings sidebar (submit/draft, status, access, plate, topic, tag, type, vote) with a cover picker. Saving now honours draft state and the featured image through the REST contract. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
144 lines
8.2 KiB
PHP
144 lines
8.2 KiB
PHP
<?php
|
|
|
|
namespace Jio\Admin\Schema;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class SchemaForum {
|
|
public static function build(): array {
|
|
return ['domain' => 'forum', 'title' => '社区论坛', 'sections' => [
|
|
'general' => self::section('general', '全局设置', [
|
|
self::field('jio_forum_enabled', '启用论坛', 'switcher', true),
|
|
self::field('jio_forum_admin_users', '论坛管理员 ID', 'input', ''),
|
|
self::field('jio_forum_forum_name', '论坛名称', 'input', '论坛'),
|
|
self::field('jio_forum_plate_name', '版块名称', 'input', '版块'),
|
|
self::field('jio_forum_post_name', '帖子名称', 'input', '帖子'),
|
|
self::field('jio_forum_topic_name', '话题名称', 'input', '话题'),
|
|
]),
|
|
'home' => self::section('home', '首页与列表', [
|
|
self::field('jio_forum_page_size', '每页帖子数', 'number', 20, ['min' => 1, 'max' => 50]),
|
|
self::field('jio_forum_home_tab_items', '首页栏目', 'repeater', \Jio\Forum\HomeTabs::defaults(), [
|
|
'addText' => '添加栏目',
|
|
'description' => '选择并排序论坛首页的栏目,访客可通过 index 参数直接打开某个栏目',
|
|
'fields' => [
|
|
self::field('title', '栏目标题', 'input', ''),
|
|
self::field('type', '栏目类型', 'select', 'posts', ['options' => self::options([
|
|
'follow' => '关注',
|
|
'synthesis' => '综合',
|
|
'plate' => '版块',
|
|
'posts' => '帖子列表',
|
|
])]),
|
|
self::field('orderby', '排序方式', 'select', 'date', ['options' => self::options([
|
|
'date' => '发布时间',
|
|
'modified' => '修改时间',
|
|
'last_reply' => '最新回复',
|
|
'popular' => '热度',
|
|
'views' => '阅读量',
|
|
'score' => '评分',
|
|
])]),
|
|
self::field('filter', '内容筛选', 'select', '', ['options' => self::options([
|
|
'' => '全部',
|
|
'essence' => '精华',
|
|
'question' => '问答',
|
|
'vote' => '投票',
|
|
])]),
|
|
self::field('style', '列表样式', 'radio', 'detail', ['options' => self::options(['detail' => '详细内容', 'mini' => '简约风格'])]),
|
|
self::field('show', '显示端', 'checkbox', ['pc_s', 'm_s'], ['options' => self::options(['pc_s' => 'PC 端', 'm_s' => '移动端'])]),
|
|
],
|
|
]),
|
|
self::field('jio_forum_home_tab_active', '默认栏目', 'number', 2, ['min' => 1, 'max' => 20, 'description' => '打开首页时默认显示第几个栏目']),
|
|
self::field('jio_forum_home_quick_post', '快速发布', 'switcher', true),
|
|
self::field('jio_forum_home_quick_post_tab', '快速发布所在栏目', 'number', 2, ['min' => 1, 'max' => 20]),
|
|
self::field('jio_forum_home_hot_plate', '版块栏目显示热门推荐', 'switcher', true),
|
|
self::field('jio_forum_home_follow_plate', '版块栏目显示已关注版块', 'switcher', true),
|
|
self::field('jio_forum_home_recommend_plate', '关注栏目显示版块推荐', 'switcher', true),
|
|
self::field('jio_forum_show_plate_cover', '显示版块封面', 'switcher', true),
|
|
self::field('jio_forum_plate_tab_active', '版块页默认栏目', 'number', 1, ['min' => 1, 'max' => 20, 'description' => '打开版块页面时默认显示第几个栏目']),
|
|
self::field('jio_forum_plate_tab_items', '版块页栏目', 'repeater', self::default_plate_tabs(), [
|
|
'addText' => '添加栏目',
|
|
'description' => '版块页顶部的栏目条;留空则使用「最新发布 / 最近回复 / 热门 / 精华」默认栏目',
|
|
'fields' => [
|
|
self::field('title', '栏目标题', 'input', ''),
|
|
self::field('orderby', '排序方式', 'select', 'date', ['options' => self::options([
|
|
'date' => '发布时间',
|
|
'modified' => '修改时间',
|
|
'last_reply' => '最新回复',
|
|
'views' => '阅读量',
|
|
'score' => '评分',
|
|
'comment_count' => '回复数量',
|
|
])]),
|
|
self::field('filter', '内容筛选', 'select', '', ['options' => self::options(['' => '全部', 'essence' => '精华'])]),
|
|
self::field('style', '列表样式', 'radio', 'detail', ['options' => self::options(['detail' => '详细内容', 'mini' => '简约风格'])]),
|
|
],
|
|
]),
|
|
self::field('jio_forum_search_enabled', '搜索包含帖子', 'switcher', true),
|
|
]),
|
|
'publishing' => self::section('publishing', '发布与审核', [
|
|
self::field('jio_forum_post_review', '新帖子需要审核', 'switcher', true),
|
|
self::field('jio_forum_plate_review', '新版块需要审核', 'switcher', true),
|
|
self::field('jio_forum_user_plates', '允许用户创建版块', 'switcher', true),
|
|
self::field('jio_forum_user_topics', '允许用户创建话题', 'switcher', true),
|
|
self::field('jio_forum_daily_post_limit', '每日发帖上限', 'number', 20, ['min' => 0, 'max' => 500]),
|
|
self::field('jio_forum_vote_max', '投票选项上限', 'number', 10, ['min' => 2, 'max' => 20]),
|
|
self::field('jio_forum_upload_image', '允许上传图片', 'switcher', true),
|
|
self::field('jio_forum_upload_video', '允许上传视频', 'switcher', false),
|
|
self::field('jio_forum_upload_file', '允许上传附件', 'switcher', false),
|
|
]),
|
|
'access' => self::section('access', '权限与版主', [
|
|
self::field('jio_forum_moderator_apply', '允许申请版主', 'switcher', true),
|
|
self::field('jio_forum_follow_required', '关注后允许发帖', 'switcher', false),
|
|
self::field('jio_forum_allow_guest_read', '允许游客阅读', 'switcher', true),
|
|
]),
|
|
'replies' => self::section('replies', '回复与互动', [
|
|
self::field('jio_forum_reply_page_size', '每页回复数', 'number', 20, ['min' => 1, 'max' => 100]),
|
|
self::field('jio_forum_reply_review', '回复需要审核', 'switcher', false),
|
|
self::field('jio_forum_vote_enabled', '启用投票', 'switcher', true),
|
|
self::field('jio_forum_vote_number_type', '投票结果显示', 'radio', 'percentage', ['options' => self::options(['percentage' => '百分比', 'number' => '票数', 'hide' => '不显示'])]),
|
|
self::field('jio_forum_question_enabled', '启用问答采纳', 'switcher', true),
|
|
self::field('jio_forum_score_enabled', '启用评分', 'switcher', true),
|
|
self::field('jio_forum_score_up_max', '单人最多加分', 'number', 5, ['min' => 0, 'max' => 100]),
|
|
self::field('jio_forum_score_down_max', '单人最多减分', 'number', 5, ['min' => 0, 'max' => 100]),
|
|
]),
|
|
'payment' => self::section('payment', '付费与积分', [
|
|
self::field('jio_forum_paid_content', '允许帖子付费解锁', 'switcher', true),
|
|
self::field('jio_forum_paid_follow', '允许付费关注版块', 'switcher', true),
|
|
self::field('jio_forum_points_enabled', '允许积分解锁', 'switcher', true),
|
|
self::field('jio_forum_vip_price_enabled', '启用会员价', 'switcher', true),
|
|
]),
|
|
'urls' => self::section('urls', '链接设置', [
|
|
self::field('jio_forum_slug_plate', '版块路径', 'input', 'forum'),
|
|
self::field('jio_forum_slug_post', '帖子路径', 'input', 'forum-post'),
|
|
self::field('jio_forum_slug_edit', '发帖路径', 'input', 'posts-edit'),
|
|
]),
|
|
]];
|
|
}
|
|
|
|
/** Initial plate-page tab rows; the listing falls back to these when unset. */
|
|
private static function default_plate_tabs(): array {
|
|
return [
|
|
['title' => '最新发布', 'orderby' => 'date', 'filter' => '', 'style' => 'detail'],
|
|
['title' => '最近回复', 'orderby' => 'last_reply', 'filter' => '', 'style' => 'detail'],
|
|
['title' => '热门', 'orderby' => 'views', 'filter' => '', 'style' => 'detail'],
|
|
['title' => '精华', 'orderby' => 'modified', 'filter' => 'essence', 'style' => 'detail'],
|
|
];
|
|
}
|
|
|
|
private static function section(string $key, string $title, array $fields): array {
|
|
return ['key' => $key, 'title' => $title, 'version' => '1.0.0', 'option_key' => 'jio_settings', 'groups' => [['key' => $key, 'fields' => $fields]]];
|
|
}
|
|
|
|
/** Initial tab rows for the forum home; mirrors the built-in home layout. */
|
|
|
|
private static function field(string $key, string $label, string $type, $default, array $extra = []): array {
|
|
return array_merge(['key' => $key, 'label' => $label, 'type' => $type, 'default' => $default], $extra);
|
|
}
|
|
|
|
private static function options(array $values): array {
|
|
$result = [];
|
|
foreach ($values as $value => $label) {
|
|
$result[] = ['value' => $value, 'label' => $label];
|
|
}
|
|
return $result;
|
|
}
|
|
}
|