<?php
/**
 * Descriptions
 * @author yzxh24
 * @email yzxh24@gmail.com
 * @created 2011-08-10 17:07:02
 */
class ListAction extends BaseAction
{
    public function run()
    {
        $sid = Yii::app()->request->getQuery('id');
        $special = Special::model()->findByPk($sid);
    	$criteria = $this->_buildCriteria(new CDbCriteria(array('condition'=>'deleted = 0 AND sid='.$sid, 'with'=>array('book'))));
        //put your code here
        $dataProvider = new CActiveDataProvider('SpecialSubject',array(
        	'pagination' => array(
        		'pageSize' => 20
        	),
        	'sort' => array(
        		'defaultOrder' => 'id DESC',
        	),
        ));
        $dataProvider->setCriteria($criteria);
        
		$this->getController()->render('list', array(
			'dataProvider' => $dataProvider,
            'special' => $special,
		));
    }
    
    /**
     * 根据url后面传递进来的参数获取一个查询条件
     * @param CDbCriteria $criteria
     * @return CDbCriteria
     */
    private function _buildCriteria(CDbCriteria $criteria)
    {
    	// 完善此功能
    	return Helper::buildCriteria($criteria, $_GET);
    }
}