Jony/core/widget.php

60 lines
2.0 KiB
PHP
Raw Normal View History

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')
2021-04-27 04:22:40 +00:00
->where('table.contents.created < ?', time())
2021-01-26 13:41:01 +00:00
->limit($this->parameter->pageSize)
->offset($offset)
->order($this->parameter->type, Typecho_Db::SORT_DESC),
array($this, 'push')
);
}
}
2021-05-10 02:48:42 +00:00
class Widget_Contents_Post extends Widget_Abstract_Contents
{
public function execute()
{
$select = $this->select();
$select->cleanAttribute('fields');
$this->db->fetchAll(
$select
->from('table.contents')
->where('table.contents.type = ?', 'post')
->where('table.contents.cid = ?', $this->parameter->cid)
->limit(1),
array($this, 'push')
);
}
}