2021-01-26 13:41:01 +00:00
|
|
|
<?php
|
|
|
|
class Widget_Contents_Hot extends Widget_Abstract_Contents
|
|
|
|
{
|
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
$this->parameter->setDefault(array('pageSize' => 10));
|
2021-02-18 14:02:19 +00:00
|
|
|
$select = $this->select();
|
|
|
|
$select->cleanAttribute('fields');
|
2021-01-26 13:41:01 +00:00
|
|
|
$this->db->fetchAll(
|
2021-02-18 14:02:19 +00:00
|
|
|
$select->from('table.contents')
|
2021-01-26 13:41:01 +00:00
|
|
|
->where("table.contents.password IS NULL OR table.contents.password = ''")
|
|
|
|
->where('table.contents.status = ?', 'publish')
|
|
|
|
->where('table.contents.created <= ?', time())
|
|
|
|
->where('table.contents.type = ?', 'post')
|
|
|
|
->limit($this->parameter->pageSize)
|
|
|
|
->order('table.contents.views', Typecho_Db::SORT_DESC),
|
|
|
|
array($this, 'push')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Widget_Contents_Sort extends Widget_Abstract_Contents
|
|
|
|
{
|
|
|
|
public function execute()
|
|
|
|
{
|
|
|
|
$this->parameter->setDefault(array('page' => 1, 'pageSize' => 10, 'type' => 'created'));
|
|
|
|
$offset = $this->parameter->pageSize * ($this->parameter->page - 1);
|
2021-02-18 14:02:19 +00:00
|
|
|
$select = $this->select();
|
|
|
|
$select->cleanAttribute('fields');
|
2021-01-26 13:41:01 +00:00
|
|
|
$this->db->fetchAll(
|
2021-02-18 14:02:19 +00:00
|
|
|
$select
|
2021-01-26 13:41:01 +00:00
|
|
|
->from('table.contents')
|
|
|
|
->where('table.contents.type = ?', 'post')
|
|
|
|
->where('table.contents.status = ?', 'publish')
|
|
|
|
->limit($this->parameter->pageSize)
|
|
|
|
->offset($offset)
|
|
|
|
->order($this->parameter->type, Typecho_Db::SORT_DESC),
|
|
|
|
array($this, 'push')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|