<?php

Class DownAction extends PublicAction {

        public function _after_show() {
            $Down = D("Down");
            $down = $this->get('list');
            // 阅读计数
            $id	= $down["id"];
            if(!isset($_SESSION['down_read_count_'.$id])) {
		$Down->setInc('readCount',"id=".$id);
		$_SESSION['down_read_count_'.$id] = true;
            }
        }

	public function index() {
            $Down = M("Down");
            $count = $Down->count();
            $listRows = 6;
            //$fields	= 'id,title,categoryId,category,cTime,readCount,commentCount';
           
            import("@.ORG.Page");
            $p = new Page($count, $listRows);
            $p->setConfig("header", "篇文档");
            $list =  $Down->order("id desc")->limit($p->firstRow.','.$p->listRows)->select();
            $page = $p->show();
            $this->assign("list", $list);
            $this->assign("count", $count);
            $this->assign("page", $page);

            //统计数据
            $Down = M("Down");
            $stat = array();
            $stat["beginTime"] = $Down->min('uploadTime');
            $stat["downCount"] = $Down->count();
            $stat["readCount"] = $Down->sum("downCount");
          
            $this->assign($stat);
            $this->display();
	}

   


 

}
?>