Index: trunk/extensions/uniwiki/Authors/Authors.i18n.php |
— | — | @@ -1,13 +1,16 @@ |
2 | 2 | <?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 | + */ |
5 | 9 | |
6 | | -if (!defined("MEDIAWIKI")) |
7 | | - die(); |
| 10 | +$messages = array(); |
8 | 11 | |
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', |
14 | 17 | ); |
Index: trunk/extensions/uniwiki/Authors/Authors.php |
— | — | @@ -3,52 +3,46 @@ |
4 | 4 | * http://www.mediawiki.org/wiki/Extension:Uniwiki_Authors |
5 | 5 | * http://www.gnu.org/licenses/gpl-3.0.txt */ |
6 | 6 | |
7 | | -if (!defined("MEDIAWIKI")) |
| 7 | +if ( !defined( "MEDIAWIKI" ) ) |
8 | 8 | die(); |
9 | 9 | |
10 | | -/* ---- CREDITS ---- */ |
| 10 | +/* ---- CONFIGURABLE OPTIONS ---- */ |
| 11 | +$wgShowAuthorsNamespaces = array ( NS_MAIN ); |
| 12 | +$wgShowAuthors = true; |
| 13 | + |
11 | 14 | $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', |
15 | 22 | ); |
16 | 23 | |
17 | | -/* ---- INTERNATIONALIZATION ---- */ |
18 | | -require_once ("Authors.i18n.php"); |
19 | | -$wgExtensionFunctions[] = "UW_Authors_i18n"; |
| 24 | +$wgExtensionMessagesFiles['Authors'] = dirname( __FILE__ ) . '/Authors.i18n.php'; |
20 | 25 | |
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 | | - |
32 | 26 | /* ---- HOOKS ---- */ |
33 | 27 | $wgHooks['OutputPageBeforeHTML'][] = "UW_Authors_List"; |
34 | | -function UW_Authors_List (&$out, &$text) { |
| 28 | +function UW_Authors_List ( &$out, &$text ) { |
35 | 29 | global $wgTitle, $wgRequest, $wgShowAuthorsNamespaces, $wgShowAuthors; |
36 | 30 | |
37 | 31 | /* do nothing if the option is disabled |
38 | 32 | * (but why would the extension be enabled?) */ |
39 | | - if (!wgShowAuthors) |
| 33 | + if ( !wgShowAuthors ) |
40 | 34 | return true; |
41 | 35 | |
42 | 36 | // only build authors on namespaces in $wgShowAuthorsNamespaces |
43 | | - if (!in_array ($wgTitle->getNamespace(), $wgShowAuthorsNamespaces)) |
| 37 | + if ( !in_array ( $wgTitle->getNamespace(), $wgShowAuthorsNamespaces ) ) |
44 | 38 | return true; |
45 | 39 | |
46 | 40 | /* get the contribs from the database (don't use the default |
47 | 41 | * MediaWiki one since it ignores the current user) */ |
48 | | - $article = new Article ($wgTitle); |
| 42 | + $article = new Article ( $wgTitle ); |
49 | 43 | $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" ); |
53 | 47 | |
54 | 48 | $sql = "SELECT rev_user, rev_user_text, user_real_name, MAX(rev_timestamp) as timestamp |
55 | 49 | FROM $rev_table LEFT JOIN $user_table ON rev_user = user_id |
— | — | @@ -56,8 +50,8 @@ |
57 | 51 | GROUP BY rev_user, rev_user_text, user_real_name |
58 | 52 | ORDER BY timestamp DESC"; |
59 | 53 | |
60 | | - $results = $db->query ($sql, __METHOD__); |
61 | | - while ($line = $db->fetchObject ($results)) { |
| 54 | + $results = $db->query ( $sql, __METHOD__ ); |
| 55 | + while ( $line = $db->fetchObject ( $results ) ) { |
62 | 56 | $contribs[] = array( |
63 | 57 | $line->rev_user, |
64 | 58 | $line->rev_user_text, |
— | — | @@ -65,36 +59,36 @@ |
66 | 60 | ); |
67 | 61 | } |
68 | 62 | |
69 | | - $db->freeResult ($results); |
| 63 | + $db->freeResult ( $results ); |
70 | 64 | |
71 | 65 | |
72 | 66 | // return if there are no authors |
73 | | - if (sizeof ($results) <= 0) |
| 67 | + if ( sizeof ( $results ) <= 0 ) |
74 | 68 | return true; |
75 | 69 | |
76 | 70 | // 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>"; |
81 | 75 | $anons = 0; |
82 | | - foreach ($contribs as $author) { |
| 76 | + foreach ( $contribs as $author ) { |
83 | 77 | $id = $author[0]; |
84 | 78 | $username = $author[1]; |
85 | 79 | $realname = $author[2]; |
86 | 80 | |
87 | | - if ($id != "0") { // user with an id |
| 81 | + if ( $id != "0" ) { // user with an id |
88 | 82 | $author_link = $realname |
89 | | - ? creditLink($username, $realname) |
90 | | - : creditLink($username); |
| 83 | + ? creditLink( $username, $realname ) |
| 84 | + : creditLink( $username ); |
91 | 85 | $authors .= "<li>$author_link</li>"; |
92 | 86 | } else { // anonymous |
93 | 87 | $anons++; |
94 | 88 | } |
95 | 89 | } |
96 | 90 | // 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>"; |
99 | 93 | $authors .= "</ul></div>"; |
100 | 94 | |
101 | 95 | $text .= $authors; |
Property changes on: trunk/extensions/uniwiki/Authors/Authors.php |
___________________________________________________________________ |
Added: svn:keywords |
102 | 96 | + LastChangedDate LastChangedRevision |