Location: PHPKode > projects > News Manager - RSS aggregator > newsmanager/category_items.php
<?php
/*******************************************************************************
 **  File          :  category_items.php                                      **
 **  Author        :  G.Ramkumar                                              **
 **  Description   :  Dispalying spotlight news 						      **
 **  Date          :  14/09/2005                                              **
 **  Last Modified :  14/09/2005                                              **
 **  PHP Version   :  5.0.3                                                   **
 **                                                                           **
 *******************************************************************************/
if($_REQUEST['cat_id']!="")
{
   $cat_name="select * from category where category_id='".$_REQUEST['cat_id']."'";
   $cat_res=$pg_sql->query_pass($cat_name,"4");
   $category_name=$cat_res[0]['category_name'];

	if($_REQUEST['cat_id']!="" && $_REQUEST['subcat_id']=="")
	{
	  $id="a.category_id=".$_REQUEST['cat_id'];
    }else{
      $id="a.subcategory_id=".$_REQUEST['subcat_id'];
    }

  $cat_item_qry="select * from newsitem_category a,rssurl_newsitem b where $id and a.newsitem_id=b.url_newsitem_id and b.frontend_export='Y' and b.language='$lang' order by b.url_newsitem_id desc ";
  $cat_item_res=$pg_sql->query_pass($cat_item_qry,"4");
  $cat_cnt=count($cat_item_res);
  $flagres=0;
  for($t=0;$t<$cat_cnt;$t++)
  {
		$T_xmlid .=$cat_item_res[$t]['url_newsitem_id'].",";
  }
  if($cat_cnt>0)
  {
  ?>

 <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" class="border">
  <?  for($i=0;$i<$cat_cnt;$i++)
      {
		$id=$cat_item_res[$i]['url_newsitem_id'];
  		$desc=html_entity_decode($cat_item_res[$i]['description']);
  		$rep_desc=$desc;
		$rep_desc=str_replace("é","é",$rep_desc);
		$rep_desc=str_replace("’","’",$rep_desc);
		$rep_desc=str_replace("è","è",$rep_desc);
		$rep_desc=str_replace("Ã","à",$rep_desc);
		$rep_desc=str_replace("àª","ê",$rep_desc);
		$rep_desc=str_replace("‘","‘",$rep_desc);
		$rep_desc=str_replace("à»",û,$rep_desc);
    	$desc=$rep_desc;


  		$hour=str_replace(":","h",$cat_item_res[$i]['hour']);
  		$date=$cat_item_res[$i]['pubdate'];

        $yesterday = strftime ("%e/%m/%Y", strtotime("-1 day"));

        $yday=explode("/",$yesterday);
        if(substr($yday[1],0,1)==0)
          $yday[1]=str_replace("0","",$yday[1]);
        else
          $yday[1]=$yday[1];


        $yesterday=trim($yday[0])."/".$yday[1]."/".$yday[2];
        $today=date('j/n/Y');

  		if($date==$today)
		  $pubdate="Today";
		elseif($date == $yesterday)
		  $pubdate="Yesterday";
		else
		 $pubdate=$date;



  		$desc=str_replace("||","'",$desc);
  		if(strlen($desc)>150)
  			 $desc=substr($desc,0,100)."....";
  		else
  		   $desc=$desc;

  		if($_REQUEST['cat_id']==123 && $_REQUEST['subcat_id']=="")
  		   $flag=1;
		else
		   $flag=0;

        $title=str_replace("||","",$cat_item_res[$i]['news_title']);
	    $rep_title=$title;
		$rep_title=str_replace("é","é",$rep_title);
		$rep_title=str_replace("’","’",$rep_title);
		$rep_title=str_replace("è","è",$rep_title);
		$rep_title=str_replace("Ã","à",$rep_title);
		$rep_title=str_replace("àª","ê",$rep_title);
		$rep_title=str_replace("‘","‘",$rep_title);
		$rep_title=str_replace("à»",û,$rep_title);
    	$title=$rep_title;

?>
        <?if($flag==1 && $flagres!=1){?>
          <tr >
		    <td bgcolor="D0D0D0" class="heading" colspan="1" height="20"><?=$spotlight_?></td>
		    <td align="right" valign="middle" bgcolor="D0D0D0" colspan="1" class="heading"><a target="_new" href="http://www.belgium.be/eportal/rss2.xml?language=en-be&feed=archive"><img border="0" src="images/xml.jpg" width="43" height="15" alt="Link to RSS Feed"></a>&nbsp;</td>
          </tr>
       <?}
         if($flag==0 && $flagres==0){?>
          <tr >
	   		    <td bgcolor="D0D0D0" class="heading" colspan="1" height="20"><?=$spotlight_?></td>
	   		    <td align="right" bgcolor="D0D0D0" valign="middle" colspan="1" class="heading"><a target="_new" href="xml.php?id=<?=base64_encode(trim($T_xmlid,","))?>"><img border="0" src="images/xml.jpg" width="43" height="15" alt="Link to RSS Feed"></a>&nbsp;</td>
          </tr>
       <?}?>
		<tr>
    		<td valign="top" colspan="2"><a class="contblue" href="<?=$cat_item_res[$i]['url']?>" target="_blank"><?=$title?></a></td>
        </tr>
        <tr>
          <td class="cont1" valign="top"><?=$desc?><br>
           <font class="contgrey"><?=$pubdate."&nbsp;&nbsp;".$hour." - ".$category_name?></font>
   		  </td>
   		<?if($cat_item_res[$i]['image']!=""){?>
   		  <td valign="middle" align="center" width="25%"><a href="<?=$cat_item_res[$i]['url']?>" target="_blank"><img src="<?=$cat_item_res[$i]['image']?>"  hspace="10" width="80" height="60" border="0" ></a></td>
  	   	<?}?>
  		</tr>
  	<?

	  $flagres=1;

    }//For Loop closing


  }//if Loop closing
  else{
  ?>
   <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
 		<tr>
 			<td valign="top"><?include('allnews.php')?></td>
 		</tr>
  <?}?>
<tr><td colspan="2">&nbsp;</td></tr>

</table>
<?
}//if($_req[cat_id]) Loop closing

?>
Return current item: News Manager - RSS aggregator