76 if ( $this->language->needsGenderDistinction() &&
81 $gender = $this->genderCache->getGenderOf( $text, __METHOD__ );
82 $name = $this->language->getGenderNsText( $namespace, $gender );
84 $name = $this->language->getNsText( $namespace );
87 if (
$name ===
false ) {
88 throw new InvalidArgumentException(
'Unknown namespace ID: ' . $namespace );
106 public function formatTitle( $namespace, $text, $fragment =
'', $interwiki =
'' ) {
107 if ( $namespace !==
false ) {
112 }
catch ( InvalidArgumentException
$e ) {
116 if ( $namespace !== 0 ) {
117 $text = $nsName .
':' . $text;
121 if ( $fragment !==
'' ) {
122 $text = $text .
'#' . $fragment;
125 if ( $interwiki !==
'' ) {
126 $text = $interwiki .
':' . $text;
129 $text = str_replace(
'_',
' ', $text );
151 if ( $parts[
'dbkey'] ===
'' ) {
208 }
catch ( InvalidArgumentException
$e ) {
213 $key .= $nsName .
':';
218 return strtr( $key,
' ',
'_' );
258 $dbkey = str_replace(
' ',
'_', $text );
263 'local_interwiki' =>
false,
265 'namespace' => $defaultNamespace,
267 'user_case_dbkey' => $dbkey,
270 # Strip Unicode bidi override characters.
271 # Sometimes they slip into cut-n-pasted page titles, where the
272 # override chars get included in list displays.
273 $dbkey = preg_replace(
'/\xE2\x80[\x8E\x8F\xAA-\xAE]/S',
'', $dbkey );
275 # Clean up whitespace
276 # Note: use of the /u option on preg_replace here will cause
277 # input with invalid UTF-8 sequences to be nullified out in PHP 5.2.x,
278 # conveniently disabling them.
279 $dbkey = preg_replace(
280 '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u',
284 $dbkey = trim( $dbkey,
'_' );
287 # Contained illegal UTF-8 sequences or forbidden Unicode chars.
291 $parts[
'dbkey'] = $dbkey;
293 # Initial colon indicates main namespace rather than specified default
294 # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
295 if ( $dbkey !==
'' &&
':' == $dbkey[0] ) {
297 $dbkey = substr( $dbkey, 1 ); #
remove the colon but
continue processing
298 $dbkey = trim( $dbkey,
'_' ); #
remove any subsequent whitespace
301 if ( $dbkey ==
'' ) {
305 # Namespace or interwiki prefix
306 $prefixRegexp =
"/^(.+?)_*:_*(.*)$/S";
309 if ( preg_match( $prefixRegexp, $dbkey, $m ) ) {
311 $ns = $this->language->getNsIndex( $p );
312 if ( $ns !==
false ) {
315 $parts[
'namespace'] = $ns;
316 # For Talk:X pages, check if X has a "namespace" prefix
317 if ( $ns ==
NS_TALK && preg_match( $prefixRegexp, $dbkey, $x ) ) {
318 if ( $this->language->getNsIndex( $x[1] ) ) {
319 # Disallow Talk:File:x type titles...
323 # Disallow Talk:Interwiki:x type titles...
330 $parts[
'interwiki'] = $this->language->lc( $p );
332 # Redundant interwiki prefix to the local wiki
333 foreach ( $this->localInterwikis
as $localIW ) {
334 if ( 0 == strcasecmp( $parts[
'interwiki'], $localIW ) ) {
335 if ( $dbkey ==
'' ) {
336 # Empty self-links should point to the Main Page, to ensure
337 # compatibility with cross-wiki transclusions and the like.
340 'interwiki' => $mainPage->getInterwiki(),
341 'local_interwiki' =>
true,
342 'fragment' => $mainPage->getFragment(),
343 'namespace' => $mainPage->getNamespace(),
344 'dbkey' => $mainPage->getDBkey(),
345 'user_case_dbkey' => $mainPage->getUserCaseDBKey()
348 $parts[
'interwiki'] =
'';
349 # local interwikis should behave like initial-colon links
350 $parts[
'local_interwiki'] =
true;
352 # Do another namespace split...
357 # If there's an initial colon after the interwiki, that also
358 # resets the default namespace
359 if ( $dbkey !==
'' && $dbkey[0] ==
':' ) {
361 $dbkey = substr( $dbkey, 1 );
364 # If there's no recognized interwiki or namespace,
365 # then let the colon expression be part of the title.
370 $fragment = strstr( $dbkey,
'#' );
371 if (
false !== $fragment ) {
372 $parts[
'fragment'] = str_replace(
'_',
' ', substr( $fragment, 1 ) );
373 $dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) );
374 # remove whitespace again: prevents "Foo_bar_#"
375 # becoming "Foo_bar_"
376 $dbkey = preg_replace(
'/_*$/',
'', $dbkey );
379 # Reject illegal characters.
380 $rxTc = self::getTitleInvalidRegex();
382 if ( preg_match( $rxTc, $dbkey,
$matches ) ) {
386 # Pages with "/./" or "/../" appearing in the URLs will often be un-
387 # reachable due to the way web browsers deal with 'relative' URLs.
388 # Also, they conflict with subpage syntax. Forbid them explicitly.
390 strpos( $dbkey,
'.' ) !==
false &&
392 $dbkey ===
'.' || $dbkey ===
'..' ||
393 strpos( $dbkey,
'./' ) === 0 ||
394 strpos( $dbkey,
'../' ) === 0 ||
395 strpos( $dbkey,
'/./' ) !==
false ||
396 strpos( $dbkey,
'/../' ) !==
false ||
397 substr( $dbkey, -2 ) ==
'/.' ||
398 substr( $dbkey, -3 ) ==
'/..'
404 # Magic tilde sequences? Nu-uh!
405 if ( strpos( $dbkey,
'~~~' ) !==
false ) {
409 # Limit the size of titles to 255 bytes. This is typically the size of the
410 # underlying database field. We make an exception for special pages, which
411 # don't need to be stored in the database, and may edge over 255 bytes due
412 # to subpage syntax for long titles, e.g. [[Special:Block/Long name]]
413 $maxLength = ( $parts[
'namespace'] !=
NS_SPECIAL ) ? 255 : 512;
414 if ( strlen( $dbkey ) > $maxLength ) {
419 # Normally, all wiki links are forced to have an initial capital letter so [[foo]]
420 # and [[Foo]] point to the same place. Don't force it for interwikis, since the
421 # other site might be case-sensitive.
422 $parts[
'user_case_dbkey'] = $dbkey;
423 if ( $parts[
'interwiki'] ===
'' ) {
427 # Can't make a link to a namespace alone... "empty" local links can only be
428 # self-links with a fragment identifier.
429 if ( $dbkey ==
'' && $parts[
'interwiki'] ===
'' ) {
430 if ( $parts[
'namespace'] !=
NS_MAIN ) {
446 if ( $dbkey !==
'' &&
':' == $dbkey[0] ) {
451 $parts[
'dbkey'] = $dbkey;
466 static $rxTc =
false;
468 # Matching titles will be held as illegal.
470 # Any character not allowed
is forbidden...
472 #
URL percent encoding sequences interfere with
the ability
473 # to round-trip titles -- you can't link to them consistently.
475 # XML/HTML character references produce similar issues.
476 '|&[A-Za-z0-9\x80-\xff]+;' .
478 '|&#x[0-9A-Fa-f]+;' .
#define the
table suitable for use with IDatabase::select()
static hasGenderDistinction($index)
Does the namespace (potentially) have different aliases for different genders.
the array() calling protocol came about after MediaWiki 1.4rc1.
static sanitizeIP($ip)
Convert an IP into a verbose, uppercase, normalized form.
static newMainPage()
Create a new Title for the Main Page.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Represents a page (or page fragment) title within MediaWiki.
Unicode normalization routines for working with UTF-8 strings.
Some quick notes on the file repository architecture Functionality is
A title parser service for MediaWiki.
Internationalisation code.
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks conditions will AND in the final query as a Content object as a Content object $title
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
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
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
Caches user genders when needed to use correct namespace aliases.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain URL
static legalChars()
Get a regex character class describing the legal characters in a link.
static capitalize($text, $ns=NS_MAIN)
Capitalize a text string for a title if it belongs to a namespace that capitalizes.
static isValidInterwiki($prefix)
Check whether an interwiki prefix exists.
Allows to change the fields on the form that will be generated $name