<?php
if (!defined('HUCART_COM')) exit('HuCart.COM No direct script access allowed');
class Article extends HC_Controller
{
	//注意无须构造函数,使用了构造函数得重构父类 parent::__construct();
	function __construct()
	{
		parent::__construct();
		$this->load_lang('adminsys/article');
		$this -> load('admin'); 
		$this -> admin -> online_admin();
		$this -> load_db();
		$this -> load('helper'); //加载辅助类
		$this -> load_model('sort'); //加载产品分类模型
		//$this -> load_model('art_type'); 	 //加载类型模型
		//$this-> lang['txt_select'];
	}
 
	
	function info_list()
	{
		$this -> load('page',$this->lang['page']);

		$sort_idval 	= $this -> input ->  req["sort_id"];
		$keywordval 	= $this -> input ->  req["keyword"];
		$page_num_val 	= $this -> input ->  req["page_num"];

 

		//只能查询一次分类数据
		$sort_info  		= $this -> sort_mod -> get_sort('art_sort','sort_');
		//echo 'dddd';
		//生成分类ID对应值
		$sort_key_val 	= $this -> helper -> mapped_key_value( $sort_info , $key_index = 'sort_id');

		//获取子分类所有ID值
		if( $sort_id !='' ){
		
			$sort_son_id = $this -> aro_sort_mod -> get_sort_son_id( $sort_id ,$sort_key_val );
			$where_add 			.= " AND ( a.sort_id IN ( ".implode(",",$sort_son_id )." ) )";
		}
		//var_dump($sort_info);
		//生成分类选择控件
		$sort_select_str = $this -> helper -> build_out_str( $sort_info , $object_name = 'sort_id', $object_id = 'sort_id' , $object_val_str = 'sort_id', $object_txt_str = 'sort_name', $sort_id  ,$lang_txt = $this-> lang['txt_select'] , $key_id = 'sort_id', $parent_id = 'sort_parent_id', $grade_val = 6 );
	
		
		if($this -> input ->  get["keyword"] !='')
		{   
			$keywordval 	= $this -> input ->  get["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		if($keywordval!='')
		{ 	
			//$endArray["keyword"] =$keywordval;
			
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			$whereadd .= " AND ( a.art_title LIKE  '%".$keywordval."%' )";  
		}
		
		
		//list_val 字段名称
		//list_type 1'',2'DESC'
		$list_val  = $this -> input ->  get["list_val"];
		$list_type = $this -> input ->  get["list_type"];
		
		
		$orderbyval = "";
		
		if($list_val!='' and $list_type =='DESC' )
		{
			//$endArray["list_type"] = 'DESC';
			//$endArray["list_val"]  = $list_val;
			$orderbyval = $list_val ."  DESC ";
			$listhtml = '';	//反向排序参数
			
		}elseif($list_val!='' )
		{
			$orderbyval = $list_val;
			$listhtml = 'DESC';
			
			//$endArray["list_type"] = '';
			//$endArray["list_val"]  = $list_val;

		}else{
			//$endArray["list_type"] = 'DESC';
			//$endArray["list_val"]  = 'art_up_time';
			$orderbyval = " a.art_up_time DESC , `art_id` DESC ";	
		}
		$this->get_art_type();
		//echo $whereadd;
		//序号 	标题 	文章分类 	浏览量 	是否显示 	更新时间 	排序
		//列表字段显示
		$show_arr = array('art_id' => 1,'art_title'=>1,'sort_id'=>1,'art_type'=>1,'art_view'=>1,'art_enabled'=>0,'art_up_time'=>1,'art_list'=>1);
		
		$field_show = $this -> helper -> get_th_list( $show_arr , $list_val , $list_type , $lang_arr = $this->lang['field_list'] );

		
		
		$sql_query = " SELECT a.art_id, a.art_title,art_small_title,art_color,art_bolder,a.art_type , a.art_view , a.sort_id , a.art_enabled ,a.art_up_time ,a.art_list,a.art_sys_file  FROM  ".$this -> db -> prefix."article as a    WHERE art_delete = 0   $whereadd  GROUP BY art_id  ORDER BY  $orderbyval LIMIT  ". $this -> page ->get_limit_val();
		$info = $this -> db -> select_info($sql_query);
		
		foreach($info as $key => $val)
		{
			$info[$key]['art_up_time'] = date("Y-m-d H:i:s",$val["art_up_time"]);
			
		}
		
		$sql_query = " SELECT count(1) as CNUM  FROM  ".$this -> db -> prefix."article as a   WHERE art_delete = 0 $whereadd  ORDER BY a.`art_id`";
		$infocount = $this -> db -> select_one($sql_query);
		
 
		$page_str = $this -> page ->get_admin_page( $infocount["CNUM"] );
		
		//$this->get_sort();
		
		$this -> view -> assign('field_show',$field_show);

		$this -> view -> assign('list_val',$list_val);
		$this -> view -> assign('list_type',$list_type);
		
		$this -> view -> assign('sort_idval',$sort_idval);
		$this -> view -> assign('keywordval',$keywordval);
		
	
		$this -> view -> assign('sort_id',$sort_id);
		$this -> view -> assign('keyword',$keyword);


		$this -> view -> assign('sort_key_val',$sort_key_val);
		$this -> view -> assign('sort_select_str',$sort_select_str);
		
		$this -> view -> assign('page_str',$page_str);
		$this -> view -> assign('info',$info);
		
		$this -> view -> display('article.tpl');

	}

	function trash_list()
	{
		$this -> load('page',$this->lang['page']);

		$sort_idval 	= $this -> input ->  req["sort_id"];
		$keywordval 	= $this -> input ->  req["keyword"];
		$page_num_val 	= $this -> input ->  req["page_num"];

 

		//只能查询一次分类数据
		$sort_info  		= $this -> sort_mod -> get_sort('art_sort','sort_');
		//echo 'dddd';
		//生成分类ID对应值
		$sort_key_val 	= $this -> helper -> mapped_key_value( $sort_info , $key_index = 'sort_id');

		//获取子分类所有ID值
		if( $sort_id !='' ){
		
			$sort_son_id = $this -> aro_sort_mod -> get_sort_son_id( $sort_id ,$sort_key_val );
			$where_add 			.= " AND ( a.sort_id IN ( ".implode(",",$sort_son_id )." ) )";
		}
		//var_dump($sort_info);
		//生成分类选择控件
		$sort_select_str = $this -> helper -> build_out_str( $sort_info , $object_name = 'sort_id', $object_id = 'sort_id' , $object_val_str = 'sort_id', $object_txt_str = 'sort_name', $sort_id  ,$lang_txt = $this-> lang['txt_select'] , $key_id = 'sort_id', $parent_id = 'sort_parent_id', $grade_val = 6 );
	
		
		if($this -> input ->  get["keyword"] !='')
		{   
			$keywordval 	= $this -> input ->  get["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		if($keywordval!='')
		{ 	
			//$endArray["keyword"] =$keywordval;
			
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			$whereadd .= " AND ( a.art_title LIKE  '%".$keywordval."%' )";  
		}
		
		
		//list_val 字段名称
		//list_type 1'',2'DESC'
		$list_val  = $this -> input ->  get["list_val"];
		$list_type = $this -> input ->  get["list_type"];
		
		
		$orderbyval = "";
		
		if($list_val!='' and $list_type =='DESC' )
		{
			//$endArray["list_type"] = 'DESC';
			//$endArray["list_val"]  = $list_val;
			$orderbyval = $list_val ."  DESC ";
			$listhtml = '';	//反向排序参数
			
		}elseif($list_val!='' )
		{
			$orderbyval = $list_val;
			$listhtml = 'DESC';
			
			//$endArray["list_type"] = '';
			//$endArray["list_val"]  = $list_val;

		}else{
			//$endArray["list_type"] = 'DESC';
			//$endArray["list_val"]  = 'art_up_time';
			$orderbyval = " a.art_up_time DESC , `art_id` DESC ";	
		}
		$this->get_art_type();
		//echo $whereadd;
		//序号 	标题 	文章分类 	浏览量 	是否显示 	更新时间 	排序
		//列表字段显示
		$show_arr = array('art_id' => 1,'art_title'=>1,'sort_id'=>1,'art_type'=>1,'art_view'=>1,'art_enabled'=>0,'art_up_time'=>1,'art_list'=>1);
		
		$field_show = $this -> helper -> get_th_list( $show_arr , $list_val , $list_type , $lang_arr = $this->lang['field_list'] );

		
		
		$sql_query = " SELECT a.art_id, a.art_title,art_small_title,art_color,art_bolder,a.art_type , a.art_view , a.sort_id , a.art_enabled ,a.art_up_time ,a.art_list,a.art_sys_file  FROM  ".$this -> db -> prefix."article as a    WHERE art_delete = 1   $whereadd  GROUP BY art_id  ORDER BY  $orderbyval LIMIT  ". $this -> page ->get_limit_val();
		$info = $this -> db -> select_info($sql_query);
		
		$sql_query = " SELECT count(1) as CNUM  FROM  ".$this -> db -> prefix."article as a   WHERE art_delete = 1 $whereadd  ORDER BY a.`art_id`  ";
		$infocount = $this -> db -> select_one($sql_query);
		
 
		$page_str = $this -> page ->get_admin_page( $infocount["CNUM"] );


		$opt = array( 'restore'=> $this->lang['restore'], 'delete'=> $this->lang['delete']);
		
		$td_rows  = $this -> helper -> get_td_list( $info , $show_arr ,$key_arr , $this -> master_act , $opt);

 		
 
		
		//$this->get_sort();
		
		$this -> view -> assign('field_show',$field_show);

		$this -> view -> assign('list_val',$list_val);
		$this -> view -> assign('list_type',$list_type);
		
		$this -> view -> assign('sort_idval',$sort_idval);
		$this -> view -> assign('keywordval',$keywordval);
		
	
		$this -> view -> assign('sort_id',$sort_id);
		$this -> view -> assign('keyword',$keyword);


		$this -> view -> assign('sort_key_val',$sort_key_val);
		$this -> view -> assign('sort_select_str',$sort_select_str);
		
		$this -> view -> assign('page_str',$page_str);
		$this -> view -> assign('info',$info);
		
		$this -> view -> display('article_trash.tpl');

	}
	


	
	
	function get_art_type()
	{
		$sql_query = " SELECT typ_id,typ_name,typ_list FROM  ".$this -> db -> prefix."type  WHERE typ_type = 'art' GROUP BY typ_id ORDER BY `typ_list` limit 50 ";
		
		$info_art_type = $this -> db -> select_info($sql_query);
		$art_type[0] = $this->lang['default_type_name'];
		foreach((array)$info_art_type as $tkey => $tval)
		{
			$art_type[$tval["typ_id"]] = $tval["typ_name"];
		}

		$this -> view -> assign('art_type',$art_type);		//列排表显示使用
		$this -> view -> assign('info_art_type',$info_art_type);		//列排表显示使用

		//return $info_art_type;
	}
	
	
	function recycler()
	{
		$page_size = 20 ;
		
		$sort_idval 		= $this -> input ->  req["sort_id"];
		$keywordval 	= $this -> input ->  req["keyword"];
		$page_num_val 	= $this -> input ->  req["page_num"];
		
		if( $page_num_val > 1 )
		{
			$page_num  = $page_num_val;
			$limit_num = ceil( ( $page_num_val -1 ) * $page_size );
		}else{
			$page_num  = 1;
			$limit_num = 0 ;
		}

		
		if($sort_idval!='' and $sort_idval !='A' )
		{ 
			
			//$endArray["sort_id"] = $sort_idval;
			 
			$sidsql  = " SELECT sort_id FROM ".$this -> db -> prefix."art_sort WHERE sort_parent_id = ".$sort_idval." or  sort_id = ".$sort_idval;
		    $sortInfo 	  = $this -> db -> select_info( $sidsql );

			$sinid  = '';
			if($sortInfo!='')
			{
				foreach( $sortInfo as $skey => $sval )
				{
					if($skey==0)
					{
						$sinid = $sval["sort_id"];
					}else{
						$sinid .= ','.$sval["sort_id"];
					}
				}
				$whereadd .= " AND ( a.sort_id IN ( ".$sinid." ) )";
			}
		 }else{ 
		 	$endurl 	   .= '&sort_id=A'; 	
		 }

		
		if($this -> input ->  get["keyword"] !='')
		{   
			$keywordval 	= $this -> input ->  get["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		if($keywordval!='')
		{ 	
			//$endArray["keyword"] =$keywordval;
			
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			$whereadd .= " AND ( a.art_title LIKE  '%".$keywordval."%' )";  
		}
		
		//list_val 字段名称
		//list_type 1'',2'DESC'
		$list_val  = $this -> input ->  get["list_val"];
		$list_type = $this -> input ->  get["list_type"];
		
		
		$orderbyval = "";
		
		if($list_val!='' and $list_type =='DESC' )
		{
			//$endArray["list_type"] = 'DESC';
			//$endArray["list_val"]  = $list_val;
			$orderbyval = $list_val ."  DESC ";
			$listhtml = '';	//反向排序参数
			
		}elseif($list_val!='' )
		{
			$orderbyval = $list_val;
			$listhtml = 'DESC';
			
			//$endArray["list_type"] = '';
			//$endArray["list_val"]  = $list_val;

		}else{
			//$endArray["list_type"] = 'DESC';
			//$endArray["list_val"]  = 'art_up_time';
			$orderbyval = " a.art_up_time DESC , `art_id` DESC ";	
		}
		$this->get_art_type();
		//echo $whereadd;
		//序号 	标题 	文章分类 	浏览量 	是否显示 	更新时间 	排序
		
		$sql_query = " SELECT  a.art_id, a.art_title,art_small_title,art_color,art_bolder, a.art_type ,a.art_view , a.sort_id , a.art_enabled ,a.art_up_time ,a.art_list,a.art_sysfile  FROM  ".$this -> db -> prefix."article as a    WHERE art_delete = 1   $whereadd  GROUP BY art_id  ORDER BY  $orderbyval LIMIT  $limit_num , $page_size ";
		$info = $this -> db -> select_info($sql_query);
		
		$sql_query = " SELECT count(1) as CNUM  FROM  ".$this -> db -> prefix."article as a   WHERE art_delete = 1 $whereadd  ORDER BY a.`art_id`  ";
		$infocount = $this -> db -> select_one($sql_query);
		
		//var_dump($info);
		
		$page_str = $this -> page ->get_admin_page( $url = '?load=article&act=recycler', $page_num  , $page_size  , $result_count = $infocount["CNUM"] , $endArray );
		
		// $this->get_sort();
		
		
		$this -> view -> assign('list_val',$list_val);
		$this -> view -> assign('list_type',$list_type);
		
		$this -> view -> assign('sort_idval',$sort_idval);
		$this -> view -> assign('keywordval',$keywordval);
		
		$this -> view -> assign('page_str',$page_str);
		$this -> view -> assign('info',$info);
		$this -> view -> display('articlerecycler.tpl');

	}
	
	
	
	function add()
	{

		$sort_info  		= $this -> sort_mod -> get_sort('art_sort','sort_');
		//生成分类选择控件
		$sort_select_str = $this -> helper -> build_out_str( $sort_info , $object_name = 'sort_id', $object_id = 'sort_id' , $object_val_str = 'sort_id', $object_txt_str = 'sort_name', $sort_id  ,$lang_txt = $this-> lang['txt_select'] , $key_id = 'sort_id', $parent_id = 'sort_parent_id', $grade_val = 6 );
		
		$this->get_art_type();

 		$ckeditorLoad 	= $this -> helper -> load_ckeditor( 'art_detail' );	//加载文本编辑器
		$this -> view -> assign( 'ckeditorLoad', $ckeditorLoad);
		
		$this -> view -> assign( 'sort_select_str', $sort_select_str);
		$this -> view -> assign( 'edit_submit', $this-> lang['add_submit']);
		$this -> view -> assign( 'txt_title', $this-> lang['add_title']);
		$this -> view -> assign('act_url',ADMIN_WEBURL."/index.php?load=article&act=add_info");
		$this -> view -> display('article_edit.tpl');
	}
	
	
	function add_info()
	{
		$art_titleval 		= $this -> input ->  funpost("art_title");
		$art_phoneticizeval = $this -> input ->  funpost("art_phoneticize");
		$art_authorval 		= $this -> input ->  funpost("art_author");
		$sort_idval 		= $this -> input ->  funpost("sort_id");
		$art_keywordval 	= $this -> input ->  delKeyword($_POST["art_keyword"]);
		$art_descriptionval = $this -> input ->  delContent($_POST["art_description"]);  
		$art_detailval 		= $this -> input ->  delart($_POST["art_detail"]);
		$art_picval 		= $this -> input ->  funpost("art_pic");
		$art_fileval 		= $this -> input ->  funpost("art_file");
		$art_enabledval 	= $this -> input ->  funpost("art_enabled");
		$art_list_val 		= $this -> input ->  funpost("art_list");
		$art_typeval		= $this -> input ->  funpost("art_type");
		$art_small_titleval = $this -> input ->  funpost("art_small_title");
		$art_colorval 		= $this -> input ->  post["art_color"];
		$art_bolderval 		= $this -> input ->  funpost("art_bolder");
		$art_typeval		= $this -> input ->  funpost("art_type");
		
		
		$art_up_timeval = $art_add_timeval 	= time();
		$adm_id = $_SESSION["admin"]["adm_id"];

		if($art_titleval !='' and $sort_idval !='' and $art_detailval !='' )
		{
			$sql_query = " SELECT count(1) as CNUM  FROM  ".$this -> db -> prefix."article  WHERE art_title = '".$art_titleval."' ORDER BY `art_id` ";
			$info = $this -> db -> select_one($sql_query);
			
			$artkeywordArr = explode(' ',$art_keywordval);
			foreach((array)$artkeywordArr as $kkey => $kval)
			{
				if($kval!='')
				{
					$this -> load_model('keyword');
					$this -> keyword_mod -> add_keyword( $kval,'art',0);
				}
			}
			
			
			if( $info["CNUM"] < 1 )
			{
				$insert_art ="INSERT INTO `".$this -> db -> prefix."article` (`art_title` , `art_small_title`,`art_color`,`art_bolder`,`art_phoneticize` ,`art_author` , `sort_id` , `art_keyword` , `art_description` , `art_detail` , `art_pic` , `art_file` , `art_enabled`, `art_list`,`art_up_time`,`art_add_time`,`art_type`,`adm_id`) VALUES (  '$art_titleval', '$art_small_titleval','$art_colorval','$art_bolderval','$art_phoneticizeval','$art_authorval', '$sort_idval', '$art_keywordval', '$art_descriptionval', '$art_detailval', '$art_picval', '$art_fileval', '$art_enabledval', '$art_list_val' ,'$art_up_timeval','$art_add_timeval','$art_typeval','$adm_id')";
				
				$this -> db -> query_sql($insert_art);
				$this -> view ->  assign('info_title',$this->lang['add_success']);
				$this -> view ->  assign('URL_TIME',URL_TIME);
				$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info_list");
				$this -> view ->  display('suggestion.tpl');	
			}else{
							
				$this -> view ->  assign('info_title',$this->lang['err_info_exist']);
				$this -> view ->  assign('URL_TIME',URL_TIME);
				$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=add");
				$this -> view ->  display('suggestion.tpl');	
			}
			
		}else{
			
			$this -> view ->  assign('info_title',$this->lang['err_info_missing'] );
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=add");
			$this -> view ->  display('suggestion.tpl');
		}
			//var_dump($_REQUEST);
	}
	
	/*
	function get_sort()
	{
		
		$sql_query = " SELECT sort_id, sort_name,sort_parent_id  FROM  ".$this -> db -> prefix."art_sort  WHERE 1 and sort_enabled = 1 GROUP BY sort_id ORDER BY `sort_list` limit 1000 ";
		
		$infosm = $this -> db -> select_info($sql_query);
		
		$asInfo = array();
		
		foreach((array)$infosm as $rowkey => $rowval)
		{
				if($rowval["sort_parent_id"] == 0)
				{
					$asInfo[$rowval["sort_id"]]['sort_id'] 		= $rowval["sort_id"] ;
					$asInfo[$rowval["sort_id"]]['sort_name'] 		= $rowval["sort_name"] ;
					$asInfo[$rowval["sort_id"]]['sort_parent_id']  = $rowval["sort_parent_id"] ;
				}else{
					$asInfo[$rowval["sort_parent_id"]]['array'][] = $rowval;	
				}
				
				$asInfoval[$rowval["sort_id"]] = $rowval["sort_name"] ;
		}

		$this -> view -> assign('asInfoval',$asInfoval);		//列排表显示使用
		
		$this -> view -> assign('asInfo',$asInfo);
		return $asInfo;
	}
	*/
	
	
	
	function del( )
	{
		$infoid = $this -> input ->  del_url($_REQUEST["id"]);
		
		$deletesql ="DELETE FROM `".$this -> db -> prefix."article`   WHERE  `art_id` in ( $infoid ) AND art_sysfile = '' ";

		@$this -> db -> query_sql($deletesql);
		
		$this -> view ->  assign('info_title',$this->lang['del_success']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info_list");
		$this -> view ->  display('suggestion.tpl');
	}
	
	function rec( )
	{
		$infoid = $this -> input ->  del_url($_REQUEST["id"]);
		
		$uprec = " UPDATE `".$this -> db -> prefix."article` SET art_delete = 1  WHERE  `art_id` in ( $infoid ) AND art_sysfile = '' ";

		@$this -> db -> query_sql($uprec);
		$this -> view ->  assign('info_title',$_LANG['bd_recsusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info_list");
		$this -> view ->  display('suggestion.tpl');
	}
	
	
	//还原
	function restore( )
	{
		$infoid = $this -> input ->  del_url($_REQUEST["id"]);
		
		$uprec = " UPDATE `".$this -> db -> prefix."article` SET art_delete = 0  WHERE  `art_id` in ( $infoid ) ";

		@$this -> db -> query_sql($uprec);
		$this -> view ->  assign('info_title',$_LANG['bd_restoresusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=recycler");
		$this -> view ->  display('suggestion.tpl');
	}
	
	
	function show( )
	{
		$infoid = $this -> input ->  del_url($_REQUEST["id"]);
		$upshow = " UPDATE `".$this -> db -> prefix."article` SET art_enabled = 1  WHERE  `art_id` in ( $infoid ) ";

		@$this -> db -> query_sql($upshow);
		$this -> view ->  assign('info_title',$_LANG['bd_showsusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info_list");
		$this -> view ->  display('suggestion.tpl');
	}
	
	function hide( )
	{
		$infoid = $this -> input ->  del_url($_REQUEST["id"]);
		$uphide = " UPDATE `".$this -> db -> prefix."article` SET art_enabled = 0  WHERE  `art_id` in ( $infoid ) ";
		@$this -> db -> query_sql($uphide);
		$this -> view ->  assign('info_title',$_LANG['bd_hidesusse']);
		$this -> view ->  assign('URL_TIME',URL_TIME);
		$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info_list");
		$this -> view ->  display('suggestion.tpl');
	}
	
	
	function info(  )
	{
		$infoid    = $this -> input ->  get["id"];
		
		$sql_query = " SELECT *  FROM  ".$this -> db -> prefix."article  WHERE art_id = '".$infoid."' ORDER BY `art_id` ";
		$info = $this -> db -> select_one($sql_query);

		$ckeditorLoad 	= $this -> helper -> load_ckeditor( 'art_detail' ,$info["art_detail"] );	//加载文本编辑器
		$this -> view -> assign( 'ckeditorLoad', $ckeditorLoad);

		//只能查询一次分类数据
		$sort_info  		= $this -> sort_mod ->  get_sort('art_sort','sort_');
		$sort_select_str = $this -> helper -> build_out_str( $sort_info , $object_name = 'sort_id', $object_id = 'sort_id' , $object_val_str = 'sort_id', $object_txt_str = 'sort_name', $info['sort_id']  ,$lang_txt = $this-> lang['txt_select'] , $key_id = 'sort_id', $parent_id = 'sort_parent_id', $grade_val = 6 );
		
		$this->get_art_type();
		
		$this -> view -> assign('sort_select_str',$sort_select_str);
		$this -> view -> assign('act_url',ADMIN_WEBURL."/index.php?load=article&act=edit_info");
		$this -> view -> assign('edit_submit', $this-> lang['edit_submit']);
		$this -> view -> assign('txt_title', $this-> lang['edit_title']);
		$this -> view -> assign('info',$info);
		$this -> view -> display('article_edit.tpl');
	
	}
	
	
	function edit_info( )
	{	
		

		$art_idval 			= $this -> input ->  funpost("art_id");

		$art_titleval 		= $this -> input ->  funpost("art_title");
		$art_phoneticizeval = $this -> input ->  funpost("art_phoneticize");
		$art_authorval 		= $this -> input ->  funpost("art_author");
		$sort_idval 		= $this -> input ->  funpost("sort_id");
		$art_keywordval 	= $this -> input ->  post["art_keyword"];
		//var_dump($this -> input);
		//echo $_POST["art_description"];
		$art_descriptionval = $this -> input ->  delContent($_POST["art_description"]); 

		$art_detailval 		= $this -> input ->  delart($_POST["art_detail"]);
		$art_picval 		= $this -> input ->  funpost("art_pic");
		$art_fileval 		= $this -> input ->  funpost("art_file");
		$art_enabledval 	= $this -> input ->  funpost("art_enabled");
		$art_list_val 		= $this -> input ->  funpost("art_list");
		
		//var_dump($this -> input);
		//exit('fff');
		
		$art_small_titleval = $this -> input ->  funpost("art_small_title");
		$art_colorval 		= $this -> input ->  post["art_color"];
		$art_bolderval 		= $this -> input ->  funpost("art_bolder");
		$art_typeval		= $this -> input ->  funpost("art_type");
		
		$art_up_timeval 		= time();
		//exit('fdafdsa');
		
		if($art_idval !='' and $art_titleval !='' )
		{
			
			$artkeywordArr = explode(' ',$art_keywordval);
			
			foreach((array)$artkeywordArr as $kkey => $kval)
			{
				if($kval!='')
				{
					$this -> load_model('keyword');
					$this -> keyword_mod -> add_keyword( $kval,'art',0);
				}
			}
			
			$updatesql = "UPDATE `".$this -> db -> prefix."article` SET  art_title = '".$art_titleval."' , art_small_title = '".$art_small_titleval."' ,art_color = '".$art_colorval."' ,art_bolder = '".$art_bolderval."' , art_phoneticize = '".$art_phoneticizeval."' , art_author = '".$art_authorval."' , sort_id = '".$sort_idval."' , art_keyword = '".$art_keywordval."' , art_description = '".$art_descriptionval."' , art_detail = '".$art_detailval."' , art_pic = '".$art_picval."' , art_file = '".$art_fileval."' , art_enabled = '".$art_enabledval."' , art_list = '".$art_list_val."' , art_up_time = '".$art_up_timeval."'  , art_type = '".$art_typeval."'  WHERE  art_id = '".$art_idval."' ";
			$this -> db -> query_sql( $updatesql );
			
			$this -> view ->  assign('info_title',$this->lang['edit_success']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info_list");
			$this -> view ->  display('suggestion.tpl');
				
		}else{
		
			$this -> view ->  assign('info_title',$this->lang['err_info_missing']);
			$this -> view ->  assign('URL_TIME',URL_TIME);
			$this -> view ->  assign('get_url',ADMIN_WEBURL."/index.php?load=article&act=info&id=".$art_idval);
			$this -> view ->  display('suggestion.tpl');	
		}

	}
		
}
