<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class SortAction extends ForumAction
{
    public function run()
    {
        $sort = S::gp('sort','G');
        $sortArray = array('d','c');
        $sortMap = array('d' => '活跃榜', 'c' => '推荐榜');
        if (!in_array($sort, $sortArray))
        {
            $sort = 'd';
        }
        $title = $sortMap[$sort];
        
        $sort = ('d' == $sort ? 'todayposts' : 'commends') . ' DESC';
        $sql = "SELECT * FROM `".BookForum::table()."` WHERE bookid <> 13089 ORDER BY {$sort} LIMIT 10";
        $forums = $this->db()->setQueryString($sql)->find();
	    
	    $this->getController()->render('sort', array(
	            'forums' => $forums,
	            'title' => $title,
	        )
	    );
    }
}