<?php
$obj_tab_article=new cls_tab_article();
if(!isset($get_pid)) $get_pid=164;
(isset($get_fid))?$get_fid=intval($get_fid):$get_fid=$get_pid;
(isset($get_page))?$get_page=intval($get_page):$get_page=1;
//目录列表
$lng_channel_id=0;
$this_folder_list=array();
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."article_folder where folder_pid='".$get_pid."'");
while($obj_rs = $obj_db->fetch_array($obj_result)){
	if($lng_channel_id==0) $lng_channel_id=$obj_rs["folder_channel_id"];
	$this_folder_list[]=$obj_rs;
}
//获取频道设置
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."article_channel where channel_id='".$lng_channel_id."'");
if($obj_rs = $obj_db->fetch_array($obj_result)){
	$this_channel=$obj_rs;
	$arr_app=$obj_tab_article->get_app($this_channel["channel_article_tpl"],$this_channel["channel_htmldir"]);
}


$arr_list=array();
$int_pagesize=20;
$str_where=" where concat(',',b.folder_pids,',') like '%,".$get_fid.",%'";
$obj_rs  = $obj_db->get_one("SELECT count(*) as num FROM ".DB_PRE."article a inner join ".DB_PRE."article_folder b on a.article_folder_id=b.folder_id".$str_where);
$int_total=$obj_rs["num"];
$int_pages= ceil($int_total/$int_pagesize);
$get_page = min($int_pages, $get_page);
$get_page = max($get_page, 1);
$page_split_page=get_pages_html($int_total, $get_page, $int_pagesize,"?app=".$get_app."&fid=".$get_fid."&pid=".$get_pid);
$int_offset = $int_pagesize*($get_page-1);
$str_limit = " limit ".$int_offset.",".$int_pagesize;
$obj_result = $obj_db->query("SELECT a.* FROM ".DB_PRE."article a inner join ".DB_PRE."article_folder b on a.article_folder_id=b.folder_id".$str_where." order by article_addtime desc".$str_limit);
while($obj_rs = $obj_db->fetch_array($obj_result)){
	if($this_channel["channel_savehtml"]==1){
		$str_url=WEB_URL.$arr_app["htmldir"]."/".$obj_rs["article_id"].".html";
	}else{
		$str_url=WEB_URL."/index.php?app=".$arr_app["app"]."&apppath=".$arr_app["path"]."&id=".$obj_rs["article_id"];
	}
	if($obj_rs["article_islink"]==1 && !empty($obj_rs["article_linkurl"])){
		$str_url=$obj_rs["article_linkurl"];
	}
	$obj_rs["url"]=$str_url;
	$arr_list[]=$obj_rs;
}
$this_folder_title="";
$this_folder_path="<a href=\"".WEB_URL."\">首页</a>";
$this_folder_path.=me_folder_path($get_fid);
function me_folder_path($msg_folderid,$msg_rootid=0)
{
	global $obj_tab_folder,$obj_db,$this_folder_title,$get_pid;
	$str_sql="select folder_id,folder_name,folder_pid from ".DB_PRE."article_folder where folder_id='".$msg_folderid."'";
	$obj_result = $obj_db->query($str_sql);
	$str_val="";
	if($obj_rs = $obj_db->fetch_array($obj_result))
	{
		if($this_folder_title=="") $this_folder_title=$obj_rs["folder_name"];
		$str_val=" -> <a href=\"?app=article_list&fid=".$obj_rs['folder_id']."&pid=".$get_pid."\">".$obj_rs['folder_name']."</a>";
		$str_val=me_folder_path($obj_rs['folder_pid'],$msg_rootid).$str_val;
	}
	return $str_val;
}
?>