r53570 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53569‎ | r53570 | r53571 >
Date:22:50, 20 July 2009
Author:minuteelectron
Status:deferred
Tags:
Comment:
Wikidata:
* Clean up include point.
* Remove hack for OmegaWikiAttributes .
Modified paths:
  • /trunk/extensions/Wikidata/App.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php (modified) (history)
  • /trunk/extensions/Wikidata/SpecialLanguages.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/App.php
@@ -1,34 +1,50 @@
22 <?php
33
4 -# DO NOT EDIT THIS FILE DIRECTLY. INSTEAD, COPY RELEVANT
5 -# CONFIGURATION VARIABLES TO LocalApp.php AND EDIT THEM
6 -# THERE.
 4+if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' );
75
8 -/**
9 - * Protect against register_globals vulnerabilities.
10 - * This line must be present before any global variable is referenced.
11 - */
12 -if ( !defined( 'MEDIAWIKI' ) ) die();
 6+$wgExtensionCredits['other'][] = array(
 7+ 'path' => __FILE__,
 8+ 'name' => 'Wikidata',
 9+ 'version' => '1.0.0',
 10+ 'author' => array(
 11+ 'Erik Möller',
 12+ 'Kim Bruning',
 13+ 'Maarten van Hoof',
 14+ 'André Malafaya Baptista'
 15+ ),
 16+ 'url' => 'http://meta.wikimedia.org/wiki/Wikidata',
 17+ 'description' => 'Adds wiki-like database for various types of content.',
 18+ 'descriptionmsg' => 'wikidata-desc',
 19+);
1320
14 -$wgDefaultGoPrefix = 'Expression:';
 21+$dir = dirname( __FILE__ ) . '/';
 22+
 23+$wgExtensionFunctions[] = 'initializeWikidata';
1524 $wgHooks['BeforePageDisplay'][] = 'addWikidataHeader';
16 -# $wgHooks['GetEditLinkTrail'][]='addWikidataEditLinkTrail'; # non-standard hook; merged with modifyTabs
17 -# $wgHooks['GetHistoryLinkTrail'][]='addHistoryLinkTrail'; # non-standard hook; merged with modifyTabs
1825 $wgHooks['SkinTemplateTabs'][] = 'modifyTabs';
1926 $wgHooks['GetPreferences'][] = 'wfWikiDataGetPreferences';
20 -$wgExtensionFunctions[] = 'initializeWikidata';
 27+$wgAutoloadClasses['ApiWikiData'] = $dir . '/extensions/Wikidata/includes/api/ApiWikiData.php';
 28+$wgAutoloadClasses['ApiWikiDataFormatBase'] = $dir . '/extensions/Wikidata/includes/api/ApiWikiDataFormatBase.php';
 29+$wgAutoloadClasses['ApiWikiDataFormatXml'] = $dir . '/extensions/Wikidata/includes/api/ApiWikiDataFormatXml.php';
 30+$wgAPIModules['wikidata'] = 'ApiWikiData';
 31+$wgExtensionMessagesFiles['Wikidata'] = $dir . 'SpecialLanguages.i18n.php';
2132
22 -$wgCustomHandlerPath = array( '*' => "{$IP}/extensions/Wikidata/OmegaWiki/" );
23 -$wgDefaultClassMids = array( 402295 );
 33+# FIXME: These should be modified to make Wikidata more reusable.
 34+$wgAvailableRights[] = 'editwikidata-uw';
 35+$wgAvailableRights[] = 'wikidata-copy';
 36+$wgGroupPermissions['wikidata-omega']['editwikidata-uw'] = true;
 37+$wgGroupPermissions['wikidata-copy']['wikidata-copy'] = true;
 38+$wgGroupPermissions['wikidata-omega']['wikidata-copy'] = true;
2439
25 -# Register the classes needed for the wikidata api with the autoloader.
26 -$wgAutoloadClasses['ApiWikiData'] = "{$IP}/extensions/Wikidata/includes/api/ApiWikiData.php";
27 -$wgAutoloadClasses['ApiWikiDataFormatBase'] = "{$IP}/extensions/Wikidata/includes/api/ApiWikiDataFormatBase.php";
28 -$wgAutoloadClasses['ApiWikiDataFormatXml'] = "{$IP}/extensions/Wikidata/includes/api/ApiWikiDataFormatXml.php";
 40+// Wikidata Configuration.
2941
30 -# Add the API module
31 -$wgAPIModules['wikidata'] = 'ApiWikiData';
 42+# Removed as part of migration from branch to trunk.
 43+# $wgCustomHandlerPath = array( '*' => "{$IP}/extensions/Wikidata/OmegaWiki/" );
3244
 45+# Array of namespace ids and the handler classes they use.
 46+//$wdHandlerClasses = array();
 47+# Path to the handler class directory, will be deprecated in favor of autoloading shortly.
 48+//$wdHandlerPath = '';
3349
3450 # The term dataset prefix identifies the Wikidata instance that will
3551 # be used as a resource for obtaining language-independent strings
@@ -46,50 +62,38 @@
4763 $wdShowCopyPanel = false;
4864 $wdShowEditCopy = true;
4965
 66+# FIXME: These should be modified to make Wikidata more reusable.
5067 $wdGroupDefaultView = array();
51 -# Here you can set group defaults.
52 -
5368 $wdGroupDefaultView['wikidata-omega'] = 'uw';
5469 # $wdGroupDefaultView['wikidata-umls']='umls';
5570 # $wdGroupDefaultView['wikidata-sp']='sp';
5671
57 -# These are the user groups
58 -$wgGroupPermissions['wikidata-omega']['editwikidata-uw'] = true;
59 -# $wgGroupPermissions['wikidata-test']['editwikidata-tt']=true;
60 -$wgGroupPermissions['wikidata-copy']['wikidata-copy'] = true;
61 -$wgGroupPermissions['wikidata-omega']['wikidata-copy'] = true;
62 -$wgAvailableRights[] = 'editwikidata-uw';
63 -$wgAvailableRights[] = 'wikidata-copy';
 72+$wgCommunity_dc = 'uw';
 73+$wgCommunityEditPermission = 'editwikidata-uw';
6474
65 -# The permission needed to do ...
66 -$wgCommunity_dc = "uw";
67 -$wgCommunityEditPermission = "editwikidata-uw"; # only used for copy for now
68 -global $wdTesting;
69 -$wdTesting = false; # useful when testing, use as needed
7075 $wdCopyAltDefinitions = false;
71 -$wdCopyDryRunOnly = false; # Copy.php:
72 - # If true: do everything needed to
73 - # make a copy, but do not actually
74 - # write to the database.
 76+$wdCopyDryRunOnly = false;
7577
 78+# FIXME: Should be renamed to prefix with wd rather than wg.
 79+$wgShowClassicPageTitles = false;
 80+$wgDefinedMeaningPageTitlePrefix = '';
 81+$wgExpressionPageTitlePrefix = 'Multiple meanings';
7682
 83+// Hacks?
 84+$wgDefaultGoPrefix = 'Expression:';
 85+$wgDefaultClassMids = array( 402295 );
 86+
 87+require_once( "$IP/extensions/Wikidata/OmegaWiki/GotoSourceTemplate.php" );
 88+$wgGotoSourceTemplates = array( 5 => $swissProtGotoSourceTemplate );
 89+
7790 # The site prefix allows us to have multiple sets of customized
7891 # messages (for different, typically site-specific UIs)
7992 # in a single database.
8093 if ( !isset( $wdSiteContext ) ) $wdSiteContext = "uw";
8194
82 -$wgShowClassicPageTitles = false;
83 -$wgDefinedMeaningPageTitlePrefix = "";
84 -$wgExpressionPageTitlePrefix = "Multiple meanings";
85 -require_once( "$IP/extensions/Wikidata/OmegaWiki/GotoSourceTemplate.php" );
86 -
87 -$dir = dirname( __FILE__ ) . '/';
88 -$wgExtensionMessagesFiles['Wikidata'] = $dir . 'SpecialLanguages.i18n.php';
89 -
90 -$wgGotoSourceTemplates = array( 5 => $swissProtGotoSourceTemplate );
91 -
92 -#require_once( "{$IP}/extensions/Wikidata/AddPrefs.php" );
9395 require_once( "{$IP}/extensions/Wikidata/SpecialLanguages.php" );
 96+
 97+# FIXME: These should be migrated to make Wikidata more reusable.
9498 require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialSuggest.php" );
9599 require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialSelect.php" );
96100 require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php" );
@@ -101,24 +105,23 @@
102106 require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialCopy.php" );
103107 require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialExportTSV.php" );
104108 require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialImportTSV.php" );
 109+
105110 require_once( "{$IP}/extensions/Wikidata/LocalApp.php" );
106111
107 -function addWikidataHeader() {
108 - global $wgOut, $wgScriptPath;
109 - $dc = wdGetDataSetContext();
110 - $wgOut->addScript( "<script type='text/javascript' src='{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.js'></script>" );
 112+# FIXME: This should be migrated to make Wikidata more reusable.
 113+function addWikidataHeader( &$out, &$skin ) {
 114+ global $wgScriptPath;
 115+ $out->addScript( "<script type='text/javascript' src='$wgScriptPath/extensions/Wikidata/OmegaWiki/suggest.js'></script>" );
111116
112117 global $wgLang;
113 - if ( $wgLang->isRTL() )
114 - {
115 - $wgOut->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => "{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest-rtl.css" ) );
116 - $wgOut->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => "{$wgScriptPath}/extensions/Wikidata/OmegaWiki/tables-rtl.css" ) );
 118+ if ( $wgLang->isRTL() ) {
 119+ $rtl = '-rtl';
 120+ } else {
 121+ $rtl = '';
117122 }
118 - else
119 - {
120 - $wgOut->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => "{$wgScriptPath}/extensions/Wikidata/OmegaWiki/suggest.css" ) );
121 - $wgOut->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => "{$wgScriptPath}/extensions/Wikidata/OmegaWiki/tables.css" ) );
122 - }
 123+
 124+ $out->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => "$wgScriptPath/extensions/Wikidata/OmegaWiki/suggest$rtl.css" ) );
 125+ $out->addLink( array( 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => "$wgScriptPath/extensions/Wikidata/OmegaWiki/tables$rtl.css" ) );
123126 return true;
124127 }
125128
@@ -155,7 +158,7 @@
156159 * @param $tabs as passed by MW
157160 */
158161 function modifyTabs( $skin, $content_actions ) {
159 - global $wgUser, $wgTitle, $wdTesting, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses;
 162+ global $wgUser, $wgTitle, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses;
160163 $dc = wdGetDataSetContext();
161164 $ns = $wgTitle->getNamespace();
162165 $editChanged = false;
@@ -168,20 +171,19 @@
169172 $dmid = ( $rpos1 && $rpos2 ) ? substr( $tt, $rpos1 + 1, $rpos2 - $rpos1 - 1 ) : 0;
170173 if ( $dmid ) {
171174 $copyTitle = SpecialPage::getTitleFor( 'Copy' );
172 - # if(wdIsWikidataNs() && (!$wgUser->isAllowed('editwikidata-'.$dc) || $wdTesting)) {
173175 if ( wdIsWikidataNs() && $dc != $wgCommunity_dc && $wdShowEditCopy ) {
174176 $editChanged = true;
175177 $content_actions['edit'] = array(
176 - 'class' => false,
177 - 'text' => wfMsg( 'ow_nstab_edit_copy' ),
178 - 'href' => $copyTitle->getLocalUrl( "action=copy&dmid=$dmid&dc1=$dc&dc2=$wgCommunity_dc" )
179 - );
 178+ 'class' => false,
 179+ 'text' => wfMsg( 'ow_nstab_edit_copy' ),
 180+ 'href' => $copyTitle->getLocalUrl( "action=copy&dmid=$dmid&dc1=$dc&dc2=$wgCommunity_dc" )
 181+ );
180182 }
181 - $content_actions['nstab-definedmeaning'] = array(
 183+ $content_actions['nstab-definedmeaning'] = array(
182184 'class' => 'selected',
183185 'text' => wfMsg( 'ow_nstab_definedmeaning' ),
184 - 'href' => $wgTitle->getLocalUrl( "dataset=$dc" ) );
185 -
 186+ 'href' => $wgTitle->getLocalUrl( "dataset=$dc" )
 187+ );
186188 }
187189 }
188190
@@ -197,26 +199,17 @@
198200 }
199201
200202 function initializeWikidata() {
201 - global $wdSiteContext, $wgPropertyToColumnFilters;
202 -
203203 wfLoadExtensionMessages( 'Wikidata' );
204204
205205 $dbr =& wfGetDB( DB_MASTER );
206 - $dbr->query( "SET NAMES utf8" );
207 -
208 - # FIXME: Temporary hack to ensure OmegaWikiAttributes does not exception.
209 - global $messageCacheOK;
210 - $messageCacheOK = true;
211 -
212 - global
213 - $wgRecordSetLanguage;
214 -
 206+ $dbr->query( 'SET NAMES utf8' );
 207+
 208+ global $wgRecordSetLanguage;
215209 $wgRecordSetLanguage = 0;
216 -
217 - # malafaya: Set RTL according to user language
 210+
218211 global $wgLang, $wgOut;
219 - if ( $wgLang->isRTL() )
220 - {
 212+ if ( $wgLang->isRTL() ) {
 213+ # FIXME: Why are we including Gadget CSS here, this is Wikidata?
221214 $wgOut->addHTML( '<style type="text/css">/*<![CDATA[*/ @import "/index.php?title=MediaWiki:Gadget-rtl.css&action=raw&ctype=text/css"; /*]]>*/</style>' );
222215 }
223216
@@ -225,7 +218,7 @@
226219
227220 function wfWikiDataGetPreferences( $user, &$preferences ) {
228221 $datasets = wdGetDatasets();
229 - # $datasetarray[wfMsgHtml( 'ow_none_selected' )] = '';
 222+ $datasetarray[wfMsgHtml( 'ow_none_selected' )] = '';
230223 foreach ( $datasets as $datasetid => $dataset ) {
231224 $datasetarray[$dataset->fetchName()] = $datasetid;
232225 }
Index: trunk/extensions/Wikidata/SpecialLanguages.i18n.php
@@ -10,6 +10,8 @@
1111 /** English
1212 */
1313 $messages['en'] = array(
 14+ 'wikidata-desc' => 'Adds wiki-like database for various types of content.',
 15+
1416 'languages' => 'Wikidata: Language manager',
1517 'langman-desc' => 'Add and change language settings with [[Special:Languages]]',
1618 'langman_title' => 'Language manager',
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php
@@ -69,11 +69,6 @@
7070 $viewInformation = $this->viewInformation;
7171
7272 if ( !is_null( $viewInformation ) ) {
73 - global $messageCacheOK;
74 - if ( !$messageCacheOK ) {
75 - # We're not ready to do this yet!
76 - return False; # so we get out, but with viewinfo cached
77 - }
7873 if ( !$this->setup_completed ) {
7974 $this->hardValues( $viewInformation );
8075 }

Status & tagging log