<?php

namespace Home\Controller;
use Think\Controller;
class ArticleController extends CommonController {
    
    public function help(){
        
        $cate = M('category');
        $news = M('news');
        $helpmap = $cate->where('pid = 1')->order('sort desc')->getField('cid,name',true);
        $hi = 0;
        foreach ($helpmap as $hk => $hv) {
            $newlist[$hi]['cid']=$hk;
            $newlist[$hi]['cname']=$hv;
            $newlist[$hi]['list']=$news->where('cid ='.$hk)->getField('id,title',true);
            $hi += 1;
        }
        $this->newlist=$newlist;
        
        $newid = I('get.id');
        $where = empty($newid) ? array('id'=>key($newlist[0]['list'])):array('id'=>$newid);
        $list = $news->where($where)->find();
        $list['content']=stripslashes($list['content']);
        $list['cname']= $cate->where('cid ='.$list['cid'])->getField('name');
        $this->list=$list;  
        $this->display();
    }
    
    public function notice(){
        $cid=I('get.cid');
        $news = M('news');
        $count = $news->where('cid = '.$cid)->count();
        $pConf = page($count,C('PAGE_SIZE'));
        $this->page = $pConf['show']; 
        $where = array('status'=>1,'cid'=>$cid); 
        $noticemap = $news->where($where)->limit($pConf['first'].','.$pConf['list'])->field('id,title,keywords,description,update_time,picture')->select();
        $this->cname=($cid==2)?'网站公告':'拍卖咨询';
        $this->cid=$cid;
        $this->list=$noticemap;

        $this->display();
    }
    public function notice_details(){
        $cid=I('get.cid');
        $news = M('news');
        $where = array('id'=>I('get.id'));
        $data = $news->where($where)->find();
        $data['content']=stripslashes($data['content']);
        $this->cname=($cid==2)?'网站公告':'拍卖咨询';
        $this->data=$data;
        $this->display();
    }
}?>
