175 static $titleCodec = null;
176 static $titleCodecFingerprint = null;
182 $fingerprint = spl_object_hash( $wgContLang ) .
'|' . join(
'+', $wgLocalInterwikis );
184 if ( $fingerprint !== $titleCodecFingerprint ) {
188 if ( !$titleCodec ) {
194 $titleCodecFingerprint = $fingerprint;
211 return self::getTitleParser();
230 $t->secureAndSplit();
245 return self::makeTitle(
265 if ( is_object( $text ) ) {
266 throw new InvalidArgumentException(
'$text must be a string.' );
267 } elseif ( !is_string( $text ) ) {
270 __METHOD__ .
': $text must be a string. ' .
271 'This will throw an InvalidArgumentException in future.',
298 if ( is_object( $text ) ) {
299 throw new MWException(
'Title::newFromTextThrow given an object' );
302 $cache = self::getTitleCache();
312 if ( $defaultNamespace ==
NS_MAIN &&
$cache->has( $text ) ) {
313 return $cache->get( $text );
316 # Convert things like é ā or 〗 into normalized (bug 14952) text
320 $t->mDbkeyform = strtr( $filteredText,
' ',
'_' );
321 $t->mDefaultNamespace = intval( $defaultNamespace );
323 $t->secureAndSplit();
324 if ( $defaultNamespace ==
NS_MAIN ) {
348 # For compatibility with old buggy URLs. "+" is usually not valid in titles,
349 # but some URLs used it as a space replacement and they still come
350 # from some external search tools.
351 if ( strpos( self::legalChars(),
'+' ) ===
false ) {
352 $url = strtr( $url,
'+',
' ' );
355 $t->mDbkeyform = strtr( $url,
' ',
'_' );
358 $t->secureAndSplit();
369 if ( self::$titleCache == null ) {
370 self::$titleCache =
new MapCacheLRU( self::CACHE_MAX );
372 return self::$titleCache;
386 'page_namespace',
'page_title',
'page_id',
387 'page_len',
'page_is_redirect',
'page_latest',
390 if ( $wgContentHandlerUseDB ) {
391 $fields[] =
'page_content_model';
406 $row = $db->selectRow(
408 self::getSelectFields(),
409 array(
'page_id' => $id ),
412 if ( $row !==
false ) {
427 if ( !count( $ids ) ) {
434 self::getSelectFields(),
440 foreach (
$res as $row ) {
453 $t = self::makeTitle( $row->page_namespace, $row->page_title );
454 $t->loadFromRow( $row );
466 if ( isset( $row->page_id ) ) {
467 $this->mArticleID = (int)$row->page_id;
469 if ( isset( $row->page_len ) ) {
470 $this->mLength = (int)$row->page_len;
472 if ( isset( $row->page_is_redirect ) ) {
473 $this->mRedirect = (bool)$row->page_is_redirect;
475 if ( isset( $row->page_latest ) ) {
476 $this->mLatestID = (int)$row->page_latest;
478 if ( isset( $row->page_content_model ) ) {
479 $this->mContentModel = strval( $row->page_content_model );
483 if ( isset( $row->page_lang ) ) {
484 $this->mDbPageLanguage = (string)$row->page_lang;
486 if ( isset( $row->page_restrictions ) ) {
487 $this->mOldRestrictions = $row->page_restrictions;
490 $this->mArticleID = 0;
492 $this->mRedirect =
false;
493 $this->mLatestID = 0;
511 public static function &
makeTitle( $ns,
$title, $fragment =
'', $interwiki =
'' ) {
513 $t->mInterwiki = $interwiki;
514 $t->mFragment = $fragment;
515 $t->mNamespace = $ns = intval( $ns );
516 $t->mDbkeyform = strtr(
$title,
' ',
'_' );
517 $t->mArticleID = ( $ns >= 0 ) ? -1 : 0;
519 $t->mTextform = strtr(
$title,
'_',
' ' );
541 $t->mDbkeyform =
Title::makeName( $ns, $title, $fragment, $interwiki,
true );
544 $t->secureAndSplit();
579 return $content->getRedirectTarget();
596 return $content->getUltimateRedirectTarget();
613 return $content->getRedirectChain();
622 public static function nameOf( $id ) {
627 array(
'page_namespace',
'page_title' ),
628 array(
'page_id' => $id ),
631 if (
$s ===
false ) {
635 $n = self::makeName(
$s->page_namespace,
$s->page_title );
673 $length = strlen( $byteClass );
675 $x0 = $x1 = $x2 =
'';
677 $d0 = $d1 = $d2 =
'';
679 $ord0 = $ord1 = $ord2 = 0;
681 $r0 = $r1 = $r2 =
'';
685 $allowUnicode =
false;
686 for ( $pos = 0; $pos < $length; $pos++ ) {
697 $inChar = $byteClass[$pos];
698 if ( $inChar ==
'\\' ) {
699 if ( preg_match(
'/x([0-9a-fA-F]{2})/A', $byteClass, $m, 0, $pos + 1 ) ) {
700 $x0 = $inChar . $m[0];
701 $d0 = chr( hexdec( $m[1] ) );
702 $pos += strlen( $m[0] );
703 } elseif ( preg_match(
'/[0-7]{3}/A', $byteClass, $m, 0, $pos + 1 ) ) {
704 $x0 = $inChar . $m[0];
705 $d0 = chr( octdec( $m[0] ) );
706 $pos += strlen( $m[0] );
707 } elseif ( $pos + 1 >= $length ) {
710 $d0 = $byteClass[$pos + 1];
719 if ( $ord0 < 32 || $ord0 == 0x7f ) {
720 $r0 = sprintf(
'\x%02x', $ord0 );
721 } elseif ( $ord0 >= 0x80 ) {
723 $r0 = sprintf(
'\x%02x', $ord0 );
724 $allowUnicode =
true;
725 } elseif ( strpos(
'-\\[]^', $d0 ) !==
false ) {
731 if ( $x0 !==
'' && $x1 ===
'-' && $x2 !==
'' ) {
733 if ( $ord2 > $ord0 ) {
735 } elseif ( $ord0 >= 0x80 ) {
737 $allowUnicode =
true;
738 if ( $ord2 < 0x80 ) {
747 $x0 = $x1 = $d0 = $d1 = $r0 = $r1 =
'';
748 } elseif ( $ord2 < 0x80 ) {
753 if ( $ord1 < 0x80 ) {
756 if ( $ord0 < 0x80 ) {
759 if ( $allowUnicode ) {
760 $out .=
'\u0080-\uFFFF';
776 public static function makeName( $ns, $title, $fragment =
'', $interwiki =
'',
777 $canoncialNamespace =
false
781 if ( $canoncialNamespace ) {
784 $namespace = $wgContLang->getNsText( $ns );
786 $name = $namespace ==
'' ? $title :
"$namespace:$title";
787 if ( strval( $interwiki ) !=
'' ) {
788 $name =
"$interwiki:$name";
790 if ( strval( $fragment ) !=
'' ) {
791 $name .=
'#' . $fragment;
803 # Note that we don't urlencode the fragment. urlencoded Unicode
804 # fragments appear not to work in IE (at least up to 7) or in at least
805 # one version of Opera 9.x. The W3C validator, for one, doesn't seem
806 # to care if they aren't encoded.
818 public static function compare( $a, $b ) {
819 if ( $a->getNamespace() == $b->getNamespace() ) {
820 return strcmp( $a->getText(), $b->getText() );
822 return $a->getNamespace() - $b->getNamespace();
837 return $iw->isLocal();
849 return $this->mInterwiki !==
'';
909 if ( $this->mTitleValue === null ) {
915 }
catch ( InvalidArgumentException $ex ) {
916 wfDebug( __METHOD__ .
': Can\'t create a TitleValue for [[' .
957 if ( !is_null( $this->mUserCaseDBKey ) ) {
983 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
984 $this->mContentModel = $linkCache->getGoodLinkFieldObj( $this,
'model' );
987 if ( !$this->mContentModel ) {
1021 $formatter = self::getTitleFormatter();
1022 return $formatter->getNamespaceName( $this->mNamespace, $this->mDbkeyform );
1023 }
catch ( InvalidArgumentException $ex ) {
1024 wfDebug( __METHOD__ .
': ' . $ex->getMessage() .
"\n" );
1064 return $this->mNamespace >=
NS_MAIN;
1094 if (
$name == $thisName ) {
1110 if ( $canonicalName ) {
1112 if ( $localName != $this->mDbkeyform ) {
1222 ? strpos( $this->
getText(),
'/' ) !==
false
1235 strpos( $this->
getText(),
'Conversiontable/' ) === 0;
1265 # @note This hook is also called in ContentHandler::getDefaultModel.
1266 # It's called here again to make sure hook functions can force this
1267 # method to return true even outside the MediaWiki namespace.
1269 Hooks::run(
'TitleIsCssOrJsPage',
array( $this, &$isCssOrJsPage ),
'1.25' );
1271 return $isCssOrJsPage;
1290 $subpage = explode(
'/', $this->mTextform );
1291 $subpage = $subpage[count( $subpage ) - 1];
1292 $lastdot = strrpos( $subpage,
'.' );
1293 if ( $lastdot ===
false ) {
1294 return $subpage; # Never happens: only called
for names ending
in '.css' or '.js'
1296 return substr( $subpage, 0, $lastdot );
1362 throw new MWException(
'Special pages cannot have other pages' );
1398 return $this->mFragment !==
'';
1425 $this->mFragment = strtr( substr( $fragment, 1 ),
'_',
' ' );
1438 $p = $this->mInterwiki .
':';
1441 if ( 0 != $this->mNamespace ) {
1454 $s = $this->
prefix( $this->mDbkeyform );
1455 $s = strtr(
$s,
' ',
'_' );
1466 if ( $this->mPrefixedText === null ) {
1467 $s = $this->
prefix( $this->mTextform );
1468 $s = strtr(
$s,
'_',
' ' );
1469 $this->mPrefixedText =
$s;
1514 return strtok( $this->
getText(),
'/' );
1549 $parts = explode(
'/', $this->
getText() );
1550 # Don't discard the real title if there's no subpage involved
1551 if ( count( $parts ) > 1 ) {
1552 unset( $parts[count( $parts ) - 1] );
1554 return implode(
'/', $parts );
1588 $parts = explode(
'/', $this->mTextform );
1589 return $parts[count( $parts ) - 1];
1626 $s = $this->
prefix( $this->mDbkeyform );
1645 if ( $query2 !==
false ) {
1646 wfDeprecated(
"Title::get{Canonical,Full,Link,Local,Internal}URL " .
1647 "method called with a second parameter is deprecated. Add your " .
1648 "parameter to an array passed as the first parameter.",
"1.19" );
1650 if ( is_array(
$query ) ) {
1654 if ( is_string( $query2 ) ) {
1685 # Hand off all the decisions on urls to getLocalURL
1688 # Expand the url to make it a full url. Note that getLocalURL has the
1689 # potential to output full urls for a variety of reasons, so we use
1690 # wfExpandUrl instead of simply prepending $wgServer
1693 # Finally, add the fragment.
1731 if ( $namespace !=
'' ) {
1732 # Can this actually happen? Interwikis shouldn't be parsed.
1733 # Yes! It can in interwiki transclusion. But... it probably shouldn't.
1736 $url = $interwiki->getURL( $namespace . $this->
getDBkey() );
1741 $url = str_replace(
'$1', $dbkey, $wgArticlePath );
1748 if ( !empty( $wgActionPaths )
1749 && preg_match(
'/^(.*&|)action=([^&]*)(&(.*)|)$/',
$query,
$matches )
1751 $action = urldecode(
$matches[2] );
1752 if ( isset( $wgActionPaths[$action] ) ) {
1757 $url = str_replace(
'$1', $dbkey, $wgActionPaths[$action] );
1765 && $wgVariantArticlePath
1770 $variant = urldecode(
$matches[1] );
1774 $url = str_replace(
'$2', urlencode( $variant ), $wgVariantArticlePath );
1775 $url = str_replace(
'$1', $dbkey, $url );
1779 if ( $url ===
false ) {
1783 $url =
"{$wgScript}?title={$dbkey}&{$query}";
1791 if ( $wgRequest->getVal(
'action' ) ==
'render' ) {
1792 $url = $wgServer . $url;
1841 $server = $wgInternalServer !==
false ? $wgInternalServer :
$wgServer;
1888 if ( is_null( $this->mWatched ) ) {
1889 if (
NS_SPECIAL == $this->mNamespace || !$wgUser->isLoggedIn() ) {
1890 $this->mWatched =
false;
1892 $this->mWatched = $wgUser->isWatched( $this );
1925 public function userCan( $action,
$user = null, $rigor =
'secure' ) {
1950 $action,
$user, $rigor =
'secure', $ignoreErrors =
array()
1955 foreach ( $errors
as $index => $error ) {
1956 $error_key = is_array( $error ) ? $error[0] : $error;
1958 if ( in_array( $error_key, $ignoreErrors ) ) {
1959 unset( $errors[$index] );
1979 array( $this,
$user, $action, &$errors, ( $rigor !==
'quick' ), $short ) )
1984 if ( $action ==
'create' ) {
1989 $errors[] =
$user->isAnon() ?
array(
'nocreatetext' ) :
array(
'nocreate-loggedin' );
1991 } elseif ( $action ==
'move' ) {
1992 if ( !
$user->isAllowed(
'move-rootuserpages' )
1995 $errors[] =
array(
'cant-move-user-page' );
1999 if ( $this->mNamespace ==
NS_FILE && !
$user->isAllowed(
'movefile' ) ) {
2000 $errors[] =
array(
'movenotallowedfile' );
2004 if ( $this->mNamespace ==
NS_CATEGORY && !
$user->isAllowed(
'move-categorypages' ) ) {
2005 $errors[] =
array(
'cant-move-category-page' );
2008 if ( !
$user->isAllowed(
'move' ) ) {
2012 if (
$user->isAnon() && ( $userCanMove || $autoconfirmedCanMove ) ) {
2014 $errors[] =
array(
'movenologintext' );
2016 $errors[] =
array(
'movenotallowed' );
2019 } elseif ( $action ==
'move-target' ) {
2020 if ( !
$user->isAllowed(
'move' ) ) {
2022 $errors[] =
array(
'movenotallowed' );
2023 } elseif ( !
$user->isAllowed(
'move-rootuserpages' )
2026 $errors[] =
array(
'cant-move-to-user-page' );
2027 } elseif ( !
$user->isAllowed(
'move-categorypages' )
2030 $errors[] =
array(
'cant-move-to-category-page' );
2032 } elseif ( !
$user->isAllowed( $action ) ) {
2053 $errors = array_merge( $errors,
$result );
2057 } elseif (
$result ===
false ) {
2059 $errors[] =
array(
'badaccess-group0' );
2088 && !( $short && count( $errors ) > 0 )
2109 # Only 'createaccount' can be performed on special pages,
2110 # which don't actually exist in the DB.
2111 if (
NS_SPECIAL == $this->mNamespace && $action !==
'createaccount' ) {
2112 $errors[] =
array(
'ns-specialprotected' );
2115 # Check $wgNamespaceProtection for restricted namespaces
2117 $ns = $this->mNamespace ==
NS_MAIN ?
2120 array(
'protectedinterface', $action ) :
array(
'namespaceprotected', $ns, $action );
2138 # Protect css/js subpages of user pages
2139 # XXX: this might be better using restrictions
2140 # XXX: right 'editusercssjs' is deprecated, for backward compatibility only
2141 if ( $action !=
'patrol' && !
$user->isAllowed(
'editusercssjs' ) ) {
2142 if ( preg_match(
'/^' . preg_quote(
$user->getName(),
'/' ) .
'\//', $this->mTextform ) ) {
2143 if ( $this->
isCssSubpage() && !
$user->isAllowedAny(
'editmyusercss',
'editusercss' ) ) {
2144 $errors[] =
array(
'mycustomcssprotected', $action );
2145 } elseif ( $this->
isJsSubpage() && !
$user->isAllowedAny(
'editmyuserjs',
'edituserjs' ) ) {
2146 $errors[] =
array(
'mycustomjsprotected', $action );
2150 $errors[] =
array(
'customcssprotected', $action );
2152 $errors[] =
array(
'customjsprotected', $action );
2176 if ( $right ==
'sysop' ) {
2177 $right =
'editprotected';
2180 if ( $right ==
'autoconfirmed' ) {
2181 $right =
'editsemiprotected';
2183 if ( $right ==
'' ) {
2186 if ( !
$user->isAllowed( $right ) ) {
2187 $errors[] =
array(
'protectedpagetext', $right, $action );
2188 } elseif ( $this->mCascadeRestriction && !
$user->isAllowed(
'protect' ) ) {
2189 $errors[] =
array(
'protectedpagetext',
'protect', $action );
2209 # We /could/ use the protection level on the source page, but it's
2210 # fairly ugly as we have to establish a precedence hierarchy for pages
2211 # included by multiple cascade-protected pages. So just restrict
2212 # it to people with 'protect' permission, as they could remove the
2213 # protection anyway.
2215 # Cascading protection depends on more than this page...
2216 # Several cascading protected pages may include this page...
2217 # Check each cascading level
2218 # This is only for protection restrictions, not for all actions
2219 if ( isset( $restrictions[$action] ) ) {
2220 foreach ( $restrictions[$action]
as $right ) {
2222 if ( $right ==
'sysop' ) {
2223 $right =
'editprotected';
2226 if ( $right ==
'autoconfirmed' ) {
2227 $right =
'editsemiprotected';
2229 if ( $right !=
'' && !
$user->isAllowedAll(
'protect', $right ) ) {
2231 foreach ( $cascadingSources
as $page ) {
2232 $pages .=
'* [[:' . $page->getPrefixedText() .
"]]\n";
2234 $errors[] =
array(
'cascadeprotected', count( $cascadingSources ), $pages, $action );
2257 if ( $action ==
'protect' ) {
2260 $errors[] =
array(
'protect-cantedit' );
2262 } elseif ( $action ==
'create' ) {
2264 if ( $title_protection ) {
2265 if ( $title_protection[
'permission'] ==
''
2266 || !
$user->isAllowed( $title_protection[
'permission'] )
2271 $title_protection[
'reason']
2275 } elseif ( $action ==
'move' ) {
2279 $errors[] =
array(
'immobile-source-namespace', $this->
getNsText() );
2282 $errors[] =
array(
'immobile-source-page' );
2284 } elseif ( $action ==
'move-target' ) {
2286 $errors[] =
array(
'immobile-target-namespace', $this->
getNsText() );
2288 $errors[] =
array(
'immobile-target-page' );
2290 } elseif ( $action ==
'delete' ) {
2292 if ( !$tempErrors ) {
2294 $user, $tempErrors, $rigor,
true );
2296 if ( $tempErrors ) {
2298 $errors[] =
array(
'deleteprotected' );
2300 if ( $rigor !==
'quick' && $wgDeleteRevisionsLimit
2303 $errors[] =
array(
'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) );
2323 if ( $rigor ===
'quick' || in_array( $action,
array(
'createaccount',
'unblock' ) ) ) {
2329 if ( $wgEmailConfirmToEdit && !
$user->isEmailConfirmed() ) {
2330 $errors[] =
array(
'confirmedittext' );
2333 $useSlave = ( $rigor !==
'secure' );
2334 if ( ( $action ==
'edit' || $action ==
'create' )
2335 && !
$user->isBlockedFrom( $this, $useSlave )
2339 } elseif (
$user->isBlocked() &&
$user->getBlock()->prevents( $action ) !==
false ) {
2361 $whitelisted =
false;
2363 # Shortcut for public wikis, allows skipping quite a bit of code
2364 $whitelisted =
true;
2365 } elseif (
$user->isAllowed(
'read' ) ) {
2366 # If the user is allowed to read pages, he is allowed to read all pages
2367 $whitelisted =
true;
2368 } elseif ( $this->
isSpecial(
'Userlogin' )
2372 # Always grant access to the login page.
2373 # Even anons need to be able to log in.
2374 $whitelisted =
true;
2375 } elseif ( is_array( $wgWhitelistRead ) && count( $wgWhitelistRead ) ) {
2376 # Time to check the whitelist
2377 # Only do these checks is there's something to check against
2382 if ( in_array(
$name, $wgWhitelistRead,
true ) || in_array( $dbName, $wgWhitelistRead,
true ) ) {
2383 $whitelisted =
true;
2385 # Old settings might have the title prefixed with
2386 # a colon for main-namespace pages
2387 if ( in_array(
':' .
$name, $wgWhitelistRead ) ) {
2388 $whitelisted =
true;
2391 # If it's a special page, ditch the subpage bit and check again
2396 if ( in_array( $pure, $wgWhitelistRead,
true ) ) {
2397 $whitelisted =
true;
2403 if ( !$whitelisted && is_array( $wgWhitelistReadRegexp ) && !empty( $wgWhitelistReadRegexp ) ) {
2406 foreach ( $wgWhitelistReadRegexp
as $listItem ) {
2407 if ( preg_match( $listItem,
$name ) ) {
2408 $whitelisted =
true;
2414 if ( !$whitelisted ) {
2415 # If the title is not whitelisted, give extensions a chance to do so...
2417 if ( !$whitelisted ) {
2436 return array(
'badaccess-group0' );
2439 $groups = array_map(
array(
'User',
'makeGroupLinkWiki' ),
2442 if ( count( $groups ) ) {
2446 $wgLang->commaList( $groups ),
2450 return array(
'badaccess-group0' );
2469 $action,
$user, $rigor =
'secure', $short =
false
2471 if ( $rigor ===
true ) {
2473 } elseif ( $rigor ===
false ) {
2475 } elseif ( !in_array( $rigor,
array(
'quick',
'full',
'secure' ) ) ) {
2476 throw new Exception(
"Invalid rigor parameter '$rigor'." );
2479 # Read has special handling
2480 if ( $action ==
'read' ) {
2482 'checkPermissionHooks',
2483 'checkReadPermissions',
2485 # Don't call checkSpecialsAndNSPermissions or checkCSSandJSPermissions
2486 # here as it will lead to duplicate error messages. This is okay to do
2487 # since anywhere that checks for create will also check for edit, and
2488 # those checks are called for edit.
2489 } elseif ( $action ==
'create' ) {
2491 'checkQuickPermissions',
2492 'checkPermissionHooks',
2493 'checkPageRestrictions',
2494 'checkCascadingSourcesRestrictions',
2495 'checkActionPermissions',
2500 'checkQuickPermissions',
2501 'checkPermissionHooks',
2502 'checkSpecialsAndNSPermissions',
2503 'checkCSSandJSPermissions',
2504 'checkPageRestrictions',
2505 'checkCascadingSourcesRestrictions',
2506 'checkActionPermissions',
2512 while ( count( $checks ) > 0 &&
2513 !( $short && count( $errors ) > 0 ) ) {
2514 $method = array_shift( $checks );
2515 $errors = $this->$method( $action,
$user, $errors, $rigor, $short );
2532 # Remove the create restriction for existing titles
2533 $types = array_diff( $types,
array(
'create' ) );
2535 # Only the create and upload restrictions apply to non-existing titles
2536 $types = array_intersect( $types,
array(
'create',
'upload' ) );
2551 $types = self::getFilteredRestrictionTypes( $this->
exists() );
2554 # Remove the upload restriction for non-file titles
2555 $types = array_diff( $types,
array(
'upload' ) );
2560 wfDebug( __METHOD__ .
': applicable restrictions to [[' .
2561 $this->
getPrefixedText() .
']] are {' . implode(
',', $types ) .
"}\n" );
2584 if ( $this->mTitleProtection === null ) {
2589 'user' =>
'pt_user',
2590 'reason' =>
'pt_reason',
2591 'expiry' =>
'pt_expiry',
2592 'permission' =>
'pt_create_perm'
2601 if ( $row[
'permission'] ==
'sysop' ) {
2602 $row[
'permission'] =
'editprotected';
2604 if ( $row[
'permission'] ==
'autoconfirmed' ) {
2605 $row[
'permission'] =
'editsemiprotected';
2607 $row[
'expiry'] =
$dbr->decodeExpiry( $row[
'expiry'] );
2609 $this->mTitleProtection = $row;
2625 $this->mTitleProtection =
false;
2640 if ( !$restrictions || !$semi ) {
2646 foreach ( array_keys( $semi,
'autoconfirmed' )
as $key ) {
2647 $semi[
$key] =
'editsemiprotected';
2649 foreach ( array_keys( $restrictions,
'autoconfirmed' )
as $key ) {
2650 $restrictions[
$key] =
'editsemiprotected';
2653 return !array_diff( $restrictions, $semi );
2668 # Special pages have inherent protection
2673 # Check regular protection levels
2674 foreach ( $restrictionTypes
as $type ) {
2675 if ( $action == $type || $action ==
'' ) {
2677 foreach ( $wgRestrictionLevels
as $level ) {
2678 if ( in_array( $level, $r ) && $level !=
'' ) {
2698 if ( isset( $wgNamespaceProtection[$this->mNamespace] ) ) {
2699 foreach ( (
array)$wgNamespaceProtection[$this->mNamespace]
as $right ) {
2700 if ( $right !=
'' && !$user->
isAllowed( $right ) ) {
2715 return ( $sources > 0 );
2728 return $getPages ? $this->mCascadeSources !== null : $this->mHasCascadingRestrictions !== null;
2745 $pagerestrictions =
array();
2747 if ( $this->mCascadeSources !== null && $getPages ) {
2748 return array( $this->mCascadeSources, $this->mCascadingRestrictions );
2749 } elseif ( $this->mHasCascadingRestrictions !== null && !$getPages ) {
2750 return array( $this->mHasCascadingRestrictions, $pagerestrictions );
2757 $where_clauses =
array(
2763 $tables =
array(
'templatelinks',
'page_restrictions' );
2764 $where_clauses =
array(
2773 $cols =
array(
'pr_page',
'page_namespace',
'page_title',
2774 'pr_expiry',
'pr_type',
'pr_level' );
2775 $where_clauses[] =
'page_id=pr_page';
2778 $cols =
array(
'pr_expiry' );
2786 foreach (
$res as $row ) {
2787 $expiry =
$dbr->decodeExpiry( $row->pr_expiry );
2788 if ( $expiry > $now ) {
2790 $page_id = $row->pr_page;
2791 $page_ns = $row->page_namespace;
2792 $page_title = $row->page_title;
2794 # Add groups needed for each restriction type if its not already there
2795 # Make sure this restriction type still exists
2797 if ( !isset( $pagerestrictions[$row->pr_type] ) ) {
2798 $pagerestrictions[$row->pr_type] =
array();
2802 isset( $pagerestrictions[$row->pr_type] )
2803 && !in_array( $row->pr_level, $pagerestrictions[$row->pr_type] )
2805 $pagerestrictions[$row->pr_type][] = $row->pr_level;
2814 $this->mCascadeSources = $sources;
2815 $this->mCascadingRestrictions = $pagerestrictions;
2817 $this->mHasCascadingRestrictions = $sources;
2820 return array( $sources, $pagerestrictions );
2844 if ( !$this->mRestrictionsLoaded ) {
2847 return isset( $this->mRestrictions[$action] )
2848 ? $this->mRestrictions[$action]
2860 if ( !$this->mRestrictionsLoaded ) {
2874 if ( !$this->mRestrictionsLoaded ) {
2877 return isset( $this->mRestrictionsExpiry[$action] ) ? $this->mRestrictionsExpiry[$action] :
false;
2886 if ( !$this->mRestrictionsLoaded ) {
2903 foreach (
$res as $row ) {
2924 foreach ( $restrictionTypes
as $type ) {
2926 $this->mRestrictionsExpiry[
$type] =
'infinity';
2929 $this->mCascadeRestriction =
false;
2931 # Backwards-compatibility: also load the restrictions from the page record (old format).
2932 if ( $oldFashionedRestrictions !== null ) {
2933 $this->mOldRestrictions = $oldFashionedRestrictions;
2936 if ( $this->mOldRestrictions ===
false ) {
2937 $this->mOldRestrictions =
$dbr->selectField(
'page',
'page_restrictions',
2941 if ( $this->mOldRestrictions !=
'' ) {
2942 foreach ( explode(
':', trim( $this->mOldRestrictions ) )
as $restrict ) {
2943 $temp = explode(
'=', trim( $restrict ) );
2944 if ( count( $temp ) == 1 ) {
2946 $this->mRestrictions[
'edit'] = explode(
',', trim( $temp[0] ) );
2947 $this->mRestrictions[
'move'] = explode(
',', trim( $temp[0] ) );
2949 $restriction = trim( $temp[1] );
2950 if ( $restriction !=
'' ) {
2951 $this->mRestrictions[$temp[0]] = explode(
',', $restriction );
2957 if ( count( $rows ) ) {
2958 # Current system - load second to make them override.
2961 # Cycle through all the restrictions.
2962 foreach ( $rows
as $row ) {
2965 if ( !in_array( $row->pr_type, $restrictionTypes ) ) {
2971 $expiry =
$dbr->decodeExpiry( $row->pr_expiry );
2974 if ( !$expiry || $expiry > $now ) {
2975 $this->mRestrictionsExpiry[$row->pr_type] = $expiry;
2976 $this->mRestrictions[$row->pr_type] = explode(
',', trim( $row->pr_level ) );
2978 $this->mCascadeRestriction |= $row->pr_cascade;
2983 $this->mRestrictionsLoaded =
true;
2993 if ( !$this->mRestrictionsLoaded ) {
2997 'page_restrictions',
2998 array(
'pr_type',
'pr_expiry',
'pr_level',
'pr_cascade' ),
3007 if ( $title_protection ) {
3009 $expiry =
$dbr->decodeExpiry( $title_protection[
'expiry'] );
3011 if ( !$expiry || $expiry > $now ) {
3013 $this->mRestrictionsExpiry[
'create'] = $expiry;
3014 $this->mRestrictions[
'create'] = explode(
',', trim( $title_protection[
'permission'] ) );
3016 $this->mTitleProtection =
false;
3019 $this->mRestrictionsExpiry[
'create'] =
'infinity';
3021 $this->mRestrictionsLoaded =
true;
3031 $this->mRestrictionsLoaded =
false;
3032 $this->mTitleProtection = null;
3043 $method = __METHOD__;
3045 $dbw->onTransactionIdle(
function ()
use ( $dbw, $method ) {
3047 'page_restrictions',
3048 array(
'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
3053 array(
'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
3070 # We dynamically add a member variable for the purpose of this method
3071 # alone to cache the result. There's no point in having it hanging
3072 # around uninitialized in every Title object; therefore we only add it
3073 # if needed and don't declare it statically.
3074 if ( $this->mHasSubpages === null ) {
3075 $this->mHasSubpages =
false;
3078 $this->mHasSubpages = (bool)$subpages->count();
3099 $conds[] =
'page_title ' .
$dbr->buildLike( $this->
getDBkey() .
'/',
$dbr->anyString() );
3105 $dbr->select(
'page',
3106 array(
'page_id',
'page_namespace',
'page_title',
'page_is_redirect' ),
3112 return $this->mSubpages;
3126 $n =
$dbr->selectField(
'archive',
'COUNT(*)',
3131 $n +=
$dbr->selectField(
'filearchive',
'COUNT(*)',
3150 $deleted = (bool)
$dbr->selectField(
'archive',
'1',
3155 $deleted = (bool)
$dbr->selectField(
'filearchive',
'1',
3156 array(
'fa_name' => $this->
getDBkey() ),
3173 $this->mArticleID = 0;
3177 if (
$flags & self::GAID_FOR_UPDATE ) {
3178 $oldUpdate = $linkCache->forUpdate(
true );
3179 $linkCache->clearLink( $this );
3180 $this->mArticleID = $linkCache->addLinkObj( $this );
3181 $linkCache->forUpdate( $oldUpdate );
3183 if ( -1 == $this->mArticleID ) {
3184 $this->mArticleID = $linkCache->addLinkObj( $this );
3198 if ( !is_null( $this->mRedirect ) ) {
3202 $this->mRedirect =
false;
3207 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3208 $cached = $linkCache->getGoodLinkFieldObj( $this,
'redirect' );
3209 if ( $cached === null ) {
3210 # Trust LinkCache's state over our own
3211 # LinkCache is telling us that the page doesn't exist, despite there being cached
3212 # data relating to an existing page in $this->mArticleID. Updaters should clear
3213 # LinkCache as appropriate, or use $flags = Title::GAID_FOR_UPDATE. If that flag is
3214 # set, then LinkCache will definitely be up to date here, since getArticleID() forces
3215 # LinkCache to refresh its data from the master.
3216 $this->mRedirect =
false;
3220 $this->mRedirect = (bool)$cached;
3233 if ( $this->mLength != -1 ) {
3241 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3242 $cached = $linkCache->getGoodLinkFieldObj( $this,
'length' );
3243 if ( $cached === null ) {
3244 # Trust LinkCache's state over our own, as for isRedirect()
3249 $this->mLength = intval( $cached );
3262 return intval( $this->mLatestID );
3265 $this->mLatestID = 0;
3269 $linkCache->addLinkObj( $this ); #
in case we already had an
article ID
3270 $cached = $linkCache->getGoodLinkFieldObj( $this,
'revision' );
3271 if ( $cached === null ) {
3272 # Trust LinkCache's state over our own, as for isRedirect()
3273 $this->mLatestID = 0;
3277 $this->mLatestID = intval( $cached );
3294 $linkCache->clearLink( $this );
3296 if ( $newid ===
false ) {
3297 $this->mArticleID = -1;
3299 $this->mArticleID = intval( $newid );
3301 $this->mRestrictionsLoaded =
false;
3302 $this->mRestrictions =
array();
3303 $this->mOldRestrictions =
false;
3304 $this->mRedirect = null;
3305 $this->mLength = -1;
3306 $this->mLatestID =
false;
3307 $this->mContentModel =
false;
3308 $this->mEstimateRevisions = null;
3309 $this->mPageLanguage =
false;
3310 $this->mDbPageLanguage = null;
3311 $this->mIsBigDeletion = null;
3316 $linkCache->clear();
3333 return $wgContLang->ucfirst( $text );
3353 $this->mInterwiki =
'';
3354 $this->mFragment =
'';
3362 $titleParser = self::getTitleParser();
3368 $this->mInterwiki = $parts[
'interwiki'];
3369 $this->mLocalInterwiki = $parts[
'local_interwiki'];
3370 $this->mNamespace = $parts[
'namespace'];
3371 $this->mUserCaseDBKey = $parts[
'user_case_dbkey'];
3373 $this->mDbkeyform = $parts[
'dbkey'];
3374 $this->mUrlform =
wfUrlencode( $this->mDbkeyform );
3375 $this->mTextform = strtr( $this->mDbkeyform,
'_',
' ' );
3377 # We already know that some pages won't be in the database!
3379 $this->mArticleID = 0;
3405 array(
'page', $table ),
3406 self::getSelectFields(),
3408 "{$prefix}_from=page_id",
3416 if (
$res->numRows() ) {
3418 foreach (
$res as $row ) {
3421 $linkCache->addGoodLinkObjFromRow( $titleObj, $row );
3422 $retVal[] = $titleObj;
3458 # If the page doesn't exist; there can't be any link from this page
3469 $blNamespace =
"{$prefix}_namespace";
3470 $blTitle =
"{$prefix}_title";
3473 array( $table,
'page' ),
3475 array( $blNamespace, $blTitle ),
3478 array(
"{$prefix}_from" => $id ),
3483 array(
"page_namespace=$blNamespace",
"page_title=$blTitle" )
3489 foreach (
$res as $row ) {
3490 if ( $row->page_id ) {
3494 $linkCache->addBadLinkObj( $titleObj );
3496 $retVal[] = $titleObj;
3526 # All links from article ID 0 are false positives
3532 array(
'page',
'pagelinks' ),
3533 array(
'pl_namespace',
'pl_title' ),
3536 'page_namespace IS NULL'
3538 __METHOD__,
array(),
3542 array(
'pl_namespace=page_namespace',
'pl_title=page_title' )
3548 foreach (
$res as $row ) {
3567 if ( $pageLang->hasVariants() ) {
3568 $variants = $pageLang->getVariants();
3569 foreach ( $variants
as $vCode ) {
3576 $urls[] = $this->getInternalUrl(
'action=raw&ctype=text/javascript' );
3578 $urls[] = $this->getInternalUrl(
'action=raw&ctype=text/css' );
3590 if ( $wgUseSquid ) {
3606 return $this->
moveTo( $nt,
false );
3622 if ( !( $nt instanceof
Title ) ) {
3629 $errors = $mp->isValidMove()->getErrorsArray();
3633 $mp->checkPermissions( $wgUser, $reason )->getErrorsArray()
3637 return $errors ?:
true;
3653 if ( !$wgUser->isAllowed(
'reupload-shared' )
3656 $errors[] =
array(
'file-exists-sharedrepo' );
3674 public function moveTo( &$nt, $auth =
true, $reason =
'', $createRedirect =
true ) {
3677 if ( is_array( $err ) ) {
3679 $wgUser->spreadAnyEditBlock();
3683 if ( $auth && !$wgUser->isAllowed(
'suppressredirect' ) ) {
3684 $createRedirect =
true;
3688 $status = $mp->move( $wgUser, $reason, $createRedirect );
3692 return $status->getErrorsArray();
3708 public function moveSubpages( $nt, $auth =
true, $reason =
'', $createRedirect =
true ) {
3711 if ( !$this->
userCan(
'move-subpages' ) ) {
3712 return array(
'cant-move-subpages' );
3716 return array(
'namespace-nosubpages',
3720 return array(
'namespace-nosubpages',
3724 $subpages = $this->
getSubpages( $wgMaximumMovedPages + 1 );
3727 foreach ( $subpages
as $oldSubpage ) {
3729 if (
$count > $wgMaximumMovedPages ) {
3730 $retval[$oldSubpage->getPrefixedText()] =
3731 array(
'movepage-max-pages',
3732 $wgMaximumMovedPages );
3739 if ( $oldSubpage->getArticleID() == $this->
getArticleID()
3740 || $oldSubpage->getArticleID() == $nt->getArticleID()
3746 $newPageName = preg_replace(
3747 '#^' . preg_quote( $this->
getDBkey(),
'#' ) .
'#',
3748 StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # bug 21234
3749 $oldSubpage->getDBkey() );
3750 if ( $oldSubpage->isTalkPage() ) {
3751 $newNs = $nt->getTalkPage()->getNamespace();
3753 $newNs = $nt->getSubjectPage()->getNamespace();
3755 # Bug 14385: we need makeTitleSafe because the new page names may
3756 # be longer than 255 characters.
3759 $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect );
3761 $retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
3781 $fields =
array(
'page_is_redirect',
'page_latest',
'page_id' );
3782 if ( $wgContentHandlerUseDB ) {
3783 $fields[] =
'page_content_model';
3786 $row = $dbw->selectRow(
'page',
3790 array(
'FOR UPDATE' )
3792 # Cache some fields we may want
3793 $this->mArticleID = $row ? intval( $row->page_id ) : 0;
3794 $this->mRedirect = $row ? (bool)$row->page_is_redirect :
false;
3795 $this->mLatestID = $row ? intval( $row->page_latest ) :
false;
3796 $this->mContentModel = $row && isset( $row->page_content_model )
3797 ? strval( $row->page_content_model )
3800 if ( !$this->mRedirect ) {
3803 # Does the article have a history?
3804 $row = $dbw->selectField(
array(
'page',
'revision' ),
3809 'page_latest != rev_id'
3812 array(
'FOR UPDATE' )
3814 # Return true if there was no history
3815 return ( $row ===
false );
3827 # Is it an existing file?
3828 if ( $nt->getNamespace() ==
NS_FILE ) {
3831 if ( $file->exists() ) {
3832 wfDebug( __METHOD__ .
": file exists\n" );
3836 # Is it a redirect with no history?
3837 if ( !$nt->isSingleRevRedirect() ) {
3838 wfDebug( __METHOD__ .
": not a one-rev redirect\n" );
3841 # Get the article text
3843 if ( !is_object(
$rev ) ) {
3847 # Does the redirect point to the source?
3848 # Or is it a broken self-redirect, usually caused by namespace collisions?
3851 if ( $redirTitle ) {
3853 $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey() ) {
3854 wfDebug( __METHOD__ .
": redirect points to other page\n" );
3860 # Fail safe (not a redirect after all. strange.)
3861 wfDebug( __METHOD__ .
": failsafe: database sais " . $nt->getPrefixedDBkey() .
3862 " is a redirect, but it doesn't contain a valid redirect.\n" );
3881 if ( $titleKey === 0 ) {
3890 array(
'cl_from' => $titleKey ),
3894 if (
$res->numRows() > 0 ) {
3895 foreach (
$res as $row ) {
3914 foreach ( $parents
as $parent => $current ) {
3915 if ( array_key_exists( $parent, $children ) ) {
3916 # Circular reference
3917 $stack[$parent] =
array();
3921 $stack[$parent] = $nt->getParentCategoryTree( $children +
array( $parent => 1 ) );
3937 if ( $this->mArticleID > 0 ) {
3939 return array(
'page_id' => $this->mArticleID );
3941 return array(
'page_namespace' => $this->mNamespace,
'page_title' => $this->mDbkeyform );
3954 $revId = $db->selectField(
'revision',
'rev_id',
3957 'rev_id < ' . intval(
$revId )
3960 array(
'ORDER BY' =>
'rev_id DESC' )
3963 if (
$revId ===
false ) {
3979 $revId = $db->selectField(
'revision',
'rev_id',
3982 'rev_id > ' . intval(
$revId )
3985 array(
'ORDER BY' =>
'rev_id' )
3988 if (
$revId ===
false ) {
4006 array(
'rev_page' => $pageId ),
4008 array(
'ORDER BY' =>
'rev_timestamp ASC',
'LIMIT' => 1 )
4025 return $rev ?
$rev->getTimestamp() : null;
4035 return (
bool)
$dbr->selectField(
'page',
'page_is_new', $this->
pageCond(), __METHOD__ );
4046 if ( !$wgDeleteRevisionsLimit ) {
4050 if ( $this->mIsBigDeletion === null ) {
4053 $revCount =
$dbr->selectRowCount(
4058 array(
'LIMIT' => $wgDeleteRevisionsLimit + 1 )
4073 if ( !$this->
exists() ) {
4077 if ( $this->mEstimateRevisions === null ) {
4079 $this->mEstimateRevisions =
$dbr->estimateRowCount(
'revision',
'*',
4096 if ( !( $old instanceof
Revision ) ) {
4099 if ( !( $new instanceof Revision ) ) {
4102 if ( !$old || !$new ) {
4108 'rev_timestamp > ' .
$dbr->addQuotes(
$dbr->timestamp( $old->getTimestamp() ) ),
4109 'rev_timestamp < ' .
$dbr->addQuotes(
$dbr->timestamp( $new->getTimestamp() ) )
4111 if ( $max !== null ) {
4112 return $dbr->selectRowCount(
'revision',
'1',
4115 array(
'LIMIT' => $max + 1 )
4118 return (
int)
$dbr->selectField(
'revision',
'count(*)', $conds, __METHOD__ );
4139 if ( !( $old instanceof Revision ) ) {
4142 if ( !( $new instanceof Revision ) ) {
4148 if ( !$old || !$new ) {
4155 if ( in_array(
'include_old',
$options ) ) {
4158 if ( in_array(
'include_new',
$options ) ) {
4161 if ( in_array(
'include_both',
$options ) ) {
4166 if ( $old->getId() === $new->getId() ) {
4167 return ( $old_cmp ===
'>' && $new_cmp ===
'<' ) ?
4169 array( $old->getUserText( Revision::RAW ) );
4170 } elseif ( $old->getId() === $new->getParentId() ) {
4171 if ( $old_cmp ===
'>=' && $new_cmp ===
'<=' ) {
4176 } elseif ( $old_cmp ===
'>=' ) {
4178 } elseif ( $new_cmp ===
'<=' ) {
4184 $res =
$dbr->select(
'revision',
'DISTINCT rev_user_text',
4187 "rev_timestamp $old_cmp " .
$dbr->addQuotes(
$dbr->timestamp( $old->getTimestamp() ) ),
4188 "rev_timestamp $new_cmp " .
$dbr->addQuotes(
$dbr->timestamp( $new->getTimestamp() ) )
4192 foreach (
$res as $row ) {
4193 $authors[] = $row->rev_user_text;
4214 return $authors ? count( $authors ) : 0;
4223 public function equals( Title $title ) {
4290 if ( !is_null( $isKnown ) ) {
4298 switch ( $this->mNamespace ) {
4308 return $this->mDbkeyform ==
'';
4349 $wgContLang->lcfirst( $this->getText() )
4351 $message =
wfMessage(
$name )->inLanguage( $wgContLang )->useDatabase(
false );
4352 return $message->exists();
4371 $wgContLang->lcfirst( $this->getText() )
4373 $message =
wfMessage(
$name )->inLanguage( $lang )->useDatabase(
false );
4375 if ( $message->exists() ) {
4376 return $message->plain();
4393 if ( $this->mArticleID === 0 ) {
4397 $method = __METHOD__;
4400 $dbw->onTransactionIdle(
function ()
use ( $dbw, $conds, $method, $purgeTime ) {
4401 $dbTimestamp = $dbw->timestamp( $purgeTime ?: time() );
4405 array(
'page_touched' => $dbTimestamp ),
4406 $conds +
array(
'page_touched < ' . $dbw->addQuotes( $dbTimestamp ) ),
4433 if ( $db === null ) {
4436 $touched = $db->selectField(
'page',
'page_touched', $this->
pageCond(), __METHOD__ );
4454 $uid = $user->
getId();
4459 if ( array_key_exists( $uid, $this->mNotificationTimestamp ) ) {
4460 return $this->mNotificationTimestamp[$uid];
4463 if ( count( $this->mNotificationTimestamp ) >= self::CACHE_MAX ) {
4464 $this->mNotificationTimestamp =
array();
4468 $this->mNotificationTimestamp[$uid] = $watchedItem->getNotificationTimestamp();
4470 return $this->mNotificationTimestamp[$uid];
4492 $namespaceKey = $wgContLang->lc( $namespaceKey );
4494 if ( $namespaceKey ==
'' ) {
4495 $namespaceKey =
'main';
4498 if ( $namespaceKey ==
'file' ) {
4499 $namespaceKey =
'image';
4501 return $prepend . $namespaceKey;
4522 $where[] =
'rd_interwiki = ' .
$dbr->addQuotes(
'' ) .
' OR rd_interwiki IS NULL';
4524 if ( !is_null( $ns ) ) {
4525 $where[
'page_namespace'] = $ns;
4529 array(
'redirect',
'page' ),
4530 array(
'page_namespace',
'page_title' ),
4535 foreach (
$res as $row ) {
4536 $redirs[] = self::newFromRow( $row );
4547 global $wgInvalidRedirectTargets;
4551 if ( $this->
isSpecial(
'Userlogout' ) ) {
4555 foreach ( $wgInvalidRedirectTargets
as $target ) {
4582 $bannedNamespaces = is_null( $wgExemptFromUserRobotsControl )
4583 ? $wgContentNamespaces
4586 return !in_array( $this->mNamespace, $bannedNamespaces );
4601 $unprefixed = $this->
getText();
4608 if ( $prefix !==
'' ) {
4609 # Separate with a line feed, so the unprefixed part is only used as
4610 # a tiebreaker when two pages have the exact same prefix.
4611 # In UCA, tab is the only character that can sort above LF
4612 # so we strip both of them from the original prefix.
4613 $prefix = strtr( $prefix,
"\n\t",
' ' );
4614 return "$prefix\n$unprefixed";
4635 if ( $this->mDbPageLanguage ) {
4639 if ( !$this->mPageLanguage || $this->mPageLanguage[1] !== $wgLanguageCode ) {
4647 $langObj =
wfGetLangObj( $contentHandler->getPageLanguage( $this ) );
4670 $variant = $wgLang->getPreferredVariant();
4671 if ( $wgLang->getCode() !== $variant ) {
4682 $pageLang = $contentHandler->getPageViewLanguage( $this );
4700 $editnotice_ns =
'editnotice-' . $this->
getNamespace();
4702 if ( $msg->exists() ) {
4703 $html = $msg->parseAsBlock();
4705 if ( trim(
$html ) !==
'' ) {
4710 'mw-editnotice-namespace',
4720 $parts = explode(
'/', $this->
getDBkey() );
4721 $editnotice_base = $editnotice_ns;
4722 while ( count( $parts ) > 0 ) {
4723 $editnotice_base .=
'-' . array_shift( $parts );
4725 if ( $msg->exists() ) {
4726 $html = $msg->parseAsBlock();
4727 if ( trim(
$html ) !==
'' ) {
4732 'mw-editnotice-base',
4742 $editnoticeText = $editnotice_ns .
'-' . strtr( $this->
getDBkey(),
'/',
'-' );
4744 if ( $msg->exists() ) {
4745 $html = $msg->parseAsBlock();
4746 if ( trim(
$html ) !==
'' ) {
4751 'mw-editnotice-page',
4760 Hooks::run(
'TitleGetEditNotices',
array( $this, $oldid, &$notices ) );
4775 'mDefaultNamespace',
4780 $this->mArticleID = ( $this->mNamespace >= 0 ) ? -1 : 0;
4781 $this->mUrlform =
wfUrlencode( $this->mDbkeyform );
4782 $this->mTextform = strtr( $this->mDbkeyform,
'_',
' ' );
getEarliestRevTime($flags=0)
Get the oldest revision timestamp of this page.
bool $mHasSubpages
Whether a page has any subpages.
isAlwaysKnown()
Should links to this title be shown as potentially viewable (i.e.
getText()
Returns the title in text form, without namespace prefix or fragment.
static newFromRow($row)
Make a Title object from a DB row.
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
getLatestRevID($flags=0)
What is the page_latest field for this page?
setFragment($fragment)
Set the fragment for this title.
static newFromID($id, $flags=0)
Create a new Title from an article ID.
static getTitleInvalidRegex()
Returns a simple regex that will match on characters and sequences invalid in titles.
static whoIs($id)
Get the username corresponding to a given user ID.
static isMovable($index)
Can pages in the given namespace be moved?
touchLinks()
Update page_touched timestamps and send squid purge messages for pages linking to this title...
getFragment()
Get the Title fragment (i.e. the bit after the #) in text form.
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 & $html
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
mixed $mTitleProtection
Cached value for getTitleProtection (create protection)
exists($flags=0)
Check if page exists.
isMovable()
Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable...
getInternalURL($query= '', $query2=false)
Get the URL form for an internal link.
getRootTitle()
Get the root page name title, i.e.
static getLocalNameFor($name, $subpage=false)
Get the local name for a specified canonical name.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
canUseNoindex()
Whether the magic words INDEX and NOINDEX function for this page.
isJsSubpage()
Is this a .js subpage of a user page?
const CONTENT_MODEL_WIKITEXT
wasLocalInterwiki()
Was this a local interwiki link?
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.$title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
getSquidURLs()
Get a list of URLs to purge from the Squid cache when this page changes.
$wgScript
The URL path to index.php.
magic word the default is to use $key to get the and $key value or $key value text $key value html to format the value $key
isContentPage()
Is this Title in a namespace which contains content? In other words, is this a content page...
getUserCaseDBKey()
Get the DB key with the initial letter case as specified by the user.
Handles the backend logic of moving a page from one title to another.
isNamespaceProtected(User $user)
Determines if $user is unable to edit this page because it has been protected by $wgNamespaceProtecti...
isSpecial($name)
Returns true if this title resolves to the named special page.
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
hasSubpages()
Does this have subpages? (Warning, usually requires an extra DB query.)
static nameOf($id)
Get the prefixed DB key associated with an ID.
getText()
Get the text form (spaces not underscores) of the main part.
getSubpageText()
Get the lowest-level subpage name, i.e.
getBaseText()
Get the base page name without a namespace, i.e.
static newMainPage()
Create a new Title for the Main Page.
getTemplateLinksFrom($options=array())
Get an array of Title objects used on this Title as a template Also stores the IDs in the link cache...
moveSubpages($nt, $auth=true, $reason= '', $createRedirect=true)
Move this page's subpages to be subpages of $nt.
getDefaultMessageText()
Get the default message text or false if the message doesn't exist.
getAuthorsBetween($old, $new, $limit, $options=array())
Get the authors between the given revisions or revision IDs.
Allows to change the fields on the form that will be generated $name
getEditNotices($oldid=0)
Get a list of rendered edit notices for this page.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
getSubjectNsText()
Get the namespace text of the subject (rather than talk) page.
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 & $ret
getUserPermissionsErrorsInternal($action, $user, $rigor= 'secure', $short=false)
Can $user perform $action on this page? This is an internal function, which checks ONLY that previous...
namespace and then decline to actually register it file or subcat img or subcat RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
getTransWikiID()
Returns the DB name of the distant wiki which owns the object.
getUserPermissionsErrors($action, $user, $rigor= 'secure', $ignoreErrors=array())
Can $user perform $action on this page?
isCssJsSubpage()
Is this a .css or .js subpage of a user page?
static canTalk($index)
Can this namespace ever have a talk namespace?
$wgInternalServer
Internal server name as known to Squid, if different.
isWatchable()
Can this title be added to a user's watchlist?
checkUserBlock($action, $user, $errors, $rigor, $short)
Check that the user isn't blocked from editing.
processing should stop and the error should be shown to the user * false
static isTalk($index)
Is the given namespace a talk namespace?
$wgRestrictionLevels
Rights which can be required for each protection level (via action=protect)
hasSubjectNamespace($ns)
Returns true if the title has the same subject namespace as the namespace specified.
secureAndSplit()
Secure and split - main initialisation function for this object.
bool $mIsBigDeletion
Would deleting this page be a big deletion?
inNamespaces()
Returns true if the title is inside one of the specified namespaces.
moveNoAuth(&$nt)
Move this page without authentication.
isTalkPage()
Is this a talk page of some sort?
string $mUrlform
URL-encoded form of the main part.
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title...
wfDebug($text, $dest= 'all', array $context=array())
Sends a line to the debug log if enabled or, optionally, to a comment in output.
null for the local wiki Added in
isRedirect($flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
Represents a page (or page fragment) title within MediaWiki.
isBigDeletion()
Check whether the number of revisions of this page surpasses $wgDeleteRevisionsLimit.
prefix($name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object. ...
getOtherPage()
Get the other title for this page, if this is a subject page get the talk page, if it is a subject pa...
static escapeFragmentForURL($fragment)
Escape a text fragment, say from a link, for a URL.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
isValidMoveTarget($nt)
Checks if $this can be moved to a given Title.
static escapeClass($class)
Given a value, escape it so that it can be used as a CSS class and return it.
$wgSemiprotectedRestrictionLevels
Restriction levels that should be considered "semiprotected".
$wgEmailConfirmToEdit
Should editors be required to have a validated e-mail address before being allowed to edit...
getPrefixedText()
Get the prefixed title with spaces.
static exists($index)
Returns whether the specified namespace exists.
wfUrlencode($s)
We want some things to be included as literal characters in our title URLs for prettiness, which urlencode encodes by default.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
getBaseTitle()
Get the base page name title, i.e.
Represents a title within MediaWiki.
when a variable name is used in a it is silently declared as a new local masking the global
wfExpandUrl($url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
getParentCategories()
Get categories to which this Title belongs and return an array of categories' names.
getBacklinkCache()
Get a backlink cache object.
wfLocalFile($title)
Get an object referring to a locally registered file.
The TitleArray class only exists to provide the newFromResult method at pre- sent.
checkQuickPermissions($action, $user, $errors, $rigor, $short)
Permissions checks that fail most often, and which are easiest to test.
getSkinFromCssJsSubpage()
Trim down a .css or .js subpage title to get the corresponding skin name.
static getFilteredRestrictionTypes($exists=true)
Get a filtered list of all restriction types supported by this wiki.
$wgRestrictionTypes
Set of available actions that can be restricted via action=protect You probably shouldn't change this...
getTalkPage()
Get a Title object associated with the talk page of this article.
array $mCascadeSources
Where are the cascading restrictions coming from on this page?
getNotificationTimestamp($user=null)
Get the timestamp when this page was updated since the user last saw it.
fixSpecialName()
If the Title refers to a special page alias which is not the local default, resolve the alias...
static isEveryoneAllowed($right)
Check if all users have the given permission.
getSubpages($limit=-1)
Get all subpages of this page.
userCan($action, $user=null, $rigor= 'secure')
Can $user perform $action on this page?
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
$wgUseSquid
Enable/disable Squid.
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
$wgContentHandlerUseDB
Set to false to disable use of the database fields introduced by the ContentHandler facility...
static isCapitalized($index)
Is the namespace first-letter capitalized?
static get(Title $title)
Create a new BacklinkCache or reuse any existing one.
getLinksTo($options=array(), $table= 'pagelinks', $prefix= 'pl')
Get an array of Title objects linking to this Title Also stores the IDs in the link cache...
$wgLanguageCode
Site language code.
bool $mCascadeRestriction
Cascade restrictions on this page to included templates and images?
inNamespace($ns)
Returns true if the title is inside the specified namespace.
flushRestrictions()
Flush the protection cache in this object and force reload from the database.
getContentModel($flags=0)
Get the page's content model id, see the CONTENT_MODEL_XXX constants.
getLength($flags=0)
What is the length of this page? Uses link cache, adding it if necessary.
string $mDbkeyform
Main part with underscores.
getNsText()
Get the namespace text.
static fromUserTitle($user, $title, $checkRights=WatchedItem::CHECK_USER_RIGHTS)
Create a WatchedItem object with the given user and title.
isValidMoveOperation(&$nt, $auth=true, $reason= '')
Check whether a given move operation would be valid.
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 article
getNextRevisionID($revId, $flags=0)
Get the revision ID of the next revision.
loadRestrictionsFromResultWrapper($res, $oldFashionedRestrictions=null)
Loads a string into mRestrictions array.
string bool $mOldRestrictions
Text form (spaces not underscores) of the main part.
wfReadOnly()
Check whether the wiki is in read-only mode.
isExternal()
Is this Title interwiki?
static fixUrlQueryArgs($query, $query2=false)
Helper to fix up the get{Canonical,Full,Link,Local,Internal}URL args get{Canonical,Full,Link,Local,Internal}URL methods accepted an optional second argument named variant.
deleteTitleProtection()
Remove any title protection due to page existing.
static getMain()
Static methods.
int $mNamespace
Namespace index, i.e.
static groupHasPermission($group, $role)
Check, if the given group has the given permission.
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
static getCanonicalName($index)
Returns the canonical (English) name for a given index.
hasSourceText()
Does this page have source text?
static newFromIDs($ids)
Make an array of titles from an array of IDs.
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
$wgWhitelistRead
Pages anonymous user may see, set as an array of pages titles.
static deprecated($func, $version, $component=false)
Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if self::$enableDeprecationWa...
static getTitleFormatter()
B/C kludge: provide a TitleParser for use by Title.
isAllowed($action= '')
Internal mechanics of testing a permission.
Class to invalidate the HTML cache of all the pages linking to a given title.
getDBkey()
Get the main part with underscores.
__toString()
Return a string representation of this title.
getPrefixedURL()
Get a URL-encoded title (not an actual URL) including interwiki.
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
hasFragment()
Check if a Title fragment is set.
hasContentModel($id)
Convenience method for checking a title's content model name.
$wgExemptFromUserRobotsControl
An array of namespace keys in which the INDEX/__NOINDEX__ magic words will not function, so users can't decide whether pages in that namespace are indexed by search engines.
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
wfGetDB($db, $groups=array(), $wiki=false)
Get a Database object.
namespace and then decline to actually register it file or subcat img or subcat RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static addUpdate(DeferrableUpdate $update)
Add an update to the deferred list.
areRestrictionsCascading()
Returns cascading restrictions for the current article.
isConversionTable()
Is this a conversion table for the LanguageConverter?
static newFromDBkey($key)
Create a new Title from a prefixed DB key.
getRootText()
Get the root page name text without a namespace, i.e.
getTouched($db=null)
Get the last touched timestamp.
getLocalURL($query= '', $query2=false)
Get a URL with no fragment or server name (relative URL) from a Title object.
checkCSSandJSPermissions($action, $user, $errors, $rigor, $short)
Check CSS/JS sub-page permissions.
bool string $mContentModel
ID of the page's content model, i.e.
canExist()
Is this in a namespace that allows actual pages?
getSubpage($text)
Get the title for a subpage of the current page.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
namespace and then decline to actually register it file or subcat img or subcat RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
static run($event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
null $mRedirect
Is the article at this title a redirect?
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
$wgWhitelistReadRegexp
Pages anonymous user may see, set as an array of regular expressions.
isValidRedirectTarget()
Check if this Title is a valid redirect target.
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 in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
isCascadeProtected()
Cascading protection: Return true if cascading restrictions apply to this page, false if not...
invalidateCache($purgeTime=null)
Updates page_touched for this page; called from LinksUpdate.php.
getDefaultNamespace()
Get the default namespace index, for when there is no namespace.
moveTo(&$nt, $auth=true, $reason= '', $createRedirect=true)
Move a title to a new location.
getRedirectsHere($ns=null)
Get all extant redirects to this Title.
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
checkSpecialsAndNSPermissions($action, $user, $errors, $rigor, $short)
Check permissions on special pages & namespaces.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getCanonicalURL($query= '', $query2=false)
Get the URL for a canonical link, for use in things like IRC and e-mail notifications.
isSubpageOf(Title $title)
Check if this title is a subpage of another title.
static makeTitleSafe($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
static subjectEquals($ns1, $ns2)
Returns whether the specified namespaces share the same subject.
validateFileMoveOperation($nt)
Check if the requested move target is a valid file move target.
isCssSubpage()
Is this a .css subpage of a user page?
isMainPage()
Is this the mainpage?
static decodeCharReferencesAndNormalize($text)
Decode any character references, numeric or named entities, in the next and normalize the resulting s...
Allows to change the fields on the form that will be generated just before adding its HTML to parser output an object of one of the gallery classes(inheriting from ImageGalleryBase) $html conditions will AND in the final query as a Content object as a Content object $title
static hasSubpages($index)
Does the namespace allow subpages?
namespace and then decline to actually register it file or subcat img or subcat RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context $revId
getNamespace()
Get the namespace index, i.e.
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 text
string $mInterwiki
Interwiki prefix.
equals(Title $title)
Compare with another title.
isKnown()
Does this title refer to a page that can (or might) be meaningfully viewed? In particular, this function may be used to determine if links to the title should be rendered as "bluelinks" (as opposed to "redlinks" to non-existent pages).
static newFromResult($res)
Handles a simple LRU key/value map with a maximum number of entries.
areRestrictionsLoaded()
Accessor for mRestrictionsLoaded.
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static newFromRedirect($text)
Extract a redirect destination from a string and return the Title, or null if the text doesn't contai...
static escapeId($id, $options=array())
Given a value, escape it so that it can be used in an id attribute and return it. ...
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
checkCascadingSourcesRestrictions($action, $user, $errors, $rigor, $short)
Check restrictions on cascading pages.
static equals($ns1, $ns2)
Returns whether the specified namespaces are the same namespace.
isSubpage()
Is this a subpage?
getInterwiki()
Get the interwiki prefix.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
loadFromRow($row)
Load Title object fields from a DB row.
areCascadeProtectionSourcesLoaded($getPages=true)
Determines whether cascading protection sources have already been loaded from the database...
namespace and then decline to actually register it & $namespaces
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
getBrokenLinksFrom()
Get an array of Title objects referring to non-existent articles linked from this page...
getNamespaceKey($prepend= 'nstab-')
Generate strings used for xml 'id' names in monobook tabs.
countRevisionsBetween($old, $new, $max=null)
Get the number of revisions between the given revision.
array $mRestrictionsExpiry
When do the restrictions on this page expire?
static fetch($prefix)
Fetch an Interwiki object.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
static newFromTitleValue(TitleValue $titleValue)
Create a new Title from a TitleValue.
getRestrictions($action)
Accessor/initialisation for mRestrictions.
namespace and then decline to actually register it file or subcat img or subcat RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
getSubjectPage()
Get a title object associated with the subject page of this talk page.
int $mLength
The page length, 0 for special pages.
Handles purging appropriate Squid URLs given a title (or titles)
wfDebugLog($logGroup, $text, $dest= 'all', array $context=array())
Send a line to a supplementary debug log file, if configured, or main debug log if not...
getFirstRevision($flags=0)
Get the first revision of the page.
static newFromTextThrow($text, $defaultNamespace=NS_MAIN)
Like Title::newFromText(), but throws MalformedTitleException when the title is invalid, rather than returning null.
isSpecialPage()
Returns true if this is a special page.
$wgContentNamespaces
Array of namespaces which can be deemed to contain valid "content", as far as the site statistics are...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
quickUserCan($action, $user=null)
Can $user perform $action on this page? This skips potentially expensive cascading permission checks ...
static newFromTitle($title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
getEditURL()
Get the edit URL for this Title.
wfGetAllCallers($limit=3)
Return a string consisting of callers in the stack.
$wgLegalTitleChars
Allowed title characters – regex character class Don't change this unless you know what you're doing...
loadRestrictions($oldFashionedRestrictions=null)
Load restrictions from the page_restrictions table.
static & singleton()
Get an instance of this class.
static getTalk($index)
Get the talk namespace index for a given namespace.
static convertByteClassToUnicodeClass($byteClass)
Utility method for converting a character sequence from bytes to Unicode.
$wgNamespaceProtection
Set the minimum permissions required to edit pages in each namespace.
isSingleRevRedirect()
Checks if this page is just a one-rev redirect.
static makeName($ns, $title, $fragment= '', $interwiki= '', $canoncialNamespace=false)
Make a prefixed DB key from a DB key and a namespace index.
getLinkURL($query= '', $query2=false, $proto=PROTO_RELATIVE)
Get a URL that's the simplest URL that will be valid to link, locally, to the current Title...
within a display generated by the Derivative if and wherever such third party notices normally appear The contents of the NOTICE file are for informational purposes only and do not modify the License You may add Your own attribution notices within Derivative Works that You alongside or as an addendum to the NOTICE text from the provided that such additional attribution notices cannot be construed as modifying the License You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for or distribution of Your or for any such Derivative Works as a provided Your and distribution of the Work otherwise complies with the conditions stated in this License Submission of Contributions Unless You explicitly state any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this without any additional terms or conditions Notwithstanding the nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions Trademarks This License does not grant permission to use the trade names
getPageViewLanguage()
Get the language in which the content of this page is written when viewed by user.
getSubpageUrlForm()
Get a URL-encoded form of the subpage text.
$mCascadingRestrictions
Caching the results of getCascadeProtectionSources.
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
const CONTENT_MODEL_JAVASCRIPT
string $mDbPageLanguage
The page language code from the database.
static resolveAlias($alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
getId()
Get the user's ID.
getRestrictionTypes()
Returns restriction types for the current Title.
static exists($name)
Check if a given name exist as a special page or as a special page alias.
static isContent($index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
TitleValue $mTitleValue
A corresponding TitleValue object.
bool $mPageLanguage
The (string) language code of the page's language and content code.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
bool $mWatched
Is $wgUser watching this page? null if unfilled, accessed through userIsWatching() ...
isTrans()
Determine whether the object refers to a page within this project and is transcludable.
string $mFragment
Title fragment (i.e.
int $mArticleID
Article ID, fetched from the link cache on demand.
int $mDefaultNamespace
Namespace index when there is no namespace.
getCategorySortkey($prefix= '')
Returns the raw sort key to be used for categories, with the specified prefix.
wfArrayToCgi($array1, $array2=null, $prefix= '')
This function takes two arrays as input, and returns a CGI-style string, e.g.
static newFromRedirectArray($text)
Extract a redirect destination from a string and return an array of Titles, or null if the text doesn...
static newFromURL($url)
THIS IS NOT THE FUNCTION YOU WANT.
getPageLanguage()
Get the language in which the content of this page is written in wikitext.
const CACHE_MAX
Title::newFromText maintains a cache to avoid expensive re-normalization of commonly used titles...
checkReadPermissions($action, $user, $errors, $rigor, $short)
Check that the user is allowed to read this page.
when a variable name is used in a function
static getTitleParser()
B/C kludge: provide a TitleParser for use by Title.
isCssOrJsPage()
Could this page contain custom CSS or JavaScript for the global UI.
getCascadeProtectionSources($getPages=true)
Cascading protection: Get the source of any cascading restrictions on this page.
getFragmentForURL()
Get the fragment in URL form, including the "#" character if there is one.
$wgDeleteRevisionsLimit
Optional to restrict deletion of pages with higher revision counts to users with the 'bigdelete' perm...
pageCond()
Get an associative array for selecting this title from the "page" table.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
isDeletedQuick()
Is there a version of this page in the deletion archive?
isNewPage()
Check if this is a new page.
missingPermissionError($action, $short)
Get a description array when the user doesn't have the right to perform $action (i.e.
isProtected($action= '')
Does the title correspond to a protected article?
canTalk()
Could this title have a corresponding talk page?
checkActionPermissions($action, $user, $errors, $rigor, $short)
Check action permissions not already checked in checkQuickPermissions.
bool $mRestrictionsLoaded
Boolean for initialisation on demand.
static legalChars()
Get a regex character class describing the legal characters in a link.
static rawElement($element, $attribs=array(), $contents= '')
Returns an HTML element in a string.
getTemplateLinksTo($options=array())
Get an array of Title objects using this Title as a template Also stores the IDs in the link cache...
$mPrefixedText
Text form (spaces not underscores) of the main part.
$wgServer
URL of the server.
isDeleted()
Is there a version of this page in the deletion archive?
isLocal()
Determine whether the object refers to a page within this project (either this wiki or a wiki with a ...
loadRestrictionsFromRows($rows, $oldFashionedRestrictions=null)
Compiles list of active page restrictions from both page table (pre 1.10) and page_restrictions table...
array $mRestrictions
Array of groups allowed to edit this article.
getTitleProtection()
Is this title subject to title protection? Title protection is the one applied against creation of su...
bool $mLocalInterwiki
Was this Title created from a string with a local interwiki prefix?
getLinksFrom($options=array(), $table= 'pagelinks', $prefix= 'pl')
Get an array of Title objects linked from this Title Also stores the IDs in the link cache...
static compare($a, $b)
Callback for usort() to do title sorts by (namespace, title)
int $mEstimateRevisions
Estimated number of revisions; null of not loaded.
wfFindFile($title, $options=array())
Find a file.
getParentCategoryTree($children=array())
Get a tree of parent categories.
getTalkNsText()
Get the namespace text of the talk page.
checkPageRestrictions($action, $user, $errors, $rigor, $short)
Check against page_restrictions table requirements on this page.
static getSelectFields()
Returns a list of fields that are to be selected for initializing Title objects or LinkCache entries...
maintenance dev scripts can help quickly setup a local MediaWiki for development purposes Wikis setup in this way are NOT meant to be publicly available They use a development database not acceptible for use in production Place a sqlite database in an unsafe location a real wiki should never place it in And use predictable default logins for the initial administrator user Running maintenance dev install sh will download and install a local copy of php
checkPermissionHooks($action, $user, $errors, $rigor, $short)
Check various permission hooks.
static factory($code)
Get a cached or new language object for a given language code.
string $mTextform
Text form (spaces not underscores) of the main part.
static selectFields()
Return the list of revision fields that should be selected to create a new page.
getAllRestrictions()
Accessor/initialisation for mRestrictions.
isSemiProtected($action= 'edit')
Is this page "semi-protected" - the only protection levels are listed in $wgSemiprotectedRestrictionL...
namespace and then decline to actually register it file or subcat img or subcat RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
static getSubject($index)
Get the subject namespace index for a given namespace Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject.
bool int $mLatestID
ID of most recent revision.
resultToError($errors, $result)
Add the resulting error code to the errors array.
getRestrictionExpiry($action)
Get the expiry time for the restriction against a given action.
userIsWatching()
Is $wgUser watching this page?
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account incomplete not yet checked for validity & $retval
getPreviousRevisionID($revId, $flags=0)
Get the revision ID of the previous revision.
$wgVariantArticlePath
Like $wgArticlePath, but on multi-variant wikis, this provides a path format that describes which par...
$wgMaximumMovedPages
Maximum number of pages to move at once when moving subpages with a page.
static isWatchable($index)
Can pages in a namespace be watched?
static capitalize($text, $ns=NS_MAIN)
Capitalize a text string for a title if it belongs to a namespace that capitalizes.
isWikitextPage()
Does that page contain wikitext, or it is JS, CSS or whatever?
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static singleton()
Get the signleton instance of this class.
purgeSquid()
Purge all applicable Squid URLs.
static getGroupsWithPermission($role)
Get all the groups who have a given permission.
resetArticleID($newid)
This clears some fields in this object, and clears any associated keys in the "bad links" section of ...
countAuthorsBetween($old, $new, $limit, $options=array())
Get the number of authors between the given revisions or revision IDs.
getTitleValue()
Get a TitleValue object representing this Title.
bool $mHasCascadingRestrictions
Are cascading restrictions in effect on this page?
getPartialURL()
Get the URL-encoded form of the main part.
static newFromRedirectRecurse($text)
Extract a redirect destination from a string and return the Title, or null if the text doesn't contai...
wfGetLangObj($langcode=false)
Return a Language object from $langcode.
getPrefixedDBkey()
Get the prefixed database key form.
getFullURL($query= '', $query2=false, $proto=PROTO_RELATIVE)
Get a real URL referring to this title, with interwiki link and fragment.
estimateRevisionCount()
Get the approximate revision count of this page.
$mNotificationTimestamp
Text form (spaces not underscores) of the main part.
string $mUserCaseDBKey
Database key with the initial letter in the case specified by the user.