diff --git a/views/admin/_announcements_form.php b/views/admin/_announcements_form.php new file mode 100644 index 0000000..4e8e260 --- /dev/null +++ b/views/admin/_announcements_form.php @@ -0,0 +1,25 @@ + + +
+ + + + field($model, 'title')->textInput(['maxlength' => true]) ?> + + field($model, 'content')->textarea(['rows' => 6]) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/views/admin/_announcements_search.php b/views/admin/_announcements_search.php new file mode 100644 index 0000000..1d39314 --- /dev/null +++ b/views/admin/_announcements_search.php @@ -0,0 +1,38 @@ + + + diff --git a/views/admin/announcements_create.php b/views/admin/announcements_create.php new file mode 100644 index 0000000..e62563b --- /dev/null +++ b/views/admin/announcements_create.php @@ -0,0 +1,20 @@ +title = '发布公告'; +$this->params['breadcrumbs'][] = ['label' => '公告管理', 'url' => ['announcements-manage']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_announcements_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/views/admin/announcements_index.php b/views/admin/announcements_index.php new file mode 100644 index 0000000..81c6077 --- /dev/null +++ b/views/admin/announcements_index.php @@ -0,0 +1,68 @@ +title = '公告管理'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ 'btn btn-success']) ?> +

+

Tips: 只有最新的三条公告对用户可见

+ + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'id', + [ + 'attribute' => 'title', + 'format' => 'raw', + 'value' => function (Announcements $model) { + return Html::a($model->title, ['announcements-view', 'id' => $model->id]); + } + ], + [ + 'attribute' => 'content', + 'label' => '内容', + // if the content is too long, only show the first 30 characters + 'value' => function (Announcements $model) { + return mb_substr($model->content, 0, 30) . '...'; + } + + ], + 'published_at', + 'updated_at', + [ + 'class' => ActionColumn::class, + 'urlCreator' => function ($action, Announcements $model, $key, $index, $column) { + if ($action === 'view') { + return Url::to(['announcements-view', 'id' => $model->id]); + } elseif ($action === 'update') { + return Url::to(['announcements-update', 'id' => $model->id]); + } else { //delete + return Url::to(['announcements-delete', 'id' => $model->id]); + } + } + ], + ], + ]); ?> + + + +
diff --git a/views/admin/announcements_update.php b/views/admin/announcements_update.php new file mode 100644 index 0000000..ca55f0d --- /dev/null +++ b/views/admin/announcements_update.php @@ -0,0 +1,21 @@ +title = '修改公告: ' . $model->title; +$this->params['breadcrumbs'][] = ['label' => '公告管理', 'url' => ['announcements-manage']]; +$this->params['breadcrumbs'][] = ['label' => '公告ID '.$model->id, 'url' => ['announcements-view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = '修改公告'; +?> +
+ +

title) ?>

+ + render('_announcements_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/views/admin/announcements_view.php b/views/admin/announcements_view.php new file mode 100644 index 0000000..d8d118e --- /dev/null +++ b/views/admin/announcements_view.php @@ -0,0 +1,41 @@ +title = '公告ID '.$model->id; +$this->params['breadcrumbs'][] = ['label' => '公告管理', 'url' => ['announcements-manage']]; +$this->params['breadcrumbs'][] = $this->title; +YiiAsset::register($this); +?> +
+ +

title) ?>

+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => '你确定要删除这条公告?', + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id', + 'title', + 'content:ntext', + 'published_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/views/layouts/admin_main.php b/views/layouts/admin_main.php index 8348b5f..c2b652c 100644 --- a/views/layouts/admin_main.php +++ b/views/layouts/admin_main.php @@ -76,7 +76,7 @@ $this->registerCssFile('@web/css/fuckyou-navpadding.css'); ['label' => '用户管理', 'url' => ['/admin/user']], ['label' => '文件分享管理', 'url' => ['/admin/share-manage']], ['label' => '文件收集管理', 'url' => ['/admin/collection-manage']], - ['label' => '站点公告管理', 'url' => ['/admin/notice-manage']], // 未完工 + ['label' => '站点公告管理', 'url' => ['/admin/announcements-manage']], ['label' => '工单支持管理', 'url' => ['/admin/ticket-manage']], ], ],