r53572 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53571‎ | r53572 | r53573 >
Date:23:31, 20 July 2009
Author:minuteelectron
Status:deferred
Tags:
Comment:
Wikidata:
* Remove patch for Article.php in favor of overriding.
* Remove two misc. unneeded patches.
Modified paths:
  • /trunk/extensions/Wikidata/App.php (modified) (history)
  • /trunk/extensions/Wikidata/includes/WikidataArticle.php (added) (history)
  • /trunk/extensions/Wikidata/patches/OmegaWiki.diff (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/patches/OmegaWiki.diff
@@ -38,41 +38,6 @@
3939 }
4040
4141 function do_populate_parent_id() {
42 -Index: includes/Article.php
43 -===================================================================
44 -+++ includes/Article.php (working copy)
45 -@@ -725,10 +725,29 @@
46 - public function view() {
47 - global $wgUser, $wgOut, $wgRequest, $wgContLang;
48 - global $wgEnableParserCache, $wgStylePath, $wgParser;
49 -- global $wgUseTrackbacks;
50 -+ global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies, $wgTitle;
51 -+ global $wgDefaultRobotPolicy;
52 -
53 - wfProfileIn( __METHOD__ );
54 -
55 -+ global $wdHandlerClasses, $wdHandlerPath;
56 -+ $ns = $this->mTitle->getNamespace();
57 -+ if( array_key_exists( $ns, $wdHandlerClasses ) ) {
58 -+ $handlerClass = $wdHandlerClasses[ $ns ];
59 -+ $handlerFile = $wdHandlerPath . $handlerClass . '.php';
60 -+ if( file_exists( $handlerFile ) ) {
61 -+ require_once $handlerFile;
62 -+ $handlerInstance = new $handlerClass();
63 -+ $handlerInstance->view();
64 -+ return;
65 -+ } else {
66 -+ $wgOut->showErrorPage( 'namespace_handler_not_found', 'namespace_handler_not_found_error',
67 -+ $handlerFile, $wgContLang->getFormattedNsText( $ns ) );
68 -+ }
69 -+ }
70 -+
71 -+ $parserCache = ParserCache::singleton();
72 -+
73 - # Get variables from query string
74 - $oldid = $this->getOldID();
75 - $parserCache = ParserCache::singleton();
7642 Index: includes/SearchEngine.php
7743 ===================================================================
7844 --- includes/SearchEngine.php (revision 53499)
@@ -146,24 +111,7 @@
147112 + if( array_key_exists( $index, $wdHandlerClasses ) ) return false;
148113 return !( $index < NS_MAIN || ($index == NS_FILE && !$wgAllowImageMoving) || $index == NS_CATEGORY );
149114 }
150 -
151 -Index: includes/SkinTemplate.php
152 -===================================================================
153 -+++ includes/SkinTemplate.php (working copy)
154 -@@ -749,10 +749,11 @@
155 - wfProfileIn( __METHOD__ . '-live' );
156 - if ( $this->mTitle->exists() ) {
157 -
158 -+ wfRunHooks( 'GetHistoryLinkTrail', array( &$trail ) );
159 - $content_actions['history'] = array(
160 - 'class' => ($action == 'history') ? 'selected' : false,
161 - 'text' => wfMsg( 'history_short' ),
162 -- 'href' => $this->mTitle->getLocalUrl( 'action=history' ),
163 -+ 'href' => $this->mTitle->getLocalUrl( 'action=history' . $trail ),
164 - 'rel' => 'archives',
165 - );
166 -
 115+
167116 Index: includes/DefaultSettings.php
168117 ===================================================================
169118 --- includes/DefaultSettings.php (revision 53499)
@@ -208,36 +156,4 @@
209157 /*
210158 * Setup page variables.
211159 */
212 -Index: includes/Skin.php
213 -===================================================================
214 -+++ includes/Skin.php (working copy)
215 -@@ -1650,6 +1650,10 @@
216 - function editUrlOptions() {
217 - global $wgArticle;
218 -
219 -+ $trail = '';
220 -+ wfRunHooks( 'GetEditLinkTrail', array( &$trail ) );
221 -+ # FIXME: $trail should be appended to $return but that is now an array.
222 -+
223 - $options = array( 'action' => 'edit' );
224 -
225 - if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
226 -@@ -1749,6 +1753,10 @@
227 - }
228 -
229 - function historyLink() {
230 -+ $trail = '';
231 -+ wfRunHooks( 'GetHistoryLinkTrail', array( &$trail ) );
232 -+ # FIXME: $trail should be appended to $return but that is now an array.
233 -+
234 - return $this->link(
235 - $this->mTitle,
236 - wfMsgHtml( 'history' ),
237 -@@ -2086,4 +2094,4 @@
238 - public function commonPrintStylesheet() {
239 - return true;
240 - }
241 --}
242 -\ No newline at end of file
243 -+}
 160+
Index: trunk/extensions/Wikidata/App.php
@@ -23,12 +23,17 @@
2424 $wgHooks['BeforePageDisplay'][] = 'addWikidataHeader';
2525 $wgHooks['SkinTemplateTabs'][] = 'modifyTabs';
2626 $wgHooks['GetPreferences'][] = 'wfWikiDataGetPreferences';
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';
 27+$wgHooks['ArticleFromTitle'][] = 'efWikidataOverrideArticle';
 28+$wgAutoloadClasses['WikidataArticle'] = $dir . 'includes/WikidataArticle.php';
 29+$wgAutoloadClasses['ApiWikiData'] = $dir . 'includes/api/ApiWikiData.php';
 30+$wgAutoloadClasses['ApiWikiDataFormatBase'] = $dir . 'includes/api/ApiWikiDataFormatBase.php';
 31+$wgAutoloadClasses['ApiWikiDataFormatXml'] = $dir . 'includes/api/ApiWikiDataFormatXml.php';
3032 $wgAPIModules['wikidata'] = 'ApiWikiData';
3133 $wgExtensionMessagesFiles['Wikidata'] = $dir . 'SpecialLanguages.i18n.php';
3234
 35+# FIXME: Rename this to make Wikidata more agnostic.
 36+$wgAutoloadClasses['OmegaWiki'] = $dir . 'OmegaWiki/OmegaWiki.php';
 37+
3338 # FIXME: These should be modified to make Wikidata more reusable.
3439 $wgAvailableRights[] = 'editwikidata-uw';
3540 $wgAvailableRights[] = 'wikidata-copy';
@@ -231,3 +236,12 @@
232237 );
233238 return true;
234239 }
 240+
 241+function efWikidataOverrideArticle( &$title, &$article ) {
 242+ global $wdHandlerClasses;
 243+ $ns = $title->getNamespace();
 244+ if ( array_key_exists( $ns, $wdHandlerClasses ) ) {
 245+ $article = new WikidataArticle( $title );
 246+ }
 247+ return true;
 248+}
Index: trunk/extensions/Wikidata/includes/WikidataArticle.php
@@ -0,0 +1,17 @@
 2+<?php
 3+
 4+class WikidataArticle extends Article {
 5+
 6+ public function view() {
 7+ wfProfileIn( __METHOD__ );
 8+
 9+ global $wdHandlerClasses;
 10+ $ns = $this->mTitle->getNamespace();
 11+ $handlerClass = $wdHandlerClasses[ $ns ];
 12+ $handlerInstance = new $handlerClass();
 13+ $handlerInstance->view();
 14+
 15+ wfProfileOut( __METHOD__ );
 16+ }
 17+
 18+}

Status & tagging log