Files
blog-source/var/Widget/Contents/Post/Recent.php
2026-03-04 00:23:03 +08:00

55 lines
1.5 KiB
PHP
Executable File

<?php
namespace Widget\Contents\Post;
use Typecho\Db;
use Widget\Base\Contents;
if (!defined('__TYPECHO_ROOT_DIR__')) {
exit;
}
/**
* 最新评论组件
*
* @category typecho
* @package Widget
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org)
* @license GNU General Public License 2.0
*/
class Recent extends Contents
{
/**
* 执行函数
*
* @throws Db\Exception
*/
public function execute()
{
$this->parameter->setDefault(['pageSize' => $this->options->postsListSize]);
$this->db->fetchAll($this->select(
'table.contents.cid',
'table.contents.title',
'table.contents.slug',
'table.contents.created',
'table.contents.modified',
'table.contents.type',
'table.contents.status',
'table.contents.commentsNum',
'table.contents.allowComment',
'table.contents.allowPing',
'table.contents.allowFeed',
'table.contents.template',
'table.contents.password',
'table.contents.authorId',
'table.contents.parent',
)
->where('table.contents.status = ?', 'publish')
->where('table.contents.created < ?', $this->options->time)
->where('table.contents.type = ?', 'post')
->order('table.contents.created', Db::SORT_DESC)
->limit($this->parameter->pageSize), [$this, 'push']);
}
}