[Pkg-mediawiki-commits] r418 - unversioned/RSS_Reader

Thorsten Glaser tg at alioth.debian.org
Sat Dec 29 22:31:00 UTC 2012


Author: tg
Date: 2012-12-29 22:31:00 +0000 (Sat, 29 Dec 2012)
New Revision: 418

Modified:
   unversioned/RSS_Reader/INFO
   unversioned/RSS_Reader/RSSReader.php
Log:
I put this into MediaWiki as
http://www.mediawiki.org/w/index.php?title=Extension:RSS_Reader&oldid=622104


Modified: unversioned/RSS_Reader/INFO
===================================================================
--- unversioned/RSS_Reader/INFO	2012-12-29 22:26:04 UTC (rev 417)
+++ unversioned/RSS_Reader/INFO	2012-12-29 22:31:00 UTC (rev 418)
@@ -6,7 +6,9 @@
 
 Author and licencing information:
 
-RSS_Reader is Copyright © 2008 Artem Kaznatcheev (Mediawiki user DFRussia)
+RSS_Reader is
+Copyright © 2008 Artem Kaznatcheev (Mediawiki user DFRussia)
+Copyright © 2012 Thorsten Glaser (Mediawiki user mirabilos)
 and covered by the terms of the GNU GPL, version 2 or later.
 
 

Modified: unversioned/RSS_Reader/RSSReader.php
===================================================================
--- unversioned/RSS_Reader/RSSReader.php	2012-12-29 22:26:04 UTC (rev 417)
+++ unversioned/RSS_Reader/RSSReader.php	2012-12-29 22:31:00 UTC (rev 418)
@@ -1,6 +1,7 @@
 <?php
-/* RSSReader 0.2.5 - a parser hook for MediaWiki
+/* RSSReader 0.2.6 - a parser hook for MediaWiki
  * Copyright © 2008  Artem Kaznatcheev
+ * Copyright © 2012  Thorsten Glaser
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,10 +23,11 @@
 }
 
 $wgExtensionFunctions[] = 'efRSSReader';
+$wgRSSReaderExtVersion = '0.2.6';
 
 $wgExtensionCredits['parserhook'][] = array(
 	'name' => 'RSS Reader',
-	'version' => '0.2.5',
+	'version' => $wgRSSReaderExtVersion,
 	'author' => 'Artem Kaznatcheev',
 	'description' => 'Adds <tt><rss></tt> tag',
 	'url' => 'http://www.mediawiki.org/wiki/Extension:RSS_Reader'
@@ -33,11 +35,12 @@
 
 ### Global Variables ###
 //path to follow for server scripts
-$egRSSReaderPath  = $wgScriptPath."/extensions/RSSReader";
+$egRSSReaderPath  = $wgScriptPath."/extensions/RSS_Reader";
 $egCacheTime      = 3600; //default cache time in seconds
 $egCacheTimeMin   = 1800; //minimum cache time in seconds
 $egCacheTimeMax   = 7200; //maximum cache time in seconds
 $egCache          = true; //boolean to determine if caching should be done
+$egCacheDir       = dirname( __FILE__ ).'/cache/'; //directory of cache
 //boolean to determine if links created should have rel="nofollow"
 $egNoFollow       = false;
 $egWidthMin       = 200;  //minimim width in pixels
@@ -69,6 +72,7 @@
 
 function efCreateRSSReader($input, $argv, $parser){
   global $wgOut, $egRSSReaderPath, $egCacheTime, $egCacheTimeMin,
+    $egCacheDir, $wgRSSReaderExtVersion,
     $egCacheTimeMax, $egCache, $rssType, $egNoFollow, $egWidthMin,
     $egWidthMax;
 
@@ -152,17 +156,20 @@
       if ($argv["title"]=="off") $dispTitle = false;
     }
 
-    $wgOut->addScript('<link rel="stylesheet" type="text/css" href="'.
-      $egRSSReaderPath.'/RSSReader.css" />'); //add CSS
+    $wgOut->addLink(array(
+	'rel' => 'stylesheet',
+	'type' => 'text/css',
+	'href' => "$egRSSReaderPath/RSSReader.css?$wgRSSReaderExtVersion",
+    ));
 
     if (!$width) {
       $output = '
-        <table  style="background: inherit;"; id="RSSMainBody">
+        <table class="RSSMainBody" style="background:inherit;">
         <tr>
       ';
     } else {
       $output = '
-        <table id="RSSMainBody" style="background: inherit;float:right;width:'.$width.'">
+        <table class="RSSMainBody" style="background:inherit; float:right; width:'.$width.'">
         <tr>
       ';
     }
@@ -173,8 +180,8 @@
     // Create cURLRSS or wikiRSS or lastRSS object
     $rss = new $rssType; //initialize an object of rssType
     // Set public variables
-    if (is_a($rssType, 'lastRSS') && $egCache) {
-      $rss->cache_dir = dirname( __FILE__ ).'/cache/'; //directory of cache
+    if (($rssType instanceof lastRSS) && $egCache) {
+      $rss->cache_dir = $egCacheDir;
     }
     $rss->cache = $egCache; //cache attribute
     $rss->cache_time = $cacheTime; //refresh time in seconds
@@ -183,7 +190,7 @@
     foreach ($fields as $field) {
       //table cell that contains a single RSS feed
       $output .= '<td valign="top" style="width: '.$width.'%;">';
-      if ($rssArray = $rss->get($field)){
+      if (($rssArray = $rss->get($field)) && (isset($rssArray['link']) || isset($rssArray['title']) || isset($rssArray['description']))) {
         if ($dispTitle) { //check if title should be displayed
           $output .=
             '<div class="RSSReader-head">'.
@@ -209,10 +216,15 @@
           $output .= '<a href="'.$item['link'].'" ';
           //decide if nofollow is needed
           if ($egNoFollow) $output .= 'rel="nofollow"';
-          $item_title=preg_replace("|\[rsslist:.+?\]|", "", $rss->unhtmlentities($item['title']));
+          $item_title=preg_replace("|\[rsslist:.+?\]|", "",
+            htmlspecialchars(html_entity_decode(html_entity_decode($item['title'],
+            ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8"));
           $output .= '>'.$item_title.'</a>';
           if ($text) {
-            $desc = preg_replace("|\[rsslist:.+?\]|", "", $rss->unhtmlentities($item['description']));
+            $desc = preg_replace("|\[rsslist:.+?\]|", "",
+              Sanitizer::removeHTMLtags(html_entity_decode($item['description'],
+              ENT_QUOTES, "UTF-8"), null, array(),
+              array('a', /* does not work */ 'img')));
             $output .= "</h3>\n$desc</div>\n";
           } else $output .= "</li>\n";
           /*if reached the number of desired display items stop working on




More information about the Pkg-mediawiki-commits mailing list