<?php
include "inc.php";
include "temp.table.lib.php";
$obj_tab_article=new cls_tab_article();
$arr_article_attribute=$obj_tab_article->get_article_attribute();

switch($get_act){
	case "source":
	{
		header("Cache-Control: no-cache, must-revalidate");
		header('Content-Type:text/html;charset=GBK');

		(isset($get_source))? $str_key=$get_source:$str_key="company";

		$str_content="";
		foreach($arr_source[$str_key] as $item=>$key){
			$str_content.= "<li><a href=\"javascript:textarea_insertstr('id_content','{\$item[\'".$item."\']}');\">".$key."</a></li>";
		}
		$str_content.="|||";
		foreach($arr_source[$str_key."_sort"] as $item=>$key){
			$str_content.="<option value='".$item."'>".$key."</option>";
		}
		echo $str_content;
		break;
	}
	case "folderlist":
	{
		header("Cache-Control: no-cache, must-revalidate");
		header('Content-Type:text/html;charset=GBK');
		$arr_x=array();
		$obj_result = $obj_db->query("SELECT channel_id,channel_name FROM ".DB_PRE."article_channel");
		while($obj_rs = $obj_db->fetch_array($obj_result)){
			echo "<li>".$obj_rs["channel_name"]."</li>".me_folder_next($obj_rs["channel_id"]);
		}
		break;
	}
	case "exe":
	{
		$str_table_name=$get_table_name;


		$str_order=$get_field_sort;


		$str_order_act=$get_fields_sort_act;
		if(!in_array($str_order_act,array("asc","desc"))) $str_order_act="desc";

		if($str_order_act!="") $str_order_act=" ".$str_order_act;

		$str_orderstr="";
		if($str_order!="") $str_orderstr=" order by ".$str_order.$str_order_act;

		if($get_field_limit=="0"){
			(isset($get_limit_0))? $get_limit_0=intval($get_limit_0):$get_limit_0=10;
			$str_limit="limit 0,".intval($get_limit_0);
			$lng_limit1=0;
			$lng_limit2=$get_limit_0;
		}else{
			(isset($get_limit_1))? $get_limit_1=intval($get_limit_1):$get_limit_1=0;
			(isset($get_limit_2))? $get_limit_2=intval($get_limit_2):$get_limit_2=10;
			$str_limit=" limit ".$get_limit_1.",".$get_limit_2;
			$lng_limit1=$get_limit_1;
			$lng_limit2=$get_limit_2;
		}
		switch($str_table_name){
			case "hr_company":
			{
				echo '{get_temp_company(\''.$str_table_name.'\','.$lng_limit1.','.$lng_limit2.',\''.$str_orderstr.'\')}';
				break;
			}
			case "hr_job":
			{
				echo '{get_temp_job(\''.$str_table_name.'\','.$lng_limit1.','.$lng_limit2.',\''.$str_orderstr.'\')}';
				break;
			}
			case "hr_resume":
			{
				echo '{get_temp_resume(\''.$str_table_name.'\','.$lng_limit1.','.$lng_limit2.',\''.$str_orderstr.'\')}';
				break;
			}
			case "company_job":
			{
				echo '{get_temp_company_job(\''.$str_table_name.'\','.$lng_limit1.','.$lng_limit2.',\''.$str_orderstr.'\')}';
				break;
			}
			case "article":
			{
				$str_folderids="";
				if(isset($get_folderlist)&&is_array($get_folderlist)){
					$str_folderids=implode(",",$get_folderlist);
				}
				$str_attribute="";
				if(isset($get_attribute_val)){
					$str_attribute=implode("|",$get_attribute_val);
				}
				echo '{get_temp_article(\''.$str_table_name.'\',\''.$str_folderids.'\','.$lng_limit1.','.$lng_limit2.',\''.$str_orderstr.'\',\''.$str_attribute.'\')}';
				break;
			}
		}
		echo chr(10).'{foreach($sql_return[\''.$str_table_name.'\'] as $item)}'.chr(10);
		echo format_request($get_content,true).chr(10);
		echo '{/foreach}';
		break;
	}
	default:
		include "tpl/temp.tpl.php";
}

function me_folder_next($msg_channelid,$msg_pid=0,$msg_lng=1)
{
	global $obj_tab_folder,$obj_db;
	$str_sql="select folder_id,folder_name,folder_pid from ".DB_PRE."article_folder where folder_pid=".$msg_pid." and folder_channel_id=".$msg_channelid;
	$obj_result = $obj_db->query($str_sql);
	$str_left="<li class='x_".$msg_lng."'>";
	$str_val="";
	while($obj_rs = $obj_db->fetch_array($obj_result))
	{
		$str_val.="<input type='checkbox' name='folderlist[]' value='".$obj_rs["folder_id"]."'>".$obj_rs["folder_name"];
		$str_x=me_folder_next($msg_channelid,$obj_rs['folder_id'],$msg_lng+1);
		if($str_x!=""){
			$str_val.="</li>".$str_x."<li class='x_".$msg_lng."'>";
		}
	}
	if($str_val!="") $str_val=$str_left.$str_val."</li>";
	return $str_val;
}

?>