<?php
//_home_article.php首页文章列表生成 {ls_homeartile} 192  _inc_allrepltags.php。图片需要有高、宽属性

	$hmnewsstyle=3; //1 列表， 2 图文， 3 图标题 
	$homefunc="application case";
	$homearfolder=getarfolder($homefunc);
	$hotlines=8;
	$ls_homeartile = "";
	$nui = 0;
	$addstrar="";
	if($val!="") $addstrar=" and functionName='".$val."' "; //类别热点文章
	$homear_sql="select * from ls_article where flag=1 and enable=1 ".$addstrar." order by Num desc limit 0, ".$hotlines." "; 
	$homear_query=$opendb->query($homear_sql);
	$catenum = mysqli_num_rows($homear_query);
	if($catenum ==0 && $val!="" ){ //大类没有，找中类
		$addstrar=" and cateName='".$val."' ";
		$homear_sql="select * from ls_article where flag=1 and enable=1 ".$addstrar." order by Num desc limit 0, ".$hotlines." "; 
		$homear_query=$opendb->query($homear_sql);
	}
		
	while($homear_rows=mysqli_fetch_assoc($homear_query)){
		$headerurl=$homear_rows['headerurl'];
		$homearfolder=getarfolder($homefunc,$homear_rows['cateName']); //获得某一个分类的案例
		$hmarhref=$homearfolder."/".$ars_show.$homear_rows['ID'].".html";
		$hmarhref=$headerurl==""?$hmarhref:$headerurl;	//headerurl优先显示
		if(strpos($homear_rows['articleText'], "<img") !== false){
			$newsImgStr=getStrbyTag("<img ","/>",$homear_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"){
					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='".$hmarhref."'><img ".$_SESSION['dda'].$newsImg." /></a>
							</div>
				<div id='hyr'>
					<h4><a href='".$hmarhref."'>".$homear_rows['articleTitle']." </a></h4>
							 <p><a href='".$hmarhref."'>".str_replace("-brbr-","<br/>",mb_substr(strip_tags(str_replace("<br/>","-brbr-",str_replace("<br />","<br/>",$homear_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='".$hmarhref."'><img src='images/demo.jpg' width='191' height='144' /></a></div>
						<div id='hyr'>
					<h4><a href='".$hmarhref."'>".$homear_rows['articleTitle']." </a></h4>
						  <p><a href='".$hmarhref."'>".str_replace("-brbr-","<br/>",mb_substr(strip_tags(str_replace("<br/>","-brbr-",str_replace("<br />","<br/>",$homear_rows['articleText']))),0,500, 'utf-8'))."</a></p>
						</div></div></div>";
					}
				}else{
					$ls_homeartile.="<li><span style='float:right;'>(".$homear_rows['articleDate'].")</span><a href='".$hmarhref."'>".$homear_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='".$hmarhref."'><img ".$_SESSION['dda'].$newsImg." /></a></div>
			  <h4><a href='".$hmarhref."'>".$homear_rows['articleTitle']." </a></h4>
					  </div></div>";
			break;
			default: //1 标题列表
			$ls_homeartile.="<li><span style='float:right;'>(".$homear_rows['articleDate'].")</span><a href='".$hmarhref."'>".$homear_rows['articleTitle']." </a>";
			$ls_homeartile.="</li>";
		}
	}
/* 图偏转
<li class="feature_item swiper-slide" style="width: 296.5px; margin-right: 60px;">
  <figure> <span class="item_img"><img src="images/1601.jpg" alt="Macleaya Cordata ..."></span>
	<h4 class="pd_tit"><a href="https://c140.goodao.net/macleaya-cordata-extract-sanguinarine-chelerythrine-product/">Macleaya Cordata Extract, S...</a></h4></figure></li>
*/
?>
