ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Title Class Reference

Title class. More...

+ Collaboration diagram for Title:

Public Member Functions

 isLocal ()
 Determine whether the object refers to a page within this project. More...
 
 isTrans ()
 Determine whether the object refers to a page within this project and is transcludable. More...
 
 getText ()
 Simple accessors. More...
 
 getPartialURL ()
 Get the URL-encoded form of the main part. More...
 
 getDBkey ()
 Get the main part with underscores. More...
 
 getNamespace ()
 Get the namespace index, i.e. More...
 
 getNsText ()
 Get the namespace text. More...
 
 getInterwiki ()
 Get the namespace text of the subject (rather than talk) page. More...
 
 getFragment ()
 Get the Title fragment (i.e. More...
 
 getFragmentForURL ()
 Get the fragment in URL form, including the "#" character if there is one. More...
 
 getDefaultNamespace ()
 Get the default namespace index, for when there is no namespace. More...
 
 getIndexTitle ()
 Get title for search index. More...
 
 getPrefixedDBkey ()
 Get the prefixed database key form. More...
 
 getPrefixedText ()
 Get the prefixed title with spaces. More...
 
 getFullText ()
 Get the prefixed title with spaces, plus any fragment (part beginning with '#') More...
 
 getBaseText ()
 Get the base name, i.e. More...
 
 getSubpageText ()
 Get the lowest-level subpage name, i.e. More...
 
 getSubpageUrlForm ()
 Get a URL-encoded form of the subpage text. More...
 
 getPrefixedURL ()
 Get a URL-encoded title (not an actual URL) including interwiki. More...
 
 getFullURL ( $query='', $variant=false)
 Get a real URL referring to this title, with interwiki link and fragment. More...
 
 getLocalURL ( $query='', $variant=false)
 Get a URL with no fragment or server name. More...
 
 escapeLocalURL ( $query='')
 Get an HTML-escaped version of the URL form, suitable for using in a link, without a server name or fragment. More...
 
 escapeFullURL ( $query='')
 Get an HTML-escaped version of the URL form, suitable for using in a link, including the server name and fragment. More...
 
 getInternalURL ( $query='', $variant=false)
 Get the URL form for an internal link. More...
 
 getEditURL ()
 Get the edit URL for this Title. More...
 
 getEscapedText ()
 Get the HTML-escaped displayable text form. More...
 
 isExternal ()
 Is this Title interwiki? More...
 
 isSemiProtected ( $action='edit')
 Is this page "semi-protected" - the only protection is autoconfirm? More...
 
 isProtected ( $action='')
 Does the title correspond to a protected article? More...
 
 userIsWatching ()
 Is $wgUser is watching this page? More...
 
 quickUserCan ( $action)
 Can $wgUser perform $action on this page? This skips potentially expensive cascading permission checks. More...
 
 userCan ( $action, $doExpensiveQueries=true)
 Can $wgUser perform $action on this page? More...
 
 userCanEdit ( $doExpensiveQueries=true)
 Can $wgUser edit this page? More...
 
 userCanCreate ( $doExpensiveQueries=true)
 Can $wgUser create this page? More...
 
 userCanMove ( $doExpensiveQueries=true)
 Can $wgUser move this page? More...
 
 userCanRead ()
 Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable. More...
 
 isSubpage ()
 Is this a talk page of some sort? More...
 
 isCssJsSubpage ()
 Is this a .css or .js subpage of a user page? More...
 
 isValidCssJsSubpage ()
 Is this a valid .css or .js subpage of a user page? Check that the corresponding skin exists. More...
 
 getSkinFromCssJsSubpage ()
 Trim down a .css or .js subpage title to get the corresponding skin name. More...
 
 isCssSubpage ()
 Is this a .css subpage of a user page? More...
 
 isJsSubpage ()
 Is this a .js subpage of a user page? More...
 
 userCanEditCssJsSubpage ()
 Protect css/js subpages of user pages: can $wgUser edit this page? More...
 
 isCascadeProtected ()
 Cascading protection: Return true if cascading restrictions apply to this page, false if not. More...
 
 getCascadeProtectionSources ( $get_pages=true)
 Cascading protection: Get the source of any cascading restrictions on this page. More...
 
 areRestrictionsCascading ()
 
 loadRestrictions ( $oldFashionedRestrictions=NULL)
 
 getRestrictions ( $action)
 Accessor/initialisation for mRestrictions. More...
 
 isDeleted ()
 Is there a version of this page in the deletion archive? More...
 
 getArticleID ( $flags=0)
 Get the article ID for this Title from the link cache, adding it if necessary. More...
 
 getLatestRevID ()
 
 resetArticleID ( $newid)
 This clears some fields in this object, and clears any associated keys in the "bad links" section of the link cache. More...
 
 invalidateCache ()
 Updates page_touched for this page; called from LinksUpdate.php. More...
 
 setFragment ( $fragment)
 Set the fragment for this title This is kind of bad, since except for this rarely-used function, Title objects are immutable. More...
 
 getLinksTo ( $options='', $table='pagelinks', $prefix='pl')
 Get a Title object associated with the talk page of this article. More...
 
 getTemplateLinksTo ( $options='')
 Get an array of Title objects using this Title as a template Also stores the IDs in the link cache. More...
 
 getBrokenLinksFrom ( $options='')
 Get an array of Title objects referring to non-existent articles linked from this page. More...
 
 getSquidURLs ()
 Get a list of URLs to purge from the Squid cache when this page changes. More...
 
 purgeSquid ()
 
 moveNoAuth (&$nt)
 Move this page without authentication. More...
 
 isValidMoveOperation (&$nt, $auth=true)
 Check whether a given move operation would be valid. More...
 
 moveTo (&$nt, $auth=true, $reason='')
 Move a title to a new location. More...
 
 isValidMoveTarget ( $nt)
 Checks if $this can be moved to a given Title. More...
 
 getParentCategories ()
 Get categories to which this Title belongs and return an array of categories' names. More...
 
 getParentCategoryTree ( $children=array())
 Get a tree of parent categories. More...
 
 pageCond ()
 Get an associative array for selecting this title from the "page" table. More...
 
 getPreviousRevisionID ( $revision)
 Get the revision ID of the previous revision. More...
 
 getNextRevisionID ( $revision)
 Get the revision ID of the next revision. More...
 
 countRevisionsBetween ( $old, $new)
 Get the number of revisions between the given revision IDs. More...
 
 equals ( $title)
 Compare with another title. More...
 
 exists ()
 Check if page exists. More...
 
 isAlwaysKnown ()
 Should a link should be displayed as a known link, just based on its title? More...
 
 touchLinks ()
 Update page_touched timestamps and send squid purge messages for pages linking to this title. More...
 
 getTouched ()
 Get the last touched timestamp. More...
 
 trackbackURL ()
 
 trackbackRDF ()
 
 getNamespaceKey ()
 Generate strings used for xml 'id' names in monobook tabs. More...
 
 isSpecial ( $name)
 Returns true if this title resolves to the named special page. More...
 
 fixSpecialName ()
 If the Title refers to a special page alias which is not the local default, returns a new Title which points to the local default. More...
 

Static Public Member Functions

static newFromDBkey ( $key)
 Create a new Title from a prefixed DB key. More...
 
static newFromText ( $text, $defaultNamespace=NS_MAIN)
 Create a new Title from text, such as what one would find in a link. More...
 
static newFromURL ( $url)
 Create a new Title from URL-encoded text. More...
 
static newFromID ( $id)
 Create a new Title from an article ID. More...
 
static newFromIDs ( $ids)
 Make an array of titles from an array of IDs. More...
 
static & makeTitle ( $ns, $title)
 Create a new Title from a namespace index and a DB key. More...
 
static makeTitleSafe ( $ns, $title)
 Create a new Title from a namespace index and a DB key. More...
 
static newMainPage ()
 Create a new Title for the Main Page. More...
 
static newFromRedirect ( $text)
 Create a new Title for a redirect. More...
 
 nameOf ( $id)
 Get the prefixed DB key associated with an ID. More...
 
static legalChars ()
 Get a regex character class describing the legal characters in a link. More...
 
static indexTitle ( $ns, $title)
 Get a string representation of a title suitable for including in a search index. More...
 
static makeName ( $ns, $title)
 
 getInterwikiLink ( $key)
 Returns the URL associated with an interwiki prefix. More...
 
static getInterwikiCached ( $key)
 Fetch interwiki prefix data from local cache in constant database. More...
 
static escapeFragmentForURL ( $fragment)
 Escape a text fragment, say from a link, for a URL. More...
 
static purgeExpiredRestrictions ()
 Purge expired restrictions from the page_restrictions table. More...
 

Data Fields

 $mUrlform
 
 $mDbkeyform
 
 $mNamespace
 
 $mInterwiki
 
 $mFragment
 
 $mArticleID
 
 $mLatestID
 
 $mRestrictions
 
 $mCascadeRestriction
 
 $mRestrictionsExpiry
 
 $mHasCascadingRestrictions
 
 $mCascadeRestrictionSources
 
 $mRestrictionsLoaded
 
 $mPrefixedText
 
 $mDefaultNamespace
 
 $mWatched
 

Private Member Functions

 __construct ()
 #- More...
 
 loadRestrictionsFromRow ( $res, $oldFashionedRestrictions=NULL)
 Loads a string into mRestrictions array. More...
 
 prefix ( $name)
 Prefix some arbitrary text with the namespace or interwiki prefix of this object. More...
 
 secureAndSplit ()
 Secure and split - main initialisation function for this object. More...
 
 moveOverExistingRedirect (&$nt, $reason='')
 Move page to a title which is at present a redirect to the source page. More...
 
 moveToNewTitle (&$nt, $reason='')
 Move page to non-existing title. More...
 

Private Attributes

 $mTextform
 All member variables should be considered private Please use the accessor functions. More...
 

Static Private Attributes

static $titleCache =array()
 Static cache variables. More...
 
static $interwikiCache =array()
 

Detailed Description

Title class.

  • Represents a title, which may contain an interwiki designation or namespace
  • Can fetch various kinds of data from the database, albeit inefficiently.

Definition at line 30 of file Title.php.

Constructor & Destructor Documentation

◆ __construct()

Title::__construct ( )
private

#-

Constructor

Definition at line 72 of file Title.php.

72 {
73 $this->mInterwiki = $this->mUrlform =
74 $this->mTextform = $this->mDbkeyform = '';
75 $this->mArticleID = -1;
76 $this->mNamespace = NS_MAIN;
77 $this->mRestrictionsLoaded = false;
78 $this->mRestrictions = array();
79 # Dont change the following, NS_MAIN is hardcoded in several place
80 # See bug #696
81 $this->mDefaultNamespace = NS_MAIN;
82 $this->mWatched = NULL;
83 $this->mLatestID = false;
84 $this->mOldRestrictions = false;
85 }

Member Function Documentation

◆ areRestrictionsCascading()

Title::areRestrictionsCascading ( )

Definition at line 1359 of file Title.php.

1359 {
1360 if (!$this->mRestrictionsLoaded) {
1361 $this->loadRestrictions();
1362 }
1363
1365 }
loadRestrictions( $oldFashionedRestrictions=NULL)
Definition: Title.php:1434
$mCascadeRestriction
Definition: Title.php:56

References $mCascadeRestriction, and loadRestrictions().

+ Here is the call graph for this function:

◆ countRevisionsBetween()

Title::countRevisionsBetween (   $old,
  $new 
)

Get the number of revisions between the given revision IDs.

Parameters
integer$oldRevision ID.
integer$newRevision ID.
Returns
integer Number of revisions between these IDs.

Definition at line 2383 of file Title.php.

2383 {
2384 $dbr = wfGetDB( DB_SLAVE );
2385 return $dbr->selectField( 'revision', 'count(*)',
2386 'rev_page = ' . intval( $this->getArticleId() ) .
2387 ' AND rev_id > ' . intval( $old ) .
2388 ' AND rev_id < ' . intval( $new ) );
2389 }

◆ equals()

Title::equals (   $title)

Compare with another title.

Parameters
Title$title
Returns
bool

Definition at line 2397 of file Title.php.

2397 {
2398 // Note: === is necessary for proper matching of number-like titles.
2399 return $this->getInterwiki() === $title->getInterwiki()
2400 && $this->getNamespace() == $title->getNamespace()
2401 && $this->getDbkey() === $title->getDbkey();
2402 }
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:543
getInterwiki()
Get the namespace text of the subject (rather than talk) page.
Definition: Title.php:594

References getInterwiki(), and getNamespace().

Referenced by isValidMoveOperation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ escapeFragmentForURL()

static Title::escapeFragmentForURL (   $fragment)
static

Escape a text fragment, say from a link, for a URL.

Definition at line 509 of file Title.php.

509 {
510 $fragment = str_replace( ' ', '_', $fragment );
511 $fragment = urlencode( Sanitizer::decodeCharReferences( $fragment ) );
512 $replaceArray = array(
513 '%3A' => ':',
514 '%' => '.'
515 );
516 return strtr( $fragment, $replaceArray );
517 }
static decodeCharReferences( $text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string.
Definition: Sanitizer.php:978

References Sanitizer\decodeCharReferences().

Referenced by getFragmentForURL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ escapeFullURL()

Title::escapeFullURL (   $query = '')

Get an HTML-escaped version of the URL form, suitable for using in a link, including the server name and fragment.

Returns
string the URL
Parameters
string$queryan optional query string

Definition at line 857 of file Title.php.

857 {
858 return htmlspecialchars( $this->getFullURL( $query ) );
859 }
getFullURL( $query='', $variant=false)
Get a real URL referring to this title, with interwiki link and fragment.
Definition: Title.php:733

References $query, and getFullURL().

+ Here is the call graph for this function:

◆ escapeLocalURL()

Title::escapeLocalURL (   $query = '')

Get an HTML-escaped version of the URL form, suitable for using in a link, without a server name or fragment.

Parameters
string$queryan optional query string
Returns
string the URL

Definition at line 846 of file Title.php.

846 {
847 return htmlspecialchars( $this->getLocalURL( $query ) );
848 }
getLocalURL( $query='', $variant=false)
Get a URL with no fragment or server name.
Definition: Title.php:772

References $query, and getLocalURL().

+ Here is the call graph for this function:

◆ exists()

Title::exists ( )

Check if page exists.

Returns
bool

Definition at line 2408 of file Title.php.

2408 {
2409 return $this->getArticleId() != 0;
2410 }

Referenced by getRestrictions(), isSemiProtected(), and isValidMoveOperation().

+ Here is the caller graph for this function:

◆ fixSpecialName()

Title::fixSpecialName ( )

If the Title refers to a special page alias which is not the local default, returns a new Title which points to the local default.

Otherwise, returns $this.

Definition at line 2534 of file Title.php.

2534 {
2535 if ( $this->getNamespace() == NS_SPECIAL ) {
2536 $canonicalName = SpecialPage::resolveAlias( $this->mDbkeyform );
2537 if ( $canonicalName ) {
2538 $localName = SpecialPage::getLocalNameFor( $canonicalName );
2539 if ( $localName != $this->mDbkeyform ) {
2540 return Title::makeTitle( NS_SPECIAL, $localName );
2541 }
2542 }
2543 }
2544 return $this;
2545 }
static & makeTitle( $ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:231

References getNamespace(), and makeTitle().

+ Here is the call graph for this function:

◆ getArticleID()

Title::getArticleID (   $flags = 0)

Get the article ID for this Title from the link cache, adding it if necessary.

Parameters
int$flagsa bit field; may be GAID_FOR_UPDATE to select for update
Returns
int the ID

Definition at line 1501 of file Title.php.

1501 {
1502 $linkCache =& LinkCache::singleton();
1503 if ( $flags & GAID_FOR_UPDATE ) {
1504 $oldUpdate = $linkCache->forUpdate( true );
1505 $this->mArticleID = $linkCache->addLinkObj( $this );
1506 $linkCache->forUpdate( $oldUpdate );
1507 } else {
1508 if ( -1 == $this->mArticleID ) {
1509 $this->mArticleID = $linkCache->addLinkObj( $this );
1510 }
1511 }
1512 return $this->mArticleID;
1513 }
const GAID_FOR_UPDATE(!class_exists( 'UtfNormal'))
See title.txt.
Definition: Title.php:12
$mArticleID
Definition: Title.php:53

References $mArticleID, and GAID_FOR_UPDATE.

Referenced by getLatestRevID(), isValidMoveOperation(), moveTo(), and moveToNewTitle().

+ Here is the caller graph for this function:

◆ getBaseText()

Title::getBaseText ( )

Get the base name, i.e.

the leftmost parts before the /

Returns
string Base name

Definition at line 669 of file Title.php.

669 {
670 global $wgNamespacesWithSubpages;
671 if( isset( $wgNamespacesWithSubpages[ $this->mNamespace ] ) && $wgNamespacesWithSubpages[ $this->mNamespace ] ) {
672 $parts = explode( '/', $this->getText() );
673 # Don't discard the real title if there's no subpage involved
674 if( count( $parts ) > 1 )
675 unset( $parts[ count( $parts ) - 1 ] );
676 return implode( '/', $parts );
677 } else {
678 return $this->getText();
679 }
680 }
getText()
Simple accessors.
Definition: Title.php:528

References getText().

+ Here is the call graph for this function:

◆ getBrokenLinksFrom()

Title::getBrokenLinksFrom (   $options = '')

Get an array of Title objects referring to non-existent articles linked from this page.

Parameters
string$optionsmay be FOR UPDATE
Returns
array the Title objects

Definition at line 1879 of file Title.php.

1879 {
1880 if ( $options ) {
1881 $db = wfGetDB( DB_MASTER );
1882 } else {
1883 $db = wfGetDB( DB_SLAVE );
1884 }
1885
1886 $res = $db->safeQuery(
1887 "SELECT pl_namespace, pl_title
1888 FROM !
1889 LEFT JOIN !
1890 ON pl_namespace=page_namespace
1891 AND pl_title=page_title
1892 WHERE pl_from=?
1893 AND page_namespace IS NULL
1894 !",
1895 $db->tableName( 'pagelinks' ),
1896 $db->tableName( 'page' ),
1897 $this->getArticleId(),
1898 $options );
1899
1900 $retVal = array();
1901 if ( $db->numRows( $res ) ) {
1902 while ( $row = $db->fetchObject( $res ) ) {
1903 $retVal[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );
1904 }
1905 }
1906 $db->freeResult( $res );
1907 return $retVal;
1908 }
if(!is_array($argv)) $options

References $options, $res, $row, and makeTitle().

+ Here is the call graph for this function:

◆ getCascadeProtectionSources()

Title::getCascadeProtectionSources (   $get_pages = true)

Cascading protection: Get the source of any cascading restrictions on this page.

Parameters
$get_pagesbool Whether or not to retrieve the actual pages that the restrictions have come from.
Returns
array( mixed title array, restriction array) Array of the Title objects of the pages from which cascading restrictions have come, false for none, or true if such restrictions exist, but $get_pages was not set. The restriction array is an array of each type, each of which contains an array of unique groups

Definition at line 1272 of file Title.php.

1272 {
1273 global $wgEnableCascadingProtection, $wgRestrictionTypes;
1274
1275 # Define our dimension of restrictions types
1276 $pagerestrictions = array();
1277 foreach( $wgRestrictionTypes as $action )
1278 $pagerestrictions[$action] = array();
1279
1280 if (!$wgEnableCascadingProtection)
1281 return array( false, $pagerestrictions );
1282
1283 if ( isset( $this->mCascadeSources ) && $get_pages ) {
1284 return array( $this->mCascadeSources, $this->mCascadingRestrictions );
1285 } else if ( isset( $this->mHasCascadingRestrictions ) && !$get_pages ) {
1286 return array( $this->mHasCascadingRestrictions, $pagerestrictions );
1287 }
1288
1289 wfProfileIn( __METHOD__ );
1290
1291 $dbr = wfGetDb( DB_SLAVE );
1292
1293 if ( $this->getNamespace() == NS_IMAGE ) {
1294 $tables = array ('imagelinks', 'page_restrictions');
1295 $where_clauses = array(
1296 'il_to' => $this->getDBkey(),
1297 'il_from=pr_page',
1298 'pr_cascade' => 1 );
1299 } else {
1300 $tables = array ('templatelinks', 'page_restrictions');
1301 $where_clauses = array(
1302 'tl_namespace' => $this->getNamespace(),
1303 'tl_title' => $this->getDBkey(),
1304 'tl_from=pr_page',
1305 'pr_cascade' => 1 );
1306 }
1307
1308 if ( $get_pages ) {
1309 $cols = array('pr_page', 'page_namespace', 'page_title', 'pr_expiry', 'pr_type', 'pr_level' );
1310 $where_clauses[] = 'page_id=pr_page';
1311 $tables[] = 'page';
1312 } else {
1313 $cols = array( 'pr_expiry' );
1314 }
1315
1316 $res = $dbr->select( $tables, $cols, $where_clauses, __METHOD__ );
1317
1318 $sources = $get_pages ? array() : false;
1319 $now = wfTimestampNow();
1320 $purgeExpired = false;
1321
1322 while( $row = $dbr->fetchObject( $res ) ) {
1323 $expiry = Block::decodeExpiry( $row->pr_expiry );
1324 if( $expiry > $now ) {
1325 if ($get_pages) {
1326 $page_id = $row->pr_page;
1327 $page_ns = $row->page_namespace;
1328 $page_title = $row->page_title;
1329 $sources[$page_id] = Title::makeTitle($page_ns, $page_title);
1330 # Add groups needed for each restriction type if its not already there
1331 # Make sure this restriction type still exists
1332 if ( isset($pagerestrictions[$row->pr_type]) && !in_array($row->pr_level, $pagerestrictions[$row->pr_type]) ) {
1333 $pagerestrictions[$row->pr_type][]=$row->pr_level;
1334 }
1335 } else {
1336 $sources = true;
1337 }
1338 } else {
1339 // Trigger lazy purge of expired restrictions from the db
1340 $purgeExpired = true;
1341 }
1342 }
1343 if( $purgeExpired ) {
1345 }
1346
1347 wfProfileOut( __METHOD__ );
1348
1349 if ( $get_pages ) {
1350 $this->mCascadeSources = $sources;
1351 $this->mCascadingRestrictions = $pagerestrictions;
1352 } else {
1353 $this->mHasCascadingRestrictions = $sources;
1354 }
1355
1356 return array( $sources, $pagerestrictions );
1357 }
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
Definition: Title.php:1448
getDBkey()
Get the main part with underscores.
Definition: Title.php:538

References $res, $row, getDBkey(), getNamespace(), makeTitle(), and purgeExpiredRestrictions().

Referenced by isCascadeProtected(), and userCan().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDBkey()

Title::getDBkey ( )

Get the main part with underscores.

Returns
string

Definition at line 538 of file Title.php.

538{ return $this->mDbkeyform; }
$mDbkeyform
Definition: Title.php:49

References $mDbkeyform.

Referenced by getCascadeProtectionSources(), getTouched(), invalidateCache(), isDeleted(), isSpecial(), and isValidMoveOperation().

+ Here is the caller graph for this function:

◆ getDefaultNamespace()

Title::getDefaultNamespace ( )

Get the default namespace index, for when there is no namespace.

Returns
int

Definition at line 615 of file Title.php.

615{ return $this->mDefaultNamespace; }
$mDefaultNamespace
Definition: Title.php:62

References $mDefaultNamespace.

◆ getEditURL()

Title::getEditURL ( )

Get the edit URL for this Title.

Returns
string the URL, or a null string if this is an interwiki link

Definition at line 882 of file Title.php.

882 {
883 if ( '' != $this->mInterwiki ) { return ''; }
884 $s = $this->getLocalURL( 'action=edit' );
885
886 return $s;
887 }

References getLocalURL().

+ Here is the call graph for this function:

◆ getEscapedText()

Title::getEscapedText ( )

Get the HTML-escaped displayable text form.

Used for the title field in tags.

Returns
string the text, including any prefixes

Definition at line 894 of file Title.php.

894 {
895 return htmlspecialchars( $this->getPrefixedText() );
896 }
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:642

References getPrefixedText().

+ Here is the call graph for this function:

◆ getFragment()

Title::getFragment ( )

Get the Title fragment (i.e.

the bit after the #) in text form

Returns
string

Definition at line 599 of file Title.php.

599{ return $this->mFragment; }
$mFragment
Definition: Title.php:52

References $mFragment.

◆ getFragmentForURL()

Title::getFragmentForURL ( )

Get the fragment in URL form, including the "#" character if there is one.

Returns
string

Definition at line 604 of file Title.php.

604 {
605 if ( $this->mFragment == '' ) {
606 return '';
607 } else {
608 return '#' . Title::escapeFragmentForURL( $this->mFragment );
609 }
610 }
static escapeFragmentForURL( $fragment)
Escape a text fragment, say from a link, for a URL.
Definition: Title.php:509

References escapeFragmentForURL().

Referenced by getFullURL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFullText()

Title::getFullText ( )

Get the prefixed title with spaces, plus any fragment (part beginning with '#')

Returns
string the prefixed title, with spaces and the fragment, including '#'

Definition at line 657 of file Title.php.

657 {
658 $text = $this->getPrefixedText();
659 if( '' != $this->mFragment ) {
660 $text .= '#' . $this->mFragment;
661 }
662 return $text;
663 }
$text

References $mFragment, $text, and getPrefixedText().

Referenced by getParentCategories().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFullURL()

Title::getFullURL (   $query = '',
  $variant = false 
)

Get a real URL referring to this title, with interwiki link and fragment.

Parameters
string$queryan optional query string, not used for interwiki links
string$variantlanguage variant of url (for sr, zh..)
Returns
string the URL

Definition at line 733 of file Title.php.

733 {
734 global $wgContLang, $wgServer, $wgRequest;
735
736 if ( '' == $this->mInterwiki ) {
737 $url = $this->getLocalUrl( $query, $variant );
738
739 // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc)
740 // Correct fix would be to move the prepending elsewhere.
741 if ($wgRequest->getVal('action') != 'render') {
742 $url = $wgServer . $url;
743 }
744 } else {
745 $baseUrl = $this->getInterwikiLink( $this->mInterwiki );
746
747 $namespace = wfUrlencode( $this->getNsText() );
748 if ( '' != $namespace ) {
749 # Can this actually happen? Interwikis shouldn't be parsed.
750 # Yes! It can in interwiki transclusion. But... it probably shouldn't.
751 $namespace .= ':';
752 }
753 $url = str_replace( '$1', $namespace . $this->mUrlform, $baseUrl );
754 $url = wfAppendQuery( $url, $query );
755 }
756
757 # Finally, add the fragment.
758 $url .= $this->getFragmentForURL();
759
760 wfRunHooks( 'GetFullURL', array( &$this, &$url, $query ) );
761 return $url;
762 }
getNsText()
Get the namespace text.
Definition: Title.php:548
getFragmentForURL()
Get the fragment in URL form, including the "#" character if there is one.
Definition: Title.php:604
getInterwikiLink( $key)
Returns the URL associated with an interwiki prefix.
Definition: Title.php:383
if($err=$client->getError()) $namespace
$url
Definition: shib_logout.php:72

References $namespace, $query, $url, getFragmentForURL(), getInterwikiLink(), and getNsText().

Referenced by escapeFullURL(), getLocalURL(), and trackbackRDF().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIndexTitle()

Title::getIndexTitle ( )

Get title for search index.

Returns
string a stripped-down title string ready for the search index

Definition at line 622 of file Title.php.

622 {
623 return Title::indexTitle( $this->mNamespace, $this->mTextform );
624 }
static indexTitle( $ns, $title)
Get a string representation of a title suitable for including in a search index.
Definition: Title.php:343

References indexTitle().

+ Here is the call graph for this function:

◆ getInternalURL()

Title::getInternalURL (   $query = '',
  $variant = false 
)

Get the URL form for an internal link.

  • Used in various Squid-related code, in case we have a different internal hostname for the server from the exposed one.
Parameters
string$queryan optional query string
string$variantlanguage variant of url (for sr, zh..)
Returns
string the URL

Definition at line 870 of file Title.php.

870 {
871 global $wgInternalServer;
872 $url = $wgInternalServer . $this->getLocalURL( $query, $variant );
873 wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
874 return $url;
875 }

References $query, $url, and getLocalURL().

Referenced by getSquidURLs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInterwiki()

Title::getInterwiki ( )

Get the namespace text of the subject (rather than talk) page.

Returns
string Get the namespace text of the talk page
string Could this title have a corresponding talk page?
bool Get the interwiki prefix (or null string)
string

Definition at line 594 of file Title.php.

594{ return $this->mInterwiki; }
$mInterwiki
Definition: Title.php:51

References $mInterwiki.

Referenced by equals().

+ Here is the caller graph for this function:

◆ getInterwikiCached()

static Title::getInterwikiCached (   $key)
static

Fetch interwiki prefix data from local cache in constant database.

More logic is explained in DefaultSettings

Returns
string URL of interwiki site

Definition at line 438 of file Title.php.

438 {
439 global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
440 static $db, $site;
441
442 if (!$db)
443 $db=dba_open($wgInterwikiCache,'r','cdb');
444 /* Resolve site name */
445 if ($wgInterwikiScopes>=3 and !$site) {
446 $site = dba_fetch('__sites:' . wfWikiID(), $db);
447 if ($site=="")
448 $site = $wgInterwikiFallbackSite;
449 }
450 $value = dba_fetch( wfMemcKey( $key ), $db);
451 if ($value=='' and $wgInterwikiScopes>=3) {
452 /* try site-level */
453 $value = dba_fetch("_{$site}:{$key}", $db);
454 }
455 if ($value=='' and $wgInterwikiScopes>=2) {
456 /* try globals */
457 $value = dba_fetch("__global:{$key}", $db);
458 }
459 if ($value=='undef')
460 $value='';
461 $s = (object)false;
462 $s->iw_url = '';
463 $s->iw_local = 0;
464 $s->iw_trans = 0;
465 if ($value!='') {
466 list($local,$url)=explode(' ',$value,2);
467 $s->iw_url=$url;
468 $s->iw_local=(int)$local;
469 }
470 Title::$interwikiCache[wfMemcKey( 'interwiki', $key )] = $s;
471 return $s->iw_url;
472 }
static $interwikiCache
Definition: Title.php:35

References $interwikiCache, and $url.

Referenced by getInterwikiLink().

+ Here is the caller graph for this function:

◆ getInterwikiLink()

Title::getInterwikiLink (   $key)
static

Returns the URL associated with an interwiki prefix.

Parameters
string$keythe interwiki prefix (e.g. "MeatBall")
Returns
the associated URL, containing "$1", which should be replaced by an article title (arguably)

Definition at line 383 of file Title.php.

383 {
384 global $wgMemc, $wgInterwikiExpiry;
385 global $wgInterwikiCache, $wgContLang;
386
387return ""; // changed. alex
388
389 $fname = 'Title::getInterwikiLink';
390
391 $key = $wgContLang->lc( $key );
392
393 $k = wfMemcKey( 'interwiki', $key );
394 if( array_key_exists( $k, Title::$interwikiCache ) ) {
395 return Title::$interwikiCache[$k]->iw_url;
396 }
397
398 if ($wgInterwikiCache) {
399 return Title::getInterwikiCached( $key );
400 }
401
402 $s = $wgMemc->get( $k );
403 # Ignore old keys with no iw_local
404 if( $s && isset( $s->iw_local ) && isset($s->iw_trans)) {
405 Title::$interwikiCache[$k] = $s;
406 return $s->iw_url;
407 }
408
409 $dbr = wfGetDB( DB_SLAVE );
410 $res = $dbr->select( 'interwiki',
411 array( 'iw_url', 'iw_local', 'iw_trans' ),
412 array( 'iw_prefix' => $key ), $fname );
413 if( !$res ) {
414 return '';
415 }
416
417 $s = $dbr->fetchObject( $res );
418 if( !$s ) {
419 # Cache non-existence: create a blank object and save it to memcached
420 $s = (object)false;
421 $s->iw_url = '';
422 $s->iw_local = 0;
423 $s->iw_trans = 0;
424 }
425 $wgMemc->set( $k, $s, $wgInterwikiExpiry );
426 Title::$interwikiCache[$k] = $s;
427
428 return $s->iw_url;
429 }
static getInterwikiCached( $key)
Fetch interwiki prefix data from local cache in constant database.
Definition: Title.php:438

References $interwikiCache, $res, and getInterwikiCached().

Referenced by getFullURL(), isLocal(), isTrans(), and secureAndSplit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLatestRevID()

Title::getLatestRevID ( )

Definition at line 1515 of file Title.php.

1515 {
1516 if ($this->mLatestID !== false)
1517 return $this->mLatestID;
1518
1519 $db = wfGetDB(DB_SLAVE);
1520 return $this->mLatestID = $db->selectField( 'revision',
1521 "max(rev_id)",
1522 array('rev_page' => $this->getArticleID()),
1523 'Title::getLatestRevID' );
1524 }
$mLatestID
Definition: Title.php:54
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:1501

References $mLatestID, and getArticleID().

+ Here is the call graph for this function:

◆ getLinksTo()

Title::getLinksTo (   $options = '',
  $table = 'pagelinks',
  $prefix = 'pl' 
)

Get a Title object associated with the talk page of this article.

Returns
Title the object for the talk page Get a title object associated with the subject page of this talk page
Title the object for the subject page Get an array of Title objects linking to this Title Also stores the IDs in the link cache.

WARNING: do not use this function on arbitrary user-supplied titles! On heavily-used templates it will max out the memory.

Parameters
string$optionsmay be FOR UPDATE
Returns
array the Title objects linking here

Definition at line 1828 of file Title.php.

1828 {
1829 $linkCache =& LinkCache::singleton();
1830
1831 if ( $options ) {
1832 $db = wfGetDB( DB_MASTER );
1833 } else {
1834 $db = wfGetDB( DB_SLAVE );
1835 }
1836
1837 $res = $db->select( array( 'page', $table ),
1838 array( 'page_namespace', 'page_title', 'page_id' ),
1839 array(
1840 "{$prefix}_from=page_id",
1841 "{$prefix}_namespace" => $this->getNamespace(),
1842 "{$prefix}_title" => $this->getDbKey() ),
1843 'Title::getLinksTo',
1844 $options );
1845
1846 $retVal = array();
1847 if ( $db->numRows( $res ) ) {
1848 while ( $row = $db->fetchObject( $res ) ) {
1849 if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) {
1850 $linkCache->addGoodLinkObj( $row->page_id, $titleObj );
1851 $retVal[] = $titleObj;
1852 }
1853 }
1854 }
1855 $db->freeResult( $res );
1856 return $retVal;
1857 }

References $options, $res, $row, getNamespace(), and makeTitle().

Referenced by getTemplateLinksTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocalURL()

Title::getLocalURL (   $query = '',
  $variant = false 
)

Get a URL with no fragment or server name.

If this page is generated with action=render, $wgServer is prepended.

Parameters
string$queryan optional query string; if not specified, $wgArticlePath will be used.
string$variantlanguage variant of url (for sr, zh..)
Returns
string the URL

Definition at line 772 of file Title.php.

772 {
773 global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
774 global $wgVariantArticlePath, $wgContLang, $wgUser;
775
776 // internal links should point to same variant as current page (only anonymous users)
777 if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){
778 $pref = $wgContLang->getPreferredVariant(false);
779 if($pref != $wgContLang->getCode())
780 $variant = $pref;
781 }
782
783 if ( $this->isExternal() ) {
784 $url = $this->getFullURL();
785 if ( $query ) {
786 // This is currently only used for edit section links in the
787 // context of interwiki transclusion. In theory we should
788 // append the query to the end of any existing query string,
789 // but interwiki transclusion is already broken in that case.
790 $url .= "?$query";
791 }
792 } else {
793 $dbkey = wfUrlencode( $this->getPrefixedDBkey() );
794 if ( $query == '' ) {
795 if($variant!=false && $wgContLang->hasVariants()){
796 if($wgVariantArticlePath==false) {
797 $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default
798 } else {
799 $variantArticlePath = $wgVariantArticlePath;
800 }
801 $url = str_replace( '$2', urlencode( $variant ), $variantArticlePath );
802 $url = str_replace( '$1', $dbkey, $url );
803 }
804 else {
805 $url = str_replace( '$1', $dbkey, $wgArticlePath );
806 }
807 } else {
808 global $wgActionPaths;
809 $url = false;
810 $matches = array();
811 if( !empty( $wgActionPaths ) &&
812 preg_match( '/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches ) )
813 {
814 $action = urldecode( $matches[2] );
815 if( isset( $wgActionPaths[$action] ) ) {
816 $query = $matches[1];
817 if( isset( $matches[4] ) ) $query .= $matches[4];
818 $url = str_replace( '$1', $dbkey, $wgActionPaths[$action] );
819 if( $query != '' ) $url .= '?' . $query;
820 }
821 }
822 if ( $url === false ) {
823 if ( $query == '-' ) {
824 $query = '';
825 }
826 $url = "{$wgScript}?title={$dbkey}&{$query}";
827 }
828 }
829
830 // FIXME: this causes breakage in various places when we
831 // actually expected a local URL and end up with dupe prefixes.
832 if ($wgRequest->getVal('action') == 'render') {
833 $url = $wgServer . $url;
834 }
835 }
836 wfRunHooks( 'GetLocalURL', array( &$this, &$url, $query ) );
837 return $url;
838 }
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:631
isExternal()
Is this Title interwiki?
Definition: Title.php:902

References $query, $url, getFullURL(), getPrefixedDBkey(), and isExternal().

Referenced by escapeLocalURL(), getEditURL(), and getInternalURL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNamespace()

Title::getNamespace ( )

Get the namespace index, i.e.

one of the NS_xxxx constants

Returns
int

Definition at line 543 of file Title.php.

543{ return $this->mNamespace; }
$mNamespace
Definition: Title.php:50

References $mNamespace.

Referenced by equals(), fixSpecialName(), getCascadeProtectionSources(), getLinksTo(), getNamespaceKey(), getTouched(), invalidateCache(), isDeleted(), isProtected(), isSpecial(), touchLinks(), and userCanRead().

+ Here is the caller graph for this function:

◆ getNamespaceKey()

Title::getNamespaceKey ( )

Generate strings used for xml 'id' names in monobook tabs.

Returns
string

Definition at line 2480 of file Title.php.

2480 {
2481 global $wgContLang;
2482 switch ($this->getNamespace()) {
2483 case NS_MAIN:
2484 case NS_TALK:
2485 return 'nstab-main';
2486 case NS_USER:
2487 case NS_USER_TALK:
2488 return 'nstab-user';
2489 case NS_MEDIA:
2490 return 'nstab-media';
2491 case NS_SPECIAL:
2492 return 'nstab-special';
2493 case NS_PROJECT:
2494 case NS_PROJECT_TALK:
2495 return 'nstab-project';
2496 case NS_IMAGE:
2497 case NS_IMAGE_TALK:
2498 return 'nstab-image';
2499 case NS_MEDIAWIKI:
2500 case NS_MEDIAWIKI_TALK:
2501 return 'nstab-mediawiki';
2502 case NS_TEMPLATE:
2503 case NS_TEMPLATE_TALK:
2504 return 'nstab-template';
2505 case NS_HELP:
2506 case NS_HELP_TALK:
2507 return 'nstab-help';
2508 case NS_CATEGORY:
2509 case NS_CATEGORY_TALK:
2510 return 'nstab-category';
2511 default:
2512 return 'nstab-' . $wgContLang->lc( $this->getSubjectNsText() );
2513 }
2514 }

References getNamespace().

+ Here is the call graph for this function:

◆ getNextRevisionID()

Title::getNextRevisionID (   $revision)

Get the revision ID of the next revision.

Parameters
integer$revisionRevision ID. Get the revision that was after this one.
Returns
integer $oldrevision|false

Definition at line 2369 of file Title.php.

2369 {
2370 $dbr = wfGetDB( DB_SLAVE );
2371 return $dbr->selectField( 'revision', 'rev_id',
2372 'rev_page=' . intval( $this->getArticleId() ) .
2373 ' AND rev_id>' . intval( $revision ) . ' ORDER BY rev_id' );
2374 }

◆ getNsText()

Title::getNsText ( )

Get the namespace text.

Returns
string

Definition at line 548 of file Title.php.

548 {
549 global $wgContLang, $wgCanonicalNamespaceNames;
550
551 if ( '' != $this->mInterwiki ) {
552 // This probably shouldn't even happen. ohh man, oh yuck.
553 // But for interwiki transclusion it sometimes does.
554 // Shit. Shit shit shit.
555 //
556 // Use the canonical namespaces if possible to try to
557 // resolve a foreign namespace.
558 if( isset( $wgCanonicalNamespaceNames[$this->mNamespace] ) ) {
559 return $wgCanonicalNamespaceNames[$this->mNamespace];
560 }
561 }
562 return $wgContLang->getNsText( $this->mNamespace );
563 }

References $mNamespace.

Referenced by getFullURL(), and prefix().

+ Here is the caller graph for this function:

◆ getParentCategories()

Title::getParentCategories ( )

Get categories to which this Title belongs and return an array of categories' names.

Returns
array an array of parents in the form: $parent => $currentarticle

Definition at line 2287 of file Title.php.

2287 {
2288 global $wgContLang;
2289
2290 $titlekey = $this->getArticleId();
2291 $dbr = wfGetDB( DB_SLAVE );
2292 $categorylinks = $dbr->tableName( 'categorylinks' );
2293
2294 # NEW SQL
2295 $sql = "SELECT * FROM $categorylinks"
2296 ." WHERE cl_from='$titlekey'"
2297 ." AND cl_from <> '0'"
2298 ." ORDER BY cl_sortkey";
2299
2300 $res = $dbr->query ( $sql ) ;
2301
2302 if($dbr->numRows($res) > 0) {
2303 while ( $x = $dbr->fetchObject ( $res ) )
2304 //$data[] = Title::newFromText($wgContLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to);
2305 $data[$wgContLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to] = $this->getFullText();
2306 $dbr->freeResult ( $res ) ;
2307 } else {
2308 $data = '';
2309 }
2310 return $data;
2311 }
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with '#')
Definition: Title.php:657
$x
Definition: example_009.php:98
$data

References $data, $res, $x, and getFullText().

Referenced by getParentCategoryTree().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentCategoryTree()

Title::getParentCategoryTree (   $children = array())

Get a tree of parent categories.

Parameters
array$childrenan array with the children in the keys, to check for circular refs
Returns
array

Definition at line 2318 of file Title.php.

2318 {
2319 $parents = $this->getParentCategories();
2320
2321 if($parents != '') {
2322 foreach($parents as $parent => $current) {
2323 if ( array_key_exists( $parent, $children ) ) {
2324 # Circular reference
2325 $stack[$parent] = array();
2326 } else {
2327 $nt = Title::newFromText($parent);
2328 if ( $nt ) {
2329 $stack[$parent] = $nt->getParentCategoryTree( $children + array($parent => 1) );
2330 }
2331 }
2332 }
2333 return $stack;
2334 } else {
2335 return array();
2336 }
2337 }
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:114
getParentCategories()
Get categories to which this Title belongs and return an array of categories' names.
Definition: Title.php:2287

References getParentCategories(), and newFromText().

+ Here is the call graph for this function:

◆ getPartialURL()

Title::getPartialURL ( )

Get the URL-encoded form of the main part.

Returns
string

Definition at line 533 of file Title.php.

533{ return $this->mUrlform; }
$mUrlform
Definition: Title.php:48

References $mUrlform.

◆ getPrefixedDBkey()

Title::getPrefixedDBkey ( )

Get the prefixed database key form.

Returns
string the prefixed title, with underscores and any interwiki and namespace prefixes

Definition at line 631 of file Title.php.

631 {
632 $s = $this->prefix( $this->mDbkeyform );
633 $s = str_replace( ' ', '_', $s );
634 return $s;
635 }
prefix( $name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object.
Definition: Title.php:1583

References prefix().

Referenced by getLocalURL(), moveToNewTitle(), and resetArticleID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrefixedText()

Title::getPrefixedText ( )

Get the prefixed title with spaces.

This is the form usually used for display

Returns
string the prefixed title, with spaces

Definition at line 642 of file Title.php.

642 {
643 if ( empty( $this->mPrefixedText ) ) { // FIXME: bad usage of empty() ?
644 $s = $this->prefix( $this->mTextform );
645 $s = str_replace( '_', ' ', $s );
646 $this->mPrefixedText = $s;
647 }
649 }
$mPrefixedText
Definition: Title.php:61

References $mPrefixedText, and prefix().

Referenced by getEscapedText(), getFullText(), moveToNewTitle(), and userCanRead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPrefixedURL()

Title::getPrefixedURL ( )

Get a URL-encoded title (not an actual URL) including interwiki.

Returns
string the URL-encoded form

Definition at line 711 of file Title.php.

711 {
712 $s = $this->prefix( $this->mDbkeyform );
713 $s = str_replace( ' ', '_', $s );
714
715 $s = wfUrlencode ( $s ) ;
716
717 # Cleaning up URL to make it look nice -- is this safe?
718 $s = str_replace( '%28', '(', $s );
719 $s = str_replace( '%29', ')', $s );
720
721 return $s;
722 }

References prefix().

+ Here is the call graph for this function:

◆ getPreviousRevisionID()

Title::getPreviousRevisionID (   $revision)

Get the revision ID of the previous revision.

Parameters
integer$revisionRevision ID. Get the revision that was before this one.
Returns
integer $oldrevision|false

Definition at line 2356 of file Title.php.

2356 {
2357 $dbr = wfGetDB( DB_SLAVE );
2358 return $dbr->selectField( 'revision', 'rev_id',
2359 'rev_page=' . intval( $this->getArticleId() ) .
2360 ' AND rev_id<' . intval( $revision ) . ' ORDER BY rev_id DESC' );
2361 }

◆ getRestrictions()

Title::getRestrictions (   $action)

Accessor/initialisation for mRestrictions.

Parameters
string$actionaction that permission needs to be checked for
Returns
array the array of groups allowed to edit this article

Definition at line 1461 of file Title.php.

1461 {
1462 if( $this->exists() ) {
1463 if( !$this->mRestrictionsLoaded ) {
1464 $this->loadRestrictions();
1465 }
1466 return isset( $this->mRestrictions[$action] )
1467 ? $this->mRestrictions[$action]
1468 : array();
1469 } else {
1470 return array();
1471 }
1472 }
exists()
Check if page exists.
Definition: Title.php:2408

References exists(), and loadRestrictions().

Referenced by isProtected(), isSemiProtected(), and userCan().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSkinFromCssJsSubpage()

Title::getSkinFromCssJsSubpage ( )

Trim down a .css or .js subpage title to get the corresponding skin name.

Definition at line 1223 of file Title.php.

1223 {
1224 $subpage = explode( '/', $this->mTextform );
1225 $subpage = $subpage[ count( $subpage ) - 1 ];
1226 return( str_replace( array( '.css', '.js' ), array( '', '' ), $subpage ) );
1227 }

Referenced by isValidCssJsSubpage().

+ Here is the caller graph for this function:

◆ getSquidURLs()

Title::getSquidURLs ( )

Get a list of URLs to purge from the Squid cache when this page changes.

Returns
array the URLs

Definition at line 1917 of file Title.php.

1917 {
1918 global $wgContLang;
1919
1920 $urls = array(
1921 $this->getInternalURL(),
1922 $this->getInternalURL( 'action=history' )
1923 );
1924
1925 // purge variant urls as well
1926 if($wgContLang->hasVariants()){
1927 $variants = $wgContLang->getVariants();
1928 foreach($variants as $vCode){
1929 if($vCode==$wgContLang->getCode()) continue; // we don't want default variant
1930 $urls[] = $this->getInternalURL('',$vCode);
1931 }
1932 }
1933
1934 return $urls;
1935 }
getInternalURL( $query='', $variant=false)
Get the URL form for an internal link.
Definition: Title.php:870

References getInternalURL().

Referenced by purgeSquid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubpageText()

Title::getSubpageText ( )

Get the lowest-level subpage name, i.e.

the rightmost part after /

Returns
string Subpage name

Definition at line 686 of file Title.php.

686 {
687 global $wgNamespacesWithSubpages;
688 if( isset( $wgNamespacesWithSubpages[ $this->mNamespace ] ) && $wgNamespacesWithSubpages[ $this->mNamespace ] ) {
689 $parts = explode( '/', $this->mTextform );
690 return( $parts[ count( $parts ) - 1 ] );
691 } else {
692 return( $this->mTextform );
693 }
694 }

Referenced by getSubpageUrlForm().

+ Here is the caller graph for this function:

◆ getSubpageUrlForm()

Title::getSubpageUrlForm ( )

Get a URL-encoded form of the subpage text.

Returns
string URL-encoded subpage name

Definition at line 700 of file Title.php.

700 {
701 $text = $this->getSubpageText();
702 $text = wfUrlencode( str_replace( ' ', '_', $text ) );
703 $text = str_replace( '%28', '(', str_replace( '%29', ')', $text ) ); # Clean up the URL; per below, this might not be safe
704 return( $text );
705 }
getSubpageText()
Get the lowest-level subpage name, i.e.
Definition: Title.php:686

References $text, and getSubpageText().

+ Here is the call graph for this function:

◆ getTemplateLinksTo()

Title::getTemplateLinksTo (   $options = '')

Get an array of Title objects using this Title as a template Also stores the IDs in the link cache.

WARNING: do not use this function on arbitrary user-supplied titles! On heavily-used templates it will max out the memory.

Parameters
string$optionsmay be FOR UPDATE
Returns
array the Title objects linking here

Definition at line 1869 of file Title.php.

1869 {
1870 return $this->getLinksTo( $options, 'templatelinks', 'tl' );
1871 }
getLinksTo( $options='', $table='pagelinks', $prefix='pl')
Get a Title object associated with the talk page of this article.
Definition: Title.php:1828

References $options, and getLinksTo().

+ Here is the call graph for this function:

◆ getText()

Title::getText ( )

Simple accessors.

Get the text form (spaces not underscores) of the main part

Returns
string

Definition at line 528 of file Title.php.

528{ return $this->mTextform; }
$mTextform
All member variables should be considered private Please use the accessor functions.
Definition: Title.php:47

References $mTextform.

Referenced by getBaseText(), isSubpage(), and trackbackRDF().

+ Here is the caller graph for this function:

◆ getTouched()

Title::getTouched ( )

Get the last touched timestamp.

Definition at line 2441 of file Title.php.

2441 {
2442 $dbr = wfGetDB( DB_SLAVE );
2443 $touched = $dbr->selectField( 'page', 'page_touched',
2444 array(
2445 'page_namespace' => $this->getNamespace(),
2446 'page_title' => $this->getDBkey()
2447 ), __METHOD__
2448 );
2449 return $touched;
2450 }

References getDBkey(), and getNamespace().

+ Here is the call graph for this function:

◆ indexTitle()

static Title::indexTitle (   $ns,
  $title 
)
static

Get a string representation of a title suitable for including in a search index.

Parameters
int$nsa namespace index
string$titletext-form main part
Returns
string a stripped-down title string ready for the search index

Definition at line 343 of file Title.php.

343 {
344 global $wgContLang;
345
346 $lc = SearchEngine::legalSearchChars() . '&#;';
347 $t = $wgContLang->stripForSearch( $title );
348 $t = preg_replace( "/[^{$lc}]+/", ' ', $t );
349 $t = $wgContLang->lc( $t );
350
351 # Handle 's, s'
352 $t = preg_replace( "/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t );
353 $t = preg_replace( "/([{$lc}]+)s'( |$)/", "\\1s ", $t );
354
355 $t = preg_replace( "/\\s+/", ' ', $t );
356
357 if ( $ns == NS_IMAGE ) {
358 $t = preg_replace( "/ (png|gif|jpg|jpeg|ogg)$/", "", $t );
359 }
360 return trim( $t );
361 }

References $t.

Referenced by getIndexTitle().

+ Here is the caller graph for this function:

◆ invalidateCache()

Title::invalidateCache ( )

Updates page_touched for this page; called from LinksUpdate.php.

Returns
bool true if the update succeded

Definition at line 1550 of file Title.php.

1550 {
1551 global $wgUseFileCache;
1552
1553 if ( wfReadOnly() ) {
1554 return;
1555 }
1556
1557 $dbw = wfGetDB( DB_MASTER );
1558 $success = $dbw->update( 'page',
1559 array( /* SET */
1560 'page_touched' => $dbw->timestamp()
1561 ), array( /* WHERE */
1562 'page_namespace' => $this->getNamespace() ,
1563 'page_title' => $this->getDBkey()
1564 ), 'Title::invalidateCache'
1565 );
1566
1567 if ($wgUseFileCache) {
1568 $cache = new HTMLFileCache($this);
1569 @unlink($cache->fileCacheName());
1570 }
1571
1572 return $success;
1573 }
$success
Definition: Utf8Test.php:87

References $success, getDBkey(), and getNamespace().

+ Here is the call graph for this function:

◆ isAlwaysKnown()

Title::isAlwaysKnown ( )

Should a link should be displayed as a known link, just based on its title?

Currently, a self-link with a fragment and special pages are in this category. Special pages never exist in the database.

Definition at line 2418 of file Title.php.

2418 {
2419 return $this->isExternal() || ( 0 == $this->mNamespace && "" == $this->mDbkeyform )
2420 || NS_SPECIAL == $this->mNamespace;
2421 }

References $mDbkeyform, and isExternal().

+ Here is the call graph for this function:

◆ isCascadeProtected()

Title::isCascadeProtected ( )

Cascading protection: Return true if cascading restrictions apply to this page, false if not.

Returns
bool If the page is subject to cascading restrictions.

Definition at line 1259 of file Title.php.

1259 {
1260 list( $sources, $restrictions ) = $this->getCascadeProtectionSources( false );
1261 return ( $sources > 0 );
1262 }
getCascadeProtectionSources( $get_pages=true)
Cascading protection: Get the source of any cascading restrictions on this page.
Definition: Title.php:1272

References getCascadeProtectionSources().

+ Here is the call graph for this function:

◆ isCssJsSubpage()

Title::isCssJsSubpage ( )

Is this a .css or .js subpage of a user page?

Returns
bool

Definition at line 1205 of file Title.php.

1205 {
1206 return ( NS_USER == $this->mNamespace and preg_match("/\\/.*\\.(?:css|js)$/", $this->mTextform ) );
1207 }

Referenced by isValidCssJsSubpage(), and userCan().

+ Here is the caller graph for this function:

◆ isCssSubpage()

Title::isCssSubpage ( )

Is this a .css subpage of a user page?

Returns
bool

Definition at line 1232 of file Title.php.

1232 {
1233 return ( NS_USER == $this->mNamespace and preg_match("/\\/.*\\.css$/", $this->mTextform ) );
1234 }

◆ isDeleted()

Title::isDeleted ( )

Is there a version of this page in the deletion archive?

Returns
int the number of archived revisions

Definition at line 1478 of file Title.php.

1478 {
1479 $fname = 'Title::isDeleted';
1480 if ( $this->getNamespace() < 0 ) {
1481 $n = 0;
1482 } else {
1483 $dbr = wfGetDB( DB_SLAVE );
1484 $n = $dbr->selectField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
1485 'ar_title' => $this->getDBkey() ), $fname );
1486 if( $this->getNamespace() == NS_IMAGE ) {
1487 $n += $dbr->selectField( 'filearchive', 'COUNT(*)',
1488 array( 'fa_name' => $this->getDBkey() ), $fname );
1489 }
1490 }
1491 return (int)$n;
1492 }
$n
Definition: RandomTest.php:80

References $n, getDBkey(), and getNamespace().

+ Here is the call graph for this function:

◆ isExternal()

Title::isExternal ( )

Is this Title interwiki?

Returns
boolean

Definition at line 902 of file Title.php.

902{ return ( '' != $this->mInterwiki ); }

Referenced by getLocalURL(), and isAlwaysKnown().

+ Here is the caller graph for this function:

◆ isJsSubpage()

Title::isJsSubpage ( )

Is this a .js subpage of a user page?

Returns
bool

Definition at line 1239 of file Title.php.

1239 {
1240 return ( NS_USER == $this->mNamespace and preg_match("/\\/.*\\.js$/", $this->mTextform ) );
1241 }

◆ isLocal()

Title::isLocal ( )

Determine whether the object refers to a page within this project.

Returns
bool TRUE if this is an in-project interwiki link or a wikilink, FALSE otherwise

Definition at line 480 of file Title.php.

480 {
481 if ( $this->mInterwiki != '' ) {
482 # Make sure key is loaded into cache
483 $this->getInterwikiLink( $this->mInterwiki );
484 $k = wfMemcKey( 'interwiki', $this->mInterwiki );
485 return (bool)(Title::$interwikiCache[$k]->iw_local);
486 } else {
487 return true;
488 }
489 }

References $interwikiCache, and getInterwikiLink().

+ Here is the call graph for this function:

◆ isProtected()

Title::isProtected (   $action = '')

Does the title correspond to a protected article?

Parameters
string$whatthe action the page is protected from, by default checks move and edit
Returns
boolean

Definition at line 935 of file Title.php.

935 {
936 global $wgRestrictionLevels;
937
938 # Special pages have inherent protection
939 if( $this->getNamespace() == NS_SPECIAL )
940 return true;
941
942 # Check regular protection levels
943 if( $action == 'edit' || $action == '' ) {
944 $r = $this->getRestrictions( 'edit' );
945 foreach( $wgRestrictionLevels as $level ) {
946 if( in_array( $level, $r ) && $level != '' ) {
947 return( true );
948 }
949 }
950 }
951
952 if( $action == 'move' || $action == '' ) {
953 $r = $this->getRestrictions( 'move' );
954 foreach( $wgRestrictionLevels as $level ) {
955 if( in_array( $level, $r ) && $level != '' ) {
956 return( true );
957 }
958 }
959 }
960
961 return false;
962 }
getRestrictions( $action)
Accessor/initialisation for mRestrictions.
Definition: Title.php:1461
$r
Definition: example_031.php:79

References $r, getNamespace(), and getRestrictions().

+ Here is the call graph for this function:

◆ isSemiProtected()

Title::isSemiProtected (   $action = 'edit')

Is this page "semi-protected" - the only protection is autoconfirm?

Parameters
stringAction to check (default: edit)
Returns
bool

Definition at line 910 of file Title.php.

910 {
911 if( $this->exists() ) {
912 $restrictions = $this->getRestrictions( $action );
913 if( count( $restrictions ) > 0 ) {
914 foreach( $restrictions as $restriction ) {
915 if( strtolower( $restriction ) != 'autoconfirmed' )
916 return false;
917 }
918 } else {
919 # Not protected
920 return false;
921 }
922 return true;
923 } else {
924 # If it doesn't exist, it can't be protected
925 return false;
926 }
927 }

References exists(), and getRestrictions().

+ Here is the call graph for this function:

◆ isSpecial()

Title::isSpecial (   $name)

Returns true if this title resolves to the named special page.

Parameters
string$nameThe special page name

Definition at line 2520 of file Title.php.

2520 {
2521 if ( $this->getNamespace() == NS_SPECIAL ) {
2522 list( $thisName, /* $subpage */ ) = SpecialPage::resolveAliasWithSubpage( $this->getDBkey() );
2523 if ( $name == $thisName ) {
2524 return true;
2525 }
2526 }
2527 return false;
2528 }

References getDBkey(), and getNamespace().

Referenced by userCanRead().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSubpage()

Title::isSubpage ( )

Is this a talk page of some sort?

Returns
bool Is this a subpage?
bool

Definition at line 1191 of file Title.php.

1191 {
1192 global $wgNamespacesWithSubpages;
1193
1194 if( isset( $wgNamespacesWithSubpages[ $this->mNamespace ] ) ) {
1195 return ( strpos( $this->getText(), '/' ) !== false && $wgNamespacesWithSubpages[ $this->mNamespace ] == true );
1196 } else {
1197 return false;
1198 }
1199 }

References getText().

+ Here is the call graph for this function:

◆ isTrans()

Title::isTrans ( )

Determine whether the object refers to a page within this project and is transcludable.

Returns
bool TRUE if this is transcludable

Definition at line 497 of file Title.php.

497 {
498 if ($this->mInterwiki == '')
499 return false;
500 # Make sure key is loaded into cache
501 $this->getInterwikiLink( $this->mInterwiki );
502 $k = wfMemcKey( 'interwiki', $this->mInterwiki );
503 return (bool)(Title::$interwikiCache[$k]->iw_trans);
504 }

References $interwikiCache, and getInterwikiLink().

+ Here is the call graph for this function:

◆ isValidCssJsSubpage()

Title::isValidCssJsSubpage ( )

Is this a valid .css or .js subpage of a user page? Check that the corresponding skin exists.

Definition at line 1212 of file Title.php.

1212 {
1213 if ( $this->isCssJsSubpage() ) {
1214 $skinNames = Skin::getSkinNames();
1215 return array_key_exists( $this->getSkinFromCssJsSubpage(), $skinNames );
1216 } else {
1217 return false;
1218 }
1219 }
getSkinFromCssJsSubpage()
Trim down a .css or .js subpage title to get the corresponding skin name.
Definition: Title.php:1223
isCssJsSubpage()
Is this a .css or .js subpage of a user page?
Definition: Title.php:1205

References getSkinFromCssJsSubpage(), and isCssJsSubpage().

+ Here is the call graph for this function:

◆ isValidMoveOperation()

Title::isValidMoveOperation ( $nt,
  $auth = true 
)

Check whether a given move operation would be valid.

Returns true if ok, or a message key string for an error message if invalid. (Scarrrrry ugly interface this.)

Parameters
Title&$ntthe new title
bool$authindicates whether $wgUser's permissions should be checked
Returns
mixed true on success, message name on failure

Definition at line 1963 of file Title.php.

1963 {
1964 if( !$this or !$nt ) {
1965 return 'badtitletext';
1966 }
1967 if( $this->equals( $nt ) ) {
1968 return 'selfmove';
1969 }
1970 if( !$this->isMovable() || !$nt->isMovable() ) {
1971 return 'immobile_namespace';
1972 }
1973
1974 $oldid = $this->getArticleID();
1975 $newid = $nt->getArticleID();
1976
1977 if ( strlen( $nt->getDBkey() ) < 1 ) {
1978 return 'articleexists';
1979 }
1980 if ( ( '' == $this->getDBkey() ) ||
1981 ( !$oldid ) ||
1982 ( '' == $nt->getDBkey() ) ) {
1983 return 'badarticleerror';
1984 }
1985
1986 if ( $auth && (
1987 !$this->userCan( 'edit' ) || !$nt->userCan( 'edit' ) ||
1988 !$this->userCan( 'move' ) || !$nt->userCan( 'move' ) ) ) {
1989 return 'protectedpage';
1990 }
1991
1992 # The move is allowed only if (1) the target doesn't exist, or
1993 # (2) the target is a redirect to the source, and has no history
1994 # (so we can undo bad moves right after they're done).
1995
1996 if ( 0 != $newid ) { # Target exists; check for validity
1997 if ( ! $this->isValidMoveTarget( $nt ) ) {
1998 return 'articleexists';
1999 }
2000 }
2001 return true;
2002 }
equals( $title)
Compare with another title.
Definition: Title.php:2397
userCan( $action, $doExpensiveQueries=true)
Can $wgUser perform $action on this page?
Definition: Title.php:1003
isValidMoveTarget( $nt)
Checks if $this can be moved to a given Title.
Definition: Title.php:2231

References $auth, equals(), exists(), getArticleID(), getDBkey(), isValidMoveTarget(), and userCan().

Referenced by moveTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isValidMoveTarget()

Title::isValidMoveTarget (   $nt)

Checks if $this can be moved to a given Title.

  • Selects for update, so don't call it unless you mean business
Parameters
Title&$ntthe new title to check

Definition at line 2231 of file Title.php.

2231 {
2232
2233 $fname = 'Title::isValidMoveTarget';
2234 $dbw = wfGetDB( DB_MASTER );
2235
2236 # Is it a redirect?
2237 $id = $nt->getArticleID();
2238 $obj = $dbw->selectRow( array( 'page', 'revision', 'text'),
2239 array( 'page_is_redirect','old_text','old_flags' ),
2240 array( 'page_id' => $id, 'page_latest=rev_id', 'rev_text_id=old_id' ),
2241 $fname, 'FOR UPDATE' );
2242
2243 if ( !$obj || 0 == $obj->page_is_redirect ) {
2244 # Not a redirect
2245 wfDebug( __METHOD__ . ": not a redirect\n" );
2246 return false;
2247 }
2248 $text = Revision::getRevisionText( $obj );
2249
2250 # Does the redirect point to the source?
2251 # Or is it a broken self-redirect, usually caused by namespace collisions?
2252 $m = array();
2253 if ( preg_match( "/\\[\\[\\s*([^\\]\\|]*)]]/", $text, $m ) ) {
2254 $redirTitle = Title::newFromText( $m[1] );
2255 if( !is_object( $redirTitle ) ||
2256 ( $redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() &&
2257 $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey() ) ) {
2258 wfDebug( __METHOD__ . ": redirect points to other page\n" );
2259 return false;
2260 }
2261 } else {
2262 # Fail safe
2263 wfDebug( __METHOD__ . ": failsafe\n" );
2264 return false;
2265 }
2266
2267 # Does the article have a history?
2268 $row = $dbw->selectRow( array( 'page', 'revision'),
2269 array( 'rev_id' ),
2270 array( 'page_namespace' => $nt->getNamespace(),
2271 'page_title' => $nt->getDBkey(),
2272 'page_id=rev_page AND page_latest != rev_id'
2273 ), $fname, 'FOR UPDATE'
2274 );
2275
2276 # Return true if there was no history
2277 return $row === false;
2278 }

References $row, $text, and newFromText().

Referenced by isValidMoveOperation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ legalChars()

static Title::legalChars ( )
static

Get a regex character class describing the legal characters in a link.

Returns
string the list of characters, not delimited

Definition at line 326 of file Title.php.

326 {
327 global $wgLegalTitleChars;
328
329 $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
330
331 return $wgLegalTitleChars;
332 }

Referenced by secureAndSplit().

+ Here is the caller graph for this function:

◆ loadRestrictions()

Title::loadRestrictions (   $oldFashionedRestrictions = NULL)

Definition at line 1434 of file Title.php.

1434 {
1435 if( !$this->mRestrictionsLoaded ) {
1436 $dbr = wfGetDB( DB_SLAVE );
1437
1438 $res = $dbr->select( 'page_restrictions', '*',
1439 array ( 'pr_page' => $this->getArticleId() ), __METHOD__ );
1440
1441 $this->loadRestrictionsFromRow( $res, $oldFashionedRestrictions );
1442 }
1443 }
loadRestrictionsFromRow( $res, $oldFashionedRestrictions=NULL)
Loads a string into mRestrictions array.
Definition: Title.php:1371

References $res, and loadRestrictionsFromRow().

Referenced by areRestrictionsCascading(), and getRestrictions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadRestrictionsFromRow()

Title::loadRestrictionsFromRow (   $res,
  $oldFashionedRestrictions = NULL 
)
private

Loads a string into mRestrictions array.

Parameters
resource$resrestrictions as an SQL result.

Definition at line 1371 of file Title.php.

1371 {
1372 $dbr = wfGetDb( DB_SLAVE );
1373
1374 $this->mRestrictions['edit'] = array();
1375 $this->mRestrictions['move'] = array();
1376
1377 # Backwards-compatibility: also load the restrictions from the page record (old format).
1378
1379 if ( $oldFashionedRestrictions == NULL ) {
1380 $oldFashionedRestrictions = $dbr->selectField( 'page', 'page_restrictions', array( 'page_id' => $this->getArticleId() ), __METHOD__ );
1381 }
1382
1383 if ($oldFashionedRestrictions != '') {
1384
1385 foreach( explode( ':', trim( $oldFashionedRestrictions ) ) as $restrict ) {
1386 $temp = explode( '=', trim( $restrict ) );
1387 if(count($temp) == 1) {
1388 // old old format should be treated as edit/move restriction
1389 $this->mRestrictions["edit"] = explode( ',', trim( $temp[0] ) );
1390 $this->mRestrictions["move"] = explode( ',', trim( $temp[0] ) );
1391 } else {
1392 $this->mRestrictions[$temp[0]] = explode( ',', trim( $temp[1] ) );
1393 }
1394 }
1395
1396 $this->mOldRestrictions = true;
1397 $this->mCascadeRestriction = false;
1398 $this->mRestrictionsExpiry = Block::decodeExpiry('');
1399
1400 }
1401
1402 if( $dbr->numRows( $res ) ) {
1403 # Current system - load second to make them override.
1404 $now = wfTimestampNow();
1405 $purgeExpired = false;
1406
1407 while ($row = $dbr->fetchObject( $res ) ) {
1408 # Cycle through all the restrictions.
1409
1410 // This code should be refactored, now that it's being used more generally,
1411 // But I don't really see any harm in leaving it in Block for now -werdna
1412 $expiry = Block::decodeExpiry( $row->pr_expiry );
1413
1414 // Only apply the restrictions if they haven't expired!
1415 if ( !$expiry || $expiry > $now ) {
1416 $this->mRestrictionsExpiry = $expiry;
1417 $this->mRestrictions[$row->pr_type] = explode( ',', trim( $row->pr_level ) );
1418
1419 $this->mCascadeRestriction |= $row->pr_cascade;
1420 } else {
1421 // Trigger a lazy purge of expired restrictions
1422 $purgeExpired = true;
1423 }
1424 }
1425
1426 if( $purgeExpired ) {
1428 }
1429 }
1430
1431 $this->mRestrictionsLoaded = true;
1432 }

References $res, $row, and purgeExpiredRestrictions().

Referenced by loadRestrictions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeName()

static Title::makeName (   $ns,
  $title 
)
static

Definition at line 369 of file Title.php.

369 {
370 global $wgContLang;
371
372 $n = $wgContLang->getNsText( $ns );
373 return $n == '' ? $title : "$n:$title";
374 }

References $n.

Referenced by makeTitleSafe(), and nameOf().

+ Here is the caller graph for this function:

◆ makeTitle()

static & Title::makeTitle (   $ns,
  $title 
)
static

Create a new Title from a namespace index and a DB key.

It's assumed that $ns and $title are valid, for instance when they came directly from the database or a special page name. For convenience, spaces are converted to underscores so that eg user_text fields can be used directly.

Parameters
int$nsthe namespace of the article
string$titlethe unprefixed database key form
Returns
Title the new object

Definition at line 231 of file Title.php.

231 {
232 $t = new Title();
233 $t->mInterwiki = '';
234 $t->mFragment = '';
235 $t->mNamespace = intval( $ns );
236 $t->mDbkeyform = str_replace( ' ', '_', $title );
237 $t->mArticleID = ( $ns >= 0 ) ? -1 : 0;
238 $t->mUrlform = wfUrlencode( $t->mDbkeyform );
239 $t->mTextform = str_replace( '_', ' ', $title );
240 return $t;
241 }
Title class.
Definition: Title.php:30

References $t.

Referenced by fixSpecialName(), getBrokenLinksFrom(), getCascadeProtectionSources(), getLinksTo(), newFromID(), and newFromIDs().

+ Here is the caller graph for this function:

◆ makeTitleSafe()

static Title::makeTitleSafe (   $ns,
  $title 
)
static

Create a new Title from a namespace index and a DB key.

The parameters will be checked for validity, which is a bit slower than makeTitle() but safer for user-provided data.

Parameters
int$nsthe namespace of the article
string$titlethe database key form
Returns
Title the new object, or NULL on an error

Definition at line 252 of file Title.php.

252 {
253 $t = new Title();
254 $t->mDbkeyform = Title::makeName( $ns, $title );
255 if( $t->secureAndSplit() ) {
256 return $t;
257 } else {
258 return NULL;
259 }
260 }
static makeName( $ns, $title)
Definition: Title.php:369

References $t, and makeName().

+ Here is the call graph for this function:

◆ moveNoAuth()

Title::moveNoAuth ( $nt)

Move this page without authentication.

Parameters
Title&$ntthe new page Title

Definition at line 1950 of file Title.php.

1950 {
1951 return $this->moveTo( $nt, false );
1952 }
moveTo(&$nt, $auth=true, $reason='')
Move a title to a new location.
Definition: Title.php:2011

References moveTo().

+ Here is the call graph for this function:

◆ moveOverExistingRedirect()

Title::moveOverExistingRedirect ( $nt,
  $reason = '' 
)
private

Move page to a title which is at present a redirect to the source page.

Parameters
Title&$ntthe page to move to, which should currently be a redirect

Definition at line 2083 of file Title.php.

2083 {
2084 global $wgUseSquid;
2085 $fname = 'Title::moveOverExistingRedirect';
2086 $comment = wfMsgForContent( '1movedto2_redir', $this->getPrefixedText(), $nt->getPrefixedText() );
2087
2088 if ( $reason ) {
2089 $comment .= ": $reason";
2090 }
2091
2092 $now = wfTimestampNow();
2093 $newid = $nt->getArticleID();
2094 $oldid = $this->getArticleID();
2095 $dbw = wfGetDB( DB_MASTER );
2096 $linkCache =& LinkCache::singleton();
2097
2098 # Delete the old redirect. We don't save it to history since
2099 # by definition if we've got here it's rather uninteresting.
2100 # We have to remove it so that the next step doesn't trigger
2101 # a conflict on the unique namespace+title index...
2102 $dbw->delete( 'page', array( 'page_id' => $newid ), $fname );
2103
2104 # Save a null revision in the page's history notifying of the move
2105 $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
2106 $nullRevId = $nullRevision->insertOn( $dbw );
2107
2108 # Change the name of the target page:
2109 $dbw->update( 'page',
2110 /* SET */ array(
2111 'page_touched' => $dbw->timestamp($now),
2112 'page_namespace' => $nt->getNamespace(),
2113 'page_title' => $nt->getDBkey(),
2114 'page_latest' => $nullRevId,
2115 ),
2116 /* WHERE */ array( 'page_id' => $oldid ),
2117 $fname
2118 );
2119 $linkCache->clearLink( $nt->getPrefixedDBkey() );
2120
2121 # Recreate the redirect, this time in the other direction.
2122 $mwRedir = MagicWord::get( 'redirect' );
2123 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
2124 $redirectArticle = new Article( $this );
2125 $newid = $redirectArticle->insertOn( $dbw );
2126 $redirectRevision = new Revision( array(
2127 'page' => $newid,
2128 'comment' => $comment,
2129 'text' => $redirectText ) );
2130 $redirectRevision->insertOn( $dbw );
2131 $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
2132 $linkCache->clearLink( $this->getPrefixedDBkey() );
2133
2134 # Log the move
2135 $log = new LogPage( 'move' );
2136 $log->addEntry( 'move_redir', $this, $reason, array( 1 => $nt->getPrefixedText() ) );
2137
2138 # Now, we record the link from the redirect to the new title.
2139 # It should have no other outgoing links...
2140 $dbw->delete( 'pagelinks', array( 'pl_from' => $newid ), $fname );
2141 $dbw->insert( 'pagelinks',
2142 array(
2143 'pl_from' => $newid,
2144 'pl_namespace' => $nt->getNamespace(),
2145 'pl_title' => $nt->getDbKey() ),
2146 $fname );
2147
2148 # Purge squid
2149 if ( $wgUseSquid ) {
2150 $urls = array_merge( $nt->getSquidURLs(), $this->getSquidURLs() );
2151 $u = new SquidUpdate( $urls );
2152 $u->doUpdate();
2153 }
2154 }
$comment
Definition: buildRTE.php:83

Referenced by moveTo().

+ Here is the caller graph for this function:

◆ moveTo()

Title::moveTo ( $nt,
  $auth = true,
  $reason = '' 
)

Move a title to a new location.

Parameters
Title&$ntthe new title
bool$authindicates whether $wgUser's permissions should be checked
Returns
mixed true on success, message name on failure

Definition at line 2011 of file Title.php.

2011 {
2012 $err = $this->isValidMoveOperation( $nt, $auth );
2013 if( is_string( $err ) ) {
2014 return $err;
2015 }
2016
2017 $pageid = $this->getArticleID();
2018 if( $nt->exists() ) {
2019 $this->moveOverExistingRedirect( $nt, $reason );
2020 $pageCountChange = 0;
2021 } else { # Target didn't exist, do normal move.
2022 $this->moveToNewTitle( $nt, $reason );
2023 $pageCountChange = 1;
2024 }
2025 $redirid = $this->getArticleID();
2026
2027 # Fixing category links (those without piped 'alternate' names) to be sorted under the new title
2028 $dbw = wfGetDB( DB_MASTER );
2029 $categorylinks = $dbw->tableName( 'categorylinks' );
2030 $sql = "UPDATE $categorylinks SET cl_sortkey=" . $dbw->addQuotes( $nt->getPrefixedText() ) .
2031 " WHERE cl_from=" . $dbw->addQuotes( $pageid ) .
2032 " AND cl_sortkey=" . $dbw->addQuotes( $this->getPrefixedText() );
2033 $dbw->query( $sql, 'SpecialMovepage::doSubmit' );
2034
2035 # Update watchlists
2036
2037 $oldnamespace = $this->getNamespace() & ~1;
2038 $newnamespace = $nt->getNamespace() & ~1;
2039 $oldtitle = $this->getDBkey();
2040 $newtitle = $nt->getDBkey();
2041
2042 if( $oldnamespace != $newnamespace || $oldtitle != $newtitle ) {
2043 WatchedItem::duplicateEntries( $this, $nt );
2044 }
2045
2046 # Update search engine
2047 $u = new SearchUpdate( $pageid, $nt->getPrefixedDBkey() );
2048 $u->doUpdate();
2049 $u = new SearchUpdate( $redirid, $this->getPrefixedDBkey(), '' );
2050 $u->doUpdate();
2051
2052 # Update site_stats
2053 if( $this->isContentPage() && !$nt->isContentPage() ) {
2054 # No longer a content page
2055 # Not viewed, edited, removing
2056 $u = new SiteStatsUpdate( 0, 1, -1, $pageCountChange );
2057 } elseif( !$this->isContentPage() && $nt->isContentPage() ) {
2058 # Now a content page
2059 # Not viewed, edited, adding
2060 $u = new SiteStatsUpdate( 0, 1, +1, $pageCountChange );
2061 } elseif( $pageCountChange ) {
2062 # Redirect added
2063 $u = new SiteStatsUpdate( 0, 0, 0, 1 );
2064 } else {
2065 # Nothing special
2066 $u = false;
2067 }
2068 if( $u )
2069 $u->doUpdate();
2070
2071 global $wgUser;
2072 wfRunHooks( 'TitleMoveComplete', array( &$this, &$nt, &$wgUser, $pageid, $redirid ) );
2073 return true;
2074 }
isValidMoveOperation(&$nt, $auth=true)
Check whether a given move operation would be valid.
Definition: Title.php:1963
moveOverExistingRedirect(&$nt, $reason='')
Move page to a title which is at present a redirect to the source page.
Definition: Title.php:2083

References $auth, getArticleID(), isValidMoveOperation(), and moveOverExistingRedirect().

Referenced by moveNoAuth().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveToNewTitle()

Title::moveToNewTitle ( $nt,
  $reason = '' 
)
private

Move page to non-existing title.

Parameters
Title&$ntthe new Title

Definition at line 2160 of file Title.php.

2160 {
2161 global $wgUseSquid;
2162 $fname = 'MovePageForm::moveToNewTitle';
2163 $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
2164 if ( $reason ) {
2165 $comment .= ": $reason";
2166 }
2167
2168 $newid = $nt->getArticleID();
2169 $oldid = $this->getArticleID();
2170 $dbw = wfGetDB( DB_MASTER );
2171 $now = $dbw->timestamp();
2172 $linkCache =& LinkCache::singleton();
2173
2174 # Save a null revision in the page's history notifying of the move
2175 $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
2176 $nullRevId = $nullRevision->insertOn( $dbw );
2177
2178 # Rename cur entry
2179 $dbw->update( 'page',
2180 /* SET */ array(
2181 'page_touched' => $now,
2182 'page_namespace' => $nt->getNamespace(),
2183 'page_title' => $nt->getDBkey(),
2184 'page_latest' => $nullRevId,
2185 ),
2186 /* WHERE */ array( 'page_id' => $oldid ),
2187 $fname
2188 );
2189
2190 $linkCache->clearLink( $nt->getPrefixedDBkey() );
2191
2192 # Insert redirect
2193 $mwRedir = MagicWord::get( 'redirect' );
2194 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
2195 $redirectArticle = new Article( $this );
2196 $newid = $redirectArticle->insertOn( $dbw );
2197 $redirectRevision = new Revision( array(
2198 'page' => $newid,
2199 'comment' => $comment,
2200 'text' => $redirectText ) );
2201 $redirectRevision->insertOn( $dbw );
2202 $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
2203 $linkCache->clearLink( $this->getPrefixedDBkey() );
2204
2205 # Log the move
2206 $log = new LogPage( 'move' );
2207 $log->addEntry( 'move', $this, $reason, array( 1 => $nt->getPrefixedText()) );
2208
2209 # Purge caches as per article creation
2210 Article::onArticleCreate( $nt );
2211
2212 # Record the just-created redirect's linking to the page
2213 $dbw->insert( 'pagelinks',
2214 array(
2215 'pl_from' => $newid,
2216 'pl_namespace' => $nt->getNamespace(),
2217 'pl_title' => $nt->getDBkey() ),
2218 $fname );
2219
2220 # Purge old title from squid
2221 # The new title, and links to the new title, are purged in Article::onArticleCreate()
2222 $this->purgeSquid();
2223 }
purgeSquid()
Definition: Title.php:1937

References $comment, $log, getArticleID(), getPrefixedDBkey(), getPrefixedText(), and purgeSquid().

+ Here is the call graph for this function:

◆ nameOf()

Title::nameOf (   $id)
static

Get the prefixed DB key associated with an ID.

Parameters
int$idthe page_id of the article
Returns
Title an object representing the article, or NULL if no such article was found

@access public

Definition at line 311 of file Title.php.

311 {
312 $fname = 'Title::nameOf';
313 $dbr = wfGetDB( DB_SLAVE );
314
315 $s = $dbr->selectRow( 'page', array( 'page_namespace','page_title' ), array( 'page_id' => $id ), $fname );
316 if ( $s === false ) { return NULL; }
317
318 $n = Title::makeName( $s->page_namespace, $s->page_title );
319 return $n;
320 }

References $n, and makeName().

+ Here is the call graph for this function:

◆ newFromDBkey()

static Title::newFromDBkey (   $key)
static

Create a new Title from a prefixed DB key.

Parameters
string$keyThe database key, which has underscores instead of spaces, possibly including namespace and interwiki prefixes
Returns
Title the new object, or NULL on an error

Definition at line 94 of file Title.php.

94 {
95 $t = new Title();
96 $t->mDbkeyform = $key;
97 if( $t->secureAndSplit() )
98 return $t;
99 else
100 return NULL;
101 }

References $t.

◆ newFromID()

static Title::newFromID (   $id)
static

Create a new Title from an article ID.

Todo:
This is inefficiently implemented, the page row is requested but not used for anything else
Parameters
int$idthe page_id corresponding to the Title to create
Returns
Title the new object, or NULL on an error

Definition at line 192 of file Title.php.

192 {
193 $fname = 'Title::newFromID';
194 $dbr = wfGetDB( DB_SLAVE );
195 $row = $dbr->selectRow( 'page', array( 'page_namespace', 'page_title' ),
196 array( 'page_id' => $id ), $fname );
197 if ( $row !== false ) {
198 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
199 } else {
200 $title = NULL;
201 }
202 return $title;
203 }

References $row, and makeTitle().

+ Here is the call graph for this function:

◆ newFromIDs()

static Title::newFromIDs (   $ids)
static

Make an array of titles from an array of IDs.

Definition at line 208 of file Title.php.

208 {
209 $dbr = wfGetDB( DB_SLAVE );
210 $res = $dbr->select( 'page', array( 'page_namespace', 'page_title' ),
211 'page_id IN (' . $dbr->makeList( $ids ) . ')', __METHOD__ );
212
213 $titles = array();
214 while ( $row = $dbr->fetchObject( $res ) ) {
215 $titles[] = Title::makeTitle( $row->page_namespace, $row->page_title );
216 }
217 return $titles;
218 }

References $res, $row, and makeTitle().

+ Here is the call graph for this function:

◆ newFromRedirect()

static Title::newFromRedirect (   $text)
static

Create a new Title for a redirect.

Parameters
string$textthe redirect title text
Returns
Title the new object, or NULL if the text is not a valid redirect

Definition at line 276 of file Title.php.

276 {
277 $mwRedir = MagicWord::get( 'redirect' );
278 $rt = NULL;
279 if ( $mwRedir->matchStart( $text ) ) {
280 $m = array();
281 if ( preg_match( '/\[{2}(.*?)(?:\||\]{2})/', $text, $m ) ) {
282 # categories are escaped using : for example one can enter:
283 # #REDIRECT [[:Category:Music]]. Need to remove it.
284 if ( substr($m[1],0,1) == ':') {
285 # We don't want to keep the ':'
286 $m[1] = substr( $m[1], 1 );
287 }
288
289 $rt = Title::newFromText( $m[1] );
290 # Disallow redirects to Special:Userlogout
291 if ( !is_null($rt) && $rt->isSpecial( 'Userlogout' ) ) {
292 $rt = NULL;
293 }
294 }
295 }
296 return $rt;
297 }

References $text, and newFromText().

+ Here is the call graph for this function:

◆ newFromText()

static Title::newFromText (   $text,
  $defaultNamespace = NS_MAIN 
)
static

Create a new Title from text, such as what one would find in a link.

Decodes any HTML entities in the text.

Parameters
string$textthe link text; spaces, prefixes, and an initial ':' indicating the main namespace are accepted
int$defaultNamespacethe namespace to use if none is specified by a prefix
Returns
Title the new object, or NULL on an error

Wiki pages often contain multiple links to the same page. Title normalization and parsing can become expensive on pages with many links, so we can save a little time by caching them.

In theory these are value objects and won't get changed...

Convert things like é &#257; or &#x3017; into real text...

Definition at line 114 of file Title.php.

114 {
115 if( is_object( $text ) ) {
116 throw new MWException( 'Title::newFromText given an object' );
117 }
118
127 if( $defaultNamespace == NS_MAIN && isset( Title::$titleCache[$text] ) ) {
129 }
130
134 $filteredText = Sanitizer::decodeCharReferences( $text );
135
136 $t = new Title();
137 $t->mDbkeyform = str_replace( ' ', '_', $filteredText );
138 $t->mDefaultNamespace = $defaultNamespace;
139
140 static $cachedcount = 0 ;
141 if( $t->secureAndSplit() ) {
142 if( $defaultNamespace == NS_MAIN ) {
143 if( $cachedcount >= MW_TITLECACHE_MAX ) {
144 # Avoid memory leaks on mass operations...
145 Title::$titleCache = array();
146 $cachedcount=0;
147 }
148 $cachedcount++;
150 }
151 return $t;
152 } else {
153 $ret = NULL;
154 return $ret;
155 }
156 }
const MW_TITLECACHE_MAX
Definition: Title.php:19
static $titleCache
Static cache variables.
Definition: Title.php:34

References $ret, $t, $text, $titleCache, Sanitizer\decodeCharReferences(), and MW_TITLECACHE_MAX.

Referenced by getParentCategoryTree(), isValidMoveTarget(), newFromRedirect(), newMainPage(), and ilWikiUtil\processInternalLinks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newFromURL()

static Title::newFromURL (   $url)
static

Create a new Title from URL-encoded text.

Ensures that the given title's length does not exceed the maximum.

Parameters
string$urlthe title, as might be taken from a URL
Returns
Title the new object, or NULL on an error

Definition at line 164 of file Title.php.

164 {
165 global $wgLegalTitleChars;
166 $t = new Title();
167
168 # For compatibility with old buggy URLs. "+" is usually not valid in titles,
169 # but some URLs used it as a space replacement and they still come
170 # from some external search tools.
171 if ( strpos( $wgLegalTitleChars, '+' ) === false ) {
172 $url = str_replace( '+', ' ', $url );
173 }
174
175 $t->mDbkeyform = str_replace( ' ', '_', $url );
176 if( $t->secureAndSplit() ) {
177 return $t;
178 } else {
179 return NULL;
180 }
181 }

References $t, and $url.

◆ newMainPage()

static Title::newMainPage ( )
static

Create a new Title for the Main Page.

Returns
Title the new object

Definition at line 266 of file Title.php.

266 {
267 return Title::newFromText( wfMsgForContent( 'mainpage' ) );
268 }

References newFromText().

+ Here is the call graph for this function:

◆ pageCond()

Title::pageCond ( )

Get an associative array for selecting this title from the "page" table.

Returns
array

Definition at line 2346 of file Title.php.

2346 {
2347 return array( 'page_namespace' => $this->mNamespace, 'page_title' => $this->mDbkeyform );
2348 }

◆ prefix()

Title::prefix (   $name)
private

Prefix some arbitrary text with the namespace or interwiki prefix of this object.

Parameters
string$namethe text
Returns
string the prefixed text

Definition at line 1583 of file Title.php.

1583 {
1584 $p = '';
1585 if ( '' != $this->mInterwiki ) {
1586 $p = $this->mInterwiki . ':';
1587 }
1588 if ( 0 != $this->mNamespace ) {
1589 $p .= $this->getNsText() . ':';
1590 }
1591 return $p . $name;
1592 }

References getNsText().

Referenced by getPrefixedDBkey(), getPrefixedText(), and getPrefixedURL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ purgeExpiredRestrictions()

static Title::purgeExpiredRestrictions ( )
static

Purge expired restrictions from the page_restrictions table.

Definition at line 1448 of file Title.php.

1448 {
1449 $dbw = wfGetDB( DB_MASTER );
1450 $dbw->delete( 'page_restrictions',
1451 array( 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
1452 __METHOD__ );
1453 }

Referenced by getCascadeProtectionSources(), and loadRestrictionsFromRow().

+ Here is the caller graph for this function:

◆ purgeSquid()

Title::purgeSquid ( )

Definition at line 1937 of file Title.php.

1937 {
1938 global $wgUseSquid;
1939 if ( $wgUseSquid ) {
1940 $urls = $this->getSquidURLs();
1941 $u = new SquidUpdate( $urls );
1942 $u->doUpdate();
1943 }
1944 }
getSquidURLs()
Get a list of URLs to purge from the Squid cache when this page changes.
Definition: Title.php:1917

References getSquidURLs().

Referenced by moveToNewTitle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ quickUserCan()

Title::quickUserCan (   $action)

Can $wgUser perform $action on this page? This skips potentially expensive cascading permission checks.

Suitable for use for nonessential UI controls in common cases, but not for functional access control.

May provide false positives, but should never provide a false negative.

Parameters
string$actionaction that permission needs to be checked for
Returns
boolean

Definition at line 993 of file Title.php.

993 {
994 return $this->userCan( $action, false );
995 }

References userCan().

+ Here is the call graph for this function:

◆ resetArticleID()

Title::resetArticleID (   $newid)

This clears some fields in this object, and clears any associated keys in the "bad links" section of the link cache.

  • This is called from Article::insertNewArticle() to allow loading of the new page_id. It's also called from Article::doDeleteArticle()
Parameters
int$newidthe new Article ID

Definition at line 1536 of file Title.php.

1536 {
1537 $linkCache =& LinkCache::singleton();
1538 $linkCache->clearBadLink( $this->getPrefixedDBkey() );
1539
1540 if ( 0 == $newid ) { $this->mArticleID = -1; }
1541 else { $this->mArticleID = $newid; }
1542 $this->mRestrictionsLoaded = false;
1543 $this->mRestrictions = array();
1544 }

References getPrefixedDBkey().

+ Here is the call graph for this function:

◆ secureAndSplit()

Title::secureAndSplit ( )
private

Secure and split - main initialisation function for this object.

Assumes that mDbkeyform has been set, and is urldecoded and uses underscores, but not otherwise munged. This function removes illegal characters, splits off the interwiki and namespace prefixes, sets the other forms, and canonicalizes everything.

Returns
bool true on success

Pages with "/./" or "/../" appearing in the URLs will often be unreachable due to the way web browsers deal with 'relative' URLs. Forbid them explicitly.

Magic tilde sequences? Nu-uh!

Limit the size of titles to 255 bytes. This is typically the size of the underlying database field. We make an exception for special pages, which don't need to be stored in the database, and may edge over 255 bytes due to subpage syntax for long titles, e.g. [[Special:Block/Long name]]

Normally, all wiki links are forced to have an initial capital letter so [[foo]] and [[Foo]] point to the same place.

Don't force it for interwikis, since the other site might be case-sensitive.

Can't make a link to a namespace alone... "empty" local links can only be self-links with a fragment identifier.

Definition at line 1604 of file Title.php.

1604 {
1605 global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks;
1606
1607 # Initialisation
1608 static $rxTc = false;
1609 if( !$rxTc ) {
1610 # % is needed as well
1611 $rxTc = '/[^' . Title::legalChars() . ']|%[0-9A-Fa-f]{2}/S';
1612 }
1613
1614 $this->mInterwiki = $this->mFragment = '';
1615 $this->mNamespace = $this->mDefaultNamespace; # Usually NS_MAIN
1616
1617 $dbkey = $this->mDbkeyform;
1618
1619 # Strip Unicode bidi override characters.
1620 # Sometimes they slip into cut-n-pasted page titles, where the
1621 # override chars get included in list displays.
1622 $dbkey = str_replace( "\xE2\x80\x8E", '', $dbkey ); // 200E LEFT-TO-RIGHT MARK
1623 $dbkey = str_replace( "\xE2\x80\x8F", '', $dbkey ); // 200F RIGHT-TO-LEFT MARK
1624
1625 # Clean up whitespace
1626 #
1627 $dbkey = preg_replace( '/[ _]+/', '_', $dbkey );
1628 $dbkey = trim( $dbkey, '_' );
1629
1630 if ( '' == $dbkey ) {
1631 return false;
1632 }
1633
1634 if( false !== strpos( $dbkey, UTF8_REPLACEMENT ) ) {
1635 # Contained illegal UTF-8 sequences or forbidden Unicode chars.
1636 return false;
1637 }
1638
1639 $this->mDbkeyform = $dbkey;
1640
1641 # Initial colon indicates main namespace rather than specified default
1642 # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
1643 if ( ':' == $dbkey{0} ) {
1644 $this->mNamespace = NS_MAIN;
1645 $dbkey = substr( $dbkey, 1 ); # remove the colon but continue processing
1646 $dbkey = trim( $dbkey, '_' ); # remove any subsequent whitespace
1647 }
1648
1649 # Namespace or interwiki prefix
1650 $firstPass = true;
1651 do {
1652 $m = array();
1653 if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $dbkey, $m ) ) {
1654 $p = $m[1];
1655 if ( $ns = $wgContLang->getNsIndex( $p )) {
1656 # Ordinary namespace
1657 $dbkey = $m[2];
1658 $this->mNamespace = $ns;
1659 } elseif( $this->getInterwikiLink( $p ) ) {
1660 if( !$firstPass ) {
1661 # Can't make a local interwiki link to an interwiki link.
1662 # That's just crazy!
1663 return false;
1664 }
1665
1666 # Interwiki link
1667 $dbkey = $m[2];
1668 $this->mInterwiki = $wgContLang->lc( $p );
1669
1670 # Redundant interwiki prefix to the local wiki
1671 if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
1672 if( $dbkey == '' ) {
1673 # Can't have an empty self-link
1674 return false;
1675 }
1676 $this->mInterwiki = '';
1677 $firstPass = false;
1678 # Do another namespace split...
1679 continue;
1680 }
1681
1682 # If there's an initial colon after the interwiki, that also
1683 # resets the default namespace
1684 if ( $dbkey !== '' && $dbkey[0] == ':' ) {
1685 $this->mNamespace = NS_MAIN;
1686 $dbkey = substr( $dbkey, 1 );
1687 }
1688 }
1689 # If there's no recognized interwiki or namespace,
1690 # then let the colon expression be part of the title.
1691 }
1692 break;
1693 } while( true );
1694
1695 # We already know that some pages won't be in the database!
1696 #
1697 if ( '' != $this->mInterwiki || NS_SPECIAL == $this->mNamespace ) {
1698 $this->mArticleID = 0;
1699 }
1700 $fragment = strstr( $dbkey, '#' );
1701 if ( false !== $fragment ) {
1702 $this->setFragment( $fragment );
1703 $dbkey = substr( $dbkey, 0, strlen( $dbkey ) - strlen( $fragment ) );
1704 # remove whitespace again: prevents "Foo_bar_#"
1705 # becoming "Foo_bar_"
1706 $dbkey = preg_replace( '/_*$/', '', $dbkey );
1707 }
1708
1709 # Reject illegal characters.
1710 #
1711 if( preg_match( $rxTc, $dbkey ) ) {
1712 return false;
1713 }
1714
1720 if ( strpos( $dbkey, '.' ) !== false &&
1721 ( $dbkey === '.' || $dbkey === '..' ||
1722 strpos( $dbkey, './' ) === 0 ||
1723 strpos( $dbkey, '../' ) === 0 ||
1724 strpos( $dbkey, '/./' ) !== false ||
1725 strpos( $dbkey, '/../' ) !== false ) )
1726 {
1727 return false;
1728 }
1729
1733 if( strpos( $dbkey, '~~~' ) !== false ) {
1734 return false;
1735 }
1736
1744 if ( ( $this->mNamespace != NS_SPECIAL && strlen( $dbkey ) > 255 ) ||
1745 strlen( $dbkey ) > 512 )
1746 {
1747 return false;
1748 }
1749
1758 if( $wgCapitalLinks && $this->mInterwiki == '') {
1759 $dbkey = $wgContLang->ucfirst( $dbkey );
1760 }
1761
1767 if( $dbkey == '' &&
1768 $this->mInterwiki == '' &&
1769 $this->mNamespace != NS_MAIN ) {
1770 return false;
1771 }
1772
1773 // Any remaining initial :s are illegal.
1774 if ( $dbkey !== '' && ':' == $dbkey{0} ) {
1775 return false;
1776 }
1777
1778 # Fill fields
1779 $this->mDbkeyform = $dbkey;
1780 $this->mUrlform = ilWikiUtil::wfUrlencode( $dbkey );
1781
1782 $this->mTextform = str_replace( '_', ' ', $dbkey );
1783
1784 return true;
1785 }
static legalChars()
Get a regex character class describing the legal characters in a link.
Definition: Title.php:326
setFragment( $fragment)
Set the fragment for this title This is kind of bad, since except for this rarely-used function,...
Definition: Title.php:1796
static wfUrlencode( $s)
From GlobalFunctions.php.
const UTF8_REPLACEMENT
Definition: UtfNormal.php:83

References $mDbkeyform, $mDefaultNamespace, getInterwikiLink(), legalChars(), setFragment(), UTF8_REPLACEMENT, and ilWikiUtil\wfUrlencode().

+ Here is the call graph for this function:

◆ setFragment()

Title::setFragment (   $fragment)

Set the fragment for this title This is kind of bad, since except for this rarely-used function, Title objects are immutable.

The reason this is here is because it's better than setting the members directly, which is what Linker::formatComment was doing previously.

Parameters
string$fragmenttext
Todo:
clarify whether access is supposed to be public (was marked as "kind of public")

Definition at line 1796 of file Title.php.

1796 {
1797 $this->mFragment = str_replace( '_', ' ', substr( $fragment, 1 ) );
1798 }

Referenced by secureAndSplit().

+ Here is the caller graph for this function:

◆ touchLinks()

Title::touchLinks ( )

Update page_touched timestamps and send squid purge messages for pages linking to this title.

May be sent to the job queue depending on the number of links. Typically called on create and delete.

Definition at line 2428 of file Title.php.

2428 {
2429 $u = new HTMLCacheUpdate( $this, 'pagelinks' );
2430 $u->doUpdate();
2431
2432 if ( $this->getNamespace() == NS_CATEGORY ) {
2433 $u = new HTMLCacheUpdate( $this, 'categorylinks' );
2434 $u->doUpdate();
2435 }
2436 }

References getNamespace().

+ Here is the call graph for this function:

◆ trackbackRDF()

Title::trackbackRDF ( )

Definition at line 2459 of file Title.php.

2459 {
2460 $url = htmlspecialchars($this->getFullURL());
2461 $title = htmlspecialchars($this->getText());
2462 $tburl = $this->trackbackURL();
2463
2464 return "
2465<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
2466 xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
2467 xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">
2468<rdf:Description
2469 rdf:about=\"$url\"
2470 dc:identifier=\"$url\"
2471 dc:title=\"$title\"
2472 trackback:ping=\"$tburl\" />
2473</rdf:RDF>";
2474 }
trackbackURL()
Definition: Title.php:2452

References $url, getFullURL(), getText(), and trackbackURL().

+ Here is the call graph for this function:

◆ trackbackURL()

Title::trackbackURL ( )

Definition at line 2452 of file Title.php.

2452 {
2453 global $wgTitle, $wgScriptPath, $wgServer;
2454
2455 return "$wgServer$wgScriptPath/trackback.php?article="
2456 . htmlspecialchars(urlencode($wgTitle->getPrefixedDBkey()));
2457 }

Referenced by trackbackRDF().

+ Here is the caller graph for this function:

◆ userCan()

Title::userCan (   $action,
  $doExpensiveQueries = true 
)

Can $wgUser perform $action on this page?

Parameters
string$actionaction that permission needs to be checked for
bool$doExpensiveQueriesSet this to false to avoid doing unnecessary queries.
Returns
boolean

Definition at line 1003 of file Title.php.

1003 {
1004 $fname = 'Title::userCan';
1005 wfProfileIn( $fname );
1006
1007 global $wgUser, $wgNamespaceProtection;
1008
1009 $result = null;
1010 wfRunHooks( 'userCan', array( &$this, &$wgUser, $action, &$result ) );
1011 if ( $result !== null ) {
1012 wfProfileOut( $fname );
1013 return $result;
1014 }
1015
1016 if( NS_SPECIAL == $this->mNamespace ) {
1017 wfProfileOut( $fname );
1018 return false;
1019 }
1020
1021 if ( array_key_exists( $this->mNamespace, $wgNamespaceProtection ) ) {
1022 $nsProt = $wgNamespaceProtection[ $this->mNamespace ];
1023 if ( !is_array($nsProt) ) $nsProt = array($nsProt);
1024 foreach( $nsProt as $right ) {
1025 if( '' != $right && !$wgUser->isAllowed( $right ) ) {
1026 wfProfileOut( $fname );
1027 return false;
1028 }
1029 }
1030 }
1031
1032 if( $this->mDbkeyform == '_' ) {
1033 # FIXME: Is this necessary? Shouldn't be allowed anyway...
1034 wfProfileOut( $fname );
1035 return false;
1036 }
1037
1038 # protect css/js subpages of user pages
1039 # XXX: this might be better using restrictions
1040 # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
1041 if( $this->isCssJsSubpage()
1042 && !$wgUser->isAllowed('editinterface')
1043 && !preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) ) {
1044 wfProfileOut( $fname );
1045 return false;
1046 }
1047
1048 if ( $doExpensiveQueries && !$this->isCssJsSubpage() ) {
1049 # We /could/ use the protection level on the source page, but it's fairly ugly
1050 # as we have to establish a precedence hierarchy for pages included by multiple
1051 # cascade-protected pages. So just restrict it to people with 'protect' permission,
1052 # as they could remove the protection anyway.
1053 list( $cascadingSources, $restrictions ) = $this->getCascadeProtectionSources();
1054 # Cascading protection depends on more than this page...
1055 # Several cascading protected pages may include this page...
1056 # Check each cascading level
1057 # This is only for protection restrictions, not for all actions
1058 if( $cascadingSources > 0 && isset($restrictions[$action]) ) {
1059 foreach( $restrictions[$action] as $right ) {
1060 $right = ( $right == 'sysop' ) ? 'protect' : $right;
1061 if( '' != $right && !$wgUser->isAllowed( $right ) ) {
1062 wfProfileOut( $fname );
1063 return false;
1064 }
1065 }
1066 }
1067 }
1068
1069 foreach( $this->getRestrictions($action) as $right ) {
1070 // Backwards compatibility, rewrite sysop -> protect
1071 if ( $right == 'sysop' ) {
1072 $right = 'protect';
1073 }
1074 if( '' != $right && !$wgUser->isAllowed( $right ) ) {
1075 wfProfileOut( $fname );
1076 return false;
1077 }
1078 }
1079
1080 if( $action == 'move' &&
1081 !( $this->isMovable() && $wgUser->isAllowed( 'move' ) ) ) {
1082 wfProfileOut( $fname );
1083 return false;
1084 }
1085
1086 if( $action == 'create' ) {
1087 if( ( $this->isTalkPage() && !$wgUser->isAllowed( 'createtalk' ) ) ||
1088 ( !$this->isTalkPage() && !$wgUser->isAllowed( 'createpage' ) ) ) {
1089 wfProfileOut( $fname );
1090 return false;
1091 }
1092 }
1093
1094 wfProfileOut( $fname );
1095 return true;
1096 }
$result

References $mNamespace, $result, getCascadeProtectionSources(), getRestrictions(), and isCssJsSubpage().

Referenced by isValidMoveOperation(), quickUserCan(), userCanCreate(), userCanEdit(), and userCanMove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userCanCreate()

Title::userCanCreate (   $doExpensiveQueries = true)

Can $wgUser create this page?

Returns
boolean
Deprecated:
use userCan('create')

Definition at line 1112 of file Title.php.

1112 {
1113 return $this->userCan( 'create', $doExpensiveQueries );
1114 }

References userCan().

+ Here is the call graph for this function:

◆ userCanEdit()

Title::userCanEdit (   $doExpensiveQueries = true)

Can $wgUser edit this page?

Returns
boolean
Deprecated:
use userCan('edit')

Definition at line 1103 of file Title.php.

1103 {
1104 return $this->userCan( 'edit', $doExpensiveQueries );
1105 }

References userCan().

+ Here is the call graph for this function:

◆ userCanEditCssJsSubpage()

Title::userCanEditCssJsSubpage ( )

Protect css/js subpages of user pages: can $wgUser edit this page?

Returns
boolean
Todo:
XXX: this might be better using restrictions

Definition at line 1249 of file Title.php.

1249 {
1250 global $wgUser;
1251 return ( $wgUser->isAllowed('editinterface') or preg_match('/^'.preg_quote($wgUser->getName(), '/').'\//', $this->mTextform) );
1252 }

◆ userCanMove()

Title::userCanMove (   $doExpensiveQueries = true)

Can $wgUser move this page?

Returns
boolean
Deprecated:
use userCan('move')

Definition at line 1121 of file Title.php.

1121 {
1122 return $this->userCan( 'move', $doExpensiveQueries );
1123 }

References userCan().

+ Here is the call graph for this function:

◆ userCanRead()

Title::userCanRead ( )

Would anybody with sufficient privileges be able to move this page? Some pages just aren't movable.

Returns
boolean Can $wgUser read this page?
boolean
Todo:
fold these checks into userCan()

Always grant access to the login page. Even anons need to be able to log in.

some pages are explicitly allowed

Definition at line 1141 of file Title.php.

1141 {
1142 global $wgUser;
1143
1144 $result = null;
1145 wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) );
1146 if ( $result !== null ) {
1147 return $result;
1148 }
1149
1150 if( $wgUser->isAllowed('read') ) {
1151 return true;
1152 } else {
1153 global $wgWhitelistRead;
1154
1159 if( $this->isSpecial( 'Userlogin' ) || $this->isSpecial( 'Resetpass' ) ) {
1160 return true;
1161 }
1162
1164 $name = $this->getPrefixedText();
1165 if( $wgWhitelistRead && in_array( $name, $wgWhitelistRead ) ) {
1166 return true;
1167 }
1168
1169 # Compatibility with old settings
1170 if( $wgWhitelistRead && $this->getNamespace() == NS_MAIN ) {
1171 if( in_array( ':' . $name, $wgWhitelistRead ) ) {
1172 return true;
1173 }
1174 }
1175 }
1176 return false;
1177 }
isSpecial( $name)
Returns true if this title resolves to the named special page.
Definition: Title.php:2520

References $result, getNamespace(), getPrefixedText(), and isSpecial().

+ Here is the call graph for this function:

◆ userIsWatching()

Title::userIsWatching ( )

Is $wgUser is watching this page?

Returns
boolean

Definition at line 968 of file Title.php.

968 {
969 global $wgUser;
970
971 if ( is_null( $this->mWatched ) ) {
972 if ( NS_SPECIAL == $this->mNamespace || !$wgUser->isLoggedIn()) {
973 $this->mWatched = false;
974 } else {
975 $this->mWatched = $wgUser->isWatched( $this );
976 }
977 }
978 return $this->mWatched;
979 }
$mWatched
Definition: Title.php:64

References $mWatched.

Field Documentation

◆ $interwikiCache

Title::$interwikiCache =array()
staticprivate

Definition at line 35 of file Title.php.

Referenced by getInterwikiCached(), getInterwikiLink(), isLocal(), and isTrans().

◆ $mArticleID

Title::$mArticleID

Definition at line 53 of file Title.php.

Referenced by getArticleID().

◆ $mCascadeRestriction

Title::$mCascadeRestriction

Definition at line 56 of file Title.php.

Referenced by areRestrictionsCascading().

◆ $mCascadeRestrictionSources

Title::$mCascadeRestrictionSources

Definition at line 59 of file Title.php.

◆ $mDbkeyform

Title::$mDbkeyform

Definition at line 49 of file Title.php.

Referenced by getDBkey(), isAlwaysKnown(), and secureAndSplit().

◆ $mDefaultNamespace

Title::$mDefaultNamespace

Definition at line 62 of file Title.php.

Referenced by getDefaultNamespace(), and secureAndSplit().

◆ $mFragment

Title::$mFragment

Definition at line 52 of file Title.php.

Referenced by getFragment(), and getFullText().

◆ $mHasCascadingRestrictions

Title::$mHasCascadingRestrictions

Definition at line 58 of file Title.php.

◆ $mInterwiki

Title::$mInterwiki

Definition at line 51 of file Title.php.

Referenced by getInterwiki().

◆ $mLatestID

Title::$mLatestID

Definition at line 54 of file Title.php.

Referenced by getLatestRevID().

◆ $mNamespace

Title::$mNamespace

Definition at line 50 of file Title.php.

Referenced by getNamespace(), getNsText(), and userCan().

◆ $mPrefixedText

Title::$mPrefixedText

Definition at line 61 of file Title.php.

Referenced by getPrefixedText().

◆ $mRestrictions

Title::$mRestrictions

Definition at line 55 of file Title.php.

◆ $mRestrictionsExpiry

Title::$mRestrictionsExpiry

Definition at line 57 of file Title.php.

◆ $mRestrictionsLoaded

Title::$mRestrictionsLoaded

Definition at line 60 of file Title.php.

◆ $mTextform

Title::$mTextform
private

All member variables should be considered private Please use the accessor functions.

#+

Definition at line 47 of file Title.php.

Referenced by getText().

◆ $mUrlform

Title::$mUrlform

Definition at line 48 of file Title.php.

Referenced by getPartialURL().

◆ $mWatched

Title::$mWatched

Definition at line 64 of file Title.php.

Referenced by userIsWatching().

◆ $titleCache

Title::$titleCache =array()
staticprivate

Static cache variables.

Definition at line 34 of file Title.php.

Referenced by newFromText().


The documentation for this class was generated from the following file: