Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -1,34 +1,50 @@ |
2 | 2 | <?php |
3 | 3 | |
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.' ); |
7 | 5 | |
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 | +); |
13 | 20 | |
14 | | -$wgDefaultGoPrefix = 'Expression:'; |
| 21 | +$dir = dirname( __FILE__ ) . '/'; |
| 22 | + |
| 23 | +$wgExtensionFunctions[] = 'initializeWikidata'; |
15 | 24 | $wgHooks['BeforePageDisplay'][] = 'addWikidataHeader'; |
16 | | -# $wgHooks['GetEditLinkTrail'][]='addWikidataEditLinkTrail'; # non-standard hook; merged with modifyTabs |
17 | | -# $wgHooks['GetHistoryLinkTrail'][]='addHistoryLinkTrail'; # non-standard hook; merged with modifyTabs |
18 | 25 | $wgHooks['SkinTemplateTabs'][] = 'modifyTabs'; |
19 | 26 | $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'; |
21 | 32 | |
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; |
24 | 39 | |
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. |
29 | 41 | |
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/" ); |
32 | 44 | |
| 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 = ''; |
33 | 49 | |
34 | 50 | # The term dataset prefix identifies the Wikidata instance that will |
35 | 51 | # be used as a resource for obtaining language-independent strings |
— | — | @@ -46,50 +62,38 @@ |
47 | 63 | $wdShowCopyPanel = false; |
48 | 64 | $wdShowEditCopy = true; |
49 | 65 | |
| 66 | +# FIXME: These should be modified to make Wikidata more reusable. |
50 | 67 | $wdGroupDefaultView = array(); |
51 | | -# Here you can set group defaults. |
52 | | - |
53 | 68 | $wdGroupDefaultView['wikidata-omega'] = 'uw'; |
54 | 69 | # $wdGroupDefaultView['wikidata-umls']='umls'; |
55 | 70 | # $wdGroupDefaultView['wikidata-sp']='sp'; |
56 | 71 | |
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'; |
64 | 74 | |
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 |
70 | 75 | $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; |
75 | 77 | |
| 78 | +# FIXME: Should be renamed to prefix with wd rather than wg. |
| 79 | +$wgShowClassicPageTitles = false; |
| 80 | +$wgDefinedMeaningPageTitlePrefix = ''; |
| 81 | +$wgExpressionPageTitlePrefix = 'Multiple meanings'; |
76 | 82 | |
| 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 | + |
77 | 90 | # The site prefix allows us to have multiple sets of customized |
78 | 91 | # messages (for different, typically site-specific UIs) |
79 | 92 | # in a single database. |
80 | 93 | if ( !isset( $wdSiteContext ) ) $wdSiteContext = "uw"; |
81 | 94 | |
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" ); |
93 | 95 | require_once( "{$IP}/extensions/Wikidata/SpecialLanguages.php" ); |
| 96 | + |
| 97 | +# FIXME: These should be migrated to make Wikidata more reusable. |
94 | 98 | require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialSuggest.php" ); |
95 | 99 | require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialSelect.php" ); |
96 | 100 | require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialDatasearch.php" ); |
— | — | @@ -101,24 +105,23 @@ |
102 | 106 | require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialCopy.php" ); |
103 | 107 | require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialExportTSV.php" ); |
104 | 108 | require_once( "{$IP}/extensions/Wikidata/OmegaWiki/SpecialImportTSV.php" ); |
| 109 | + |
105 | 110 | require_once( "{$IP}/extensions/Wikidata/LocalApp.php" ); |
106 | 111 | |
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>" ); |
111 | 116 | |
112 | 117 | 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 = ''; |
117 | 122 | } |
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" ) ); |
123 | 126 | return true; |
124 | 127 | } |
125 | 128 | |
— | — | @@ -155,7 +158,7 @@ |
156 | 159 | * @param $tabs as passed by MW |
157 | 160 | */ |
158 | 161 | function modifyTabs( $skin, $content_actions ) { |
159 | | - global $wgUser, $wgTitle, $wdTesting, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses; |
| 162 | + global $wgUser, $wgTitle, $wgCommunity_dc, $wdShowEditCopy, $wdHandlerClasses; |
160 | 163 | $dc = wdGetDataSetContext(); |
161 | 164 | $ns = $wgTitle->getNamespace(); |
162 | 165 | $editChanged = false; |
— | — | @@ -168,20 +171,19 @@ |
169 | 172 | $dmid = ( $rpos1 && $rpos2 ) ? substr( $tt, $rpos1 + 1, $rpos2 - $rpos1 - 1 ) : 0; |
170 | 173 | if ( $dmid ) { |
171 | 174 | $copyTitle = SpecialPage::getTitleFor( 'Copy' ); |
172 | | - # if(wdIsWikidataNs() && (!$wgUser->isAllowed('editwikidata-'.$dc) || $wdTesting)) { |
173 | 175 | if ( wdIsWikidataNs() && $dc != $wgCommunity_dc && $wdShowEditCopy ) { |
174 | 176 | $editChanged = true; |
175 | 177 | $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 | + ); |
180 | 182 | } |
181 | | - $content_actions['nstab-definedmeaning'] = array( |
| 183 | + $content_actions['nstab-definedmeaning'] = array( |
182 | 184 | 'class' => 'selected', |
183 | 185 | 'text' => wfMsg( 'ow_nstab_definedmeaning' ), |
184 | | - 'href' => $wgTitle->getLocalUrl( "dataset=$dc" ) ); |
185 | | - |
| 186 | + 'href' => $wgTitle->getLocalUrl( "dataset=$dc" ) |
| 187 | + ); |
186 | 188 | } |
187 | 189 | } |
188 | 190 | |
— | — | @@ -197,26 +199,17 @@ |
198 | 200 | } |
199 | 201 | |
200 | 202 | function initializeWikidata() { |
201 | | - global $wdSiteContext, $wgPropertyToColumnFilters; |
202 | | - |
203 | 203 | wfLoadExtensionMessages( 'Wikidata' ); |
204 | 204 | |
205 | 205 | $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; |
215 | 209 | $wgRecordSetLanguage = 0; |
216 | | - |
217 | | - # malafaya: Set RTL according to user language |
| 210 | + |
218 | 211 | global $wgLang, $wgOut; |
219 | | - if ( $wgLang->isRTL() ) |
220 | | - { |
| 212 | + if ( $wgLang->isRTL() ) { |
| 213 | + # FIXME: Why are we including Gadget CSS here, this is Wikidata? |
221 | 214 | $wgOut->addHTML( '<style type="text/css">/*<![CDATA[*/ @import "/index.php?title=MediaWiki:Gadget-rtl.css&action=raw&ctype=text/css"; /*]]>*/</style>' ); |
222 | 215 | } |
223 | 216 | |
— | — | @@ -225,7 +218,7 @@ |
226 | 219 | |
227 | 220 | function wfWikiDataGetPreferences( $user, &$preferences ) { |
228 | 221 | $datasets = wdGetDatasets(); |
229 | | - # $datasetarray[wfMsgHtml( 'ow_none_selected' )] = ''; |
| 222 | + $datasetarray[wfMsgHtml( 'ow_none_selected' )] = ''; |
230 | 223 | foreach ( $datasets as $datasetid => $dataset ) { |
231 | 224 | $datasetarray[$dataset->fetchName()] = $datasetid; |
232 | 225 | } |
Index: trunk/extensions/Wikidata/SpecialLanguages.i18n.php |
— | — | @@ -10,6 +10,8 @@ |
11 | 11 | /** English |
12 | 12 | */ |
13 | 13 | $messages['en'] = array( |
| 14 | + 'wikidata-desc' => 'Adds wiki-like database for various types of content.', |
| 15 | + |
14 | 16 | 'languages' => 'Wikidata: Language manager', |
15 | 17 | 'langman-desc' => 'Add and change language settings with [[Special:Languages]]', |
16 | 18 | 'langman_title' => 'Language manager', |
Index: trunk/extensions/Wikidata/OmegaWiki/OmegaWikiAttributes.php |
— | — | @@ -69,11 +69,6 @@ |
70 | 70 | $viewInformation = $this->viewInformation; |
71 | 71 | |
72 | 72 | 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 | | - } |
78 | 73 | if ( !$this->setup_completed ) { |
79 | 74 | $this->hardValues( $viewInformation ); |
80 | 75 | } |