1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Fixes #948 - RSS admin area rewrite. RSS menu updated for Bootstrap and RSS sef-urls added.

This commit is contained in:
Cameron
2015-04-03 18:39:56 -07:00
parent 11f199e4ef
commit 5be3a86e71
9 changed files with 694 additions and 333 deletions

View File

@@ -20,7 +20,7 @@ if (!defined('e107_INIT')) { exit; }
//##### create feed for admin, return array $eplug_rss_feed --------------------------------
// Download
$feed['name'] = ADLAN_24;
$feed['name'] = LAN_PLUGIN_DOWNLOAD_NAME;
$feed['url'] = 'download';
$feed['topic_id'] = '';
$feed['path'] = 'download';
@@ -36,9 +36,9 @@ if (!defined('e107_INIT')) { exit; }
if($sqli -> db_Select("download_category", "*","download_category_id!='' ORDER BY download_category_order "))
{
while($rowi = $sqli -> db_Fetch())
while($rowi = $sqli ->fetch())
{
$feed['name'] = ADLAN_24.' > '.$rowi['download_category_name'];
$feed['name'] = LAN_PLUGIN_DOWNLOAD_NAME.' > '.$rowi['download_category_name'];
$feed['url'] = 'download';
$feed['topic_id'] = $rowi['download_category_id'];
$feed['path'] = 'download';

View File

@@ -55,10 +55,10 @@ class rss_admin extends e_admin_dispatcher
protected $adminMenu = array(
'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'),
'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
'main/import' => array('caption'=> "Add New Feed", 'perm' => 'P'),
/*
'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'),
/*
'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
*/
@@ -69,6 +69,15 @@ class rss_admin extends e_admin_dispatcher
);
protected $menuTitle = 'RSS';
function init()
{
if(E107_DEBUG_LEVEL > 0)
{
$this->adminMenu['main/create'] = array('caption'=> "Add Custom Feed", 'perm' => 'P');
}
}
}
@@ -79,51 +88,255 @@ class rss_ui extends e_admin_ui
{
protected $pluginTitle = 'RSS';
protected $pluginName = 'myplugin';
protected $pluginName = 'core';
protected $table = 'rss';
protected $pid = 'rss_id';
protected $perPage = 10;
protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => '', 'data' => '', 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
'rss_id' => array ( 'title' => 'LAN_ID', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_name' => array ( 'title' => 'LAN_TITLE', 'type' => 'text', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_url' => array ( 'title' => 'LAN_URL', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '.{Type}.{Topic id}', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_topicid' => array ( 'title' => 'Topic id', 'type' => 'text', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'rss_path' => array ( 'title' => 'Path', 'type' => 'text', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_text' => array ( 'title' => 'Text', 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'rss_datestamp' => array ( 'title' => 'LAN_DATESTAMP', 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_class' => array ( 'title' => 'LAN_VISIBILITY', 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_limit' => array ( 'title' => 'Limit', 'type' => 'number', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'options' => array ( 'title' => 'LAN_OPTIONS', 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
'rss_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_path' => array ( 'title' => 'Plugin-Dir', 'type' => 'text', 'data' => 'int', 'readonly'=>1, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_url' => array ( 'title' => LAN_URL, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_topicid' => array ( 'title' => 'Topic id', 'type' => 'text', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'rss_text' => array ( 'title' => 'Text', 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
'rss_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'readonly'=>true, 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'rss_class' => array ( 'title' => LAN_VISIBILITY, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => array('optArray'=> array(RSS_LAN_ADMIN_21,RSS_LAN_ADMIN_22,RSS_LAN_ADMIN_23),'size'=>'xlarge'), 'class' => 'left', 'thclass' => 'left', ),
'rss_limit' => array ( 'title' => 'Limit', 'type' => 'number', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
);
protected $fieldpref = array('checkboxes', 'rss_name','rss_url', 'rss_topicid', 'rss_path', 'rss_class', 'options');
protected $fieldpref = array('checkboxes', 'rss_name','rss_url', 'rss_topicid', 'rss_limit', 'rss_class', 'options');
/*
protected = array(
'pref_type' => array('title'=> 'type', 'type'=>'text', 'data' => 'string', 'validate' => true),
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean', 'data' => 'integer'),
'pref_name' => array('title'=> 'name', 'type' => 'text', 'data' => 'string', 'validate' => 'regex', 'rule' => '#^[\w]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')
protected $prefs = array(
'rss_othernews' => array('title'=> RSS_LAN_ADMIN_13, 'type' => 'boolean', 'data' => 'int'),
'rss_summarydiz' => array('title'=> RSS_LAN_ADMIN_19, 'type' => 'boolean', 'data' => 'integer'),
'rss_shownewsimage' => array('title'=> RSS_LAN_ADMIN_33, 'type' => 'boolean', 'data' => 'int')
);
// optional
public function init()
// optional
public function init()
{
if(!empty($_POST['importid']))
{
$this->dbrssImport();
}
}
public function customPage()
function dbrssImport()
{
$sql = e107::getDb();
$tp = e107::getParser();
foreach($_POST['importid'] as $key=>$value)
{
$rssVals = array();
$rssVals['rss_topicid'] = $tp -> toDB(varset($_POST['topic_id'][$key], ''));
$rssVals['rss_url'] = $tp -> toDB(varset($_POST['url'][$key], ''));
$rssVals['rss_path'] = $tp -> toDB(varset($_POST['path'][$key], ''));
$rssVals['rss_name'] = $tp -> toDB(varset($_POST['name'][$key], ''));
$rssVals['rss_text'] = $tp -> toDB(varset($_POST['text'][$key], ''));
$rssVals['rss_datestamp'] = time();
$rssVals['rss_class'] = intval(varset($_POST['class'][$key], '0'));
$rssVals['rss_limit'] = intval(varset($_POST['limit'][$key], '0'));
$sql->insert("rss", $rssVals);
e107::getLog()->logArrayAll('RSS_04',$rssVals);
}
$message = count($_POST['importid'])." ".RSS_LAN_ADMIN_18;
return $message;
}
public function importPage()
{
// Import - put up the list of possible feeds to import
$sql = e107::getDb();
$ns = e107::getRender();
$text = 'Hello World!';
$ns->tablerender('Hello',$text);
$mes = e107::getMessage();
$tp = e107::getParser();
$frm = e107::getForm();
global $i,$rss_shortcodes, $feed, $pref;
require_once(e_PLUGIN.'rss_menu/rss_shortcodes.php');
if(!isset($RSS_ADMIN_IMPORT_HEADER))
{
$RSS_ADMIN_IMPORT_HEADER = "
<form action='".e_SELF."' id='imlistform' method='post' >
<table class='table adminform'>
<tr>
<th>".RSS_LAN_ADMIN_16."</td>
<th>".RSS_LAN_ADMIN_3."</td>
<th>".LAN_NAME."</td>
<th>".RSS_LAN_ADMIN_5."</td>
<th>".RSS_LAN_ADMIN_12."</td>
</tr>";
}
if(!isset($RSS_ADMIN_IMPORT_TABLE))
{
$RSS_ADMIN_IMPORT_TABLE = "
<tr>
<td>{RSS_ADMIN_IMPORT_CHECK}</td>
<td>{RSS_ADMIN_IMPORT_PATH}</td>
<td><b>{RSS_ADMIN_IMPORT_NAME}</b><br />{RSS_ADMIN_IMPORT_TEXT}</td>
<td>{RSS_ADMIN_IMPORT_URL}</td>
<td>{RSS_ADMIN_IMPORT_TOPICID}</td>
</tr>";
}
if(!isset($RSS_ADMIN_IMPORT_FOOTER))
{
$RSS_ADMIN_IMPORT_FOOTER = "
</table>
<div class='buttons-bar center'>
".$frm->admin_button('import_rss',RSS_LAN_ADMIN_17,'submit')."
</div>
</form>
";
}
*/
// global $RSS_ADMIN_IMPORT_HEADER, $RSS_ADMIN_IMPORT_TABLE, $RSS_ADMIN_IMPORT_FOOTER;
$sqli = new db;
$feedlist = array();
// News
$feed['name'] = ADLAN_0;
$feed['url'] = 'news'; // The identifier for the rss feed url
$feed['topic_id'] = ''; // The topic_id, empty on default (to select a certain category)
$feed['path'] = 'news'; // This is the plugin path location
$feed['text'] = RSS_PLUGIN_LAN_7;
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
// News categories
if($sqli -> db_Select("news_category", "*","category_id!='' ORDER BY category_name "))
{
while($rowi = $sqli -> db_Fetch())
{
$feed['name'] = ADLAN_0.' > '.$rowi['category_name'];
$feed['url'] = 'news';
$feed['topic_id'] = $rowi['category_id'];
$feed['path'] = 'news';
$feed['text'] = RSS_PLUGIN_LAN_10.' '.$rowi['category_name'];
$feed['class'] = '0';
$feed['limit'] = '9';
// $feed['exclude_class'] = '';
$feedlist[] = $feed;
}
}
/* // Download
$feed['name'] = ADLAN_24;
$feed['url'] = 'download';
$feed['topic_id'] = '';
$feed['path'] = 'download';
$feed['text'] = RSS_PLUGIN_LAN_8;
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
// Download categories
if($sqli -> db_Select("download_category", "*","download_category_id!='' ORDER BY download_category_order "))
{
while($rowi = $sqli -> db_Fetch())
{
$feed['name'] = ADLAN_24.' > '.$rowi['download_category_name'];
$feed['url'] = 'download';
$feed['topic_id'] = $rowi['download_category_id'];
$feed['path'] = 'download';
$feed['text'] = RSS_PLUGIN_LAN_11.' '.$rowi['download_category_name'];
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
}
}
*/
// Comments
$feed['name'] = RSS_PLUGIN_LAN_14;
$feed['url'] = 'comments';
$feed['topic_id'] = '';
$feed['path'] = 'comments';
$feed['text'] = RSS_PLUGIN_LAN_9;
$feed['class'] = '0';
$feed['limit'] = '9';
$feedlist[] = $feed;
// Plugin rss feed, using e_rss.php in plugin folder
$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");
$className = $val."_rss";
$data = false;
if(!$data = e107::callMethod($className,'config'))
{
$data = $eplug_rss_feed;
}
foreach($data as $v)
{
$v['path'] = $val;
array_push($plugin_feedlist,$v);
}
}
}
$feedlist = array_merge($feedlist, $plugin_feedlist);
// print_a($feedlist);
$render=FALSE;
$i=0;
$text = $RSS_ADMIN_IMPORT_HEADER;
foreach($feedlist as $k=>$feed)
{
$feed['topic_id'] = $tp -> toDB($feed['topic_id']);
$feed['url'] = $tp -> toDB($feed['url']);
// Check if feed is not yet present
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);
$i++;
}
}
$text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_FOOTER, FALSE, $rss_shortcodes);
if(!$render)
{
$this->show_message(RSS_LAN_ADMIN_11, RSS_LAN_ERROR_6);
}
else
{
// $ns->tablerender(RSS_LAN_ADMIN_11, $mes->render(). $text);
return $text;
}
}
}
@@ -134,41 +347,44 @@ class rss_form_ui extends e_admin_form_ui
// Custom Method/Function
function rss_class($curVal,$mode)
function rss_url($curVal,$mode)
{
$frm = e107::getForm();
$array = array(RSS_LAN_ADMIN_21,RSS_LAN_ADMIN_22,RSS_LAN_ADMIN_23);
switch($mode)
{
case 'read': // List Page
return vartrue($array[$curVal]);
$type = $this->getController()->getListModel()->get('rss_type');
$topic = $this->getController()->getListModel()->get('rss_topicid');
$link = e107::url('rss_menu', 'rss', array('rss_type'=>$type, 'rss_url'=>$curVal, 'rss_topicid'=>$topic));
return "<a href='".$link."'>".$curVal."</a>";
break;
case 'write': // Edit Page
return $frm->select('rss_class',$array, $curVal);
$link = SITEURL."feed/"; // e107::url('rss_menu','index').'/';
return "<div class='form-inline'>".$link.e107::getForm()->text('rss_url', $curVal,255, 'size=small')."/rss/{Topic id}</div>";
break;
case 'filter':
case 'batch':
return $array;
return null;
break;
}
}
}
/*
new rss_admin();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
new rss_admin();
require_once(e_ADMIN."footer.php");
exit;
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
*/
require_once(e_ADMIN."footer.php");
exit;
@@ -179,6 +395,9 @@ exit;
/// ------------------------------- Legacy Code -------------------------------
@@ -801,7 +1020,9 @@ class rss
// Update options
function dboptions()
{
global $tp, $pref, $admin_log;
global $tp, $pref;
$admin_log = e107::getLog();
$temp = array();
$temp['rss_othernews'] = $_POST['rss_othernews'];

View File

@@ -23,16 +23,24 @@ global $PLUGINS_DIRECTORY;
$tp = e107::getParser();
$sql = e107::getDb();
if(USER_AREA && $sql->db_Select("rss", "*", "rss_class='0' AND rss_limit>0 ORDER BY rss_name"))
if(USER_AREA && $sql->select("rss", "*", "rss_class='0' AND rss_limit>0 ORDER BY rss_name"))
{
while($row=$sql->db_Fetch())
{ // Wildcard topic_id's should not be listed
if(strpos($row['rss_url'], "*")===FALSE)
while($row = $sql->fetch())
{
if(strpos($row['rss_url'], "*") === false) // Wildcard topic_id's should not be listed
{
$url = SITEURL.$PLUGINS_DIRECTORY."rss_menu/rss.php?".$tp->toHTML($row['rss_url'], TRUE, 'constants, no_hook, emotes_off').".2";
$url .= ($row['rss_topicid']) ? ".".$row['rss_topicid'] : "";
// $url = SITEURL.$PLUGINS_DIRECTORY."rss_menu/rss.php?".$tp->toHTML($row['rss_url'], TRUE, 'constants, no_hook, emotes_off').".2";
// $url .= ($row['rss_topicid']) ? ".".$row['rss_topicid'] : "";
$url2 = e107::url('rss_menu','rss', $row);
$url4 = e107::url('rss_menu','atom', $row);
$name = $tp->toHTML($row['rss_name'], TRUE, 'no_hook, emotes_off');
echo "<link rel='alternate' type='application/rss+xml' title='".htmlspecialchars(SITENAME, ENT_QUOTES, 'utf-8')." ".htmlspecialchars($name, ENT_QUOTES, 'utf-8')."' href='".$url."' />\n";
echo "<link rel='alternate' type='application/rss+xml' title='".htmlspecialchars(SITENAME, ENT_QUOTES, 'utf-8')." ".htmlspecialchars($name, ENT_QUOTES, 'utf-8')."' href='".$url2."' />\n";
echo "<link rel='alternate' type='application/atom+xml' title='".htmlspecialchars(SITENAME, ENT_QUOTES, 'utf-8')." ".htmlspecialchars($name, ENT_QUOTES, 'utf-8')."' href='".$url4."' />\n";
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
/*
* e107 Bootstrap CMS
*
* 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)
*/
if (!defined('e107_INIT')) { exit; }
// v2.x Standard - Simple mod-rewrite module.
class rss_menu_url // plugin-folder + '_url'
{
function config()
{
$config = array();
$config['rss'] = array(
'regex' => '^feed/(.*)/rss/?([\d]*)?$',
'sef' => 'feed/{rss_url}/rss/{rss_topicid}',
'redirect' => '{e_PLUGIN}rss_menu/rss.php?cat=$1&type=2&topic=$2'
);
$config['atom'] = array(
'regex' => '^feed/(.*)/atom/?([\d]*)?$',
'sef' => 'feed/{rss_url}/atom/{rss_topicid}',
'redirect' => '{e_PLUGIN}rss_menu/rss.php?cat=$1&type=4&topic=$2'
);
$config['index'] = array(
'regex' => '^feed/?$',
'sef' => 'feed',
'redirect' => '{e_PLUGIN}rss_menu/rss.php',
);
return $config;
}
}

View File

@@ -2,5 +2,6 @@
define("LAN_PLUGIN_RSS_NAME", "RSS");
define("LAN_PLUGIN_RSS_DESCRIPTION", "RSS Feeds from your site.");
define("LAN_PLUGIN_RSS_SUBSCRIBE", "Subscribe");
define("LAN_PLUGIN_RSS_SUBSCRIBE_TO", "Subscribe to [x]");
?>

View File

@@ -19,9 +19,13 @@ Query string: content_type.rss_type.[topic id]
Plugins should use an e_rss.php file in their plugin folder
----------------------------------------------------------------
*/
if (!defined('e107_INIT'))
{
require_once('../../class2.php');
}
require_once('../../class2.php');
$e107 = e107::getInstance();
if (!$e107->isInstalled('rss_menu'))
{
header('Location: '.e_BASE.'index.php');
@@ -56,7 +60,14 @@ else
}
// Query handler
if (e_QUERY)
if(!empty($_GET))
{
$content_type = $tp->toDB($_GET['cat']);
$rss_type = intval(varset($_GET['type'],0));
$topic_id = $tp->toDB($_GET['topic'],'');
}
elseif (e_QUERY)
{
$tmp = explode('.', e_QUERY);
$content_type = $tp->toDB($tmp[0]);
@@ -64,6 +75,7 @@ if (e_QUERY)
$topic_id = $tp->toDB($tmp[2],'');
}
// List available rss feeds
if (!$rss_type)
{ // Display list of all feeds

View File

@@ -2,87 +2,102 @@
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Copyright (C) 2008-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/rss_menu/rss_menu.php,v $
* $Revision$
* $Date$
* $Author$
*/
if (!defined('e107_INIT')) { exit; }
if (!e107::isInstalled('rss_menu'))
{
return '';
}
if (!defined('e107_INIT')) { exit; }
$FILES_DIRECTORY = e107::getInstance()->getFolder('files');
$sql = e107::getDb();
$path = e_PLUGIN_ABS."rss_menu/";
include_lan(e_PLUGIN."rss_menu/languages/".e_LANGUAGE."_admin_rss_menu.php");
$des = "";
$topic = "";
if(strstr(e_SELF, "comment.php") && $sql -> db_Select("rss", "rss_path", " rss_path = 'comments' LIMIT 1"))
{
$type = 5;
$des = RSS_MENU_L4;
}
if(strstr(e_SELF, "/forum")&& $sql -> db_Select("rss", "rss_path", " rss_path = 'forum|name' LIMIT 1") )
{
$type = 6;
$des = RSS_MENU_L5;
}
if(strstr(e_SELF, "forum_viewtopic") && $sql -> db_Select("rss", "rss_path", " rss_path = 'forum|topic' LIMIT 1"))
{
$type = 7;
$des = RSS_MENU_L6;
}
if(strstr(e_SELF, "chat.php")&& $sql -> db_Select("rss", "rss_path", " rss_path = 'chatbox_menu' LIMIT 1"))
{
$type = 9;
$des = RSS_MENU_L7;
}
if(strstr(e_SELF, "/bugtracker"))
{
$type = 10;
$des = RSS_MENU_L8;
}
if(strstr(e_SELF, "download.php") && $sql -> db_Select("rss", "rss_path", " rss_path = 'download' LIMIT 1"))
{
$type = 12;
$des = RSS_MENU_L9;
}
if(!$des)
{
$type = 1;
$des = RSS_MENU_L3;
}
if(e_PAGE == "news.php" && e107::getPref('rss_newscats'))
{
$qry = explode(".",e_QUERY);
if($qry[0] == "cat" || $qry[0] == "list")
if (!e107::isInstalled('rss_menu'))
{
$topic = intval($qry[1]);
return '';
}
}
$text = "
<div>
".$des.RSS_MENU_L1."<br />
<div class='spacer'><a href='".$path."rss.php?$type.1".($topic ? ".".$topic : "")."'><img src='".$path."images/rss1.png' alt='rss1.0' /></a></div>
<div class='spacer'><a href='".$path."rss.php?$type.2".($topic ? ".".$topic : "")."'><img src='".$path."images/rss2.png' alt='rss2.0' /></a></div>
<div class='spacer'><a href='".$path."rss.php?$type.3".($topic ? ".".$topic : "")."'><img src='".$path."images/rss3.png' alt='rdf' /></a></div>
<div class='spacer'><a href='".$path."rss.php?$type.4".($topic ? ".".$topic : "")."'><img src='".$path."images/rss4.png' alt='atom' /></a></div>
</div>";
$sql = e107::getDb();
// Deprecated - can be controlled within tablestyle (theme) - case mod == 'rss_menu'
//$caption = (file_exists(THEME."images/RSS_menu.png") ? "<img src='".THEME_ABS."images/RSS_menu.png' alt='' style='vertical-align:middle' /> ".RSS_MENU_L2 : RSS_MENU_L2);
e107::getRender()->tablerender(RSS_MENU_L2, $text, 'rss_menu');
e107::includeLan(e_PLUGIN."rss_menu/languages/".e_LANGUAGE."_admin_rss_menu.php");
$topic = "";
$caption = "";
if(e_PAGE == "news.php" && e107::getPref('rss_newscats'))
{
$qry = explode(".",e_QUERY);
if($qry[0] == "cat" || $qry[0] == "list")
{
$topic = intval($qry[1]);
}
}
if(deftrue('e_CURRENT_PLUGIN') && $res = $sql->retrieve("rss", "rss_path,rss_url", " rss_path = '".e_CURRENT_PLUGIN."' LIMIT 1"))
{
$caption = e107::getParser()->lanVars(LAN_PLUGIN_RSS_SUBSCRIBE_TO, deftrue('LAN_PLUGIN_'.strtoupper(e_CURRENT_PLUGIN).'_NAME'));
$type = $res['rss_url'];
$plug = $res['rss_path'];
}
elseif($sql->select("rss", "rss_path", " rss_path = 'news' LIMIT 1")) // Fall back to news, if available.
{
$caption = LAN_PLUGIN_RSS_SUBSCRIBE;
$type = 'news';
$plug = 'news';
}
if(!empty($type))
{
$arr = array('rss_topicid'=> $topic, 'rss_url'=>$type);
if(deftrue('BOOTSTRAP') === 3) // v2.x
{
$text = "
<div>
<a class='btn btn-sm btn-default' href='".e107::url('rss_menu', 'rss', $arr)."'>".$tp->toGlyph('fa-rss')." RSS</a>
<a class='btn btn-sm btn-default' href='".e107::url('rss_menu', 'atom', $arr)."'>".$tp->toGlyph('fa-rss')." Atom</a>
</div>";
}
else // v1.x
{
$path = e_PLUGIN_ABS."rss_menu/";
$description = array(
'chatbox' => RSS_MENU_L7,
'download' => RSS_MENU_L9,
'bugtracker' => RSS_MENU_L8,
'forumtopic' => RSS_MENU_L6,
'forumname' => RSS_MENU_L5,
'forumposts' => '',
'comments' => RSS_MENU_L4,
5 => RSS_MENU_L4,
6 => RSS_MENU_L5,
7 => RSS_MENU_L6,
9 => RSS_MENU_L7,
10 => RSS_MENU_L8,
12 => RSS_MENU_L9,
);
$text = "
<div>
".varset($description[$type]).RSS_MENU_L1."<br />
<div class='spacer'><a href='".e107::url('rss_menu', 'rss', $arr)."'><img src='".$path."images/rss2.png' alt='rss2.0' /></a></div>
<div class='spacer'><a href='".e107::url('rss_menu', 'atom', $arr)."'><img src='".$path."images/rss4.png' alt='atom' /></a></div>
</div>";
$caption = RSS_MENU_L2;
}
e107::getRender()->tablerender($caption, $text, 'rss_menu');
}
?>

View File

@@ -2,207 +2,269 @@
// $Id$
if (!defined('e107_INIT')) { exit; }
include_once(e_HANDLER.'shortcode_handler.php');
$rss_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
/*
SC_BEGIN RSS_FEED
global $row, $tp;
$url2 = e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
return "<a href='".$url2."'>".$tp->toHTML($row['rss_name'], TRUE)."</a>";
SC_END
include_once(e_HANDLER.'shortcode_handler.php');
// $rss_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__);
SC_BEGIN RSS_ICON
global $row, $tp;
$url2 = e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
return "<a href='".$url2."'>".RSS_ICON."</a>";
SC_END
SC_BEGIN RSS_TEXT
global $row, $tp;
return $tp->toHTML($row['rss_text'], TRUE, "defs");
SC_END
SC_BEGIN RSS_TYPES
global $row, $tp;
$url1 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".1".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url3 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".3".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url4 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".4".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$text = "
<a href='".$url1."' class='rss'><img src='".e_PLUGIN."rss_menu/images/rss1.png' class='icon' alt='RSS 0.92' /></a>
<a href='".$url2."' class='rss'><img src='".e_PLUGIN."rss_menu/images/rss2.png' class='icon' alt='RSS 2.0' /></a>
<a href='".$url3."' class='rss'><img src='".e_PLUGIN."rss_menu/images/rss3.png' class='icon' alt='RDF' /></a>
<a href='".$url4."' class='rss'><img src='".e_PLUGIN."rss_menu/images/rss4.png' class='icon' alt='ATOM' /></a>
";
return $text;
SC_END
//##### ADMIN --------------------------------------------------
SC_BEGIN RSS_ADMIN_CAPTION
global $sort;
list($field,$txt) = explode(",",$parm);
$txt = constant($txt);
return "<a href='".e_SELF."?list.{$field}.".($sort == "desc" ? "asc" : "desc")."'>".$txt."</a>\n";
SC_END
SC_BEGIN RSS_ADMIN_ID
global $row;
return $row['rss_id'];
SC_END
SC_BEGIN RSS_ADMIN_NAME
global $row;
return $row['rss_name'];
SC_END
SC_BEGIN RSS_ADMIN_PATH
global $row;
return $row['rss_path'];
SC_END
SC_BEGIN RSS_ADMIN_URL
global $row;
return "<a href='".e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$row['rss_url']."'>".$row['rss_url']."</a>";
SC_END
SC_BEGIN RSS_ADMIN_TOPICID
global $row;
return $row['rss_topicid'];
SC_END
SC_BEGIN RSS_ADMIN_LIMIT
global $row, $rs;
$id = $row['rss_id'];
$frm = e107::getForm();
return $frm->number("limit[$id]",$row['rss_limit']);
return "<input class='tbox' type='text' name=\"limit[$id]\" title=\"".RSS_LAN05."\" value='".intval($row['rss_limit'])."' size='3' maxlength='3' />";
SC_END
SC_BEGIN RSS_ADMIN_LIMITBUTTON
$frm = e107::getForm();
return $frm->admin_button('update_limit',LAN_UPDATE,'update');
SC_END
SC_BEGIN RSS_ADMIN_OPTIONS
global $row, $tp;
$delname = $row['rss_name'];
$delid = $row['rss_id'];
$options = "
<a href='".e_SELF."?create.edit.".$row['rss_id']."' >".ADMIN_EDIT_ICON."</a>
<input type='image' title=\"".LAN_DELETE."\" name='delete[{$delid}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(LAN_CONFIRMDEL ." [".RSS_LAN_ADMIN_2.": ".$delid." : ".$delname."]\\n\\n")."')\"/>";
return $options;
SC_END
SC_BEGIN RSS_ADMIN_FORM_NAME
global $row;
return "<input class='tbox' type='text' name='rss_name' size='74' value=\"".$row['rss_name']."\" />\n";
SC_END
SC_BEGIN RSS_ADMIN_FORM_URL
global $row,$PLUGINS_DIRECTORY;
return SITEURL.$PLUGINS_DIRECTORY."rss_menu/rss.php?".e_LANQRY." <input class='tbox' type='text' name='rss_url' size='10' value=\"".$row['rss_url']."\" maxlength='50' /> .{".LAN_TYPE."}.{".RSS_LAN_ADMIN_12."}";
SC_END
SC_BEGIN RSS_ADMIN_FORM_TOPICID
global $row;
return "<input class='tbox' type='text' name='rss_topicid' size='74' value=\"".$row['rss_topicid']."\" maxlength='250' />";
SC_END
SC_BEGIN RSS_ADMIN_FORM_PATH
global $row;
return "<input class='tbox' type='text' name='rss_path' size='74' value=\"".$row['rss_path']."\" maxlength='250' />";
SC_END
SC_BEGIN RSS_ADMIN_FORM_TEXT
global $row;
return "<textarea class='tbox' name='rss_text' cols='74' rows='5' >".$row['rss_text']."</textarea>\n";
SC_END
SC_BEGIN RSS_ADMIN_FORM_CLASS
global $row;
$vals = array(RSS_LAN_ADMIN_21,RSS_LAN_ADMIN_22,RSS_LAN_ADMIN_23);
$text = "<select class='tbox' name='rss_class'>";
foreach($vals as $key=>$val)
class rss_menu_shortcodes extends e_shortcode
{
$sel = ($row['rss_class'] == $key) ? " selected='selected'" : "";
$text .= "<option value='{$key}'{$sel}>$val</option>\n";
}
$text .= "</select>";
return $text;
SC_END
SC_BEGIN RSS_ADMIN_FORM_LIMIT
global $row;
$frm = e107::getForm();
return $frm->number('rss_limit',$row['rss_limit'],3);
return "<input class='tbox' name='rss_limit' size='3' title=\"".RSS_LAN05."\" value='".intval($row['rss_limit'])."' maxlength='3' />";
SC_END
SC_BEGIN RSS_ADMIN_FORM_CREATEBUTTON
global $row;
$qs = explode(".", e_QUERY);
$frm = e107::getForm();
if(isset($qs[1]) && $qs[1] == "edit" && isset($qs[2]) && is_numeric($qs[2]) )
{
$text = "<input type='hidden' name='rss_datestamp' value='".$row['rss_datestamp']."' />
<input type='hidden' name='rss_id' value='".$row['rss_id']."' />";
$text .= $frm->admin_button('update_rss',LAN_UPDATE,'update');
function sc_rss_feed()
{
global $row, $tp;
// $url2 = e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e107::url('rss_menu','rss', $row);
return "<a href='".$url2."'>".$tp->toHTML($row['rss_name'], TRUE)."</a>";
}
function sc_rss_icon()
{
global $row, $tp;
// $url2 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e107::url('rss_menu','rss', $row);
return "<a href='".$url2."'>".RSS_ICON."</a>";
}
function sc_rss_text()
{
global $row, $tp;
return $tp->toHTML($row['rss_text'], TRUE, "defs");
}
function sc_rss_types()
{
global $row, $tp;
// $url1 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".1".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
// $url2 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".2".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
// $url3 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".3".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
// $url4 = e_PLUGIN_ABS."rss_menu/rss.php?".e_LANQRY.$tp->toHTML($row['rss_url'], TRUE, 'constants').".4".($row['rss_topicid'] ? ".".$row['rss_topicid'] : '');
$url2 = e107::url('rss_menu','rss', $row);
$url4 = e107::url('rss_menu','atom', $row);
$text = "";
// $text .= "<a href='".$url1."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss1.png' class='icon' alt='RSS 0.92' /></a>";
$text .= "<a href='".$url2."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss2.png' class='icon' alt='RSS 2.0' /></a>";
// $text .= "<a href='".$url3."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss3.png' class='icon' alt='RDF' /></a>";
$text .= "<a href='".$url4."' class='rss'><img src='".e_PLUGIN_ABS."rss_menu/images/rss4.png' class='icon' alt='ATOM' /></a>";
return $text;
}
//##### ADMIN --------------------------------------------------
function sc_rss_admin_caption($parm='')
{
global $sort;
list($field,$txt) = explode(",",$parm);
$txt = constant($txt);
return "<a href='".e_SELF."?list.{$field}.".($sort == "desc" ? "asc" : "desc")."'>".$txt."</a>\n";
}
function sc_rss_admin_id()
{
global $row;
return $row['rss_id'];
}
function sc_rss_admin_name()
{
global $row;
return $row['rss_name'];
}
function sc_rss_admin_path()
{
global $row;
return $row['rss_path'];
}
function sc_rss_admin_url()
{
global $row;
return "<a href='".e_PLUGIN."rss_menu/rss.php?".e_LANQRY.$row['rss_url']."'>".$row['rss_url']."</a>";
}
function sc_rss_admin_topicid()
{
global $row;
return $row['rss_topicid'];
}
function sc_rss_admin_limit()
{
global $row, $rs;
$id = $row['rss_id'];
$frm = e107::getForm();
return $frm->number("limit[$id]",$row['rss_limit']);
return "<input class='tbox' type='text' name=\"limit[$id]\" title=\"".RSS_LAN05."\" value='".intval($row['rss_limit'])."' size='3' maxlength='3' />";
}
function sc_rss_admin_limitbutton()
{
$frm = e107::getForm();
return $frm->admin_button('update_limit',LAN_UPDATE,'update');
}
function sc_rss_admin_options()
{
global $row, $tp;
$delname = $row['rss_name'];
$delid = $row['rss_id'];
$options = "
<a href='".e_SELF."?create.edit.".$row['rss_id']."' >".ADMIN_EDIT_ICON."</a>
<input type='image' title=\"".LAN_DELETE."\" name='delete[{$delid}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(LAN_CONFIRMDEL ." [".RSS_LAN_ADMIN_2.": ".$delid." : ".$delname."]\\n\\n")."')\"/>";
return $options;
}
function sc_rss_admin_form_name()
{
global $row;
return "<input class='tbox' type='text' name='rss_name' size='74' value=\"".$row['rss_name']."\" />\n";
}
function sc_rss_admin_form_url()
{
global $row,$PLUGINS_DIRECTORY;
return SITEURL.$PLUGINS_DIRECTORY."rss_menu/rss.php?".e_LANQRY." <input class='tbox' type='text' name='rss_url' size='10' value=\"".$row['rss_url']."\" maxlength='50' /> .{".LAN_TYPE."}.{".RSS_LAN_ADMIN_12."}";
}
function sc_rss_admin_form_topicid()
{
global $row;
return "<input class='tbox' type='text' name='rss_topicid' size='74' value=\"".$row['rss_topicid']."\" maxlength='250' />";
}
function sc_rss_admin_form_path()
{
global $row;
return "<input class='tbox' type='text' name='rss_path' size='74' value=\"".$row['rss_path']."\" maxlength='250' />";
}
function sc_rss_admin_form_text()
{
global $row;
return "<textarea class='tbox' name='rss_text' cols='74' rows='5' >".$row['rss_text']."</textarea>\n";
}
function sc_rss_admin_form_class()
{
global $row;
$vals = array(RSS_LAN_ADMIN_21,RSS_LAN_ADMIN_22,RSS_LAN_ADMIN_23);
$text = "<select class='tbox' name='rss_class'>";
foreach($vals as $key=>$val)
{
$sel = ($row['rss_class'] == $key) ? " selected='selected'" : "";
$text .= "<option value='{$key}'{$sel}>$val</option>\n";
}
$text .= "</select>";
return $text;
}
function sc_rss_admin_form_limit()
{
global $row;
$frm = e107::getForm();
return $frm->number('rss_limit',$row['rss_limit'],3);
return "<input class='tbox' name='rss_limit' size='3' title=\"".RSS_LAN05."\" value='".intval($row['rss_limit'])."' maxlength='3' />";
}
function sc_rss_admin_form_createbutton()
{
global $row;
$qs = explode(".", e_QUERY);
$frm = e107::getForm();
if(isset($qs[1]) && $qs[1] == "edit" && isset($qs[2]) && is_numeric($qs[2]) )
{
$text = "<input type='hidden' name='rss_datestamp' value='".$row['rss_datestamp']."' />
<input type='hidden' name='rss_id' value='".$row['rss_id']."' />";
$text .= $frm->admin_button('update_rss',LAN_UPDATE,'update');
}
else
{
$text = $frm->admin_button('create_rss',LAN_CREATE,'submit');
}
return $text;
}
function sc_rss_admin_import_check()
{
global $feed, $rs, $tp, $i;
if($feed['description'])
{
$feed['text'] = $feed['description'];
}
$text = "<input type='checkbox' name='importid[$i]' value='1' />";
$text .= "<input type='hidden' name='name[$i]' value='".$tp->toForm($feed['name'])."' />";
$text .= "<input type='hidden' name='url[$i]' value='".$tp->toForm($feed['url'])."' />";
$text .= "<input type='hidden' name='topic_id[$i]' value='".$tp->toForm($feed['topic_id'])."' />";
$text .= "<input type='hidden' name='path[$i]' value='".$tp->toForm($feed['path'])."' />";
$text .= "<input type='hidden' name='text[$i]' value='".$tp->toForm($feed['text'])."' />";
$text .= "<input type='hidden' name='class[$i]' value='".$tp->toForm($feed['class'])."' />";
$text .= "<input type='hidden' name='limit[$i]' value='".intval($feed['limit'])."' />";
return $text;
}
function sc_rss_admin_import_path()
{
global $feed;
return $feed['path'];
}
function sc_rss_admin_import_name()
{
global $feed;
return $feed['name'];
}
function sc_rss_admin_import_text()
{
global $feed;
return ($feed['description']) ? $feed['description'] : $feed['text'];
}
function sc_rss_admin_import_url()
{
global $feed;
return $feed['url'];
}
function sc_rss_admin_import_topicid()
{
global $feed;
return $feed['topic_id'];
}
}
else
{
$text = $frm->admin_button('create_rss',LAN_CREATE,'submit');
}
return $text;
SC_END
SC_BEGIN RSS_ADMIN_IMPORT_CHECK
global $feed, $rs, $tp, $i;
if($feed['description'])
{
$feed['text'] = $feed['description'];
}
$text = "<input type='checkbox' name='importid[$i]' value='1' />";
$text .= "<input type='hidden' name='name[$i]' value='".$tp->toForm($feed['name'])."' />";
$text .= "<input type='hidden' name='url[$i]' value='".$tp->toForm($feed['url'])."' />";
$text .= "<input type='hidden' name='topic_id[$i]' value='".$tp->toForm($feed['topic_id'])."' />";
$text .= "<input type='hidden' name='path[$i]' value='".$tp->toForm($feed['path'])."' />";
$text .= "<input type='hidden' name='text[$i]' value='".$tp->toForm($feed['text'])."' />";
$text .= "<input type='hidden' name='class[$i]' value='".$tp->toForm($feed['class'])."' />";
$text .= "<input type='hidden' name='limit[$i]' value='".intval($feed['limit'])."' />";
return $text;
SC_END
SC_BEGIN RSS_ADMIN_IMPORT_PATH
global $feed;
return $feed['path'];
SC_END
SC_BEGIN RSS_ADMIN_IMPORT_NAME
global $feed;
return $feed['name'];
SC_END
SC_BEGIN RSS_ADMIN_IMPORT_TEXT
global $feed;
return ($feed['description']) ? $feed['description'] : $feed['text'];
SC_END
SC_BEGIN RSS_ADMIN_IMPORT_URL
global $feed;
return $feed['url'];
SC_END
SC_BEGIN RSS_ADMIN_IMPORT_TOPICID
global $feed;
return $feed['topic_id'];
SC_END
*/
$rss_shortcodes = new rss_menu_shortcodes;
?>

View File

@@ -7,8 +7,8 @@ if(!isset($RSS_LIST_HEADER))
{
$RSS_LIST_HEADER = "<table class='table table-striped fborder' style='".USER_WIDTH."'>
<tr>
<td class='fcaption' style='width:55%'> </td>
<td class='fcaption' style='text-align:right'>".RSS_PLUGIN_LAN_6."</td>
<th class='fcaption' style='width:55%'> </th>
<th class='fcaption' style='text-align:right'>".RSS_PLUGIN_LAN_6."</th>
</tr>";
}
if(!isset($RSS_LIST_TABLE))