Extension:RSS Reader

This RSS Reader extension tries to provide a tool for including RSS feeds inside various articles across your wiki. It is best used on specialty pages made so that users can easily track the news, etc. This extension was made because all the other RSS extensions did not work or performed poorly on MediaWiki 1.10.

Usage
This extension is a parser extension and thus is used by the wiki users. The function adds an   tag to use inside articles. Some modification of its behaviour is possible from LocalSettings.php as well

LocalSettings.php
All the global variables used by the extension and modifiable by the user are listed here. If you modify these variables do so after the require_once statement:
 * $egCache
 * The boolean value that determines if caching should be done or not


 * $egCacheTime
 * The default amount of time (in seconds) between cachings of a feed. By default it is set to 3600 (1 hour). If a user does not specify a time argument or their argument is somehow corrupt, this value will be used.


 * $egCacheTimeMin
 * The minimum amount of time (in seconds) between cachings of a feed. By default it is set to 1800 (30 minutes). This is the most often a user can ask a feed to be refetched. Settings this time too low on busy servers might eat up a lot of server resources


 * $egCacheTimeMax
 * The maximum amount of time (in seconds) between cachings of a feed. By default it is set to 7200 (2 hours). This is the least often a user can ask a feed to be refetched.

The tag
The custom tag is called  . For instance, if you put  http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml  then you will create a feed to BBC World news. You can add more than one feed in a single   tag to have them display in columns. Do so by adding "|" between the feed urls. Thus,  firsturl|secondurl|thirdurl  will create a reader with 3 columns, displaying items from all 3 feeds.

number
By default, the reader will display all the items in the feed. If you want to display upto a maximum of a certain number of items, then add number=n (where n is the max number) inside the rss tag:  http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml  will display the last 10 stories from BBC World.

time
By default, the reader will take the value of $egCacheTime as the amount of time (in seconds) between each local caching of the RSS feed. If you want a certain feed to refresh its cache more or less frequently, then add time=t (where t is the refresh time in seconds) inside the rss tag:  http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml  will refresh the cach of stories from BBC World every 7200 seconds (2 hours).

The max and min time allowed for the time argument is governed by $egCacheTimeMin and $egCacheTimeMax in LocalSettings.php. If the specified time falls outside this range, then it will revert to the default $egCacheTime value.

Installing
If you want to install RSS Reader to use database-centric caching instead of file-centric caching, refer to alternative RSS parser below.
 * 1) Create a folder called RSSReader in your extensions directory
 * 2) Download the lastRSScode and save it in your newly created folder as lastRSS.php
 * 3) Create a file called RSSReader.php in your new folder
 * 4) Copy and paste the RSSReader.php code into your new file
 * 5) Create a file called RSSReader.css in your new folder
 * 6) Copy and paste the RSSReader.css code into your new file
 * 7) Create a folder called cache in your RSSReader folder
 * 8) In LocalSettings.php, add the following line:
 * 9) Modify RSSReader.css to your liking to better fit your skin

RSSReader.php
"; } //close main "else"  return $output; } ?>

Alternative RSS Parser
If you do not want to (or can't) use files for caching, then an alternative to lastRSS exists. The alternative, wikiRSS, is not recomended since benchmarks have shown it to be upto three times slower (not a super big deal, since both are fast but still a concern).

Possible Issues
There is very little error checking in this code, since it was made for one specific use. Therefore, it is possible to run into a number of issues or errors that you would have to fix yourself or report in the discussion section of this article.

Different Directory
If you do not install this code in $IP/extensions/RSSReader/ then there could be some issues. If the RSSReader.css file is not placed in $IP/extensions/RSSReader/ then you should add a new remote path name to LocalSettings.php. For reference, the default value is: Do not forget the $wgScriptPath at the start of the path.

RSSReader.php and lastRSS.php have less restrictions on them than RSSReader.css. The only thing you need to insure is that the two files are in the same directory, and RSSReader.php is properly linked to from LocalSettings.php

Warnings

 * This extension turns off parser caching for all the pages on which the   tag is present. This could result in server strain if rss tags are present on many high traffic pages.

Warning: Cannot modify header information
This bug happens when there is extra whitespace at the end of a file (most commonly lastRSS.php). Make sure there are no trailing spaces or linebreaks after the closing php tag (?>).

Acknowledgement

 * lastRSS.php was not written by the author of this extension. lastRSS.php was written by Vojtech Semecky and licensed under GPL. If you want more information about lastRSS.php check it's site

0.2.1

 * Added recognition if wikiRSS or lastRSS is present
 * Added dynamic object loading (wikiRSS or lastRSS)
 * Added $egCache global variable to determine if caching should be done
 * Moved object initialization outside of fields for loop
 * Fixed an error in the error output to show the url
 * Improvement to comments and white space placing

0.2

 * Added license
 * Decoupled HTML and CSS (creating a seperate file for the CSS)
 * Gave more flexible control over time between cache
 * added new "time" attribute inside tag
 * Improved commenting in code
 * Improved error checking

Future Improvements

 * Expand on error checking
 * Provide more options for the user both inside the article and from LocalSettings.php
 * Find alternative caching strategies