MediaWiki  1.30.0
Interwiki_hooks.php
Go to the documentation of this file.
1 <?php
2 
4  public static function onExtensionFunctions() {
5  global $wgInterwikiViewOnly;
6 
7  if ( $wgInterwikiViewOnly === false ) {
9 
10  // New user right, required to modify the interwiki table through Special:Interwiki
11  $wgAvailableRights[] = 'interwiki';
12 
13  // Set up the new log type - interwiki actions are logged to this new log
14  $wgLogTypes[] = 'interwiki';
15  // interwiki, iw_add, iw_delete, iw_edit
16  $wgLogActionsHandlers['interwiki/*'] = 'InterwikiLogFormatter';
17  }
18 
19  return true;
20  }
21 
22  public static function onInterwikiLoadPrefix( $prefix, &$iwData ) {
23  global $wgInterwikiCentralDB;
24  // docs/hooks.txt says: Return true without providing an interwiki to continue interwiki search.
25  if ( $wgInterwikiCentralDB === null || $wgInterwikiCentralDB === wfWikiID() ) {
26  // No global set or this is global, nothing to add
27  return true;
28  }
29  if ( !Language::fetchLanguageName( $prefix ) ) {
30  // Check if prefix exists locally and skip
31  foreach ( Interwiki::getAllPrefixes( null ) as $id => $localPrefixInfo ) {
32  if ( $prefix === $localPrefixInfo['iw_prefix'] ) {
33  return true;
34  }
35  }
36  $dbr = wfGetDB( DB_SLAVE, [], $wgInterwikiCentralDB );
37  $res = $dbr->selectRow(
38  'interwiki',
39  '*',
40  [ 'iw_prefix' => $prefix ],
41  __METHOD__
42  );
43  if ( !$res ) {
44  return true;
45  }
46  // Excplicitly make this an array since it's expected to be one
47  $iwData = (array)$res;
48  // At this point, we can safely return false because we know that we have something
49  return false;
50  }
51  return true;
52  }
53 
54 }
Interwiki\getAllPrefixes
static getAllPrefixes( $local=null)
Returns all interwiki prefix definitions.
Definition: Interwiki.php:103
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:37
InterwikiHooks
Definition: Interwiki_hooks.php:3
$res
$res
Definition: database.txt:21
InterwikiHooks\onInterwikiLoadPrefix
static onInterwikiLoadPrefix( $prefix, &$iwData)
Definition: Interwiki_hooks.php:22
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2856
$wgLogTypes
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
Definition: DefaultSettings.php:7568
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:2807
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition: Language.php:896
InterwikiHooks\onExtensionFunctions
static onExtensionFunctions()
Definition: Interwiki_hooks.php:4
$wgLogActionsHandlers
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
Definition: DefaultSettings.php:7680
$dbr
if(! $regexes) $dbr
Definition: cleanup.php:94
$wgAvailableRights
$wgAvailableRights
A list of available rights, in addition to the ones defined by the core.
Definition: DefaultSettings.php:5528
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
array
the array() calling protocol came about after MediaWiki 1.4rc1.