r43019 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43018‎ | r43019 | r43020 >
Date:19:55, 1 November 2008
Author:siebrand
Status:old
Tags:
Comment:
Update for uniwiki/Authors:
* standard i18n
* complete extension credits
* update indentation, remove trailing whitespace, stylize.php
Modified paths:
  • /trunk/extensions/uniwiki/Authors/Authors.i18n.php (modified) (history)
  • /trunk/extensions/uniwiki/Authors/Authors.php (modified) (history)

Diff [purge]

Index: trunk/extensions/uniwiki/Authors/Authors.i18n.php
@@ -1,13 +1,16 @@
22 <?php
3 -/* vim: noet ts=4 sw=4
4 - * http://www.gnu.org/licenses/gpl-3.0.txt */
 3+/**
 4+ * Internationalisation for Uniwiki/Authors extension
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
59
6 -if (!defined("MEDIAWIKI"))
7 - die();
 10+$messages = array();
811
9 -$wgAuthorsMessages = array();
10 -
11 -$wgAuthorsMessages['en'] = array(
12 - 'authors_authors' => "Authors",
13 - 'authors_anonymous' => "Anonymous",
 12+/** English */
 13+$messages['en'] = array(
 14+ 'authors-desc' => 'Appends a list of contributors to articles',
 15+ 'authors_authors' => 'Authors',
 16+ 'authors_anonymous' => 'Anonymous',
1417 );
Index: trunk/extensions/uniwiki/Authors/Authors.php
@@ -3,52 +3,46 @@
44 * http://www.mediawiki.org/wiki/Extension:Uniwiki_Authors
55 * http://www.gnu.org/licenses/gpl-3.0.txt */
66
7 -if (!defined("MEDIAWIKI"))
 7+if ( !defined( "MEDIAWIKI" ) )
88 die();
99
10 -/* ---- CREDITS ---- */
 10+/* ---- CONFIGURABLE OPTIONS ---- */
 11+$wgShowAuthorsNamespaces = array ( NS_MAIN );
 12+$wgShowAuthors = true;
 13+
1114 $wgExtensionCredits['other'][] = array(
12 - 'name' => "Authors",
13 - 'author' => "Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)",
14 - 'description' => "Appends a list of contributors to articles"
 15+ 'name' => 'Authors',
 16+ 'author' => 'Merrick Schaefer, Mark Johnston, Evan Wheeler and Adam Mckaig (at UNICEF)',
 17+ 'description' => 'Appends a list of contributors to articles'
 18+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Uniwiki/Authors',
 19+ 'svn-date' => '$LastChangedDate$',
 20+ 'svn-revision' => '$LastChangedRevision$',
 21+ 'descriptionmsg' => 'authors-desc',
1522 );
1623
17 -/* ---- INTERNATIONALIZATION ---- */
18 -require_once ("Authors.i18n.php");
19 -$wgExtensionFunctions[] = "UW_Authors_i18n";
 24+$wgExtensionMessagesFiles['Authors'] = dirname( __FILE__ ) . '/Authors.i18n.php';
2025
21 -function UW_Authors_i18n() {
22 - // add this extension's messages to the message cache
23 - global $wgMessageCache, $wgAuthorsMessages;
24 - foreach ($wgAuthorsMessages as $lang => $messages)
25 - $wgMessageCache->addMessages ($messages, $lang);
26 -}
27 -
28 -/* ---- CONFIGURABLE OPTIONS ---- */
29 -$wgShowAuthorsNamespaces = array (NS_MAIN);
30 -$wgShowAuthors = true;
31 -
3226 /* ---- HOOKS ---- */
3327 $wgHooks['OutputPageBeforeHTML'][] = "UW_Authors_List";
34 -function UW_Authors_List (&$out, &$text) {
 28+function UW_Authors_List ( &$out, &$text ) {
3529 global $wgTitle, $wgRequest, $wgShowAuthorsNamespaces, $wgShowAuthors;
3630
3731 /* do nothing if the option is disabled
3832 * (but why would the extension be enabled?) */
39 - if (!wgShowAuthors)
 33+ if ( !wgShowAuthors )
4034 return true;
4135
4236 // only build authors on namespaces in $wgShowAuthorsNamespaces
43 - if (!in_array ($wgTitle->getNamespace(), $wgShowAuthorsNamespaces))
 37+ if ( !in_array ( $wgTitle->getNamespace(), $wgShowAuthorsNamespaces ) )
4438 return true;
4539
4640 /* get the contribs from the database (don't use the default
4741 * MediaWiki one since it ignores the current user) */
48 - $article = new Article ($wgTitle);
 42+ $article = new Article ( $wgTitle );
4943 $contribs = array();
50 - $db = wfGetDB (DB_MASTER);
51 - $rev_table = $db->tableName ("revision");
52 - $user_table = $db->tableName ("user");
 44+ $db = wfGetDB ( DB_MASTER );
 45+ $rev_table = $db->tableName ( "revision" );
 46+ $user_table = $db->tableName ( "user" );
5347
5448 $sql = "SELECT rev_user, rev_user_text, user_real_name, MAX(rev_timestamp) as timestamp
5549 FROM $rev_table LEFT JOIN $user_table ON rev_user = user_id
@@ -56,8 +50,8 @@
5751 GROUP BY rev_user, rev_user_text, user_real_name
5852 ORDER BY timestamp DESC";
5953
60 - $results = $db->query ($sql, __METHOD__);
61 - while ($line = $db->fetchObject ($results)) {
 54+ $results = $db->query ( $sql, __METHOD__ );
 55+ while ( $line = $db->fetchObject ( $results ) ) {
6256 $contribs[] = array(
6357 $line->rev_user,
6458 $line->rev_user_text,
@@ -65,36 +59,36 @@
6660 );
6761 }
6862
69 - $db->freeResult ($results);
 63+ $db->freeResult ( $results );
7064
7165
7266 // return if there are no authors
73 - if (sizeof ($results) <= 0)
 67+ if ( sizeof ( $results ) <= 0 )
7468 return true;
7569
7670 // now build a sensible authors display in HTML
77 - require_once ("includes/Credits.php");
78 - $authors = "\n<div class='authors'>".
79 - "<h4>" . wfMsg('authors_authors') . "</h4>".
80 - "<ul>";
 71+ require_once ( "includes/Credits.php" );
 72+ $authors = "\n<div class='authors'>" .
 73+ "<h4>" . wfMsg( 'authors_authors' ) . "</h4>" .
 74+ "<ul>";
8175 $anons = 0;
82 - foreach ($contribs as $author) {
 76+ foreach ( $contribs as $author ) {
8377 $id = $author[0];
8478 $username = $author[1];
8579 $realname = $author[2];
8680
87 - if ($id != "0") { // user with an id
 81+ if ( $id != "0" ) { // user with an id
8882 $author_link = $realname
89 - ? creditLink($username, $realname)
90 - : creditLink($username);
 83+ ? creditLink( $username, $realname )
 84+ : creditLink( $username );
9185 $authors .= "<li>$author_link</li>";
9286 } else { // anonymous
9387 $anons++;
9488 }
9589 }
9690 // add the anonymous entries
97 - if ($anons > 0)
98 - $authors .= "<li>" . wfMsg('authors_anonymous') . "</li>";
 91+ if ( $anons > 0 )
 92+ $authors .= "<li>" . wfMsg( 'authors_anonymous' ) . "</li>";
9993 $authors .= "</ul></div>";
10094
10195 $text .= $authors;
Property changes on: trunk/extensions/uniwiki/Authors/Authors.php
___________________________________________________________________
Added: svn:keywords
10296 + LastChangedDate LastChangedRevision

Status & tagging log