<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class LogsAction extends ForumAction
{
    public function run()
    {
        $count = $this->db()->getValue("SELECT COUNT(*) FROM `".BookManageLog::table()."` WHERE bookid = {$this->id()}");
        
        $pageObj = new iPage();
        $pageObj->setPageSize(10);
        $pageObj->setTotalRecord($count);
        $sql = "SELECT * FROM `".BookManageLog::table()."` WHERE `bookid` = {$this->id()} ORDER BY `id` DESC LIMIT {$pageObj->getOffset()},{$pageObj->getPageSize()}";
        $logs = $this->db()->setQueryString($sql)->find();
        $floor = $pageObj->getFloor();
        
        $this->getController()->render('logs', array(
                'bookid' => $this->id(),
                'logs' => $logs,
                'floor' => $floor,
                'pageObj' => $pageObj,
                'forumInfo' => $this->forumInfo(),
            )
        );
    }
}