<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class CategoryAction extends SoftAction
{
    public function run()
    {
        $cid = S::gp('id', 'G', 2);
        $cName = softCategoryName($cid);

        $count = $this->db()->getValue('SELECT COUNT(*) FROM '.SoftContents::table().' WHERE cid='.$cid.' AND isdelete = 0');

        $pageObj = new iPage();
        $pageObj->setPageSize(10);
        $pageObj->setTotalRecord($count);

        $sql = 'SELECT id,name FROM '.SoftContents::table().' WHERE cid = '.$cid.' AND isdelete = 0 ORDER BY id DESC '.S::sqlLimit($pageObj->getOffset(), $pageObj->getPageSize());
        $softs = $this->db()->setQueryString($sql)->find();
        $floor = $pageObj->getFloor();

        $this->getController()->render('category', array(
                'cName' => $cName,
                'cid' => $cid,
                'softs' => $softs,
                'pageObj' => $pageObj,
                'floor' => $floor,
            )
        );
    }
}