r37400 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37399‎ | r37400 | r37401 >
Date:16:05, 9 July 2008
Author:yaron
Status:old
Tags:
Comment:
Added autoloading of classes and language values; simplified language
retrieval (extension now requires MW 1.11 or higher)
Modified paths:
  • /trunk/extensions/DataTransfer/includes/DT_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransfer/includes/DT_GlobalFunctions.php
@@ -13,59 +13,25 @@
1414 define('DT_SP_HAS_XML_GROUPING', 1);
1515 define('DT_SP_IS_EXCLUDED_FROM_XML', 2);
1616
17 -$wgExtensionFunctions[] = 'dtgSetupExtension';
 17+$wgExtensionCredits['specialpage'][]= array(
 18+ 'name' => 'Data Transfer',
 19+ 'version' => DT_VERSION,
 20+ 'author' => 'Yaron Koren',
 21+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Data_Transfer',
 22+ 'description' => 'Exports wiki pages as XML, using template calls as the data structure',
 23+ 'descriptionmsg' => 'dt-desc',
 24+);
1825
1926 $dtgIP = $IP . '/extensions/DataTransfer';
20 -require_once($dtgIP . '/languages/DT_Language.php');
2127
22 -if (version_compare($wgVersion, '1.11', '>=' )) {
23 - $wgExtensionMessagesFiles['DataTransfer'] = $dtgIP . '/languages/DT_Messages.php';
24 -} else {
25 - $wgExtensionFunctions[] = 'dtfLoadMessagesManually';
26 -}
 28+// register all special pages and other classes
 29+$wgSpecialPages['ViewXML'] = 'DTViewXML';
 30+$wgAutoloadClasses['DTViewXML'] = $dtgIP . '/specials/DT_ViewXML.php';
2731
28 -/**
29 - * Do the actual intialisation of the extension. This is just a delayed init that makes sure
30 - * MediaWiki is set up properly before we add our stuff.
31 - */
32 -function dtgSetupExtension() {
33 - global $dtgIP, $dtgVersion, $dtgNamespace;
34 - global $wgVersion, $wgLanguageCode, $wgExtensionCredits;
 32+require_once($dtgIP . '/languages/DT_Language.php');
 33+$wgExtensionMessagesFiles['DataTransfer'] = $dtgIP . '/languages/DT_Messages.php';
3534
36 - if (version_compare($wgVersion, '1.11', '>='))
37 - wfLoadExtensionMessages('DataTransfer');
38 -
39 - dtfInitContentLanguage($wgLanguageCode);
40 -
41 - /**********************************************/
42 - /***** register specials *****/
43 - /**********************************************/
44 - require_once($dtgIP . '/specials/DT_ViewXML.php');
45 -
46 - /**********************************************/
47 - /***** register hooks *****/
48 - /**********************************************/
49 -
50 - /**********************************************/
51 - /***** credits (see "Special:Version") *****/
52 - /**********************************************/
53 - $wgExtensionCredits['specialpage'][]= array(
54 - 'name' => 'Data Transfer',
55 - 'version' => DT_VERSION,
56 - 'author' => 'Yaron Koren',
57 - 'url' => 'http://www.mediawiki.org/wiki/Extension:Data_Transfer',
58 - 'description' => 'Exports wiki pages as XML, using template calls as the data structure',
59 - 'descriptionmsg' => 'dt-desc',
60 - );
61 -
62 - return true;
63 -}
64 -
6535 /**********************************************/
66 -/***** namespace settings *****/
67 -/**********************************************/
68 -
69 -/**********************************************/
7036 /***** language settings *****/
7137 /**********************************************/
7238
@@ -120,20 +86,6 @@
12187 }
12288 }
12389
124 -/**
125 - * Setting of message cache for versions of MediaWiki that do not support
126 - * wgExtensionMessagesFiles
127 - */
128 -function dtfLoadMessagesManually() {
129 - global $dtgIP, $wgMessageCache;
130 -
131 - # add messages
132 - require($dtgIP . '/languages/DT_Messages.php');
133 - foreach($messages as $key => $value) {
134 - $wgMessageCache->addMessages($messages[$key], $key);
135 - }
136 -}
137 -
13890 /**********************************************/
13991 /***** other global helpers *****/
14092 /**********************************************/

Status & tagging log