r14204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14203‎ | r14204 | r14205 >
Date:21:52, 13 May 2006
Author:robchurch
Status:old
Tags:
Comment:
* Moved internationalisation into a separate file
* Add absolute limit of 5000 pages, for performance
* Allow the default limit to be customised
* Correct inconsistent documentation
Modified paths:
  • /trunk/extensions/NewestPages/NewestPages (modified) (history)
  • /trunk/extensions/NewestPages/NewestPages.i18n.php (added) (history)
  • /trunk/extensions/NewestPages/NewestPages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/NewestPages/NewestPages
@@ -1,6 +1,6 @@
22 NEWEST PAGES EXTENSION
33
4 - Version 1.1
 4+ Version 1.2
55 © 2006 Rob Church
66
77 This is free software licensed under the GNU General Public Licence. Please
@@ -14,7 +14,9 @@
1515 3. Accessing the special page
1616 4. Including the special page
1717 5. Customising the interface text
18 -6. Change log
 18+6. Customising extension behaviour
 19+7. Notes
 20+8. Change log
1921
2022 == 1. Introduction ==
2123
@@ -25,13 +27,13 @@
2628
2729 == 2. Installing the extension ==
2830
29 -To install the Newest Pages extension, first upload/copy the extension file
30 -NewestPages.php into your MediaWiki extensions directory. Then edit your
31 -LocalSettings.php file and add the following line:
 31+To install the Newest Pages extension, first upload/copy the extension files
 32+NewestPages.php and NewestPages.i18n.php into your MediaWiki extensions directory.
 33+Then edit your LocalSettings.php file and add the following line:
3234
3335 require_once( 'extensions/NewestPages.php' );
3436
35 -Save the file (uploading if applicable) to complete the installation.
 37+Save the file to complete the installation.
3638
3739 == 3. Accessing the special page ==
3840
@@ -61,8 +63,19 @@
6264 the MediaWiki namespace. See Special:Allmessages for a list of customisable
6365 interface messages in the wiki.
6466
65 -== 6. Notes ==
 67+== 6. Customising extension behaviour ==
6668
 69+The default page limit for the extension can be altered using the
 70+$wgNewestPagesLimit variable, e.g.
 71+
 72+ $wgNewestPages = 500;
 73+
 74+sets the default limit to be 500. This should be set after the call
 75+to include the extension file. The default remains at 50 pages, and there
 76+is an absolute limit of 5000 pages, to avoid crippling the database server(s).
 77+
 78+== 7. Notes ==
 79+
6780 This extension was written in a much more specific form to serve the needs of a
6881 user in the #mediawiki IRC channel. Following a second request for a similar
6982 page, I decided to clean up the code, give the page a more generalised function,
@@ -70,7 +83,7 @@
7184
7285 Feedback welcomed at <robchur@gmail.com> as usual.
7386
74 -== 7. Change log ==
 87+== 8. Change log ==
7588
7689 15/04/2006
7790 Version 1.0
@@ -78,4 +91,10 @@
7992
8093 30/04/2006
8194 Version 1.1
82 - * Fix issues when using a table prefix
\ No newline at end of file
 95+ * Fix issues when using a table prefix
 96+
 97+13/05/2006
 98+Version 1.2
 99+ * Moved internationalisation into a separate file
 100+ * Add absolute limit of 5000 pages, for performance
 101+ * Allow the default limit to be customised
\ No newline at end of file
Index: trunk/extensions/NewestPages/NewestPages.i18n.php
@@ -0,0 +1,23 @@
 2+<?php
 3+
 4+/**
 5+ * Internationalisation file for the NewestPages extension
 6+ * @package MediaWiki
 7+ * @subpackage Extensions
 8+ * @author Rob Church <robchur@gmail.com>
 9+ * @copyright © 2006 Rob Church
 10+ * @licence GNU General Public Licence 2.0
 11+ */
 12+
 13+global $wgNewestPagesMessages;
 14+$wgNewestPagesMessages = array(
 15+
 16+'newestpages' => 'Newest pages',
 17+'newestpages-header' => "'''This page lists the $1 newest pages on the wiki.'''",
 18+'newestpages-limitlinks' => 'Show up to $1 pages',
 19+'newestpages-showing' => 'Found $1 pages; listing newest first:',
 20+'newestpages-none' => 'No entries were found.',
 21+
 22+);
 23+
 24+?>
\ No newline at end of file
Property changes on: trunk/extensions/NewestPages/NewestPages.i18n.php
___________________________________________________________________
Added: svn:eol-style
125 + native
Index: trunk/extensions/NewestPages/NewestPages.php
@@ -14,17 +14,15 @@
1515 if( defined( 'MEDIAWIKI' ) ) {
1616
1717 require_once( 'SpecialPage.php' );
 18+ require_once( 'NewestPages.i18n.php' );
1819 $wgExtensionFunctions[] = 'efNewestPages';
1920 $wgExtensionCredits['specialpage'][] = array( 'name' => 'Newest Pages', 'author' => 'Rob Church', 'url' => 'http://meta.wikimedia.org/wiki/Newest_Pages_%28extension%29' );
 21+ $wgNewestPagesLimit = 50;
2022
2123 function efNewestPages() {
22 - global $wgMessageCache;
 24+ global $wgMessageCache, $wgNewestPagesMessages;
 25+ $wgMessageCache->addMessages( $wgNewestPagesMessages );
2326 SpecialPage::addPage( new NewestPages() );
24 - $wgMessageCache->addMessage( 'newestpages', 'Newest pages' );
25 - $wgMessageCache->addMessage( 'newestpages-header', "'''This page lists the $1 newest pages on the wiki.'''" );
26 - $wgMessageCache->addMessage( 'newestpages-limitlinks', 'Show up to $1 pages' );
27 - $wgMessageCache->addMessage( 'newestpages-showing', 'Found $1 pages; listing newest first:' );
28 - $wgMessageCache->addMessage( 'newestpages-none', 'No entries were found.' );
2927 }
3028
3129 class NewestPages extends IncludableSpecialPage {
@@ -63,7 +61,7 @@
6462 }
6563 $dbr->freeResult( $res );
6664 }
67 -
 65+
6866 function setLimit( $par ) {
6967 if( $par ) {
7068 $this->limit = intval( $par );
@@ -75,6 +73,7 @@
7674 $this->limit = 50;
7775 }
7876 }
 77+ $this->limit = min( $this->limit, 5000 );
7978 }
8079
8180 function makeListItem( $row ) {

Status & tagging log