72 MediaWikiServices::getInstance()->getInterwikiLookup();
85 if ( $this->
language->needsGenderDistinction() &&
86 MWNamespace::hasGenderDistinction( $namespace )
89 $gender = $this->genderCache->getGenderOf( $text, __METHOD__ );
90 $name = $this->
language->getGenderNsText( $namespace, $gender );
92 $name = $this->
language->getNsText( $namespace );
95 if ( $name ===
false ) {
96 throw new InvalidArgumentException(
'Unknown namespace ID: ' . $namespace );
114 public function formatTitle( $namespace, $text, $fragment =
'', $interwiki =
'' ) {
115 if ( $namespace !==
false ) {
120 }
catch ( InvalidArgumentException
$e ) {
124 if ( $namespace !== 0 ) {
125 $text = $nsName .
':' . $text;
129 if ( $fragment !==
'' ) {
130 $text = $text .
'#' . $fragment;
133 if ( $interwiki !==
'' ) {
134 $text = $interwiki .
':' . $text;
137 $text = str_replace(
'_',
' ', $text );
159 if ( $parts[
'dbkey'] ===
'' ) {
194 $title->getInterwiki()
216 }
catch ( InvalidArgumentException
$e ) {
221 $key .= $nsName .
':';
226 return strtr( $key,
' ',
'_' );
240 $title->getFragment(),
241 $title->getInterwiki()
266 $dbkey = str_replace(
' ',
'_', $text );
271 'local_interwiki' =>
false,
273 'namespace' => $defaultNamespace,
275 'user_case_dbkey' => $dbkey,
278 # Strip Unicode bidi override characters.
279 # Sometimes they slip into cut-n-pasted page titles, where the
280 # override chars get included in list displays.
281 $dbkey = preg_replace(
'/\xE2\x80[\x8E\x8F\xAA-\xAE]/S',
'', $dbkey );
283 # Clean up whitespace
284 # Note: use of the /u option on preg_replace here will cause
285 # input with invalid UTF-8 sequences to be nullified out in PHP 5.2.x,
286 # conveniently disabling them.
287 $dbkey = preg_replace(
288 '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u',
292 $dbkey = trim( $dbkey,
'_' );
294 if ( strpos( $dbkey,
UtfNormal\Constants::UTF8_REPLACEMENT ) !==
false ) {
295 # Contained illegal UTF-8 sequences or forbidden Unicode chars.
299 $parts[
'dbkey'] = $dbkey;
301 # Initial colon indicates main namespace rather than specified default
302 # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
303 if ( $dbkey !==
'' && $dbkey[0] ==
':' ) {
305 $dbkey = substr( $dbkey, 1 ); #
remove the colon but
continue processing
306 $dbkey = trim( $dbkey,
'_' ); #
remove any subsequent whitespace
309 if ( $dbkey ==
'' ) {
313 # Namespace or interwiki prefix
314 $prefixRegexp =
"/^(.+?)_*:_*(.*)$/S";
317 if ( preg_match( $prefixRegexp, $dbkey, $m ) ) {
319 $ns = $this->
language->getNsIndex( $p );
320 if ( $ns !==
false ) {
323 $parts[
'namespace'] = $ns;
324 # For Talk:X pages, check if X has a "namespace" prefix
325 if ( $ns ==
NS_TALK && preg_match( $prefixRegexp, $dbkey, $x ) ) {
326 if ( $this->
language->getNsIndex( $x[1] ) ) {
327 # Disallow Talk:File:x type titles...
329 } elseif ( $this->interwikiLookup->isValidInterwiki( $x[1] ) ) {
330 # Disallow Talk:Interwiki:x type titles...
334 } elseif ( $this->interwikiLookup->isValidInterwiki( $p ) ) {
337 $parts[
'interwiki'] = $this->
language->lc( $p );
339 # Redundant interwiki prefix to the local wiki
340 foreach ( $this->localInterwikis as $localIW ) {
341 if ( 0 == strcasecmp( $parts[
'interwiki'], $localIW ) ) {
342 if ( $dbkey ==
'' ) {
343 # Empty self-links should point to the Main Page, to ensure
344 # compatibility with cross-wiki transclusions and the like.
345 $mainPage = Title::newMainPage();
347 'interwiki' => $mainPage->getInterwiki(),
348 'local_interwiki' =>
true,
349 'fragment' => $mainPage->getFragment(),
350 'namespace' => $mainPage->getNamespace(),
351 'dbkey' => $mainPage->getDBkey(),
352 'user_case_dbkey' => $mainPage->getUserCaseDBKey()
355 $parts[
'interwiki'] =
'';
356 # local interwikis should behave like initial-colon links
357 $parts[
'local_interwiki'] =
true;
359 # Do another namespace split...
364 # If there's an initial colon after the interwiki, that also
365 # resets the default namespace
366 if ( $dbkey !==
'' && $dbkey[0] ==
':' ) {
368 $dbkey = substr( $dbkey, 1 );
369 $dbkey = trim( $dbkey,
'_' );
372 # If there's no recognized interwiki or namespace,
373 # then let the colon expression be part of the title.
378 $fragment = strstr( $dbkey,
'#' );
379 if (
false !== $fragment ) {
380 $parts[
'fragment'] = str_replace(
'_',
' ', substr( $fragment, 1 ) );
381 $dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) );
382 # remove whitespace again: prevents "Foo_bar_#"
383 # becoming "Foo_bar_"
384 $dbkey = preg_replace(
'/_*$/',
'', $dbkey );
387 # Reject illegal characters.
390 if ( preg_match( $rxTc, $dbkey,
$matches ) ) {
394 # Pages with "/./" or "/../" appearing in the URLs will often be un-
395 # reachable due to the way web browsers deal with 'relative' URLs.
396 # Also, they conflict with subpage syntax. Forbid them explicitly.
398 strpos( $dbkey,
'.' ) !==
false &&
400 $dbkey ===
'.' || $dbkey ===
'..' ||
401 strpos( $dbkey,
'./' ) === 0 ||
402 strpos( $dbkey,
'../' ) === 0 ||
403 strpos( $dbkey,
'/./' ) !==
false ||
404 strpos( $dbkey,
'/../' ) !==
false ||
405 substr( $dbkey, -2 ) ==
'/.' ||
406 substr( $dbkey, -3 ) ==
'/..'
412 # Magic tilde sequences? Nu-uh!
413 if ( strpos( $dbkey,
'~~~' ) !==
false ) {
417 # Limit the size of titles to 255 bytes. This is typically the size of the
418 # underlying database field. We make an exception for special pages, which
419 # don't need to be stored in the database, and may edge over 255 bytes due
420 # to subpage syntax for long titles, e.g. [[Special:Block/Long name]]
421 $maxLength = ( $parts[
'namespace'] !=
NS_SPECIAL ) ? 255 : 512;
422 if ( strlen( $dbkey ) > $maxLength ) {
424 [ Message::numParam( $maxLength ) ] );
427 # Normally, all wiki links are forced to have an initial capital letter so [[foo]]
428 # and [[Foo]] point to the same place. Don't force it for interwikis, since the
429 # other site might be case-sensitive.
430 $parts[
'user_case_dbkey'] = $dbkey;
431 if ( $parts[
'interwiki'] ===
'' ) {
432 $dbkey = Title::capitalize( $dbkey, $parts[
'namespace'] );
435 # Can't make a link to a namespace alone... "empty" local links can only be
436 # self-links with a fragment identifier.
437 if ( $dbkey ==
'' && $parts[
'interwiki'] ===
'' ) {
438 if ( $parts[
'namespace'] !=
NS_MAIN ) {
449 if ( $parts[
'namespace'] == NS_USER || $parts[
'namespace'] ==
NS_USER_TALK ) {
450 $dbkey = IP::sanitizeIP( $dbkey );
454 if ( $dbkey !==
'' &&
':' == $dbkey[0] ) {
459 $parts[
'dbkey'] = $dbkey;
474 static $rxTc =
false;
476 # Matching titles will be held as illegal.
478 # Any character not allowed is forbidden...
479 '[^' . Title::legalChars() .
']' .
480 #
URL percent encoding sequences interfere with the ability
481 # to round-trip titles -- you can't link to them consistently.
483 # XML/HTML character references produce similar issues.
484 '|&[A-Za-z0-9\x80-\xff]+;' .
486 '|&#x[0-9A-Fa-f]+;' .
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
Caches user genders when needed to use correct namespace aliases.
Internationalisation code.
Represents a page (or page fragment) title within MediaWiki.
Unicode normalization routines for working with UTF-8 strings.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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
Allows to change the fields on the form that will be generated $name
returning false will NOT prevent logging $e
A title parser service for MediaWiki.