r43010 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43009‎ | r43010 | r43011 >
Date:18:29, 1 November 2008
Author:brion
Status:old
Tags:
Comment:
cleanup a little
Modified paths:
  • /trunk/extensions/ContributionReporting/ContributionReporting.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/ContributionReporting.php
@@ -2,51 +2,62 @@
33
44 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
55 if (!defined('MEDIAWIKI')) {
6 - echo <<<EOT
 6+ echo <<<EOT
77 To install my extension, put the following line in LocalSettings.php:
88 require_once( "\$IP/extensions/ContributionReporting/ContributionReporting.php" );
99 EOT;
10 - exit( 1 );
 10+ exit( 1 );
1111 }
12 -
 12+
 13+// Override these with appropriate DB settings for the CiviCRM database...
 14+$wgContributionReportingDBserver = $wgDBserver;
 15+$wgContributionReportingDBuser = $wgDBuser;
 16+$wgContributionReportingDBpassword = $wgDBpassword;
 17+$wgContributionReportingDBname = $wgDBname;
 18+
1319 $dir = dirname(__FILE__) . '/';
14 -
15 -$wgHooks['LanguageGetSpecialPageAliases'][] = 'contributionReportingLocalizedPageName'; # Add any aliases for the special page.
1620
 21+// Add any aliases for the special page.
 22+$wgHooks['LanguageGetSpecialPageAliases'][] = 'contributionReportingLocalizedPageName';
 23+
1724 $wgExtensionMessagesFiles['ContributionHistory'] = $dir . 'ContributionHistory.i18n.php';
18 -$wgAutoloadClasses['ContributionHistory'] = $dir . 'ContributionHistory_body.php'; # Tell MediaWiki to load the extension body.
19 -$wgSpecialPages['ContributionHistory'] = 'ContributionHistory'; # Let MediaWiki know about your new special page.
 25+$wgAutoloadClasses['ContributionHistory'] = $dir . 'ContributionHistory_body.php';
 26+$wgSpecialPages['ContributionHistory'] = 'ContributionHistory';
2027
2128 $wgExtensionMessagesFiles['ContributionTotal'] = $dir . 'ContributionTotal.i18n.php';
22 -$wgAutoloadClasses['ContributionTotal'] = $dir . 'ContributionTotal_body.php'; # Tell MediaWiki to load the extension body.
23 -$wgSpecialPages['ContributionTotal'] = 'ContributionTotal'; # Let MediaWiki know about your new special page.
 29+$wgAutoloadClasses['ContributionTotal'] = $dir . 'ContributionTotal_body.php';
 30+$wgSpecialPages['ContributionTotal'] = 'ContributionTotal';
2431
2532 function contributionReportingLocalizedPageName(&$specialPageArray, $code) {
26 - # The localized title of the special page is among the messages of the extension:
27 - wfLoadExtensionMessages('ContributionHistory');
28 - $text = wfMsg('contributionhistory');
29 -
30 - # Convert from title in text form to DBKey and put it into the alias array:
31 - $title = Title::newFromText($text);
32 - $specialPageArray['ContributionHistory'][] = $title->getDBKey();
33 -
34 - wfLoadExtensionMessages('ContributionTotal');
35 - $text = wfMsg('contributiontotal');
36 - $title = Title::newFromText($text);
37 - $specialPageArray['ContributionTotal'][] = $title->getDBKey();
38 -
39 - return true;
 33+ # The localized title of the special page is among the messages of the extension:
 34+ wfLoadExtensionMessages('ContributionHistory');
 35+ $text = wfMsg('contributionhistory');
 36+
 37+ # Convert from title in text form to DBKey and put it into the alias array:
 38+ $title = Title::newFromText($text);
 39+ $specialPageArray['ContributionHistory'][] = $title->getDBKey();
 40+
 41+ wfLoadExtensionMessages('ContributionTotal');
 42+ $text = wfMsg('contributiontotal');
 43+ $title = Title::newFromText($text);
 44+ $specialPageArray['ContributionTotal'][] = $title->getDBKey();
 45+
 46+ return true;
4047 }
4148
4249 function contributionReportingConnection() {
43 - global $wgContributionReportingDBserver, $wgContributionReportingDBname;
44 - global $wgContributionReportingDBuser, $wgContributionReportingDBpassword;
45 -
46 - static $db;
47 -
48 - if (!$db) {
49 - $db = new DatabaseMysql($wgContributionReportingDBserver, $wgContributionReportingDBuser, $wgContributionReportingDBpassword, $wgContributionReportingDBname);
50 - }
51 -
52 - return $db;
 50+ global $wgContributionReportingDBserver, $wgContributionReportingDBname;
 51+ global $wgContributionReportingDBuser, $wgContributionReportingDBpassword;
 52+
 53+ static $db;
 54+
 55+ if (!$db) {
 56+ $db = new DatabaseMysql(
 57+ $wgContributionReportingDBserver,
 58+ $wgContributionReportingDBuser,
 59+ $wgContributionReportingDBpassword,
 60+ $wgContributionReportingDBname );
 61+ }
 62+
 63+ return $db;
5364 }

Status & tagging log