[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation; either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * @file 9 * @ingroup Extensions 10 * @version 3.0 11 * @author Stephanie Amanda Stevens <[email protected]> 12 * @author Robin Pepermans (SPQRobin) <[email protected]> 13 * @author Jack Phoenix <[email protected]> 14 * @author Calimonius the Estrange <[email protected]> 15 * @copyright Copyright © 2005-2007 Stephanie Amanda Stevens 16 * @copyright Copyright © 2007-2011 Robin Pepermans (SPQRobin) 17 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later 18 * @link http://www.mediawiki.org/wiki/Extension:SpecialInterwiki Documentation 19 * Formatting improvements Stephen Kennedy, 2006. 20 */ 21 22 if ( !defined( 'MEDIAWIKI' ) ) { 23 die( "This is not a valid entry point.\n" ); 24 } 25 26 // Set this value to true in LocalSettings.php if you will not use this 27 // extension to actually change any interwiki table entries. It will suppress 28 // the addition of a log for interwiki link changes. 29 $wgInterwikiViewOnly = false; 30 31 // Name of a database where global interwikis will be stored. 32 $wgInterwikiCentralDB = null; 33 34 // Extension credits for Special:Version 35 $wgExtensionCredits['specialpage'][] = array( 36 'path' => __FILE__, 37 'name' => 'Interwiki', 38 'author' => array( 39 'Stephanie Amanda Stevens', 40 'Alexandre Emsenhuber', 41 'Robin Pepermans', 42 'Siebrand Mazeland', 43 'Platonides', 44 'Raimond Spekking', 45 'Sam Reed', 46 'Jack Phoenix', 47 'Calimonius the Estrange', 48 '...' 49 ), 50 'version' => '3.0 20140719', 51 'url' => 'https://www.mediawiki.org/wiki/Extension:Interwiki', 52 'descriptionmsg' => 'interwiki-desc', 53 ); 54 55 $wgExtensionFunctions[] = 'setupInterwikiExtension'; 56 57 $wgResourceModules['ext.interwiki.specialpage'] = array( 58 'styles' => 'Interwiki.css', 59 'localBasePath' => dirname( __FILE__ ), 60 'remoteExtPath' => 'Interwiki', 61 'dependencies' => array( 62 'jquery.makeCollapsible', 63 ), 64 ); 65 66 // Set up the new special page 67 $dir = dirname( __FILE__ ) . '/'; 68 $wgMessagesDirs['Interwiki'] = __DIR__ . '/i18n'; 69 $wgExtensionMessagesFiles['Interwiki'] = $dir . 'Interwiki.i18n.php'; 70 $wgExtensionMessagesFiles['InterwikiAlias'] = $dir . 'Interwiki.alias.php'; 71 $wgAutoloadClasses['SpecialInterwiki'] = $dir . 'Interwiki_body.php'; 72 $wgAutoloadClasses['InterwikiLogFormatter'] = $dir . 'Interwiki_body.php'; 73 $wgSpecialPages['Interwiki'] = 'SpecialInterwiki'; 74 $wgSpecialPageGroups['Interwiki'] = 'wiki'; 75 76 $wgHooks['InterwikiLoadPrefix'][] = 'wfGlobalInterwikis'; 77 78 79 function setupInterwikiExtension() { 80 global $wgInterwikiViewOnly; 81 82 if ( $wgInterwikiViewOnly === false ) { 83 global $wgAvailableRights, $wgLogTypes, $wgLogActionsHandlers; 84 85 // New user right, required to modify the interwiki table through Special:Interwiki 86 $wgAvailableRights[] = 'interwiki'; 87 88 // Set up the new log type - interwiki actions are logged to this new log 89 $wgLogTypes[] = 'interwiki'; 90 // interwiki, iw_add, iw_delete, iw_edit 91 $wgLogActionsHandlers['interwiki/*'] = 'InterwikiLogFormatter'; 92 } 93 94 return true; 95 } 96 97 function wfGlobalInterwikis( $prefix, &$iwData ) { 98 global $wgInterwikiCentralDB; 99 // docs/hooks.txt says: Return true without providing an interwiki to continue interwiki search. 100 if ( $wgInterwikiCentralDB === null || $wgInterwikiCentralDB === wfWikiId() ) { 101 // No global set or this is global, nothing to add 102 return true; 103 } 104 if ( !Language::fetchLanguageName( $prefix ) ) { 105 // Check if prefix exists locally and skip 106 foreach ( Interwiki::getAllPrefixes( null ) as $id => $localPrefixInfo ) { 107 if ( $prefix === $localPrefixInfo['iw_prefix'] ) { 108 return true; 109 } 110 } 111 $dbr = wfGetDB( DB_SLAVE, array(), $wgInterwikiCentralDB ); 112 $res = $dbr->selectRow( 113 'interwiki', 114 '*', 115 array( 'iw_prefix' => $prefix ), 116 __METHOD__ 117 ); 118 if ( !$res ) { 119 return true; 120 } 121 // Excplicitly make this an array since it's expected to be one 122 $iwData = (array)$res; 123 // At this point, we can safely return false because we know that we have something 124 return false; 125 } 126 return true; 127 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |