mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Added new e_related.php files to news and page
This commit is contained in:
parent
375d1899ef
commit
064e461fc2
@ -2241,6 +2241,8 @@ class e_form
|
||||
$tp = e107::getParser();
|
||||
|
||||
$types = explode(',',$type);
|
||||
$list = array();
|
||||
|
||||
|
||||
foreach($types as $plug)
|
||||
{
|
||||
|
55
e107_plugins/news/e_related.php
Normal file
55
e107_plugins/news/e_related.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?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'];
|
||||
|
||||
if($sql->gen($query))
|
||||
{
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
$items[] = array(
|
||||
'title' => $row['news_title'],
|
||||
'url' => e107::getUrl()->create('news/view/item',$row), // '{e_BASE}news.php?extend.'.$row['news_id'],
|
||||
'body' => $row['news_summary'],
|
||||
'image' => $row['news_image']
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
elseif(ADMIN)
|
||||
{
|
||||
return array(array('title'=>$query,'url'=>''));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
88
e107_plugins/page/e_related.php
Normal file
88
e107_plugins/page/e_related.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?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 page_related // replace 'e_' with 'plugin-folder_'
|
||||
{
|
||||
private $chapterSef = array();
|
||||
private $chapterParent = array();
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
|
||||
$books = $sql->retrieve("SELECT chapter_id,chapter_sef,chapter_parent FROM #page_chapters ORDER BY chapter_id ASC" , true);
|
||||
|
||||
foreach($books as $row)
|
||||
{
|
||||
$id = $row['chapter_id'];
|
||||
$this->chapterSef[$id] = $row['chapter_sef'];
|
||||
$this->chapterParent[$id] = $row['chapter_parent'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getSef($chapter)
|
||||
{
|
||||
return vartrue($this->chapterSef[$chapter],'--sef-not-assigned--');
|
||||
}
|
||||
|
||||
private function getParent($chapter)
|
||||
{
|
||||
return varset($this->chapterParent[$chapter], false);
|
||||
}
|
||||
|
||||
|
||||
function compile($tags,$parm=array())
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$items = array();
|
||||
|
||||
|
||||
$tag_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'";
|
||||
|
||||
$query = "SELECT * FROM #page WHERE page_id != ".$parm['current']." AND page_class REGEXP '".e_CLASS_REGEXP."' AND page_metakeys REGEXP ".$tag_regexp." ORDER BY page_datestamp DESC LIMIT ".$parm['limit'];
|
||||
|
||||
if($sql->gen($query))
|
||||
{
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
$row['chapter_sef'] = $this->getSef($row['page_chapter']);
|
||||
$book = $this->getParent($row['page_chapter']);
|
||||
$row['book_sef'] = $this->getSef($book);
|
||||
|
||||
|
||||
$items[] = array(
|
||||
'title' => $row['page_title'],
|
||||
'url' => e107::getUrl()->create('page/view/index',$row), // '{e_BASE}news.php?extend.'.$row['news_id'],
|
||||
'body' => $row['news_summary'],
|
||||
'image' => $row['news_image']
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(array('title'=>$query,'url'=>''));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user