mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Updated e_rss.php to v2.x spec.
This commit is contained in:
@@ -1,8 +1,88 @@
|
|||||||
<?php
|
<?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; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
// v2.x Standard
|
||||||
|
class chatbox_menu_rss // plugin-folder + '_rss'
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Admin RSS Configuration
|
||||||
|
*/
|
||||||
|
function config() // XXX TODO // Have admin read this.
|
||||||
|
{
|
||||||
|
$config = array();
|
||||||
|
|
||||||
|
$config[] = array(
|
||||||
|
'name' => 'Chatbox Posts',
|
||||||
|
'url' => 'chatbox',
|
||||||
|
'topic_id' => '',
|
||||||
|
'path' => 'chatbox_menu', // known
|
||||||
|
'description' => 'this is the rss feed for the chatbox entries', // that's 'description' not 'text'
|
||||||
|
'class' => '0',
|
||||||
|
'limit' => '9'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile RSS Data
|
||||||
|
* @param $parms array url, limit, id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function data($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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 --------------------------------
|
//##### create feed for admin, return array $eplug_rss_feed --------------------------------
|
||||||
|
|
||||||
$feed['name'] = 'Chatbox';
|
$feed['name'] = 'Chatbox';
|
||||||
$feed['url'] = 'chatbox'; //the identifier for the rss feed url
|
$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['topic_id'] = ''; //the topic_id, empty on default (to select a certain category)
|
||||||
@@ -41,3 +121,5 @@ if($items = $sql -> db_Select('chatbox', "*", "cb_blocked=0 ORDER BY cb_datestam
|
|||||||
|
|
||||||
$eplug_rss_data[] = $rss;
|
$eplug_rss_data[] = $rss;
|
||||||
$eplug_rss_feed[] = $feed;
|
$eplug_rss_feed[] = $feed;
|
||||||
|
*/
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / threads";
|
$feed['name'] = "Forum / threads";
|
||||||
$feed['url'] = '6';
|
$feed['url'] = '6';
|
||||||
$feed['topic_id'] = '';
|
$feed['topic_id'] = '';
|
||||||
$feed['path'] = 'forum|threads';
|
$feed['path'] = 'forum|threads'; //FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_threads entries';
|
$feed['text'] = 'this is the rss feed for the forum_threads entries';
|
||||||
$feed['class'] = '1';
|
$feed['class'] = '1';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -27,7 +27,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / threads";
|
$feed['name'] = "Forum / threads";
|
||||||
$feed['url'] = 'forumthreads';
|
$feed['url'] = 'forumthreads';
|
||||||
$feed['topic_id'] = '';
|
$feed['topic_id'] = '';
|
||||||
$feed['path'] = 'forum|threads';
|
$feed['path'] = 'forum|threads';//FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_threads entries';
|
$feed['text'] = 'this is the rss feed for the forum_threads entries';
|
||||||
$feed['class'] = '0';
|
$feed['class'] = '0';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -37,7 +37,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / posts";
|
$feed['name'] = "Forum / posts";
|
||||||
$feed['url'] = '7';
|
$feed['url'] = '7';
|
||||||
$feed['topic_id'] = '';
|
$feed['topic_id'] = '';
|
||||||
$feed['path'] = 'forum|posts';
|
$feed['path'] = 'forum|posts';//FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_posts entries';
|
$feed['text'] = 'this is the rss feed for the forum_posts entries';
|
||||||
$feed['class'] = '1';
|
$feed['class'] = '1';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -47,7 +47,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / posts";
|
$feed['name'] = "Forum / posts";
|
||||||
$feed['url'] = 'forumposts';
|
$feed['url'] = 'forumposts';
|
||||||
$feed['topic_id'] = '';
|
$feed['topic_id'] = '';
|
||||||
$feed['path'] = 'forum|posts';
|
$feed['path'] = 'forum|posts';//FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_posts entries';
|
$feed['text'] = 'this is the rss feed for the forum_posts entries';
|
||||||
$feed['class'] = '0';
|
$feed['class'] = '0';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -57,7 +57,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / topic";
|
$feed['name'] = "Forum / topic";
|
||||||
$feed['url'] = '8';
|
$feed['url'] = '8';
|
||||||
$feed['topic_id'] = '*';
|
$feed['topic_id'] = '*';
|
||||||
$feed['path'] = 'forum|topic';
|
$feed['path'] = 'forum|topic';//FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_topic entries';
|
$feed['text'] = 'this is the rss feed for the forum_topic entries';
|
||||||
$feed['class'] = '1';
|
$feed['class'] = '1';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -67,7 +67,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / topic";
|
$feed['name'] = "Forum / topic";
|
||||||
$feed['url'] = 'forumtopic';
|
$feed['url'] = 'forumtopic';
|
||||||
$feed['topic_id'] = '*';
|
$feed['topic_id'] = '*';
|
||||||
$feed['path'] = 'forum|topic';
|
$feed['path'] = 'forum|topic'; //FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_topic entries';
|
$feed['text'] = 'this is the rss feed for the forum_topic entries';
|
||||||
$feed['class'] = '0';
|
$feed['class'] = '0';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -77,7 +77,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / name";
|
$feed['name'] = "Forum / name";
|
||||||
$feed['url'] = '11';
|
$feed['url'] = '11';
|
||||||
$feed['topic_id'] = '*';
|
$feed['topic_id'] = '*';
|
||||||
$feed['path'] = 'forum|name';
|
$feed['path'] = 'forum|name'; //FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_name entries';
|
$feed['text'] = 'this is the rss feed for the forum_name entries';
|
||||||
$feed['class'] = '1';
|
$feed['class'] = '1';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -87,7 +87,7 @@ function get_forum_rss(){
|
|||||||
$feed['name'] = "Forum / name";
|
$feed['name'] = "Forum / name";
|
||||||
$feed['url'] = 'forumname';
|
$feed['url'] = 'forumname';
|
||||||
$feed['topic_id'] = '*';
|
$feed['topic_id'] = '*';
|
||||||
$feed['path'] = 'forum|name';
|
$feed['path'] = 'forum|name'; //FIXME
|
||||||
$feed['text'] = 'this is the rss feed for the forum_name entries';
|
$feed['text'] = 'this is the rss feed for the forum_name entries';
|
||||||
$feed['class'] = '0';
|
$feed['class'] = '0';
|
||||||
$feed['limit'] = '9';
|
$feed['limit'] = '9';
|
||||||
@@ -101,7 +101,7 @@ function get_forum_rss(){
|
|||||||
//##### create rss data, return as array $eplug_rss_data -----------------------------------
|
//##### create rss data, return as array $eplug_rss_data -----------------------------------
|
||||||
$sqlrss = new db;
|
$sqlrss = new db;
|
||||||
|
|
||||||
switch($this->parm){
|
switch($this->parm){ //FIXME use v2.x standard and replace this with $parm['url'] check.
|
||||||
|
|
||||||
case threads:
|
case threads:
|
||||||
case 6:
|
case 6:
|
||||||
|
@@ -74,7 +74,7 @@ class rss_admin extends e_admin_dispatcher
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//TODO - Use this .. .
|
||||||
class rss_ui extends e_admin_ui
|
class rss_ui extends e_admin_ui
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ if(!isset($RSS_ADMIN_IMPORT_HEADER))
|
|||||||
<tr>
|
<tr>
|
||||||
<th>".RSS_LAN_ADMIN_16."</td>
|
<th>".RSS_LAN_ADMIN_16."</td>
|
||||||
<th>".RSS_LAN_ADMIN_3."</td>
|
<th>".RSS_LAN_ADMIN_3."</td>
|
||||||
<th>".RSS_LAN_ADMIN_4."</td>
|
<th>".LAN_NAME."</td>
|
||||||
<th>".RSS_LAN_ADMIN_5."</td>
|
<th>".RSS_LAN_ADMIN_5."</td>
|
||||||
<th>".RSS_LAN_ADMIN_12."</td>
|
<th>".RSS_LAN_ADMIN_12."</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
@@ -636,15 +636,31 @@ class rss
|
|||||||
$plugin_feedlist = array();
|
$plugin_feedlist = array();
|
||||||
foreach($pref['e_rss_list'] as $val)
|
foreach($pref['e_rss_list'] as $val)
|
||||||
{
|
{
|
||||||
|
$eplug_rss_feed = array();
|
||||||
if (is_readable(e_PLUGIN.$val."/e_rss.php"))
|
if (is_readable(e_PLUGIN.$val."/e_rss.php"))
|
||||||
{
|
{
|
||||||
require_once(e_PLUGIN.$val."/e_rss.php");
|
require_once(e_PLUGIN.$val."/e_rss.php");
|
||||||
$plugin_feedlist = $eplug_rss_feed;
|
|
||||||
|
$className = $val."_rss";
|
||||||
|
$data = false;
|
||||||
|
|
||||||
|
if(!$data = e107::callMethod($className,'config'))
|
||||||
|
{
|
||||||
|
$data = $eplug_rss_feed;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($data as $v)
|
||||||
|
{
|
||||||
|
array_push($plugin_feedlist,$v);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$feedlist = array_merge($feedlist, $plugin_feedlist);
|
$feedlist = array_merge($feedlist, $plugin_feedlist);
|
||||||
|
|
||||||
|
// print_a($feedlist);
|
||||||
|
|
||||||
$render=FALSE;
|
$render=FALSE;
|
||||||
$i=0;
|
$i=0;
|
||||||
$text = $RSS_ADMIN_IMPORT_HEADER;
|
$text = $RSS_ADMIN_IMPORT_HEADER;
|
||||||
@@ -654,7 +670,7 @@ class rss
|
|||||||
$feed['url'] = $tp -> toDB($feed['url']);
|
$feed['url'] = $tp -> toDB($feed['url']);
|
||||||
|
|
||||||
// Check if feed is not yet present
|
// Check if feed is not yet present
|
||||||
if(!$sql -> db_Select("rss", "*", "rss_path='".$feed['path']."' AND rss_url='".$feed['url']."' AND rss_topicid='".$feed['topic_id']."' "))
|
if(!$sql->select("rss", "*", "rss_path='".$feed['path']."' AND rss_url='".$feed['url']."' AND rss_topicid='".$feed['topic_id']."' "))
|
||||||
{
|
{
|
||||||
$render=TRUE;
|
$render=TRUE;
|
||||||
$text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_TABLE, FALSE, $rss_shortcodes);
|
$text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_TABLE, FALSE, $rss_shortcodes);
|
||||||
|
@@ -181,11 +181,11 @@ class rssCreate
|
|||||||
{
|
{
|
||||||
$path = e_PLUGIN.$row['rss_path'].'/e_rss.php';
|
$path = e_PLUGIN.$row['rss_path'].'/e_rss.php';
|
||||||
}
|
}
|
||||||
if(strpos($row['rss_path'],'|')!==FALSE)
|
if(strpos($row['rss_path'],'|')!==FALSE) //FIXME remove this check completely.
|
||||||
{
|
{
|
||||||
$tmp = explode("|", $row['rss_path']);
|
$tmp = explode("|", $row['rss_path']);
|
||||||
$path = e_PLUGIN.$tmp[0]."/e_rss.php";
|
$path = e_PLUGIN.$tmp[0]."/e_rss.php";
|
||||||
$this -> parm = $tmp[1]; // Parm is used in e_rss.php to define which feed you need to prepare
|
$this->parm = $tmp[1]; // FIXME @Deprecated - use $parm['url'] instead in data() method within e_rss.php. Parm is used in e_rss.php to define which feed you need to prepare
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($content_type)
|
switch ($content_type)
|
||||||
@@ -324,6 +324,16 @@ class rssCreate
|
|||||||
if (is_readable($path))
|
if (is_readable($path))
|
||||||
{
|
{
|
||||||
require_once($path);
|
require_once($path);
|
||||||
|
|
||||||
|
$className = basename(dirname($path)).'_rss';
|
||||||
|
|
||||||
|
// v2.x standard
|
||||||
|
if($data = e107::callMethod($className,'data', array('url' => $content_type, 'id' => $this->topicid, 'limit' => $this->limit)))
|
||||||
|
{
|
||||||
|
$eplug_rss_data = array(0 => $data);
|
||||||
|
unset($data);
|
||||||
|
}
|
||||||
|
|
||||||
foreach($eplug_rss_data as $key=>$rs)
|
foreach($eplug_rss_data as $key=>$rs)
|
||||||
{
|
{
|
||||||
foreach($rs as $k=>$row)
|
foreach($rs as $k=>$row)
|
||||||
@@ -498,9 +508,8 @@ class rssCreate
|
|||||||
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
|
$link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link'];
|
||||||
$catlink = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link'];
|
$catlink = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link'];
|
||||||
|
|
||||||
echo "
|
echo "<item>\n";
|
||||||
<item>
|
echo "<title>".$tp->toRss($value['title'])."</title>\n";
|
||||||
<title>".$tp->toRss($value['title'])."</title>\n";
|
|
||||||
|
|
||||||
if($link)
|
if($link)
|
||||||
{
|
{
|
||||||
|
@@ -187,7 +187,7 @@ SC_END
|
|||||||
|
|
||||||
SC_BEGIN RSS_ADMIN_IMPORT_TEXT
|
SC_BEGIN RSS_ADMIN_IMPORT_TEXT
|
||||||
global $feed;
|
global $feed;
|
||||||
return $feed['text'];
|
return ($feed['description']) ? $feed['description'] : $feed['text'];
|
||||||
SC_END
|
SC_END
|
||||||
|
|
||||||
SC_BEGIN RSS_ADMIN_IMPORT_URL
|
SC_BEGIN RSS_ADMIN_IMPORT_URL
|
||||||
|
Reference in New Issue
Block a user