<?php
//首页新闻列表生成 {ls_news}  2468  ls-syscode，第二{ls_news} public 产品2,3级页，详细页新闻列表 Start 

	$news = "";
	$nui = 0;
	$hmnewsstyle=$news_cate_rows3['newstype']==0?1:$news_cate_rows3['newstype']; //1 列表， 2 图文， 3 图标题 $news_cate_rows3['hotWords']
	$mysuffStr=trim($news_cate_rows3['suffStr']);
	$suffix_str2 = $mysuffStr==""? $news_cate_rows3['cateName']:$mysuffStr;
	$addhomesuffstr=$homesuffStr? " cate = '".$suffix_str2."' and	":" ";	
	
	$suffix_str2 = $suffix_str2 =="news"?"":$suffix_str2 ; //避免newsnews
	$newshot=$news_cate_rows3['hotLines'];
	$limitnews=($newshot==""||$newshot==NULL)?0:$newshot;
	$news_sql="select * from ls_news where ".$addhomesuffstr." enable=1 order by Num desc limit 0, ".$limitnews." "; 
	$news_query=$opendb->query($news_sql);
	while($news_rows=mysqli_fetch_assoc($news_query)){
		if(strpos($news_rows['newsText'], "<img") !== false){
			$newsImgStr=getStrbyTag("<img ","/>",$news_rows['newsText']);
			
			$imgHeight=getStrbyTag('height="','" ',$newsImgStr,false);
			$imgWidth=getStrbyTag('width="','" ',$newsImgStr,false);
			$newsImg=getStrbyTag('src="','" ',$newsImgStr);
			$newsImg = str_replace('../','',$newsImg);
			$srcImg = getSubstr($newsImg,"src=\"",'"');
			$srcImg = strtolower(getSubstr($newsImg,'src="','"'));  //变小写，清除 src= " 等
			$srcImg = str_replace('src=','',$srcImg);
			$srcImg = str_replace('"','',$srcImg);
			
			$proportion = $imgWidth/$imgHeight;
			
			if($proportion > (191/144)){
				$proportion = "width='".($proportion*144)."' height='144' ";
			}else{
				$proportion = " width='191' height='".(191/$proportion)."' ";
			}
		}else{
			
			$newsImg=" src=\"images/demo.jpg\" width=\"\" height=\"144\" "; 	
		}
		if(strpos(newsImg, "width") === false) $newsImg=$newsImg." width='191' ";

		$hmnewhref=$newsshowFolders."/".strtolower($news_rows['cate']).$suffix_str2.$news_rows['ID'].".html"; //news
		
		switch($hmnewsstyle){
			case 2: //2 默认图文
		
			if($mainpartsubject!="index_m"){
					//$suffix_str2 = $suffix_str2==""? $news_cate_rows3['suffStr']:$suffix_str2;
					if( !$suffStrlist || $suffix_str2 =="news" ){
								
						$news .= "<div class=\"col-lg-6 col-md-6 col-sm-12 col-xs-12 a1\">
<div class=\"bbj\"><div id=\"hyl\"><a href=\"".$hmnewhref."\"><img ".$_SESSION['dda'].$newsImg."  alt=\"".$news_rows['newsTitle']."\" /></a>
							</div>
				<div id=\"hyr\">
					<h4><a href=\"".$hmnewhref."\">".$news_rows['newsTitle']." </a></h4>
							  <p><a href=\"".$hmnewhref."\">".mb_substr(strip_tags($news_rows['newsText']),0,500, 'utf-8')."</a></p>
							</div></div></div>";
					}else{
						$news .= "<div class=\"col-lg-6 col-md-6 col-sm-12 col-xs-12 a1\">
<div class=\"bbj\"><div id=\"hyl\"><a href=\"".$hmnewhref."\"><img src=\"images/demo.jpg\" width=\"191\" height=\"144\" /></a></div>
						<div id=\"hyr\">
					<h4><a href=\"".$hmnewhref."\">".$news_rows['newsTitle']." </a></h4>
						  <p><a href=\"".$hmnewhref."\">".mb_substr(strip_tags($news_rows['newsText']),0,500, 'utf-8')."</a></p>
						</div></div></div>";
					}
				}else{
					$news.="<li><span style='float:right;'>(".$news_rows['newsDate'].")</span><a href=\"".$hmnewhref."\">".$news_rows['newsTitle']." </a>";
					$news.="</li>";
				}
		

			break;
			case 3: //3 图-标题竖排
				  $news .= "<div class=\"col-lg-6 col-md-6 col-sm-12 col-xs-12 a1\">
<div class=\"bbj\"><div id=\"hyl\"><a href=\"".$hmnewhref."\"><img ".$_SESSION['dda'].$newsImg." /></a>
			  <h4><a href=\"".$hmnewhref."\">".$news_rows['newsTitle']." </a></h4>
					  </div></div></div>";
			
			break;
			default: //1 标题列表
			$news.="<li><span style='float:right;'>(".$news_rows['newsDate'].")</span><a href=\"".$hmnewhref."\">".$news_rows['newsTitle']." </a>";
			$news.="</li>";
		}
	}
?>
