<?php
function tpl_modifier_qishi_categoryname($string)
{
		global $db;
		$val=explode(",",$string);
		$type=trim($val[0]);
		if ($type=="QS_jobs")
		{
			$return_value = array();
			for ($i=1; $i < strlen($val); $i++) { 
				$category_arr = explode(".", $val[$i]);
				if($category_arr[2]!=0){
					$cat=$db->getone("select categoryname from ".table('category_jobs')." WHERE  id='{$category_arr[2]}' LIMIT  1");
				}elseif($category_arr[1]!=0){
					$cat=$db->getone("select categoryname from ".table('category_jobs')." WHERE  id='{$category_arr[1]}' LIMIT  1");
				}else{
					$cat=$db->getone("select categoryname from ".table('category_jobs')." WHERE  id='{$category_arr[0]}' LIMIT  1");
				}
				if($cat){
					$return_value[$i]=$cat['categoryname'];
				}
			}
			$return_value = !empty($return_value)?implode("|", $return_value):"";
			return $return_value;
		}
		elseif ($type=="QS_district")
		{
			$return_value = array();
			for ($i=1; $i < strlen($val); $i++) { 
				$category_arr = explode(".", $val[$i]);
				if($category_arr[1]!=0){
					$cat=$db->getone("select categoryname from ".table('category_district')." WHERE  id='{$category_arr[1]}' LIMIT  1");
				}else{
					$cat=$db->getone("select categoryname from ".table('category_district')." WHERE  id='{$category_arr[0]}' LIMIT  1");
				}
				if($cat){
					$return_value[$i]=$cat['categoryname'];
				}
			}
			$return_value = !empty($return_value)?implode("|", $return_value):"";
			return $return_value;
		}
		elseif ($type=="QS_trade")
		{
			$return_value = array();
			for ($i=1; $i < strlen($val); $i++) { 
				$cat=$db->getone("select c_name from ".table('category')." WHERE  c_id='".$val[$i]."' LIMIT  1");
				if($cat){
					$return_value[$i]=$cat['c_name'];
				}
			}
			$return_value = !empty($return_value)?implode("|", $return_value):"";
			return $return_value;
		}
		else
		{
			$_CAT=get_cache('category');
			return $_CAT[$type][$val[1]]['categoryname'];
		}		 
}
?>