mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
RSS News feeds upgraded and corrected.
This commit is contained in:
@@ -144,7 +144,7 @@ function show_admins()
|
|||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
while ($row = $sql->db_Fetch())
|
while ($row = $sql->fetch())
|
||||||
{
|
{
|
||||||
//$permtxt = "";
|
//$permtxt = "";
|
||||||
$text .= "
|
$text .= "
|
||||||
@@ -196,6 +196,8 @@ require_once("footer.php");
|
|||||||
*/
|
*/
|
||||||
function headerjs()
|
function headerjs()
|
||||||
{
|
{
|
||||||
|
return '';
|
||||||
|
/*
|
||||||
require_once(e_HANDLER.'js_helper.php');
|
require_once(e_HANDLER.'js_helper.php');
|
||||||
$ret = "
|
$ret = "
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
@@ -205,6 +207,6 @@ function headerjs()
|
|||||||
<script type='text/javascript' src='".e_JS."core/admin.js'></script>
|
<script type='text/javascript' src='".e_JS."core/admin.js'></script>
|
||||||
";
|
";
|
||||||
|
|
||||||
return $ret;
|
return $ret;*/
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@@ -2961,9 +2961,92 @@ class e_parser
|
|||||||
|
|
||||||
|
|
||||||
return "<img class='icon' src='".$path."' alt='".basename($path)."' />";
|
return "<img class='icon' src='".$path."' alt='".basename($path)."' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $file
|
||||||
|
* @param array $parm legacy|w|h
|
||||||
|
* @return string
|
||||||
|
* @example $tp->toImage('welcome.png', array('legacy'=>{e_IMAGE}newspost_images/','w'=>200));
|
||||||
|
*/
|
||||||
|
public function toImage($file, $parm=array())
|
||||||
|
{
|
||||||
|
|
||||||
|
if(!vartrue($file))
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = trim($file);
|
||||||
|
|
||||||
|
$ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if($ext != 'jpg' && $ext !='gif' && $ext != 'png') // Bootstrap or Font-Awesome.
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
if(!empty($parm['w']))
|
||||||
|
{
|
||||||
|
$tp->setThumbSize($parm['w']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($parm['h']))
|
||||||
|
{
|
||||||
|
$tp->setThumbSize(null, $parm['h']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(strpos($file,'e_MEDIA')!==false || strpos($file,'e_THEME')!==false) //v2.x path.
|
||||||
|
{
|
||||||
|
$path = $tp->thumbUrl($file,null,null,true);
|
||||||
|
}
|
||||||
|
elseif($file[0] == '{') // Legacy v1.x path. Example: {e_WHEREEVER}
|
||||||
|
{
|
||||||
|
$path = $tp->replaceConstants($file,'full');
|
||||||
|
}
|
||||||
|
elseif(!empty($parm['legacy'])) // Search legacy path for image.
|
||||||
|
{
|
||||||
|
|
||||||
|
$legacyPath = $parm['legacy'].$file;
|
||||||
|
$filePath = $tp->replaceConstants($legacyPath,'rel');
|
||||||
|
|
||||||
|
if(is_readable($filePath))
|
||||||
|
{
|
||||||
|
$path = $tp->replaceConstants($legacyPath,'full');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$log = e107::getAdminLog();
|
||||||
|
$log->addDebug('Broken Icon Path: '.$legacyPath."\n".print_r(debug_backtrace(null,2), true), false)->save('IMALAN_00');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else // usually http://....
|
||||||
|
{
|
||||||
|
$path = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(empty($style))
|
||||||
|
{
|
||||||
|
$insertStyle = '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$insertStyle = "style='";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$alt = (!empty($parm['alt'])) ? $tp->toAttribute($parm['alt']) : basename($path);
|
||||||
|
|
||||||
|
return "<img class='img-responsive' src='".$path."' alt=\"".$alt."\" {$insertStyle} />";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a file is an video or not.
|
* Check if a file is an video or not.
|
||||||
@@ -2978,6 +3061,18 @@ class e_parser
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a file is an image or not.
|
||||||
|
* @param $file string
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function isImage($file)
|
||||||
|
{
|
||||||
|
$ext = pathinfo($file,PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
return ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg') ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a Video file.
|
* Display a Video file.
|
||||||
@@ -3070,7 +3165,7 @@ class e_parser
|
|||||||
return '
|
return '
|
||||||
<div class="video-responsive">
|
<div class="video-responsive">
|
||||||
<video width="320" height="240" controls>
|
<video width="320" height="240" controls>
|
||||||
<source src="movie.mp4" type="video/mp4">
|
<source src="'.$file.'" type="video/mp4">
|
||||||
|
|
||||||
Your browser does not support the video tag.
|
Your browser does not support the video tag.
|
||||||
</video>
|
</video>
|
||||||
|
359
e107_plugins/news/e_rss.php
Normal file
359
e107_plugins/news/e_rss.php
Normal file
@@ -0,0 +1,359 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
|
*
|
||||||
|
* RSS chatbox feed addon
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
// v2.x Standard
|
||||||
|
class news_rss // plugin-folder + '_rss'
|
||||||
|
{
|
||||||
|
|
||||||
|
private $showImages =false;
|
||||||
|
private $summaryDescription = false;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Admin RSS Configuration
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function config()
|
||||||
|
{
|
||||||
|
$config = array();
|
||||||
|
|
||||||
|
$config[] = array(
|
||||||
|
'name' => ADLAN_0,
|
||||||
|
'url' => 'news', // The identifier and plugin-path location for the rss feed url
|
||||||
|
'topic_id' => '', // The topic_id, empty on default (to select a certain category)
|
||||||
|
'description' => RSS_PLUGIN_LAN_7, // that's 'description' not 'text'
|
||||||
|
'class' => '0',
|
||||||
|
'limit' => '9'
|
||||||
|
);
|
||||||
|
|
||||||
|
// News categories
|
||||||
|
$sqli = e107::getDb();
|
||||||
|
if($sqli ->select("news_category", "*","category_id!='' ORDER BY category_name "))
|
||||||
|
{
|
||||||
|
while($rowi = $sqli ->fetch())
|
||||||
|
{
|
||||||
|
|
||||||
|
$config[] = array(
|
||||||
|
'name' => ADLAN_0.' > '.$rowi['category_name'],
|
||||||
|
'url' => 'news',
|
||||||
|
'topic_id' => $rowi['category_id'],
|
||||||
|
'description' => RSS_PLUGIN_LAN_10.' '.$rowi['category_name'], // that's 'description' not 'text'
|
||||||
|
'class' => '0',
|
||||||
|
'limit' => '9'
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the Feed Data
|
||||||
|
* @param string $parms
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function data($parms='')
|
||||||
|
{
|
||||||
|
|
||||||
|
$pref = e107::getConfig()->getPref();
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
$this->showImages = vartrue($pref['rss_shownewsimage'],false);
|
||||||
|
$this->summaryDescription = vartrue($pref['rss_summarydiz'],false);
|
||||||
|
|
||||||
|
$render = ($pref['rss_othernews'] != 1) ? "AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))" : "";
|
||||||
|
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
||||||
|
$topic = (!empty($parms['id']) && is_numeric($parms['id'])) ? " AND news_category = ".intval($parms['id']) : '';
|
||||||
|
$limit = vartrue($parms['limit'],10);
|
||||||
|
|
||||||
|
$rssQuery = "SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
|
||||||
|
LEFT JOIN #user AS u ON n.news_author = u.user_id
|
||||||
|
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
|
||||||
|
WHERE n.news_class IN (".USERCLASS_LIST.") AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") {$render} {$topic} ORDER BY n.news_datestamp DESC LIMIT 0,".$limit;
|
||||||
|
|
||||||
|
$sql = e107::getDb();
|
||||||
|
|
||||||
|
|
||||||
|
$sql->gen($rssQuery);
|
||||||
|
$tmp = $sql->db_getList();
|
||||||
|
|
||||||
|
$rss = array();
|
||||||
|
$i=0;
|
||||||
|
|
||||||
|
foreach($tmp as $value)
|
||||||
|
{
|
||||||
|
$rss[$i]['title'] = $value['news_title'];
|
||||||
|
$rss[$i]['link'] = e107::getUrl()->create('news/view/item', $value, 'full=1');
|
||||||
|
$rss[$i]['author'] = $value['user_name'];
|
||||||
|
$rss[$i]['author_email'] = $value['user_email'];
|
||||||
|
$rss[$i]['category_name'] = $tp->toHTML($value['category_name'],TRUE,'defs');
|
||||||
|
$rss[$i]['category_link'] = SITEURL."news.php?cat.".$value['news_category']; //TODO SEFURL.
|
||||||
|
$rss[$i]['pubdate'] = $value['news_datestamp'];
|
||||||
|
$rss[$i]['description'] = $this->getDescription($value);
|
||||||
|
|
||||||
|
if($value['news_allow_comments'] && $pref['comments_disabled'] != 1)
|
||||||
|
{
|
||||||
|
$rss[$i]['comment'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['news_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$rss[$i]['media'] = $this->getMedia($value);
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rss;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function getDescription($row)
|
||||||
|
{
|
||||||
|
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
if($row['news_summary'] && $this->summaryDescription == true)
|
||||||
|
{
|
||||||
|
$text = $row['news_summary'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text= ($row['news_body']."<br />".$row['news_extended']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->showImages == true && !empty($row['news_thumbnail']))
|
||||||
|
{
|
||||||
|
$tmp = explode(",", $row['news_thumbnail']);
|
||||||
|
|
||||||
|
foreach($tmp as $img)
|
||||||
|
{
|
||||||
|
|
||||||
|
$text .= "<br />\n";
|
||||||
|
$text .= $tp->toImage($img, array('alt'=>basename($img), 'w'=>800,'h'=>600, 'legacy'=> "{e_IMAGE}newspost_images/"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function getMedia($row)
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
if(empty($this->showImages) || empty($row['news_thumbnail']))
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = explode(",", $row['news_thumbnail']);
|
||||||
|
|
||||||
|
$ret = array();
|
||||||
|
|
||||||
|
foreach($tmp as $v)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($tp->isImage($v))
|
||||||
|
{
|
||||||
|
$ret[] = array(
|
||||||
|
'media:content' => array(
|
||||||
|
'url'=>$tp->thumbUrl($v,array('w'=>800), true, true),
|
||||||
|
'medium'=>'image',
|
||||||
|
'value' => array('media:title'=> array('type'=>'html', 'value'=>basename($v)))
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif($tp->isVideo($v))
|
||||||
|
{
|
||||||
|
list($code,$type) = explode(".",$v);
|
||||||
|
|
||||||
|
if($type == 'youtube')
|
||||||
|
{
|
||||||
|
|
||||||
|
//TODO Needs to be verified as working.
|
||||||
|
$ret[] = array(
|
||||||
|
'media:player' => array('url'=>"http://www.youtube.com/embed/".$code, 'height'=>"560", 'width'=>"315" )
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile RSS Data
|
||||||
|
* @param $parms array url, limit, id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function dataChat($parms='')
|
||||||
|
{
|
||||||
|
$sql = e107::getDb();
|
||||||
|
|
||||||
|
$rss = array();
|
||||||
|
$i=0;
|
||||||
|
|
||||||
|
if($items = $sql->select('chatbox', "*", "cb_blocked=0 ORDER BY cb_datestamp DESC LIMIT 0,".$parms['limit']))
|
||||||
|
{
|
||||||
|
|
||||||
|
while($row = $sql->fetch())
|
||||||
|
{
|
||||||
|
$tmp = explode(".", $row['cb_nick']);
|
||||||
|
$rss[$i]['author'] = $tmp[1];
|
||||||
|
$rss[$i]['author_email'] = '';
|
||||||
|
$rss[$i]['link'] = "chatbox_menu/chat.php?".$row['cb_id'];
|
||||||
|
$rss[$i]['linkid'] = $row['cb_id'];
|
||||||
|
$rss[$i]['title'] = '';
|
||||||
|
$rss[$i]['description'] = $row['cb_message'];
|
||||||
|
$rss[$i]['category_name'] = '';
|
||||||
|
$rss[$i]['category_link'] = '';
|
||||||
|
$rss[$i]['datestamp'] = $row['cb_datestamp'];
|
||||||
|
$rss[$i]['enc_url'] = "";
|
||||||
|
$rss[$i]['enc_leng'] = "";
|
||||||
|
$rss[$i]['enc_type'] = "";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rss;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* if($topic_id && is_numeric($topic_id))
|
||||||
|
{
|
||||||
|
$topic = " AND news_category = ".intval($topic_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$topic = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$path='';
|
||||||
|
$render = ($pref['rss_othernews'] != 1) ? "AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))" : "";
|
||||||
|
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
||||||
|
|
||||||
|
$this -> rssQuery = "
|
||||||
|
SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
|
||||||
|
LEFT JOIN #user AS u ON n.news_author = u.user_id
|
||||||
|
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
|
||||||
|
WHERE n.news_class IN (".USERCLASS_LIST.") AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") {$render} {$topic} ORDER BY n.news_datestamp DESC LIMIT 0,".$this -> limit;
|
||||||
|
$sql->gen($this->rssQuery);
|
||||||
|
$tmp = $sql->db_getList();
|
||||||
|
$rss = array();
|
||||||
|
$i=0;
|
||||||
|
foreach($tmp as $value)
|
||||||
|
{
|
||||||
|
$rss[$i]['title'] = $value['news_title'];
|
||||||
|
// $rss[$i]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."news.php?item.".$value['news_id'].".".$value['news_category'];
|
||||||
|
|
||||||
|
$rss[$i]['link'] = e107::getUrl()->create('news/view/item', $value, 'full=1');
|
||||||
|
|
||||||
|
if($value['news_summary'] && $pref['rss_summarydiz'])
|
||||||
|
{
|
||||||
|
$rss[$i]['description'] = $value['news_summary'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$rss[$i]['description'] = ($value['news_body']."<br />".$value['news_extended']);
|
||||||
|
}
|
||||||
|
$rss[$i]['author'] = $value['user_name'];
|
||||||
|
$rss[$i]['author_email'] = $value['user_email'];
|
||||||
|
// $rss[$i]['category'] = "<category domain='".SITEURL."news.php?cat.".$value['news_category']."'>".$value['category_name']."</category>";
|
||||||
|
$rss[$i]['category_name'] = $tp->toHTML($value['category_name'],TRUE,'defs');
|
||||||
|
$rss[$i]['category_link'] = SITEURL."news.php?cat.".$value['news_category']; //TODO SEFURL.
|
||||||
|
|
||||||
|
if($value['news_allow_comments'] && $pref['comments_disabled'] != 1)
|
||||||
|
{
|
||||||
|
$rss[$i]['comment'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['news_id'];
|
||||||
|
}
|
||||||
|
$rss[$i]['pubdate'] = $value['news_datestamp'];
|
||||||
|
if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0) {
|
||||||
|
$rss[$i]['news_thumbnail'] = $value['news_thumbnail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* XXX Left here as an example of how to convert from v1.x to v2.x
|
||||||
|
*
|
||||||
|
//##### create feed for admin, return array $eplug_rss_feed --------------------------------
|
||||||
|
|
||||||
|
$feed['name'] = 'Chatbox';
|
||||||
|
$feed['url'] = 'chatbox'; //the identifier for the rss feed url
|
||||||
|
$feed['topic_id'] = ''; //the topic_id, empty on default (to select a certain category)
|
||||||
|
$feed['path'] = 'chatbox_menu'; //this is the plugin path location
|
||||||
|
$feed['text'] = 'this is the rss feed for the chatbox entries';
|
||||||
|
$feed['class'] = '0';
|
||||||
|
$feed['limit'] = '9';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//##### create rss data, return as array $eplug_rss_data -----------------------------------
|
||||||
|
$rss = array();
|
||||||
|
if($items = $sql -> db_Select('chatbox', "*", "cb_blocked=0 ORDER BY cb_datestamp DESC LIMIT 0,".$this -> limit)){
|
||||||
|
$i=0;
|
||||||
|
while($rowrss = $sql -> db_Fetch()){
|
||||||
|
$tmp = explode(".", $rowrss['cb_nick']);
|
||||||
|
$rss[$i]['author'] = $tmp[1];
|
||||||
|
$rss[$i]['author_email'] = '';
|
||||||
|
$rss[$i]['link'] = $e107->base_path.$PLUGINS_DIRECTORY."chatbox_menu/chat.php?".$rowrss['cb_id'];
|
||||||
|
$rss[$i]['linkid'] = $rowrss['cb_id'];
|
||||||
|
$rss[$i]['title'] = '';
|
||||||
|
$rss[$i]['description'] = $rowrss['cb_message'];
|
||||||
|
$rss[$i]['category_name'] = '';
|
||||||
|
$rss[$i]['category_link'] = '';
|
||||||
|
$rss[$i]['datestamp'] = $rowrss['cb_datestamp'];
|
||||||
|
$rss[$i]['enc_url'] = "";
|
||||||
|
$rss[$i]['enc_leng'] = "";
|
||||||
|
$rss[$i]['enc_type'] = "";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//##### ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$eplug_rss_data[] = $rss;
|
||||||
|
$eplug_rss_feed[] = $feed;
|
||||||
|
*/
|
||||||
|
|
@@ -218,6 +218,8 @@ class rss_ui extends e_admin_ui
|
|||||||
$sqli = new db;
|
$sqli = new db;
|
||||||
$feedlist = array();
|
$feedlist = array();
|
||||||
|
|
||||||
|
// @see e107_plugins/news/e_rss.php
|
||||||
|
/*
|
||||||
// News
|
// News
|
||||||
$feed['name'] = ADLAN_0;
|
$feed['name'] = ADLAN_0;
|
||||||
$feed['url'] = 'news'; // The identifier for the rss feed url
|
$feed['url'] = 'news'; // The identifier for the rss feed url
|
||||||
@@ -243,7 +245,7 @@ class rss_ui extends e_admin_ui
|
|||||||
// $feed['exclude_class'] = '';
|
// $feed['exclude_class'] = '';
|
||||||
$feedlist[] = $feed;
|
$feedlist[] = $feed;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/* // Download
|
/* // Download
|
||||||
$feed['name'] = ADLAN_24;
|
$feed['name'] = ADLAN_24;
|
||||||
@@ -271,6 +273,9 @@ class rss_ui extends e_admin_ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
// Comments
|
// Comments
|
||||||
$feed['name'] = RSS_PLUGIN_LAN_14;
|
$feed['name'] = RSS_PLUGIN_LAN_14;
|
||||||
$feed['url'] = 'comments';
|
$feed['url'] = 'comments';
|
||||||
|
@@ -147,7 +147,19 @@ else
|
|||||||
if($rss = new rssCreate($content_type, $rss_type, $topic_id, $row))
|
if($rss = new rssCreate($content_type, $rss_type, $topic_id, $row))
|
||||||
{
|
{
|
||||||
$rss_title = ($rss->contentType ? $rss->contentType : ucfirst($content_type));
|
$rss_title = ($rss->contentType ? $rss->contentType : ucfirst($content_type));
|
||||||
$rss->buildRss($rss_title);
|
|
||||||
|
if(E107_DEBUG_LEVEL > 0)
|
||||||
|
{
|
||||||
|
define('e_IFRAME',true);
|
||||||
|
require_once(HEADERF);
|
||||||
|
$rss->debug();
|
||||||
|
require_once(FOOTERF);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$rss->buildRss($rss_title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -204,61 +216,8 @@ class rssCreate
|
|||||||
{
|
{
|
||||||
case 'news' :
|
case 'news' :
|
||||||
case 1:
|
case 1:
|
||||||
if($topic_id && is_numeric($topic_id))
|
$path = e_PLUGIN."news/e_rss.php";
|
||||||
{
|
break;;
|
||||||
$topic = " AND news_category = ".intval($topic_id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$topic = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$path='';
|
|
||||||
$render = ($pref['rss_othernews'] != 1) ? "AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type))" : "";
|
|
||||||
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
|
|
||||||
|
|
||||||
$this -> rssQuery = "
|
|
||||||
SELECT n.*, u.user_id, u.user_name, u.user_email, u.user_customtitle, nc.category_name, nc.category_icon FROM #news AS n
|
|
||||||
LEFT JOIN #user AS u ON n.news_author = u.user_id
|
|
||||||
LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id
|
|
||||||
WHERE n.news_class IN (".USERCLASS_LIST.") AND NOT (n.news_class REGEXP ".$nobody_regexp.") AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") {$render} {$topic} ORDER BY n.news_datestamp DESC LIMIT 0,".$this -> limit;
|
|
||||||
$sql->gen($this->rssQuery);
|
|
||||||
$tmp = $sql->db_getList();
|
|
||||||
$this -> rssItems = array();
|
|
||||||
$loop=0;
|
|
||||||
foreach($tmp as $value)
|
|
||||||
{
|
|
||||||
$this -> rssItems[$loop]['title'] = $value['news_title'];
|
|
||||||
// $this -> rssItems[$loop]['link'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."news.php?item.".$value['news_id'].".".$value['news_category'];
|
|
||||||
|
|
||||||
$this -> rssItems[$loop]['link'] = e107::getUrl()->create('news/view/item', $value, 'full=1');
|
|
||||||
|
|
||||||
if($value['news_summary'] && $pref['rss_summarydiz'])
|
|
||||||
{
|
|
||||||
$this -> rssItems[$loop]['description'] = $value['news_summary'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this -> rssItems[$loop]['description'] = ($value['news_body']."<br />".$value['news_extended']);
|
|
||||||
}
|
|
||||||
$this -> rssItems[$loop]['author'] = $value['user_name'];
|
|
||||||
$this -> rssItems[$loop]['author_email'] = $value['user_email'];
|
|
||||||
// $this -> rssItems[$loop]['category'] = "<category domain='".SITEURL."news.php?cat.".$value['news_category']."'>".$value['category_name']."</category>";
|
|
||||||
$this -> rssItems[$loop]['category_name'] = $tp->toHTML($value['category_name'],TRUE,'defs');
|
|
||||||
$this -> rssItems[$loop]['category_link'] = SITEURL."news.php?cat.".$value['news_category']; //TODO SEFURL.
|
|
||||||
|
|
||||||
if($value['news_allow_comments'] && $pref['comments_disabled'] != 1)
|
|
||||||
{
|
|
||||||
$this -> rssItems[$loop]['comment'] = "http://".$_SERVER['HTTP_HOST'].e_HTTP."comment.php?comment.news.".$value['news_id'];
|
|
||||||
}
|
|
||||||
$this -> rssItems[$loop]['pubdate'] = $value['news_datestamp'];
|
|
||||||
if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0) {
|
|
||||||
$this -> rssItems[$loop]['news_thumbnail'] = $value['news_thumbnail'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$loop++;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
$path='';
|
$path='';
|
||||||
$this -> contentType = "articles";
|
$this -> contentType = "articles";
|
||||||
@@ -271,7 +230,7 @@ class rssCreate
|
|||||||
$path='';
|
$path='';
|
||||||
$this -> contentType = "content";
|
$this -> contentType = "content";
|
||||||
break;
|
break;
|
||||||
case 'comments' :
|
case 'comments' : //TODO Eventually move to e107_plugins/comments
|
||||||
case 5:
|
case 5:
|
||||||
$path='';
|
$path='';
|
||||||
$this -> rssQuery = "SELECT * FROM `#comments` WHERE `comment_blocked` = 0 ORDER BY `comment_datestamp` DESC LIMIT 0,".$this -> limit;
|
$this -> rssQuery = "SELECT * FROM `#comments` WHERE `comment_blocked` = 0 ORDER BY `comment_datestamp` DESC LIMIT 0,".$this -> limit;
|
||||||
@@ -377,7 +336,7 @@ class rssCreate
|
|||||||
$this -> rssItems[$k]['enc_leng'] = $row['enc_leng'];
|
$this -> rssItems[$k]['enc_leng'] = $row['enc_leng'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($eplug_rss['enc_type'])
|
if(!empty($eplug_rss['enc_type']))
|
||||||
{
|
{
|
||||||
$this -> rssItems[$k]['enc_type'] = $this->getmime($eplug_rss['enc_type']);
|
$this -> rssItems[$k]['enc_type'] = $this->getmime($eplug_rss['enc_type']);
|
||||||
}
|
}
|
||||||
@@ -403,15 +362,27 @@ class rssCreate
|
|||||||
$this -> rssItems[$k]['pubdate'] = $row['datestamp'];
|
$this -> rssItems[$k]['pubdate'] = $row['datestamp'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($row['custom']){
|
if($row['custom'])
|
||||||
|
{
|
||||||
$this -> rssItems[$k]['custom'] = $row['custom'];
|
$this -> rssItems[$k]['custom'] = $row['custom'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($row['media'])
|
||||||
|
{
|
||||||
|
$this -> rssItems[$k]['media'] = $row['media'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function debug()
|
||||||
|
{
|
||||||
|
print_a($this);
|
||||||
|
// print_a($this -> rssItems);
|
||||||
|
}
|
||||||
|
|
||||||
function buildRss($rss_title)
|
function buildRss($rss_title)
|
||||||
{
|
{
|
||||||
global $pref;
|
global $pref;
|
||||||
@@ -472,6 +443,7 @@ class rssCreate
|
|||||||
xmlns:atom=\"http://www.w3.org/2005/Atom\"
|
xmlns:atom=\"http://www.w3.org/2005/Atom\"
|
||||||
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
|
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
|
||||||
xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"
|
xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\"
|
||||||
|
xmlns:media=\"http://search.yahoo.com/mrss/\"
|
||||||
>
|
>
|
||||||
<channel>
|
<channel>
|
||||||
<title>".$tp->toRss($rss_title)."</title>
|
<title>".$tp->toRss($rss_title)."</title>
|
||||||
@@ -531,18 +503,11 @@ class rssCreate
|
|||||||
echo "<link>".$link."</link>\n";
|
echo "<link>".$link."</link>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<description>".$tp->toRss($value['description'],TRUE);
|
echo "<description>".$tp->toRss($value['description'],true). "</description>\n";
|
||||||
if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0) //FIXME - Fixed path and height?
|
|
||||||
{
|
|
||||||
$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
|
|
||||||
echo "<a href="".$link.""><img src="".$news_thumbnail."" height="50" border="0" hspace="10" vspace="10" align="right"></a>";
|
|
||||||
unset($news_thumbail);
|
|
||||||
}
|
|
||||||
echo "</description>\n";
|
|
||||||
|
|
||||||
if($value['content_encoded'])
|
if($value['content_encoded'])
|
||||||
{
|
{
|
||||||
echo "<content:encoded>".$tp->toRss($value['content_encoded'],TRUE)."</content:encoded>\n";
|
echo "<content:encoded>".$tp->toRss($value['content_encoded'],true)."</content:encoded>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($value['category_name'] && $catlink)
|
if($value['category_name'] && $catlink)
|
||||||
@@ -581,6 +546,20 @@ class rssCreate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($value['media']))
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach($value['media'] as $cVal)
|
||||||
|
{
|
||||||
|
foreach($cVal as $k=>$v)
|
||||||
|
{
|
||||||
|
echo $this->buildTag($k,$v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "</item>\n\n";
|
echo "</item>\n\n";
|
||||||
}
|
}
|
||||||
// echo "<atom:link href=\"".e_SELF."?".($this -> contentType).".4.".$this -> topicId ."\" rel=\"self\" type=\"application/rss+xml\" />";
|
// echo "<atom:link href=\"".e_SELF."?".($this -> contentType).".4.".$this -> topicId ."\" rel=\"self\" type=\"application/rss+xml\" />";
|
||||||
@@ -635,14 +614,7 @@ class rssCreate
|
|||||||
<dc:date>".$this->get_iso_8601_date($time + $this -> offset)."</dc:date>
|
<dc:date>".$this->get_iso_8601_date($time + $this -> offset)."</dc:date>
|
||||||
<dc:creator>".$value['author']."</dc:creator>
|
<dc:creator>".$value['author']."</dc:creator>
|
||||||
<dc:subject>".$tp->toRss($value['category_name'])."</dc:subject>
|
<dc:subject>".$tp->toRss($value['category_name'])."</dc:subject>
|
||||||
<description>".$tp->toRss($value['description']);
|
<description>".$tp->toRss($value['description']). "</description>
|
||||||
if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0)
|
|
||||||
{
|
|
||||||
$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
|
|
||||||
echo "<a href="".$link.""><img src="".$news_thumbnail."" height="50" border="0" hspace="10" vspace="10" align="right"></a>";
|
|
||||||
unset($news_thumbail);
|
|
||||||
}
|
|
||||||
echo "</description>
|
|
||||||
</item>";
|
</item>";
|
||||||
}
|
}
|
||||||
echo "
|
echo "
|
||||||
@@ -713,17 +685,11 @@ class rssCreate
|
|||||||
//<content>complete story here</content>\n
|
//<content>complete story here</content>\n
|
||||||
echo "
|
echo "
|
||||||
<link rel='alternate' type='text/html' href='".$value['link']."' />\n
|
<link rel='alternate' type='text/html' href='".$value['link']."' />\n
|
||||||
<summary type='text'>".$tp->toRss($value['description']);
|
<summary type='text'>".$tp->toRss($value['description']). "</summary>\n";
|
||||||
if($pref['rss_shownewsimage'] == 1 && strlen(trim($value['news_thumbnail'])) > 0)
|
|
||||||
{
|
|
||||||
$news_thumbnail = SITEURLBASE.e_IMAGE_ABS."newspost_images/".$tp->toRss($value['news_thumbnail']);
|
|
||||||
echo "<a href="".$value['link'].""><img src="".$news_thumbnail."" height="50" border="0" hspace="10" vspace="10" align="right"></a>";
|
|
||||||
unset($news_thumbail);
|
|
||||||
}
|
|
||||||
echo "</summary>\n";
|
|
||||||
|
|
||||||
// Optional
|
// Optional
|
||||||
if($value['category_name']){
|
if(!empty($value['category_name']))
|
||||||
|
{
|
||||||
echo "<category term='".$tp->toRss($value['category_name'])."'/>\n";
|
echo "<category term='".$tp->toRss($value['category_name'])."'/>\n";
|
||||||
}
|
}
|
||||||
//<contributor>
|
//<contributor>
|
||||||
@@ -746,6 +712,64 @@ class rssCreate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build an XML Tag
|
||||||
|
* @param string $name
|
||||||
|
* @param array $attributes
|
||||||
|
* @param bool $closing
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function buildTag($name='', $attributes=array())
|
||||||
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
if(empty($name))
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($attributes['value']))
|
||||||
|
{
|
||||||
|
$value = $attributes['value'];
|
||||||
|
unset($attributes['value']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = "\n<".$name;
|
||||||
|
|
||||||
|
foreach($attributes as $att=>$attVal)
|
||||||
|
{
|
||||||
|
|
||||||
|
$text .= " ".$att."=\"".$tp->toRss($attVal)."\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= ">";
|
||||||
|
|
||||||
|
if(!empty($value))
|
||||||
|
{
|
||||||
|
if(is_array($value))
|
||||||
|
{
|
||||||
|
foreach($value as $t=>$r)
|
||||||
|
{
|
||||||
|
$text .= $this->buildTag($t,$r);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= $tp->toRss($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</".$name.">\n";
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getmime($file)
|
function getmime($file)
|
||||||
{
|
{
|
||||||
$ext = strtolower(str_replace(".","",strrchr(basename($file), ".")));
|
$ext = strtolower(str_replace(".","",strrchr(basename($file), ".")));
|
||||||
|
Reference in New Issue
Block a user