<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty {textformat}{/textformat} block plugin
 *
 * Type:     block function<br>
 * Name:     textformat<br>
 * Purpose:  format text a certain way with preset styles
 *           or custom wrap/indent settings<br>
 * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
 *       (Smarty online manual)
 * @param array
 * <pre>
 * Params:   style: string (email)
 *           indent: integer (0)
 *           wrap: integer (80)
 *           wrap_char string ("\n")
 *           indent_char: string (" ")
 *           wrap_boundary: boolean (true)
 * </pre>
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param string contents of the block
 * @param Smarty clever simulation of a method
 * @return string string $content re-formatted
 */
function smarty_block_thislist($params, $content, &$smarty)
{
    if (is_null($content)) {
        return;
    }

 extract($params); 
 $inid = isset($params['inid']) ? $params['inid'] : '';
 $num = isset($params['innum']) ? $params['innum'] : 20;
 $order = isset($params['inorder']) ? $params['inorder'] : 'lm_id';
 $id = isset($_GET['lm_nmid']) ? cinput($_GET['lm_nmid']) : cinput($inid);
 $i = 0;
	$lsql = "select * from limao_nm where lm_nmid=".$id;
	$lrs = mysql_query($lsql) or die('传入的参数错误');
	while($ldata=mysql_fetch_object($lrs)){
	$lm_type = $ldata->lm_id;
  switch($ldata->lm_error){
  case 1:
  $mytable = "limao_article";
  $lm_nmid = $ldata->lm_nmid;
  $outtable = 'show_article.php';  	
  break;
   case 2:
  $mytable = "limao_shop";
  $lm_nmid = $ldata->lm_nmid;
  $outtable = 'show_shop.php';
  break;
  	}

  
	$msql = "select * from $mytable where lm_type=".cinput($lm_type)." order by $order desc";
	$mrs = mysql_query($msql) or die('执行数据查询时出现错误');
if($mrs){
	$cols = mysql_num_fields($mrs)-1;
	$str = '';
	while($rows=mysql_fetch_array($mrs)){
	  if($i<=$num-1){ 		
			$tmp = $content;
	 for($m=0;$m<=$cols;$m++){
	$fieldname = mysql_field_name($mrs,$m);
	$tmp = str_replace("[\$field.".$fieldname."]",mb_substr(rinput($rows[$m]),0,200,'utf-8'),$tmp);
	$tmp = str_replace("[\$field.tourl]",$outtable."?id=".rinput($rows[0])."&lm_nmid=".rinput($lm_nmid),$tmp);
	$tmp = str_replace("[\$field.toimg]",rinput(webupimgurl).rinput($rows['lm_img']),$tmp);	
}
 $str .= $tmp;
 $i++;
}
}
$str2 .= $str;
}else{
return 'NO Data';
	}


}
return $str2;
}

/* vim: set expandtab: */

?>
