-
Notifications
You must be signed in to change notification settings - Fork 0
/
e_related.php
64 lines (46 loc) · 1.68 KB
/
e_related.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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).")(,|$)'";
// $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'];
if($sql->gen($query))
{
while($row = $sql->fetch())
{
$thumbs = !empty($row['news_thumbnail']) ? explode(",",$row['news_thumbnail']) : array();
$items[] = array(
'title' => varset($row['news_title']),
'url' => e107::url('news','item',$row), // '{e_BASE}news.php?extend.'.$row['news_id'],
'summary' => varset($row['news_summary']),
'image' => varset($thumbs[0]),
'date' => e107::getParser()->toDate(varset($row['news_datestamp']), 'short'),
);
}
return $items;
}
//elseif(ADMIN)
//{
// return array(array('title'=>$query,'url'=>''));
//}
}
}