Go to the documentation of this file.
72 MediaWikiServices::getInstance()->getInterwikiLookup();
85 if ( $this->
language->needsGenderDistinction() &&
89 $gender = $this->genderCache->getGenderOf( $text, __METHOD__ );
90 $name = $this->
language->getGenderNsText( $namespace, $gender );
95 if (
$name ===
false ) {
96 throw new InvalidArgumentException(
'Unknown namespace ID: ' . $namespace );
114 public function formatTitle( $namespace, $text, $fragment =
'', $interwiki =
'' ) {
116 if ( $interwiki !==
'' ) {
117 $out = $interwiki .
':';
120 if ( $namespace != 0 ) {
123 }
catch ( InvalidArgumentException
$e ) {
128 $out .= $nsName .
':';
132 if ( $fragment !==
'' ) {
133 $out .=
'#' . $fragment;
136 $out = str_replace(
'_',
' ',
$out );
158 if ( $parts[
'dbkey'] ===
'' ) {
189 if ( !isset(
$title->prefixedText ) ) {
198 return $title->prefixedText;
253 $dbkey = str_replace(
' ',
'_', $text );
258 'local_interwiki' =>
false,
260 'namespace' => $defaultNamespace,
262 'user_case_dbkey' => $dbkey,
265 # Strip Unicode bidi override characters.
266 # Sometimes they slip into cut-n-pasted page titles, where the
267 # override chars get included in list displays.
268 $dbkey = preg_replace(
'/\xE2\x80[\x8E\x8F\xAA-\xAE]/S',
'', $dbkey );
270 # Clean up whitespace
271 # Note: use of the /u option on preg_replace here will cause
272 # input with invalid UTF-8 sequences to be nullified out in PHP 5.2.x,
273 # conveniently disabling them.
274 $dbkey = preg_replace(
275 '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u',
279 $dbkey = trim( $dbkey,
'_' );
281 if ( strpos( $dbkey,
UtfNormal\Constants::UTF8_REPLACEMENT ) !==
false ) {
282 # Contained illegal UTF-8 sequences or forbidden Unicode chars.
286 $parts[
'dbkey'] = $dbkey;
288 # Initial colon indicates main namespace rather than specified default
289 # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
290 if ( $dbkey !==
'' && $dbkey[0] ==
':' ) {
292 $dbkey = substr( $dbkey, 1 ); #
remove the colon but
continue processing
293 $dbkey = trim( $dbkey,
'_' ); #
remove any subsequent whitespace
296 if ( $dbkey ==
'' ) {
300 # Namespace or interwiki prefix
301 $prefixRegexp =
"/^(.+?)_*:_*(.*)$/S";
304 if ( preg_match( $prefixRegexp, $dbkey, $m ) ) {
306 $ns = $this->
language->getNsIndex( $p );
307 if ( $ns !==
false ) {
310 $parts[
'namespace'] = $ns;
311 # For Talk:X pages, check if X has a "namespace" prefix
312 if ( $ns ==
NS_TALK && preg_match( $prefixRegexp, $dbkey, $x ) ) {
313 if ( $this->
language->getNsIndex( $x[1] ) ) {
314 # Disallow Talk:File:x type titles...
316 } elseif ( $this->interwikiLookup->isValidInterwiki( $x[1] ) ) {
317 # Disallow Talk:Interwiki:x type titles...
321 } elseif ( $this->interwikiLookup->isValidInterwiki( $p ) ) {
324 $parts[
'interwiki'] = $this->
language->lc( $p );
326 # Redundant interwiki prefix to the local wiki
327 foreach ( $this->localInterwikis
as $localIW ) {
328 if ( 0 == strcasecmp( $parts[
'interwiki'], $localIW ) ) {
329 if ( $dbkey ==
'' ) {
330 # Empty self-links should point to the Main Page, to ensure
331 # compatibility with cross-wiki transclusions and the like.
334 'interwiki' => $mainPage->getInterwiki(),
335 'local_interwiki' =>
true,
336 'fragment' => $mainPage->getFragment(),
337 'namespace' => $mainPage->getNamespace(),
338 'dbkey' => $mainPage->getDBkey(),
339 'user_case_dbkey' => $mainPage->getUserCaseDBKey()
342 $parts[
'interwiki'] =
'';
343 # local interwikis should behave like initial-colon links
344 $parts[
'local_interwiki'] =
true;
346 # Do another namespace split...
351 # If there's an initial colon after the interwiki, that also
352 # resets the default namespace
353 if ( $dbkey !==
'' && $dbkey[0] ==
':' ) {
355 $dbkey = substr( $dbkey, 1 );
356 $dbkey = trim( $dbkey,
'_' );
359 # If there's no recognized interwiki or namespace,
360 # then let the colon expression be part of the title.
365 $fragment = strstr( $dbkey,
'#' );
366 if (
false !== $fragment ) {
367 $parts[
'fragment'] = str_replace(
'_',
' ', substr( $fragment, 1 ) );
368 $dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) );
369 # remove whitespace again: prevents "Foo_bar_#"
370 # becoming "Foo_bar_"
371 $dbkey = preg_replace(
'/_*$/',
'', $dbkey );
374 # Reject illegal characters.
377 if ( preg_match( $rxTc, $dbkey,
$matches ) ) {
381 # Pages with "/./" or "/../" appearing in the URLs will often be un-
382 # reachable due to the way web browsers deal with 'relative' URLs.
383 # Also, they conflict with subpage syntax. Forbid them explicitly.
385 strpos( $dbkey,
'.' ) !==
false &&
387 $dbkey ===
'.' || $dbkey ===
'..' ||
388 strpos( $dbkey,
'./' ) === 0 ||
389 strpos( $dbkey,
'../' ) === 0 ||
390 strpos( $dbkey,
'/./' ) !==
false ||
391 strpos( $dbkey,
'/../' ) !==
false ||
392 substr( $dbkey, -2 ) ==
'/.' ||
393 substr( $dbkey, -3 ) ==
'/..'
399 # Magic tilde sequences? Nu-uh!
400 if ( strpos( $dbkey,
'~~~' ) !==
false ) {
404 # Limit the size of titles to 255 bytes. This is typically the size of the
405 # underlying database field. We make an exception for special pages, which
406 # don't need to be stored in the database, and may edge over 255 bytes due
407 # to subpage syntax for long titles, e.g. [[Special:Block/Long name]]
408 $maxLength = ( $parts[
'namespace'] !=
NS_SPECIAL ) ? 255 : 512;
409 if ( strlen( $dbkey ) > $maxLength ) {
411 [ Message::numParam( $maxLength ) ] );
414 # Normally, all wiki links are forced to have an initial capital letter so [[foo]]
415 # and [[Foo]] point to the same place. Don't force it for interwikis, since the
416 # other site might be case-sensitive.
417 $parts[
'user_case_dbkey'] = $dbkey;
418 if ( $parts[
'interwiki'] ===
'' ) {
422 # Can't make a link to a namespace alone... "empty" local links can only be
423 # self-links with a fragment identifier.
424 if ( $dbkey ==
'' && $parts[
'interwiki'] ===
'' ) {
425 if ( $parts[
'namespace'] !=
NS_MAIN ) {
441 if ( $dbkey !==
'' &&
':' == $dbkey[0] ) {
446 $parts[
'dbkey'] = $dbkey;
461 static $rxTc =
false;
463 # Matching titles will be held as illegal.
465 # Any character
not allowed
is forbidden...
467 # URL percent encoding sequences interfere with the ability
468 # to round-trip titles -- you can't link to them consistently.
470 # XML/HTML character references produce similar issues.
471 '|&[A-Za-z0-9\x80-\xff]+;' .
473 '|&#x[0-9A-Fa-f]+;' .
static hasGenderDistinction( $index)
Does the namespace (potentially) have different aliases for different genders.
static newMainPage()
Create a new Title for the Main Page.
Caches user genders when needed to use correct namespace aliases.
This document provides an overview of the usage of PageUpdater and that is
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
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after processing
namespace and then decline to actually register it file or subcat img or subcat $title
Unicode normalization routines for working with UTF-8 strings.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
A title parser service for MediaWiki.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
Allows to change the fields on the form that will be generated $name
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying
static sanitizeIP( $ip)
Convert an IP into a verbose, uppercase, normalized form.
static capitalize( $text, $ns=NS_MAIN)
Capitalize a text string for a title if it belongs to a namespace that capitalizes.
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
static legalChars()
Get a regex character class describing the legal characters in a link.
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 MediaWikiServices
Internationalisation code.
Represents a page (or page fragment) title within MediaWiki.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out