<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class LogAction extends BbsAction
{
    public function run()
    {
        $fid = S::gp('fid', 'G', 2);
        $forum = Forums::single()->getCache($fid);
        $mapArray = $this->_logTypeArray;

        $pageSize = 10;
        $pageObj = new iPage();
        $pageObj->setPageSize($pageSize);
        $count = $this->db()->getValue('SELECT COUNT(*) FROM '.ForumLog::table().' WHERE fid='.S::sqlEscape($fid));
        $pageObj->setTotalRecord($count);

        $sql = 'SELECT * FROM '.ForumLog::table().' WHERE fid='.S::sqlEscape($fid).' ORDER BY id DESC '.S::sqlLimit($pageObj->getOffset(), $pageObj->getPageSize());
        $result = $this->db()->setQueryString($sql)->find();
        $floor = $pageObj->getFloor();
        
        $this->getController()->render('log', array(
                'result' => $result,
                'pageObj' => $pageObj,
                'floor' => $floor,
                'mapArray' => $mapArray,
                'forum' => $forum,
            )
        );
    }
}
