<?
define('SOFTPUBS_IN', true);
require_once(dirname(__FILE__) . '/includes/init.php');
require_once(ROOT_PATH.'includes/header.php');
this_channel(CHANNEL_ARTICLE_LIST_ID);	

$limit			=		10;
$page   			=  	@(int)$_GET['page']?(int)$_GET['page']:1;
$this_page     =  	($page-1)*$limit;	
$sql				=		"SELECT * FROM {$db_obj->db_pre}article WHERE 1=1";
$count_sql		=		"SELECT COUNT(article_id) AS count FROM  {$db_obj->db_pre}article WHERE 1=1 ";	
	

if($art_cat_id=(int)$_GET['cat_id']){
	$cat_id_str			=		$glo_category_obj->recursion_category('article',$art_cat_id);	
	$sql					.=		" AND cat_id in ($cat_id_str)";
	$count_sql			.=		" AND cat_id in ($cat_id_str)";
	$order_type				=	"  ";	

	$this_cat			=		$glo_category_obj->get_cat_this_is_here('article',$art_cat_id,'article_list');
}else{
	$order_type			=	"  ";
}
$sql				.=		" ORDER BY sort_order DESC,last_update DESC  limit $this_page,$limit";

$article_list_res	=	$db_obj->getRecords($sql);
if($article_list_res){
	$article_list_res				=		format_art_list($article_list_res);
	$count							=		$db_obj->getNumber($count_sql);
	$page_arr						=		pagination_arr($page,$count,$limit,10,'page');	
	foreach($page_arr['thepage'] as $key=>$val){
		$page_arr['thepage'][$key]	=	get_url($val,$this_cat['cat_name']);
	}
}
parse_template('article_list.html');
