<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class UbbAction extends BbsAction
{
    public function run()
    {
        if ('smiles' == $_GET['do'])
        {
            exit($this->_smiles());
        }

        $sql = 'SELECT id,name FROM '.Smile::table().' WHERE type = 0';
        $smileType = $this->db()->setQueryString($sql)->find();
        
        $this->getController()->render('ubb',array(
                'smileType' => $smileType,
            )
        );
    }
    
    private function _smiles()
    {
        $id = intval(S::gp('id','G'));
        $smile = $this->db()->select(array('name'))->from(Smile::table())->where('id='.$id)->find(true);
        empty($smile) && $this->showMessage('不存在的表情');
        
        $smiles = $this->db()->select()->from(Smile::table())->where('`type`='.$id)->find();
        
        $this->getController()->render('smiles',array(
                'smile' => $smile,
                'smiles' => $smiles,
            )
        );
    }
}