2014-01-22 07:40:01 -08:00
< ? php
/*
* e107 website system
*
* Copyright ( C ) 2008 - 2014 e107 Inc ( e107 . org )
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
* Related configuration module - News
*
*
*/
if ( ! defined ( 'e107_INIT' )) { exit ; }
class news_related // include plugin-folder in the name.
{
function compile ( $tags , $parm = array ())
{
$sql = e107 :: getDb ();
$items = array ();
$tag_regexp = " '(^|,)( " . str_replace ( " , " , " | " , $tags ) . " )(,| $ )' " ;
2021-01-22 17:33:29 -08:00
// $query = "SELECT * FROM #news WHERE news_id != ".$parm['current']." AND news_class REGEXP '".e_CLASS_REGEXP."' AND news_meta_keywords REGEXP ".$tag_regexp." ORDER BY news_datestamp DESC LIMIT ".$parm['limit'];
$query = " SELECT n.*, nc.category_id, nc.category_name, nc.category_sef
FROM #news AS n
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
WHERE n . news_id != " . $parm['current'] . " AND n . news_class REGEXP '".e_CLASS_REGEXP."' AND n . news_meta_keywords REGEXP " . $tag_regexp . " ORDER BY n . news_datestamp DESC LIMIT " . $parm['limit'] ;
2014-01-22 07:40:01 -08:00
if ( $sql -> gen ( $query ))
{
while ( $row = $sql -> fetch ())
{
2016-03-10 17:32:36 -08:00
$thumbs = ! empty ( $row [ 'news_thumbnail' ]) ? explode ( " , " , $row [ 'news_thumbnail' ]) : array ();
2014-01-22 07:40:01 -08:00
$items [] = array (
2014-02-04 06:58:13 -08:00
'title' => varset ( $row [ 'news_title' ]),
2014-01-22 07:40:01 -08:00
'url' => e107 :: getUrl () -> create ( 'news/view/item' , $row ), // '{e_BASE}news.php?extend.'.$row['news_id'],
2016-03-10 17:32:36 -08:00
'summary' => varset ( $row [ 'news_summary' ]),
2021-01-06 11:54:51 -08:00
'image' => varset ( $thumbs [ 0 ]),
2019-05-09 11:00:42 +02:00
'date' => e107 :: getParser () -> toDate ( varset ( $row [ 'news_datestamp' ]), 'short' ),
2014-01-22 07:40:01 -08:00
);
}
return $items ;
}
2020-12-18 19:55:12 -08:00
//elseif(ADMIN)
//{
2014-01-22 07:51:38 -08:00
// return array(array('title'=>$query,'url'=>''));
2020-12-18 19:55:12 -08:00
//}
2014-01-22 07:40:01 -08:00
}
}
2019-05-09 15:41:57 -07:00