<?php
//首页文章列表生成 {ls_homeartile} 192  _inc_allrepltags.php

	$hmnewsstyle=3; //1 列表， 2 图文， 3 图标题 $news_cate_rows3['hotWords']
	$homefunc="application case";
	$folder=getarfolder($homefunc);
	$hotlines=8;
	$ls_homeartile = "";
	$nui = 0;
	$news_sql="select * from ls_article where functionName = '".$homefunc."' and enable=1  and flag=1 order by Num desc limit 0, ".$hotlines." "; 
	$news_query=$opendb->query($news_sql);
	while($news_rows=mysqli_fetch_assoc($news_query)){
		if(strpos($news_rows['articleText'], "<img") !== false){
			$newsImgStr=getStrbyTag("<img ","/>",$news_rows['articleText']);
			
			$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\" "; 	
		}

		
		switch($hmnewsstyle){
			case 2: //2 默认图文
		
			if($mainpartsubject!="index_m"){
					$ars_show = $ars_show==""? $news_cate_rows3['suffStr']:$ars_show;
					if( 1 ){
								
						$ls_homeartile .= "<div class=\"col-lg-3 col-md-3 col-sm-3 col-xs-6 a1\">
<div class=\"bbj\"><div id=\"hyl\"><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\"><img ".$newsImg." /></a>
							</div>
				<div id=\"hyr\">
					<h4><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".$news_rows['articleTitle']." </a></h4>
							  <p><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".mb_substr(strip_tags($news_rows['articleText']),0,500, 'utf-8')."</a></p>
							</div></div></div>";
					}else{
						$ls_homeartile .= "<div class=\"col-lg-3 col-md-3 col-sm-3 col-xs-6 a1\">
<div class=\"bbj\"><div id=\"hyl\"><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\"><img src=\"images/demo.jpg\" width=\"191\" height=\"144\" /></a></div>
						<div id=\"hyr\">
					<h4><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".$news_rows['articleTitle']." </a></h4>
						  <p><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".mb_substr(strip_tags($news_rows['articleText']),0,500, 'utf-8')."</a></p>
						</div></div></div>";
					}
				}else{
					$ls_homeartile.="<li><span style='float:right;'>(".$news_rows['articleDate'].")</span><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".$news_rows['articleTitle']." </a>";
					$ls_homeartile.="</li>";
				}
		

			break;
			case 3: //3 图-标题竖排
				  $ls_homeartile .= "<div class=\"col-lg-3 col-md-3 col-sm-3 col-xs-6 a1\">
<div class=\"bbj\" id=\"yingyong\"><div id=\"hyarticle\"><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\"><img ".$newsImg." /></a></div>
			  <p><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".$news_rows['articleTitle']." </a></p>
					  </div></div>";
			
			break;
			default: //1 标题列表
			$ls_homeartile.="<li><span style='float:right;'>(".$news_rows['articleDate'].")</span><a href=\"".$folder."/".$ars_show.$news_rows['ID'].".html\">".$news_rows['articleTitle']." </a>";
			$ls_homeartile.="</li>";
		}
		
	}
?>
