You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.7 KiB
63 lines
1.7 KiB
<?php |
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit; |
|
/** |
|
* Typecho Blog Platform |
|
* |
|
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org) |
|
* @license GNU General Public License 2.0 |
|
* @version $Id$ |
|
*/ |
|
|
|
/** |
|
* 最近评论组件 |
|
* |
|
* @category typecho |
|
* @package Widget |
|
* @copyright Copyright (c) 2008 Typecho team (http://www.typecho.org) |
|
* @license GNU General Public License 2.0 |
|
*/ |
|
class Widget_Comments_Recent extends Widget_Abstract_Comments |
|
{ |
|
/** |
|
* 构造函数,初始化组件 |
|
* |
|
* @access public |
|
* @param mixed $request request对象 |
|
* @param mixed $response response对象 |
|
* @param mixed $params 参数列表 |
|
* @return void |
|
*/ |
|
public function __construct($request, $response, $params = NULL) |
|
{ |
|
parent::__construct($request, $response, $params); |
|
$this->parameter->setDefault(array('pageSize' => $this->options->commentsListSize, 'parentId' => 0, 'ignoreAuthor' => false)); |
|
} |
|
|
|
/** |
|
* 执行函数 |
|
* |
|
* @access public |
|
* @return void |
|
*/ |
|
public function execute() |
|
{ |
|
$select = $this->select()->limit($this->parameter->pageSize) |
|
->where('table.comments.status = ?', 'approved') |
|
->order('table.comments.coid', Typecho_Db::SORT_DESC); |
|
|
|
if ($this->parameter->parentId) { |
|
$select->where('cid = ?', $this->parameter->parentId); |
|
} |
|
|
|
if ($this->options->commentsShowCommentOnly) { |
|
$select->where('type = ?', 'comment'); |
|
} |
|
|
|
/** 忽略作者评论 */ |
|
if ($this->parameter->ignoreAuthor) { |
|
$select->where('ownerId <> authorId'); |
|
} |
|
|
|
$this->db->fetchAll($select, array($this, 'push')); |
|
} |
|
}
|
|
|