<?php 
class Html_comment_Controller extends Front_Controller {
	function __construct(){
		parent::__construct();
		$this->htmlcomment	=	new Html_comment_Model();
	}
	function index($channelid,$conid,$page=1){
		$this->lmtpl->defineload(self::tplpath('model_comment'));
		$GLOBALS['sum']		=	$this->htmlcomment->get($channelid,$conid)->count();
		$GLOBALS['page']	=	$page;
		$GLOBALS['dir']		=	BASEURI."html_comment/index";
		$GLOBALS['pagesize']=	$this->lmtpl->pagesize;
		$GLOBALS['is_html']	=	false;
		$GLOBALS['uri_segment']	=	"$channelid/$conid";
		$this->lmtpl->content->title	=	"评论";
		$this->lmtpl->contentid			=	$conid;
		$this->lmtpl->channelid			=	$channelid;
		$this->lmtpl->lists				=	$this->htmlcomment->get($channelid,$conid,$page,$this->lmtpl->pagesize)->result_array();
		$this->lmtpl->render(self::tplpath('model_comment'));
	}
	function add(){
		if($this->input->post()){
			$comment	=	$this->input->post("comment");
			$comment['dtime']	=	time();
			$comment['ip']		=	$this->input->ip_address();
			if(@$_SESSION['user']){
				$comment['userid']	=	$_SESSION['user']->user_id;
			}
			$this->htmlcomment->insert($comment);
		}
		$this->index($comment['channelid'],$comment['conid']);
	}
	function content_comment($channelid,$conid,$page=1){
		$this->lmtpl->defineload(self::tplpath('model_content_comment'));
		$GLOBALS['sum']		=	$this->htmlcomment->get($channelid,$conid)->count();
		$GLOBALS['page']	=	$page;
		$GLOBALS['dir']		=	BASEURI."html_comment/index";
		$GLOBALS['pagesize']=	$this->lmtpl->pagesize;
		$GLOBALS['is_html']	=	false;
		$GLOBALS['uri_segment']	=	"$channelid/$conid";
		$this->lmtpl->contentid			=	$conid;
		$this->lmtpl->channelid			=	$channelid;
		$this->lmtpl->lists				=	$this->htmlcomment->get($channelid,$conid,$page,$this->lmtpl->pagesize)->result_array();
		$this->lmtpl->render(self::tplpath('model_content_comment'));
	}
}