From 34f0eeb409e3ab9184aec30ca3c2e9f3006375fb Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 18 Jun 2013 20:21:39 -0700 Subject: [PATCH] Updated e_rss.php to v2.x spec. --- e107_plugins/chatbox_menu/e_rss.php | 84 +++++++++++++++++++++++- e107_plugins/forum/e_rss.php | 18 ++--- e107_plugins/rss_menu/admin_prefs.php | 24 +++++-- e107_plugins/rss_menu/rss.php | 21 ++++-- e107_plugins/rss_menu/rss_shortcodes.php | 2 +- 5 files changed, 128 insertions(+), 21 deletions(-) diff --git a/e107_plugins/chatbox_menu/e_rss.php b/e107_plugins/chatbox_menu/e_rss.php index fda2d1f37..933dd6aca 100644 --- a/e107_plugins/chatbox_menu/e_rss.php +++ b/e107_plugins/chatbox_menu/e_rss.php @@ -1,8 +1,88 @@ '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 -------------------------------- + $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) @@ -41,3 +121,5 @@ if($items = $sql -> db_Select('chatbox', "*", "cb_blocked=0 ORDER BY cb_datestam $eplug_rss_data[] = $rss; $eplug_rss_feed[] = $feed; +*/ + diff --git a/e107_plugins/forum/e_rss.php b/e107_plugins/forum/e_rss.php index 24895e110..7ee27b7f3 100644 --- a/e107_plugins/forum/e_rss.php +++ b/e107_plugins/forum/e_rss.php @@ -17,7 +17,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / threads"; $feed['url'] = '6'; $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['class'] = '1'; $feed['limit'] = '9'; @@ -27,7 +27,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / threads"; $feed['url'] = 'forumthreads'; $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['class'] = '0'; $feed['limit'] = '9'; @@ -37,7 +37,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / posts"; $feed['url'] = '7'; $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['class'] = '1'; $feed['limit'] = '9'; @@ -47,7 +47,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / posts"; $feed['url'] = 'forumposts'; $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['class'] = '0'; $feed['limit'] = '9'; @@ -57,7 +57,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / topic"; $feed['url'] = '8'; $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['class'] = '1'; $feed['limit'] = '9'; @@ -67,7 +67,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / topic"; $feed['url'] = 'forumtopic'; $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['class'] = '0'; $feed['limit'] = '9'; @@ -77,7 +77,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / name"; $feed['url'] = '11'; $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['class'] = '1'; $feed['limit'] = '9'; @@ -87,7 +87,7 @@ function get_forum_rss(){ $feed['name'] = "Forum / name"; $feed['url'] = 'forumname'; $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['class'] = '0'; $feed['limit'] = '9'; @@ -101,7 +101,7 @@ function get_forum_rss(){ //##### create rss data, return as array $eplug_rss_data ----------------------------------- $sqlrss = new db; -switch($this->parm){ +switch($this->parm){ //FIXME use v2.x standard and replace this with $parm['url'] check. case threads: case 6: diff --git a/e107_plugins/rss_menu/admin_prefs.php b/e107_plugins/rss_menu/admin_prefs.php index 4717e0721..fc8489f76 100644 --- a/e107_plugins/rss_menu/admin_prefs.php +++ b/e107_plugins/rss_menu/admin_prefs.php @@ -74,7 +74,7 @@ class rss_admin extends e_admin_dispatcher - +//TODO - Use this .. . class rss_ui extends e_admin_ui { @@ -391,7 +391,7 @@ if(!isset($RSS_ADMIN_IMPORT_HEADER)) ".RSS_LAN_ADMIN_16." ".RSS_LAN_ADMIN_3." - ".RSS_LAN_ADMIN_4." + ".LAN_NAME." ".RSS_LAN_ADMIN_5." ".RSS_LAN_ADMIN_12." "; @@ -636,14 +636,30 @@ class rss $plugin_feedlist = array(); foreach($pref['e_rss_list'] as $val) { + $eplug_rss_feed = array(); if (is_readable(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); + + // print_a($feedlist); $render=FALSE; $i=0; @@ -654,7 +670,7 @@ class rss $feed['url'] = $tp -> toDB($feed['url']); // 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; $text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_TABLE, FALSE, $rss_shortcodes); diff --git a/e107_plugins/rss_menu/rss.php b/e107_plugins/rss_menu/rss.php index 0c7f301e2..5e079cc70 100644 --- a/e107_plugins/rss_menu/rss.php +++ b/e107_plugins/rss_menu/rss.php @@ -135,7 +135,7 @@ else if($rss = new rssCreate($content_type, $rss_type, $topic_id, $row)) { $rss_title = ($rss->contentType ? $rss->contentType : ucfirst($content_type)); - $rss->buildRss ($rss_title); + $rss->buildRss($rss_title); } else { @@ -181,11 +181,11 @@ class rssCreate { $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']); $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) @@ -324,6 +324,16 @@ class rssCreate if (is_readable($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($rs as $k=>$row) @@ -498,9 +508,8 @@ class rssCreate $link = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['link']) : $value['link']; $catlink = (e_LANQRY) ? str_replace("?","?".e_LANQRY,$value['category_link']) : $value['category_link']; - echo " - - ".$tp->toRss($value['title'])."\n"; + echo "\n"; + echo "".$tp->toRss($value['title'])."\n"; if($link) { diff --git a/e107_plugins/rss_menu/rss_shortcodes.php b/e107_plugins/rss_menu/rss_shortcodes.php index 02a3998ef..ef08c7e45 100644 --- a/e107_plugins/rss_menu/rss_shortcodes.php +++ b/e107_plugins/rss_menu/rss_shortcodes.php @@ -187,7 +187,7 @@ SC_END SC_BEGIN RSS_ADMIN_IMPORT_TEXT global $feed; -return $feed['text']; +return ($feed['description']) ? $feed['description'] : $feed['text']; SC_END SC_BEGIN RSS_ADMIN_IMPORT_URL