From 0173ac4984a86221f7ec64b93acc9973473265f5 Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 17 Apr 2024 15:22:28 +0800 Subject: [PATCH] add nickname support --- themes/tajian/controller/ListController.php | 8 ++++++- themes/tajian/controller/SiteController.php | 23 +++++++++++++++++++-- themes/tajian/views/layout/main.php | 3 +++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/themes/tajian/controller/ListController.php b/themes/tajian/controller/ListController.php index bfc21cf..c0f3346 100644 --- a/themes/tajian/controller/ListController.php +++ b/themes/tajian/controller/ListController.php @@ -58,6 +58,9 @@ Class ListController extends SiteController { } } + //昵称支持 + $nickname = $this->getNickname($readmeFile); + $pageTitle = $defaultTitle = !empty($titles) ? $titles[0]['name'] : FSC::$app['config']['site_name']; if (!empty($tagItem)) { $pageTitle = "{$tagItem['name']}精选视频,来自{$defaultTitle}"; @@ -66,7 +69,10 @@ Class ListController extends SiteController { } } $viewName = '//site/index'; //共享视图 - $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme', 'tags'); + $params = compact( + 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', + 'breadcrumbs', 'htmlCateReadme', 'tags', 'nickname' + ); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/tajian/controller/SiteController.php b/themes/tajian/controller/SiteController.php index 22464b5..6861b68 100644 --- a/themes/tajian/controller/SiteController.php +++ b/themes/tajian/controller/SiteController.php @@ -59,6 +59,8 @@ Class SiteController extends Controller { $tags = $this->sortTags($menus_sorted, $tags); } + //昵称支持 + $nickname = $this->getNickname($readmeFile); $pageTitle = $defaultTitle = !empty($titles) ? $titles[0]['name'] : FSC::$app['config']['site_name']; if (!empty($readmeFile['title'])) { @@ -66,7 +68,10 @@ Class SiteController extends Controller { } $viewName = 'index'; - $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme', 'tags'); + $params = compact( + 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme', 'tags', + 'nickname' + ); return $this->render($viewName, $params, $pageTitle); } @@ -127,6 +132,18 @@ Class SiteController extends Controller { return $sorted_tags; } + protected function getNickname($readmeFile) { + $nickname = ''; + + if (!empty($readmeFile['nickname'])) { + $nickname = $readmeFile['nickname']; + }else if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['user_id'])) { + $nickname = FSC::$app['user_id']; + } + + return $nickname; + } + //添加新视频 public function actionNew() { //获取数据 @@ -164,10 +181,12 @@ Class SiteController extends Controller { $tags = $this->sortTags($menus_sorted, $tags); } + //昵称支持 + $nickname = $this->getNickname($readmeFile); $pageTitle = '添加视频收藏'; $viewName = 'new'; - $params = compact('dirTree', 'scanResults', 'htmlReadme', 'tags'); + $params = compact('dirTree', 'scanResults', 'htmlReadme', 'tags', 'nickname'); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/tajian/views/layout/main.php b/themes/tajian/views/layout/main.php index 9c008fe..d7d7ef5 100644 --- a/themes/tajian/views/layout/main.php +++ b/themes/tajian/views/layout/main.php @@ -22,6 +22,9 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use
Ta荐 + + - +