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 =
'' ) {
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'] ===
'' ) {
178 return $title->getText();
189 if ( !isset( $title->prefixedText ) ) {
194 $title->getInterwiki()
198 return $title->prefixedText;
227 $title->getFragment(),
228 $title->getInterwiki()
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.
332 $mainPage = Title::newMainPage();
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'] ===
'' ) {
419 $dbkey = Title::capitalize( $dbkey, $parts[
'namespace'] );
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 ) {
436 if ( $parts[
'namespace'] == NS_USER || $parts[
'namespace'] ==
NS_USER_TALK ) {
437 $dbkey = IP::sanitizeIP( $dbkey );
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...
466 '[^' . Title::legalChars() .
']' .
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]+;' .
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.
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
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
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.
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))