<?php
function module_article_main()
{
	global $global,$smarty;
	if(!$global['id'])
	{
		$list_len = get_varia('art_list_len');
		$obj = new article();
		if($global['cat'] > 1)
		{
			$family = implode(',',get_cat_family('cat_art',$global['cat']));
			$obj->set_where("art_cat_id in ($family)");
		}else{
			$family = implode(',',get_cat_family('cat_art',1));
			$obj->set_where("art_cat_id not in ($family)");
		}
		$obj->set_page_size($list_len ? $list_len : 20);
		$obj->set_page_num($global['page']);
		$sheet = $obj->get_sheet();
		for($i = 0; $i < count($sheet); $i ++)
		{
			$sheet[$i]['short_title'] = cut_str($sheet[$i]['art_title'],50);
		}
		set_link($obj->get_page_sum());
		$smarty->assign('show_sheet',1);
		$smarty->assign('article',$sheet);
	}else{
		$obj = new article();
		$obj->set_field('art_id,art_title,art_author,art_add_time,art_text');
		$obj->set_where('art_id = '.$global['id']);
		$article = $obj->get_one();
		$smarty->assign('article',$article);
		
		$obj = new article();
		$obj->set_field('art_id,art_title');
		$obj->set_where('art_id < '.$global['id']);
		$one = $obj->get_one();
		if(count($one))
		{
			$smarty->assign('next_id',$one['art_id']);
			$smarty->assign('next_title',cut_str($one['art_title'],20));
		}else{
			$smarty->assign('next_id','');
			$smarty->assign('next_title','');
		}
				
		$obj = new article();
		$obj->set_field('art_id,art_title');
		$obj->set_where('art_id > '.$global['id']);
		$obj->set_order('');
		$obj->set_order('art_top','asc');
		$obj->set_order('art_index','asc');
		$obj->set_order('art_id','asc');
		$one = $obj->get_one();
		if(count($one))
		{
			$smarty->assign('prev_id',$one['art_id']);
			$smarty->assign('prev_title',cut_str($one['art_title'],20));
		}else{
			$smarty->assign('prev_id','');
			$smarty->assign('prev_title','');
		}
		
		$obj = new varia();
		$smarty->assign('share_code',$obj->get_value('share_code',true));
		
		$smarty->assign('show_sheet',0);
	}
}
//红头船
?>