<?php
/** 文章管理 
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaoq <xiaoq@570035208.com>
 */

namespace App\Controller;
class ArticleController extends BaseController {
	public function index() {
		$return['status']=2;
		$return['msg']='没有更多数据';
		$this->ajaxReturn($return);
	}
	public function content() {
		$return['status'] = 3;
		$paramdata = I('param.');
		if(empty($paramdata['id'])){
			$return['msg'] = '参数错误';
			$this->ajaxReturn($return);
		}
		$articlecont = D('Mobile/Article')->article_con($paramdata['id']);
		if($articlecont){
            if($articlecont['content']) {
                $return['data'] = $this->formatcontent($articlecont);
                $return['status'] = 1;
            }else{
                $return['status']=2;
            }
		}else{
			$return['msg'] = '未获取到数据';
		}
		$this->ajaxReturn($return);
	}
	private function formatcontent($cont) {
		if($cont['content']){
			$return = $cont['content'];
			$return['addtime'] = time_format($return['addtime'],'Y-m-d');
			$return['content'] = h($return['content']);
		}
		return $return;
	}

    /**文章分类
     * @return array
     */
    public function  cate_article(){
        $return=array('status'=>1);
        $where=array();
        $where['pid']=0;
        $article_cat=M('ArticleCat')->where($where)->field('id,name,img')->select();

        if($article_cat){
            $return['data']=$article_cat;
        }else{
            $return['status']=2;
            $return['msg']='没有获取到数据';
        }
       $this->ajaxReturn($return);
    }
	public function news() {
		$return['status']=3;
		$return['msg']='没有更多数据';
		$this->ajaxReturn($return);
	}
	private function format_con($cont) {
		if($cont){
			$cont['updatetime'] = time_format($cont['updatetime'],'Y-m-d');
			$cont['content'] = html_entity_decode($cont['content']);
//				h($return['content']);
		}
		return $cont;
	}
}