From 1a15ad58c98dec14f723ac3d8c49ac1f44ff8712 Mon Sep 17 00:00:00 2001 From: koogua Date: Thu, 13 May 2021 17:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B6=E6=AE=B5=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 +- ...cleHotAuthorList.php => TopAuthorList.php} | 4 +- app/Console/Tasks/RevokeVipTask.php | 2 +- app/Console/Tasks/UpgradeTask.php | 18 +++++ .../Admin/Controllers/AnswerController.php | 8 +- .../Admin/Controllers/ArticleController.php | 2 +- .../Admin/Controllers/QuestionController.php | 2 +- app/Http/Admin/Services/Answer.php | 16 ++++ app/Http/Admin/Services/Article.php | 8 ++ app/Http/Admin/Services/AuthNode.php | 80 +++++++++---------- app/Http/Admin/Services/Question.php | 8 ++ app/Http/Admin/Views/answer/review.volt | 8 +- app/Http/Admin/Views/article/list.volt | 2 +- app/Http/Admin/Views/article/review.volt | 16 +++- app/Http/Admin/Views/macros/article.volt | 8 +- app/Http/Admin/Views/moderation/articles.volt | 3 +- app/Http/Admin/Views/question/review.volt | 8 +- .../Home/Controllers/AnswerController.php | 21 ++--- .../Home/Controllers/ArticleController.php | 39 ++++----- .../Home/Controllers/QuestionController.php | 48 ++++------- .../Home/Controllers/WidgetController.php | 15 ++++ app/Http/Home/Views/answer/edit.volt | 1 + app/Http/Home/Views/article/edit.volt | 1 + app/Http/Home/Views/article/list.volt | 4 +- app/Http/Home/Views/article/show.volt | 5 +- app/Http/Home/Views/question/answer_tips.volt | 17 ---- app/Http/Home/Views/question/answers.volt | 66 ++++++++------- app/Http/Home/Views/question/edit.volt | 1 + app/Http/Home/Views/question/list.volt | 4 +- app/Http/Home/Views/question/show.volt | 11 ++- .../Home/Views/user/console/articles.volt | 15 +--- .../Views/user/console/favorites_article.volt | 7 +- .../user/console/favorites_question.volt | 7 +- app/Http/Home/Views/user/console/menu.volt | 2 +- .../Home/Views/user/console/questions.volt | 6 -- .../{question => widget}/hot_questions.volt | 0 .../{question => widget}/top_answerers.volt | 0 .../top_authors.volt} | 0 app/Services/Logic/Answer/AnswerInfo.php | 1 + app/Services/Logic/Article/ArticleInfo.php | 1 + .../{HotAuthorList.php => TopAuthorList.php} | 6 +- app/Services/Logic/Question/QuestionInfo.php | 1 + db/migrations/20210430023157.php | 61 ++++++++++++++ public/static/admin/css/common.css | 4 + public/static/home/css/common.css | 54 +++++++++++-- public/static/home/js/article.list.js | 10 +-- 46 files changed, 373 insertions(+), 236 deletions(-) rename app/Caches/{ArticleHotAuthorList.php => TopAuthorList.php} (96%) delete mode 100644 app/Http/Home/Views/question/answer_tips.volt rename app/Http/Home/Views/{question => widget}/hot_questions.volt (100%) rename app/Http/Home/Views/{question => widget}/top_answerers.volt (100%) rename app/Http/Home/Views/{article/hot_authors.volt => widget/top_authors.volt} (100%) rename app/Services/Logic/Article/{HotAuthorList.php => TopAuthorList.php} (56%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 965bfae9..c1b2c565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,15 @@ ### 更新 -- 前台增加问答功能 +- 增加问答功能 +- 增加标签关注功能 - 优化标签功能 - 优化文章功能以及全文搜索 - 优化课程评价,咨询,文章等相关统计 -- 后台增加提问和回答审核功能 -- 后台增加查看用户在线记录 修正后台编辑角色权限错误 - 优化前台界面 +- 后台增加提问和回答审核功能 +- 后台增加查看用户在线记录 +- 修正后台编辑角色权限错误 ### [v1.3.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.3.3)(2021-04-30) diff --git a/app/Caches/ArticleHotAuthorList.php b/app/Caches/TopAuthorList.php similarity index 96% rename from app/Caches/ArticleHotAuthorList.php rename to app/Caches/TopAuthorList.php index ff4440be..9fe35c24 100644 --- a/app/Caches/ArticleHotAuthorList.php +++ b/app/Caches/TopAuthorList.php @@ -8,7 +8,7 @@ use App\Repos\User as UserRepo; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; -class ArticleHotAuthorList extends Cache +class TopAuthorList extends Cache { protected $lifetime = 1 * 86400; @@ -20,7 +20,7 @@ class ArticleHotAuthorList extends Cache public function getKey($id = null) { - return 'article_hot_author_list'; + return 'top_author_list'; } public function getContent($id = null) diff --git a/app/Console/Tasks/RevokeVipTask.php b/app/Console/Tasks/RevokeVipTask.php index 58380c4b..461df80f 100644 --- a/app/Console/Tasks/RevokeVipTask.php +++ b/app/Console/Tasks/RevokeVipTask.php @@ -24,7 +24,7 @@ class RevokeVipTask extends Task } /** - * 查找待解锁用户 + * 查找待撤销会员 * * @param int $limit * @return ResultsetInterface|Resultset|UserModel[] diff --git a/app/Console/Tasks/UpgradeTask.php b/app/Console/Tasks/UpgradeTask.php index 521289f1..e36388a7 100644 --- a/app/Console/Tasks/UpgradeTask.php +++ b/app/Console/Tasks/UpgradeTask.php @@ -2,6 +2,7 @@ namespace App\Console\Tasks; +use App\Caches\NavTreeList as NavTreeListCache; use App\Caches\Setting as SettingCache; use App\Models\Setting as SettingModel; @@ -14,6 +15,7 @@ class UpgradeTask extends Task $this->resetAnnotationAction(); $this->resetMetadataAction(); $this->resetVoltAction(); + $this->resetNavAction(); } /** @@ -103,6 +105,22 @@ class UpgradeTask extends Task echo '------ end reset volt ------' . PHP_EOL; } + /** + * 重置导航 + * + * @command: php console.php upgrade reset_nav + */ + public function resetNavAction() + { + echo '------ start reset navigation ------' . PHP_EOL; + + $cache = new NavTreeListCache(); + + $cache->delete(); + + echo '------ end reset navigation ------' . PHP_EOL; + } + protected function handlePhKeys($keys) { return array_map(function ($key) { diff --git a/app/Http/Admin/Controllers/AnswerController.php b/app/Http/Admin/Controllers/AnswerController.php index e22ca8f3..42f0af5d 100644 --- a/app/Http/Admin/Controllers/AnswerController.php +++ b/app/Http/Admin/Controllers/AnswerController.php @@ -171,8 +171,6 @@ class AnswerController extends Controller { $answerService = new AnswerService(); - $answer = $answerService->getAnswer($id); - if ($this->request->isPost()) { $answerService->reviewAnswer($id); @@ -188,13 +186,9 @@ class AnswerController extends Controller } $reasons = $answerService->getReasons(); - - $questionService = new QuestionService(); - - $question = $questionService->getQuestion($answer->question_id); + $answer = $answerService->getAnswerInfo($id); $this->view->setVar('reasons', $reasons); - $this->view->setVar('question', $question); $this->view->setVar('answer', $answer); } diff --git a/app/Http/Admin/Controllers/ArticleController.php b/app/Http/Admin/Controllers/ArticleController.php index 26080afb..a849d35e 100644 --- a/app/Http/Admin/Controllers/ArticleController.php +++ b/app/Http/Admin/Controllers/ArticleController.php @@ -190,7 +190,7 @@ class ArticleController extends Controller } $reasons = $articleService->getReasons(); - $article = $articleService->getArticle($id); + $article = $articleService->getArticleInfo($id); $this->view->setVar('reasons', $reasons); $this->view->setVar('article', $article); diff --git a/app/Http/Admin/Controllers/QuestionController.php b/app/Http/Admin/Controllers/QuestionController.php index ef92e49d..082139dd 100644 --- a/app/Http/Admin/Controllers/QuestionController.php +++ b/app/Http/Admin/Controllers/QuestionController.php @@ -186,7 +186,7 @@ class QuestionController extends Controller } $reasons = $questionService->getReasons(); - $question = $questionService->getQuestion($id); + $question = $questionService->getQuestionInfo($id); $this->view->setVar('reasons', $reasons); $this->view->setVar('question', $question); diff --git a/app/Http/Admin/Services/Answer.php b/app/Http/Admin/Services/Answer.php index b1fd1263..abaf914e 100644 --- a/app/Http/Admin/Services/Answer.php +++ b/app/Http/Admin/Services/Answer.php @@ -11,6 +11,7 @@ use App\Models\User as UserModel; use App\Repos\Answer as AnswerRepo; use App\Repos\Question as QuestionRepo; use App\Repos\User as UserRepo; +use App\Services\Logic\Answer\AnswerInfo as AnswerInfoService; use App\Services\Logic\Notice\System\AnswerApproved as AnswerApprovedNotice; use App\Services\Logic\Notice\System\AnswerRejected as AnswerRejectedNotice; use App\Services\Logic\Notice\System\QuestionAnswered as QuestionAnsweredNotice; @@ -54,6 +55,13 @@ class Answer extends Service return $this->findOrFail($id); } + public function getAnswerInfo($id) + { + $service = new AnswerInfoService(); + + return $service->handle($id); + } + public function createAnswer() { $post = $this->request->getPost(); @@ -78,6 +86,8 @@ class Answer extends Service $this->handleAnswerPostPoint($answer); $this->handleQuestionAnsweredNotice($answer); + $this->eventsManager->fire('Answer:afterCreate', $this, $answer); + return $answer; } @@ -110,6 +120,8 @@ class Answer extends Service $answer->update($data); + $this->eventsManager->fire('Answer:afterUpdate', $this, $answer); + return $answer; } @@ -129,6 +141,8 @@ class Answer extends Service $this->recountUserAnswers($owner); + $this->eventsManager->fire('Answer:afterDelete', $this, $answer); + return $answer; } @@ -148,6 +162,8 @@ class Answer extends Service $this->recountUserAnswers($owner); + $this->eventsManager->fire('Answer:afterRestore', $this, $answer); + return $answer; } diff --git a/app/Http/Admin/Services/Article.php b/app/Http/Admin/Services/Article.php index fa39df84..3ccb3aef 100644 --- a/app/Http/Admin/Services/Article.php +++ b/app/Http/Admin/Services/Article.php @@ -15,6 +15,7 @@ use App\Repos\Category as CategoryRepo; use App\Repos\Tag as TagRepo; use App\Repos\User as UserRepo; use App\Services\Logic\Article\ArticleDataTrait; +use App\Services\Logic\Article\ArticleInfo as ArticleInfoService; use App\Services\Logic\Notice\System\ArticleApproved as ArticleApprovedNotice; use App\Services\Logic\Notice\System\ArticleRejected as ArticleRejectedNotice; use App\Services\Logic\Point\History\ArticlePost as ArticlePostPointHistory; @@ -111,6 +112,13 @@ class Article extends Service return $this->findOrFail($id); } + public function getArticleInfo($id) + { + $service = new ArticleInfoService(); + + return $service->handle($id); + } + public function createArticle() { $post = $this->request->getPost(); diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index b62914ae..2ed2d003 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -243,6 +243,43 @@ class AuthNode extends Service ], ], ], + [ + 'id' => '1-8', + 'title' => '标签管理', + 'type' => 'menu', + 'children' => [ + [ + 'id' => '1-8-1', + 'title' => '标签列表', + 'type' => 'menu', + 'route' => 'admin.tag.list', + ], + [ + 'id' => '1-8-2', + 'title' => '搜索标签', + 'type' => 'menu', + 'route' => 'admin.tag.search', + ], + [ + 'id' => '1-8-3', + 'title' => '添加标签', + 'type' => 'menu', + 'route' => 'admin.tag.add', + ], + [ + 'id' => '1-8-4', + 'title' => '编辑标签', + 'type' => 'button', + 'route' => 'admin.tag.edit', + ], + [ + 'id' => '1-8-5', + 'title' => '删除标签', + 'type' => 'button', + 'route' => 'admin.tag.delete', + ], + ], + ], [ 'id' => '1-7', 'title' => '文章管理', @@ -390,43 +427,6 @@ class AuthNode extends Service ], ], ], - [ - 'id' => '1-8', - 'title' => '标签管理', - 'type' => 'menu', - 'children' => [ - [ - 'id' => '1-8-1', - 'title' => '标签列表', - 'type' => 'menu', - 'route' => 'admin.tag.list', - ], - [ - 'id' => '1-8-2', - 'title' => '搜索标签', - 'type' => 'menu', - 'route' => 'admin.tag.search', - ], - [ - 'id' => '1-8-3', - 'title' => '添加标签', - 'type' => 'menu', - 'route' => 'admin.tag.add', - ], - [ - 'id' => '1-8-4', - 'title' => '编辑标签', - 'type' => 'button', - 'route' => 'admin.tag.edit', - ], - [ - 'id' => '1-8-5', - 'title' => '删除标签', - 'type' => 'button', - 'route' => 'admin.tag.delete', - ], - ], - ], [ 'id' => '1-9', 'title' => '评论管理', @@ -475,19 +475,19 @@ class AuthNode extends Service 'children' => [ [ 'id' => '2-10-1', - 'title' => '文章列表', + 'title' => '文章审核', 'type' => 'menu', 'route' => 'admin.mod.articles', ], [ 'id' => '2-10-2', - 'title' => '问题列表', + 'title' => '问题审核', 'type' => 'menu', 'route' => 'admin.mod.questions', ], [ 'id' => '2-10-3', - 'title' => '回答列表', + 'title' => '回答审核', 'type' => 'menu', 'route' => 'admin.mod.answers', ], diff --git a/app/Http/Admin/Services/Question.php b/app/Http/Admin/Services/Question.php index eda8ffd3..a83914fd 100644 --- a/app/Http/Admin/Services/Question.php +++ b/app/Http/Admin/Services/Question.php @@ -17,6 +17,7 @@ use App\Services\Logic\Notice\System\QuestionApproved as QuestionApprovedNotice; use App\Services\Logic\Notice\System\QuestionRejected as QuestionRejectedNotice; use App\Services\Logic\Point\History\QuestionPost as QuestionPostPointHistory; use App\Services\Logic\Question\QuestionDataTrait; +use App\Services\Logic\Question\QuestionInfo as QuestionInfoService; use App\Services\Sync\QuestionIndex as QuestionIndexSync; use App\Validators\Question as QuestionValidator; @@ -105,6 +106,13 @@ class Question extends Service return $this->findOrFail($id); } + public function getQuestionInfo($id) + { + $service = new QuestionInfoService(); + + return $service->handle($id); + } + public function createQuestion() { $post = $this->request->getPost(); diff --git a/app/Http/Admin/Views/answer/review.volt b/app/Http/Admin/Views/answer/review.volt index c94e5e6e..f93a7162 100644 --- a/app/Http/Admin/Views/answer/review.volt +++ b/app/Http/Admin/Views/answer/review.volt @@ -2,12 +2,18 @@ {% block content %} + {% set owner_url = url({'for':'home.user.show','id':answer.owner.id}) %} +
审核内容
-
{{ question.title }}
+
{{ answer.question.title }}
+
+ {{ answer.owner.name }} + {{ date('Y-m-d H:i',answer.create_time) }} +
{{ answer.content }}
diff --git a/app/Http/Admin/Views/article/list.volt b/app/Http/Admin/Views/article/list.volt index b13ccdea..272c8348 100644 --- a/app/Http/Admin/Views/article/list.volt +++ b/app/Http/Admin/Views/article/list.volt @@ -70,7 +70,7 @@ {% endif %}

- 来源:{{ source_info(item.source_type,item.source_url) }} + 来源:{{ source_type(item.source_type) }} 作者:{{ item.owner.name }} 创建:{{ date('Y-m-d',item.create_time) }}

diff --git a/app/Http/Admin/Views/article/review.volt b/app/Http/Admin/Views/article/review.volt index f24ca97d..67187d96 100644 --- a/app/Http/Admin/Views/article/review.volt +++ b/app/Http/Admin/Views/article/review.volt @@ -2,20 +2,34 @@ {% block content %} + {{ partial('macros/article') }} + + {% set owner_url = url({'for':'home.user.show','id':article.owner.id}) %} +
审核内容
{{ article.title }}
+
+ {{ source_type(article.source_type) }} + {{ article.owner.name }} + {{ date('Y-m-d H:i',article.create_time) }} +
{{ article.content }}
{% if article.tags %}
{% for item in article.tags %} - {{ item['name'] }} + {{ item.name }} {% endfor %}
{% endif %} + {% if article.source_url %} + + {% endif %}
diff --git a/app/Http/Admin/Views/macros/article.volt b/app/Http/Admin/Views/macros/article.volt index c904f6ba..fa74535e 100644 --- a/app/Http/Admin/Views/macros/article.volt +++ b/app/Http/Admin/Views/macros/article.volt @@ -10,13 +10,13 @@ {% endif %} {%- endmacro %} -{%- macro source_info(type,url) %} +{%- macro source_type(type) %} {% if type == 1 %} - 原创 + 原创 {% elseif type == 2 %} - 转载 + 转载 {% elseif type == 3 %} - 翻译 + 翻译 {% else %} N/A {% endif %} diff --git a/app/Http/Admin/Views/moderation/articles.volt b/app/Http/Admin/Views/moderation/articles.volt index f9e1a631..8df081d8 100644 --- a/app/Http/Admin/Views/moderation/articles.volt +++ b/app/Http/Admin/Views/moderation/articles.volt @@ -33,8 +33,9 @@ {% set review_url = url({'for':'admin.article.review','id':item.id}) %} -

标题:{{ item.title }} {{ source_info(item.source_type,item.source_url) }}

+

标题:{{ item.title }}

+ 来源:{{ source_type(item.source_type) }} {% if item.tags %} 标签:{{ tags_info(item.tags) }} {% endif %} diff --git a/app/Http/Admin/Views/question/review.volt b/app/Http/Admin/Views/question/review.volt index e1491b8a..b5360d45 100644 --- a/app/Http/Admin/Views/question/review.volt +++ b/app/Http/Admin/Views/question/review.volt @@ -2,17 +2,23 @@ {% block content %} + {% set owner_url = url({'for':'home.user.show','id':question.owner.id}) %} +

审核内容
{{ question.title }}
+
+ {{ question.owner.name }} + {{ date('Y-m-d H:i',question.create_time) }} +
{{ question.content }}
{% if question.tags %}
{% for item in question.tags %} - {{ item['name'] }} + {{ item.name }} {% endfor %}
{% endif %} diff --git a/app/Http/Home/Controllers/AnswerController.php b/app/Http/Home/Controllers/AnswerController.php index f51c77d6..0314918e 100644 --- a/app/Http/Home/Controllers/AnswerController.php +++ b/app/Http/Home/Controllers/AnswerController.php @@ -57,8 +57,11 @@ class AnswerController extends Controller $this->seo->prependTitle('编辑回答'); + $referer = $this->request->getHTTPReferer(); + $this->view->setVar('question', $question); $this->view->setVar('answer', $answer); + $this->view->setVar('referer', $referer); } /** @@ -102,12 +105,13 @@ class AnswerController extends Controller { $service = new AnswerUpdateService(); - $answer = $service->handle($id); + $service->handle($id); - $location = $this->url->get([ - 'for' => 'home.question.show', - 'id' => $answer->question_id, - ]); + $location = $this->request->getPost('referer'); + + if (empty($location)) { + $location = $this->url->get(['for' => 'home.uc.answers']); + } $content = [ 'location' => $location, @@ -124,12 +128,9 @@ class AnswerController extends Controller { $service = new AnswerDeleteService(); - $answer = $service->handle($id); + $service->handle($id); - $location = $this->url->get([ - 'for' => 'home.question.show', - 'id' => $answer->question_id, - ]); + $location = $this->request->getHTTPReferer(); $content = [ 'location' => $location, diff --git a/app/Http/Home/Controllers/ArticleController.php b/app/Http/Home/Controllers/ArticleController.php index 36adbfd8..87dac7ea 100644 --- a/app/Http/Home/Controllers/ArticleController.php +++ b/app/Http/Home/Controllers/ArticleController.php @@ -11,7 +11,6 @@ use App\Services\Logic\Article\ArticleInfo as ArticleInfoService; use App\Services\Logic\Article\ArticleLike as ArticleLikeService; use App\Services\Logic\Article\ArticleList as ArticleListService; use App\Services\Logic\Article\ArticleUpdate as ArticleUpdateService; -use App\Services\Logic\Article\HotAuthorList as HotAuthorListService; use App\Services\Logic\Article\RelatedArticleList as RelatedArticleListService; use Phalcon\Mvc\View; @@ -28,13 +27,11 @@ class ArticleController extends Controller { $service = new ArticleQueryService(); - $categories = $service->handleCategories(); $sorts = $service->handleSorts(); $params = $service->getParams(); $this->seo->prependTitle('专栏'); - $this->view->setVar('categories', $categories); $this->view->setVar('sorts', $sorts); $this->view->setVar('params', $params); } @@ -54,20 +51,6 @@ class ArticleController extends Controller $this->view->setVar('pager', $pager); } - /** - * @Get("/hot/authors", name="home.article.hot_authors") - */ - public function hotAuthorsAction() - { - $service = new HotAuthorListService(); - - $authors = $service->handle(); - - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('article/hot_authors'); - $this->view->setVar('authors', $authors); - } - /** * @Get("/add", name="home.article.add") */ @@ -76,7 +59,6 @@ class ArticleController extends Controller $service = new ArticleService(); $sourceTypes = $service->getSourceTypes(); - $categories = $service->getCategories(); $article = $service->getArticleModel(); $xmTags = $service->getXmTags(0); @@ -84,7 +66,6 @@ class ArticleController extends Controller $this->view->pick('article/edit'); $this->view->setVar('source_types', $sourceTypes); - $this->view->setVar('categories', $categories); $this->view->setVar('article', $article); $this->view->setVar('xm_tags', $xmTags); } @@ -97,14 +78,15 @@ class ArticleController extends Controller $service = new ArticleService(); $sourceTypes = $service->getSourceTypes(); - $categories = $service->getCategories(); $article = $service->getArticle($id); $xmTags = $service->getXmTags($id); $this->seo->prependTitle('编辑文章'); + $referer = $this->request->getHTTPReferer(); + $this->view->setVar('source_types', $sourceTypes); - $this->view->setVar('categories', $categories); + $this->view->setVar('referer', $referer); $this->view->setVar('article', $article); $this->view->setVar('xm_tags', $xmTags); } @@ -150,9 +132,12 @@ class ArticleController extends Controller { $service = new ArticleCreateService(); - $service->handle(); + $article = $service->handle(); - $location = $this->url->get(['for' => 'home.uc.articles']); + $location = $this->url->get([ + 'for' => 'home.article.show', + 'id' => $article->id, + ]); $content = [ 'location' => $location, @@ -171,7 +156,11 @@ class ArticleController extends Controller $service->handle($id); - $location = $this->url->get(['for' => 'home.uc.articles']); + $location = $this->request->getPost('referer'); + + if (empty($location)) { + $location = $this->url->get(['for' => 'home.uc.articles']); + } $content = [ 'location' => $location, @@ -190,7 +179,7 @@ class ArticleController extends Controller $service->handle($id); - $location = $this->url->get(['for' => 'home.uc.articles']); + $location = $this->request->getHTTPReferer(); $content = [ 'location' => $location, diff --git a/app/Http/Home/Controllers/QuestionController.php b/app/Http/Home/Controllers/QuestionController.php index a691a5ea..78fcbf20 100644 --- a/app/Http/Home/Controllers/QuestionController.php +++ b/app/Http/Home/Controllers/QuestionController.php @@ -5,7 +5,6 @@ namespace App\Http\Home\Controllers; use App\Http\Home\Services\Question as QuestionService; use App\Http\Home\Services\QuestionQuery as QuestionQueryService; use App\Services\Logic\Question\AnswerList as AnswerListService; -use App\Services\Logic\Question\HotQuestionList as HotQuestionListService; use App\Services\Logic\Question\QuestionCreate as QuestionCreateService; use App\Services\Logic\Question\QuestionDelete as QuestionDeleteService; use App\Services\Logic\Question\QuestionFavorite as QuestionFavoriteService; @@ -14,7 +13,6 @@ use App\Services\Logic\Question\QuestionLike as QuestionLikeService; use App\Services\Logic\Question\QuestionList as QuestionListService; use App\Services\Logic\Question\QuestionUpdate as QuestionUpdateService; use App\Services\Logic\Question\RelatedQuestionList as RelatedQuestionListService; -use App\Services\Logic\Question\TopAnswererList as TopAnswererListService; use Phalcon\Mvc\View; /** @@ -23,34 +21,6 @@ use Phalcon\Mvc\View; class QuestionController extends Controller { - /** - * @Get("/hot/questions", name="home.question.hot_questions") - */ - public function hotQuestionsAction() - { - $service = new HotQuestionListService(); - - $questions = $service->handle(); - - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('question/hot_questions'); - $this->view->setVar('questions', $questions); - } - - /** - * @Get("/top/answerers", name="home.question.top_answerers") - */ - public function topAnswerersAction() - { - $service = new TopAnswererListService(); - - $answerers = $service->handle(); - - $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); - $this->view->pick('question/top_answerers'); - $this->view->setVar('answerers', $answerers); - } - /** * @Get("/list", name="home.question.list") */ @@ -113,6 +83,9 @@ class QuestionController extends Controller $this->seo->prependTitle('编辑问题'); + $referer = $this->request->getHTTPReferer(); + + $this->view->setVar('referer', $referer); $this->view->setVar('question', $question); $this->view->setVar('xm_tags', $xmTags); } @@ -172,9 +145,12 @@ class QuestionController extends Controller { $service = new QuestionCreateService(); - $service->handle(); + $question = $service->handle(); - $location = $this->url->get(['for' => 'home.uc.questions']); + $location = $this->url->get([ + 'for' => 'home.question.show', + 'id' => $question->id, + ]); $content = [ 'location' => $location, @@ -193,7 +169,11 @@ class QuestionController extends Controller $service->handle($id); - $location = $this->url->get(['for' => 'home.uc.questions']); + $location = $this->request->getPost('referer'); + + if (empty($location)) { + $location = $this->url->get(['for' => 'home.uc.questions']); + } $content = [ 'location' => $location, @@ -212,7 +192,7 @@ class QuestionController extends Controller $service->handle($id); - $location = $this->url->get(['for' => 'home.uc.questions']); + $location = $this->request->getHTTPReferer(); $content = [ 'location' => $location, diff --git a/app/Http/Home/Controllers/WidgetController.php b/app/Http/Home/Controllers/WidgetController.php index b129692d..9a3f9742 100644 --- a/app/Http/Home/Controllers/WidgetController.php +++ b/app/Http/Home/Controllers/WidgetController.php @@ -2,6 +2,7 @@ namespace App\Http\Home\Controllers; +use App\Services\Logic\Article\TopAuthorList as TopAuthorListService; use App\Services\Logic\Question\HotQuestionList as HotQuestionListService; use App\Services\Logic\Question\TopAnswererList as TopAnswererListService; use App\Services\Logic\Tag\FollowList as FollowListService; @@ -41,6 +42,20 @@ class WidgetController extends Controller $this->view->setVar('questions', $questions); } + /** + * @Get("/top/authors", name="home.widget.top_authors") + */ + public function topAuthorsAction() + { + $service = new TopAuthorListService(); + + $authors = $service->handle(); + + $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); + $this->view->pick('widget/top_authors'); + $this->view->setVar('authors', $authors); + } + /** * @Get("/top/answerers", name="home.widget.top_answerers") */ diff --git a/app/Http/Home/Views/answer/edit.volt b/app/Http/Home/Views/answer/edit.volt index bbed9ada..47d43d88 100644 --- a/app/Http/Home/Views/answer/edit.volt +++ b/app/Http/Home/Views/answer/edit.volt @@ -26,6 +26,7 @@
+
diff --git a/app/Http/Home/Views/article/edit.volt b/app/Http/Home/Views/article/edit.volt index f88d3a5f..5feaf7ab 100644 --- a/app/Http/Home/Views/article/edit.volt +++ b/app/Http/Home/Views/article/edit.volt @@ -31,6 +31,7 @@
+
diff --git a/app/Http/Home/Views/article/list.volt b/app/Http/Home/Views/article/list.volt index e540ac25..bcc3bfc2 100644 --- a/app/Http/Home/Views/article/list.volt +++ b/app/Http/Home/Views/article/list.volt @@ -4,7 +4,7 @@ {% set sort_val = request.get('sort','trim','latest') %} {% set pager_url = url({'for':'home.article.pager'}, params) %} - {% set hot_authors_url = url({'for':'home.article.hot_authors'}) %} + {% set top_authors_url = url({'for':'home.widget.top_authors'}) %} {% set my_tags_url = url({'for':'home.widget.my_tags'},{'type':'article'}) %} diff --git a/app/Http/Home/Views/article/show.volt b/app/Http/Home/Views/article/show.volt index 7b145569..87db375a 100644 --- a/app/Http/Home/Views/article/show.volt +++ b/app/Http/Home/Views/article/show.volt @@ -33,7 +33,10 @@
{{ article.title }}
- {{ source_type(article.source_type) }} + {% if article.published == 1 %} + 审核中 + {% endif %} + {{ source_type(article.source_type) }} {{ article.owner.name }} {{ article.create_time|time_ago }} {{ article.view_count }} 阅读 diff --git a/app/Http/Home/Views/question/answer_tips.volt b/app/Http/Home/Views/question/answer_tips.volt deleted file mode 100644 index bf7e38ce..00000000 --- a/app/Http/Home/Views/question/answer_tips.volt +++ /dev/null @@ -1,17 +0,0 @@ -
-
答题指南
-
-

适合作为回答的

-
    -
  • 经过验证的有效解决办法
  • -
  • 自己的经验指引,对解决问题有帮助
  • -
  • 遵循 Markdown 语法排版,表达语义正确
  • -
-

不该作为回答的

-
    -
  • 询问内容细节或回复楼层
  • -
  • 与题目无关的内容
  • -
  • “赞” “顶” “同问” 等毫无意义的内容
  • -
-
-
\ No newline at end of file diff --git a/app/Http/Home/Views/question/answers.volt b/app/Http/Home/Views/question/answers.volt index c74f5bf8..11951277 100644 --- a/app/Http/Home/Views/question/answers.volt +++ b/app/Http/Home/Views/question/answers.volt @@ -5,45 +5,43 @@ {% set report_url = url({'for':'home.answer.report','id':item.id}) %} {% set edit_url = url({'for':'home.answer.edit','id':item.id}) %} {% set delete_url = url({'for':'home.answer.delete','id':item.id}) %} -
-
- - {{ item.owner.name }} - +
+
+ + + {{ item.owner.name }} + + + {{ item.owner.name }}
-
- -
{{ item.content }}
-