Files
typecho/var/Widget/CommentPage.php
T
joyqi e89b1bbcf6 Feat/tree pages (#1646)
* add tree trait

* finish category tree trait

* support select fields

* fix select fields

* refactor admin trait

* fix draft status

* Add new contents type "revision"

* minor refactor

* add more tree view abstracts

* add tree trait to pages

* get ready for tree view pages

* improve page edit

* fix revision

* fix slug

* add router params delegate

* fix params delegate

* fix

* fix

* fix all

* fix all

* fix tree

* fix page link

* fix feed

* fix page

* fix permalink

* fix permalink input

* fix offset query
2023-11-27 21:57:18 -08:00

51 lines
1.2 KiB
PHP

<?php
namespace Widget;
use Exception;
use Typecho\Router;
use Typecho\Widget\Exception as WidgetException;
/**
* Comment Page Widget
*/
class CommentPage extends Base implements ActionInterface
{
/**
* Perform comment page action
*
* @throws Exception
*/
public function action()
{
$page = abs($this->request->filter('int')->get('commentPage'));
$archive = Router::match($this->request->get('permalink'), [
'checkPermalink' => false,
'commentPage' => $page
]);
if (!($archive instanceof Archive) || !$archive->is('single')) {
throw new WidgetException(_t('请求的地址不存在'), 404);
}
$currentCommentUrl = Router::url('comment_page', [
'permalink' => $archive->path,
'commentPage' => $page
], $this->options->index);
$this->checkPermalink($currentCommentUrl);
$archive->render();
}
/**
* @param string $commentUrl
*/
private function checkPermalink(string $commentUrl)
{
if ($commentUrl != $this->request->getRequestUrl()) {
$this->response->redirect($commentUrl, true);
}
}
}