ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Title Class Reference

Title class. More...

+ Collaboration diagram for Title:

Public Member Functions

 __construct ()
 #- More...
 
 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...
 
 prefix ($name)
 Prefix some arbitrary text with the namespace or interwiki prefix of this object. 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

 $mTextform
 All member variables should be considered private Please use the accessor functions. More...
 
 $mUrlform
 
 $mDbkeyform
 
 $mNamespace
 
 $mInterwiki
 
 $mFragment
 
 $mArticleID
 
 $mLatestID
 
 $mRestrictions
 
 $mCascadeRestriction
 
 $mRestrictionsExpiry
 
 $mHasCascadingRestrictions
 
 $mCascadeRestrictionSources
 
 $mRestrictionsLoaded
 
 $mPrefixedText
 
 $mDefaultNamespace
 
 $mWatched
 

Private Member Functions

 loadRestrictionsFromRow ($res, $oldFashionedRestrictions=null)
 Loads a string into mRestrictions array. 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...
 

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 36 of file Title.php.

Constructor & Destructor Documentation

◆ __construct()

Title::__construct ( )

#-

Constructor

Definition at line 79 of file Title.php.

References NS_MAIN.

80  {
81  $this->mInterwiki = $this->mUrlform =
82  $this->mTextform = $this->mDbkeyform = '';
83  $this->mArticleID = -1;
84  $this->mNamespace = NS_MAIN;
85  $this->mRestrictionsLoaded = false;
86  $this->mRestrictions = array();
87  # Dont change the following, NS_MAIN is hardcoded in several place
88  # See bug #696
89  $this->mDefaultNamespace = NS_MAIN;
90  $this->mWatched = null;
91  $this->mLatestID = false;
92  $this->mOldRestrictions = false;
93  }
const NS_MAIN(!class_exists('UtfNormal'))
See title.txt.
Definition: Title.php:15

Member Function Documentation

◆ areRestrictionsCascading()

Title::areRestrictionsCascading ( )

Definition at line 1474 of file Title.php.

References $mCascadeRestriction, and loadRestrictions().

1475  {
1476  if (!$this->mRestrictionsLoaded) {
1477  $this->loadRestrictions();
1478  }
1479 
1481  }
$mCascadeRestriction
Definition: Title.php:63
loadRestrictions($oldFashionedRestrictions=null)
Definition: Title.php:1549
+ 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 2571 of file Title.php.

2572  {
2573  $dbr = wfGetDB(DB_SLAVE);
2574  return $dbr->selectField(
2575  'revision',
2576  'count(*)',
2577  'rev_page = ' . intval($this->getArticleId()) .
2578  ' AND rev_id > ' . intval($old) .
2579  ' AND rev_id < ' . intval($new)
2580  );
2581  }

◆ equals()

Title::equals (   $title)

Compare with another title.

Parameters
Title$title
Returns
bool

Definition at line 2589 of file Title.php.

References $title, getInterwiki(), and getNamespace().

Referenced by isValidMoveOperation().

2590  {
2591  // Note: === is necessary for proper matching of number-like titles.
2592  return $this->getInterwiki() === $title->getInterwiki()
2593  && $this->getNamespace() == $title->getNamespace()
2594  && $this->getDbkey() === $title->getDbkey();
2595  }
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
getInterwiki()
Get the namespace text of the subject (rather than talk) page.
Definition: Title.php:651
+ 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 552 of file Title.php.

References Sanitizer\decodeCharReferences().

Referenced by getFragmentForURL().

553  {
554  $fragment = str_replace(' ', '_', $fragment);
555  $fragment = urlencode(Sanitizer::decodeCharReferences($fragment));
556  $replaceArray = array(
557  '%3A' => ':',
558  '%' => '.'
559  );
560  return strtr($fragment, $replaceArray);
561  }
static decodeCharReferences($text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string...
Definition: Sanitizer.php:1018
+ 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 939 of file Title.php.

References $query, and getFullURL().

940  {
941  return htmlspecialchars($this->getFullURL($query));
942  }
getFullURL($query='', $variant=false)
Get a real URL referring to this title, with interwiki link and fragment.
Definition: Title.php:809
$query
+ 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 927 of file Title.php.

References $query, and getLocalURL().

928  {
929  return htmlspecialchars($this->getLocalURL($query));
930  }
getLocalURL($query='', $variant=false)
Get a URL with no fragment or server name.
Definition: Title.php:849
$query
+ Here is the call graph for this function:

◆ exists()

Title::exists ( )

Check if page exists.

Returns
bool

Definition at line 2601 of file Title.php.

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

2602  {
2603  return $this->getArticleId() != 0;
2604  }
+ 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 2738 of file Title.php.

References getNamespace(), makeTitle(), and NS_SPECIAL.

2739  {
2740  if ($this->getNamespace() == NS_SPECIAL) {
2741  $canonicalName = SpecialPage::resolveAlias($this->mDbkeyform);
2742  if ($canonicalName) {
2743  $localName = SpecialPage::getLocalNameFor($canonicalName);
2744  if ($localName != $this->mDbkeyform) {
2745  return Title::makeTitle(NS_SPECIAL, $localName);
2746  }
2747  }
2748  }
2749  return $this;
2750  }
const NS_SPECIAL
Definition: Title.php:16
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
static & makeTitle($ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:253
+ 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 1630 of file Title.php.

References $mArticleID, and GAID_FOR_UPDATE.

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

1631  {
1632  $linkCache = &LinkCache::singleton();
1633  if ($flags & GAID_FOR_UPDATE) {
1634  $oldUpdate = $linkCache->forUpdate(true);
1635  $this->mArticleID = $linkCache->addLinkObj($this);
1636  $linkCache->forUpdate($oldUpdate);
1637  } else {
1638  if (-1 == $this->mArticleID) {
1639  $this->mArticleID = $linkCache->addLinkObj($this);
1640  }
1641  }
1642  return $this->mArticleID;
1643  }
$mArticleID
Definition: Title.php:60
const GAID_FOR_UPDATE
Definition: Title.php:18
+ 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 740 of file Title.php.

References getText().

741  {
742  global $wgNamespacesWithSubpages;
743  if (isset($wgNamespacesWithSubpages[ $this->mNamespace ]) && $wgNamespacesWithSubpages[ $this->mNamespace ]) {
744  $parts = explode('/', $this->getText());
745  # Don't discard the real title if there's no subpage involved
746  if (count($parts) > 1) {
747  unset($parts[ count($parts) - 1 ]);
748  }
749  return implode('/', $parts);
750  } else {
751  return $this->getText();
752  }
753  }
getText()
Simple accessors.
Definition: Title.php:572
+ 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 2026 of file Title.php.

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

2027  {
2028  if ($options) {
2029  $db = wfGetDB(DB_MASTER);
2030  } else {
2031  $db = wfGetDB(DB_SLAVE);
2032  }
2033 
2034  $res = $db->safeQuery(
2035  "SELECT pl_namespace, pl_title
2036  FROM !
2037  LEFT JOIN !
2038  ON pl_namespace=page_namespace
2039  AND pl_title=page_title
2040  WHERE pl_from=?
2041  AND page_namespace IS NULL
2042  !",
2043  $db->tableName('pagelinks'),
2044  $db->tableName('page'),
2045  $this->getArticleId(),
2046  $options
2047  );
2048 
2049  $retVal = array();
2050  if ($db->numRows($res)) {
2051  while ($row = $db->fetchObject($res)) {
2052  $retVal[] = Title::makeTitle($row->pl_namespace, $row->pl_title);
2053  }
2054  }
2055  $db->freeResult($res);
2056  return $retVal;
2057  }
foreach($_POST as $key=> $value) $res
$row
static & makeTitle($ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:253
+ 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 1384 of file Title.php.

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

Referenced by isCascadeProtected(), and userCan().

1385  {
1386  global $wgEnableCascadingProtection, $wgRestrictionTypes;
1387 
1388  # Define our dimension of restrictions types
1389  $pagerestrictions = array();
1390  foreach ($wgRestrictionTypes as $action) {
1391  $pagerestrictions[$action] = array();
1392  }
1393 
1394  if (!$wgEnableCascadingProtection) {
1395  return array( false, $pagerestrictions );
1396  }
1397 
1398  if (isset($this->mCascadeSources) && $get_pages) {
1399  return array( $this->mCascadeSources, $this->mCascadingRestrictions );
1400  } elseif (isset($this->mHasCascadingRestrictions) && !$get_pages) {
1401  return array( $this->mHasCascadingRestrictions, $pagerestrictions );
1402  }
1403 
1404  wfProfileIn(__METHOD__);
1405 
1406  $dbr = wfGetDb(DB_SLAVE);
1407 
1408  if ($this->getNamespace() == NS_IMAGE) {
1409  $tables = array('imagelinks', 'page_restrictions');
1410  $where_clauses = array(
1411  'il_to' => $this->getDBkey(),
1412  'il_from=pr_page',
1413  'pr_cascade' => 1 );
1414  } else {
1415  $tables = array('templatelinks', 'page_restrictions');
1416  $where_clauses = array(
1417  'tl_namespace' => $this->getNamespace(),
1418  'tl_title' => $this->getDBkey(),
1419  'tl_from=pr_page',
1420  'pr_cascade' => 1 );
1421  }
1422 
1423  if ($get_pages) {
1424  $cols = array('pr_page', 'page_namespace', 'page_title', 'pr_expiry', 'pr_type', 'pr_level' );
1425  $where_clauses[] = 'page_id=pr_page';
1426  $tables[] = 'page';
1427  } else {
1428  $cols = array( 'pr_expiry' );
1429  }
1430 
1431  $res = $dbr->select($tables, $cols, $where_clauses, __METHOD__);
1432 
1433  $sources = $get_pages ? array() : false;
1434  $now = wfTimestampNow();
1435  $purgeExpired = false;
1436 
1437  while ($row = $dbr->fetchObject($res)) {
1438  $expiry = Block::decodeExpiry($row->pr_expiry);
1439  if ($expiry > $now) {
1440  if ($get_pages) {
1441  $page_id = $row->pr_page;
1442  $page_ns = $row->page_namespace;
1443  $page_title = $row->page_title;
1444  $sources[$page_id] = Title::makeTitle($page_ns, $page_title);
1445  # Add groups needed for each restriction type if its not already there
1446  # Make sure this restriction type still exists
1447  if (isset($pagerestrictions[$row->pr_type]) && !in_array($row->pr_level, $pagerestrictions[$row->pr_type])) {
1448  $pagerestrictions[$row->pr_type][] = $row->pr_level;
1449  }
1450  } else {
1451  $sources = true;
1452  }
1453  } else {
1454  // Trigger lazy purge of expired restrictions from the db
1455  $purgeExpired = true;
1456  }
1457  }
1458  if ($purgeExpired) {
1460  }
1461 
1462  wfProfileOut(__METHOD__);
1463 
1464  if ($get_pages) {
1465  $this->mCascadeSources = $sources;
1466  $this->mCascadingRestrictions = $pagerestrictions;
1467  } else {
1468  $this->mHasCascadingRestrictions = $sources;
1469  }
1470 
1471  return array( $sources, $pagerestrictions );
1472  }
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
Definition: Title.php:1568
$action
getDBkey()
Get the main part with underscores.
Definition: Title.php:588
foreach($_POST as $key=> $value) $res
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
$row
static & makeTitle($ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:253
$cols
Definition: xhr_table.php:11
+ 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 588 of file Title.php.

References $mDbkeyform.

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

589  {
590  return $this->mDbkeyform;
591  }
$mDbkeyform
Definition: Title.php:56
+ 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 679 of file Title.php.

References $mDefaultNamespace.

680  {
682  }
$mDefaultNamespace
Definition: Title.php:69

◆ 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 966 of file Title.php.

References $s, and getLocalURL().

967  {
968  if ('' != $this->mInterwiki) {
969  return '';
970  }
971  $s = $this->getLocalURL('action=edit');
972 
973  return $s;
974  }
getLocalURL($query='', $variant=false)
Get a URL with no fragment or server name.
Definition: Title.php:849
$s
Definition: pwgen.php:45
+ 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 981 of file Title.php.

References getPrefixedText().

982  {
983  return htmlspecialchars($this->getPrefixedText());
984  }
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:711
+ 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 659 of file Title.php.

References $mFragment.

660  {
661  return $this->mFragment;
662  }
$mFragment
Definition: Title.php:59

◆ getFragmentForURL()

Title::getFragmentForURL ( )

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

Returns
string

Definition at line 667 of file Title.php.

References escapeFragmentForURL().

Referenced by getFullURL().

668  {
669  if ($this->mFragment == '') {
670  return '';
671  } else {
672  return '#' . Title::escapeFragmentForURL($this->mFragment);
673  }
674  }
static escapeFragmentForURL($fragment)
Escape a text fragment, say from a link, for a URL.
Definition: Title.php:552
+ 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 727 of file Title.php.

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

Referenced by getParentCategories().

728  {
729  $text = $this->getPrefixedText();
730  if ('' != $this->mFragment) {
731  $text .= '#' . $this->mFragment;
732  }
733  return $text;
734  }
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:711
$mFragment
Definition: Title.php:59
$text
Definition: errorreport.php:18
+ 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 809 of file Title.php.

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

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

810  {
811  global $wgContLang, $wgServer, $wgRequest;
812 
813  if ('' == $this->mInterwiki) {
814  $url = $this->getLocalUrl($query, $variant);
815 
816  // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc)
817  // Correct fix would be to move the prepending elsewhere.
818  if ($wgRequest->getVal('action') != 'render') {
819  $url = $wgServer . $url;
820  }
821  } else {
822  $baseUrl = $this->getInterwikiLink($this->mInterwiki);
823 
824  $namespace = wfUrlencode($this->getNsText());
825  if ('' != $namespace) {
826  # Can this actually happen? Interwikis shouldn't be parsed.
827  # Yes! It can in interwiki transclusion. But... it probably shouldn't.
828  $namespace .= ':';
829  }
830  $url = str_replace('$1', $namespace . $this->mUrlform, $baseUrl);
831  $url = wfAppendQuery($url, $query);
832  }
833 
834  # Finally, add the fragment.
835  $url .= $this->getFragmentForURL();
836 
837  wfRunHooks('GetFullURL', array( &$this, &$url, $query ));
838  return $url;
839  }
if($err=$client->getError()) $namespace
getInterwikiLink($key)
Returns the URL associated with an interwiki prefix.
Definition: Title.php:415
getNsText()
Get the namespace text.
Definition: Title.php:604
$query
getFragmentForURL()
Get the fragment in URL form, including the "#" character if there is one.
Definition: Title.php:667
$url
+ 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 689 of file Title.php.

References indexTitle().

690  {
691  return Title::indexTitle($this->mNamespace, $this->mTextform);
692  }
static indexTitle($ns, $title)
Get a string representation of a title suitable for including in a search index.
Definition: Title.php:373
+ 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 953 of file Title.php.

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

Referenced by getSquidURLs().

954  {
955  global $wgInternalServer;
956  $url = $wgInternalServer . $this->getLocalURL($query, $variant);
957  wfRunHooks('GetInternalURL', array( &$this, &$url, $query ));
958  return $url;
959  }
getLocalURL($query='', $variant=false)
Get a URL with no fragment or server name.
Definition: Title.php:849
$query
$url
+ 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 651 of file Title.php.

References $mInterwiki.

Referenced by equals().

652  {
653  return $this->mInterwiki;
654  }
$mInterwiki
Definition: Title.php:58
+ 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 474 of file Title.php.

References $interwikiCache, $key, $s, and $url.

Referenced by getInterwikiLink().

475  {
476  global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
477  static $db, $site;
478 
479  if (!$db) {
480  $db = dba_open($wgInterwikiCache, 'r', 'cdb');
481  }
482  /* Resolve site name */
483  if ($wgInterwikiScopes >= 3 and !$site) {
484  $site = dba_fetch('__sites:' . wfWikiID(), $db);
485  if ($site == "") {
486  $site = $wgInterwikiFallbackSite;
487  }
488  }
489  $value = dba_fetch(wfMemcKey($key), $db);
490  if ($value == '' and $wgInterwikiScopes >= 3) {
491  /* try site-level */
492  $value = dba_fetch("_{$site}:{$key}", $db);
493  }
494  if ($value == '' and $wgInterwikiScopes >= 2) {
495  /* try globals */
496  $value = dba_fetch("__global:{$key}", $db);
497  }
498  if ($value == 'undef') {
499  $value = '';
500  }
501  $s = (object) false;
502  $s->iw_url = '';
503  $s->iw_local = 0;
504  $s->iw_trans = 0;
505  if ($value != '') {
506  list($local, $url) = explode(' ', $value, 2);
507  $s->iw_url = $url;
508  $s->iw_local = (int) $local;
509  }
510  Title::$interwikiCache[wfMemcKey('interwiki', $key)] = $s;
511  return $s->iw_url;
512  }
static $interwikiCache
Definition: Title.php:42
$s
Definition: pwgen.php:45
$url
$key
Definition: croninfo.php:18
+ 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 415 of file Title.php.

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

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

416  {
417  global $wgMemc, $wgInterwikiExpiry;
418  global $wgInterwikiCache, $wgContLang;
419 
420  return ""; // changed. alex
421 
422  $fname = 'Title::getInterwikiLink';
423 
424  $key = $wgContLang->lc($key);
425 
426  $k = wfMemcKey('interwiki', $key);
427  if (array_key_exists($k, Title::$interwikiCache)) {
428  return Title::$interwikiCache[$k]->iw_url;
429  }
430 
431  if ($wgInterwikiCache) {
433  }
434 
435  $s = $wgMemc->get($k);
436  # Ignore old keys with no iw_local
437  if ($s && isset($s->iw_local) && isset($s->iw_trans)) {
439  return $s->iw_url;
440  }
441 
442  $dbr = wfGetDB(DB_SLAVE);
443  $res = $dbr->select(
444  'interwiki',
445  array( 'iw_url', 'iw_local', 'iw_trans' ),
446  array( 'iw_prefix' => $key ),
447  $fname
448  );
449  if (!$res) {
450  return '';
451  }
452 
453  $s = $dbr->fetchObject($res);
454  if (!$s) {
455  # Cache non-existence: create a blank object and save it to memcached
456  $s = (object) false;
457  $s->iw_url = '';
458  $s->iw_local = 0;
459  $s->iw_trans = 0;
460  }
461  $wgMemc->set($k, $s, $wgInterwikiExpiry);
463 
464  return $s->iw_url;
465  }
static getInterwikiCached($key)
Fetch interwiki prefix data from local cache in constant database.
Definition: Title.php:474
static $interwikiCache
Definition: Title.php:42
$s
Definition: pwgen.php:45
foreach($_POST as $key=> $value) $res
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLatestRevID()

Title::getLatestRevID ( )

Definition at line 1645 of file Title.php.

References $mLatestID, and getArticleID().

1646  {
1647  if ($this->mLatestID !== false) {
1648  return $this->mLatestID;
1649  }
1650 
1651  $db = wfGetDB(DB_SLAVE);
1652  return $this->mLatestID = $db->selectField(
1653  'revision',
1654  "max(rev_id)",
1655  array('rev_page' => $this->getArticleID()),
1656  'Title::getLatestRevID'
1657  );
1658  }
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:1630
$mLatestID
Definition: Title.php:61
+ 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 1971 of file Title.php.

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

Referenced by getTemplateLinksTo().

1972  {
1973  $linkCache = &LinkCache::singleton();
1974 
1975  if ($options) {
1976  $db = wfGetDB(DB_MASTER);
1977  } else {
1978  $db = wfGetDB(DB_SLAVE);
1979  }
1980 
1981  $res = $db->select(
1982  array( 'page', $table ),
1983  array( 'page_namespace', 'page_title', 'page_id' ),
1984  array(
1985  "{$prefix}_from=page_id",
1986  "{$prefix}_namespace" => $this->getNamespace(),
1987  "{$prefix}_title" => $this->getDbKey() ),
1988  'Title::getLinksTo',
1989  $options
1990  );
1991 
1992  $retVal = array();
1993  if ($db->numRows($res)) {
1994  while ($row = $db->fetchObject($res)) {
1995  if ($titleObj = Title::makeTitle($row->page_namespace, $row->page_title)) {
1996  $linkCache->addGoodLinkObj($row->page_id, $titleObj);
1997  $retVal[] = $titleObj;
1998  }
1999  }
2000  }
2001  $db->freeResult($res);
2002  return $retVal;
2003  }
foreach($_POST as $key=> $value) $res
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
$row
static & makeTitle($ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:253
if(empty($password)) $table
Definition: pwgen.php:24
+ 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 849 of file Title.php.

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

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

850  {
851  global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
852  global $wgVariantArticlePath, $wgContLang, $wgUser;
853 
854  // internal links should point to same variant as current page (only anonymous users)
855  if ($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()) {
856  $pref = $wgContLang->getPreferredVariant(false);
857  if ($pref != $wgContLang->getCode()) {
858  $variant = $pref;
859  }
860  }
861 
862  if ($this->isExternal()) {
863  $url = $this->getFullURL();
864  if ($query) {
865  // This is currently only used for edit section links in the
866  // context of interwiki transclusion. In theory we should
867  // append the query to the end of any existing query string,
868  // but interwiki transclusion is already broken in that case.
869  $url .= "?$query";
870  }
871  } else {
872  $dbkey = wfUrlencode($this->getPrefixedDBkey());
873  if ($query == '') {
874  if ($variant != false && $wgContLang->hasVariants()) {
875  if ($wgVariantArticlePath == false) {
876  $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default
877  } else {
878  $variantArticlePath = $wgVariantArticlePath;
879  }
880  $url = str_replace('$2', urlencode($variant), $variantArticlePath);
881  $url = str_replace('$1', $dbkey, $url);
882  } else {
883  $url = str_replace('$1', $dbkey, $wgArticlePath);
884  }
885  } else {
886  global $wgActionPaths;
887  $url = false;
888  $matches = array();
889  if (!empty($wgActionPaths) &&
890  preg_match('/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches)) {
891  $action = urldecode($matches[2]);
892  if (isset($wgActionPaths[$action])) {
893  $query = $matches[1];
894  if (isset($matches[4])) {
895  $query .= $matches[4];
896  }
897  $url = str_replace('$1', $dbkey, $wgActionPaths[$action]);
898  if ($query != '') {
899  $url .= '?' . $query;
900  }
901  }
902  }
903  if ($url === false) {
904  if ($query == '-') {
905  $query = '';
906  }
907  $url = "{$wgScript}?title={$dbkey}&{$query}";
908  }
909  }
910 
911  // FIXME: this causes breakage in various places when we
912  // actually expected a local URL and end up with dupe prefixes.
913  if ($wgRequest->getVal('action') == 'render') {
914  $url = $wgServer . $url;
915  }
916  }
917  wfRunHooks('GetLocalURL', array( &$this, &$url, $query ));
918  return $url;
919  }
$action
isExternal()
Is this Title interwiki?
Definition: Title.php:990
getFullURL($query='', $variant=false)
Get a real URL referring to this title, with interwiki link and fragment.
Definition: Title.php:809
$query
$url
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:699
+ 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 596 of file Title.php.

References $mNamespace.

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

597  {
598  return $this->mNamespace;
599  }
$mNamespace
Definition: Title.php:57
+ 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 2682 of file Title.php.

References getNamespace(), NS_MAIN, and NS_SPECIAL.

2683  {
2684  global $wgContLang;
2685  switch ($this->getNamespace()) {
2686  case NS_MAIN:
2687  case NS_TALK:
2688  return 'nstab-main';
2689  case NS_USER:
2690  case NS_USER_TALK:
2691  return 'nstab-user';
2692  case NS_MEDIA:
2693  return 'nstab-media';
2694  case NS_SPECIAL:
2695  return 'nstab-special';
2696  case NS_PROJECT:
2697  case NS_PROJECT_TALK:
2698  return 'nstab-project';
2699  case NS_IMAGE:
2700  case NS_IMAGE_TALK:
2701  return 'nstab-image';
2702  case NS_MEDIAWIKI:
2703  case NS_MEDIAWIKI_TALK:
2704  return 'nstab-mediawiki';
2705  case NS_TEMPLATE:
2706  case NS_TEMPLATE_TALK:
2707  return 'nstab-template';
2708  case NS_HELP:
2709  case NS_HELP_TALK:
2710  return 'nstab-help';
2711  case NS_CATEGORY:
2712  case NS_CATEGORY_TALK:
2713  return 'nstab-category';
2714  default:
2715  return 'nstab-' . $wgContLang->lc($this->getSubjectNsText());
2716  }
2717  }
const NS_MAIN(!class_exists('UtfNormal'))
See title.txt.
Definition: Title.php:15
const NS_SPECIAL
Definition: Title.php:16
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
+ 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 2553 of file Title.php.

2554  {
2555  $dbr = wfGetDB(DB_SLAVE);
2556  return $dbr->selectField(
2557  'revision',
2558  'rev_id',
2559  'rev_page=' . intval($this->getArticleId()) .
2560  ' AND rev_id>' . intval($revision) . ' ORDER BY rev_id'
2561  );
2562  }

◆ getNsText()

Title::getNsText ( )

Get the namespace text.

Returns
string

Definition at line 604 of file Title.php.

References $mNamespace.

Referenced by getFullURL(), and prefix().

605  {
606  global $wgContLang, $wgCanonicalNamespaceNames;
607 
608  if ('' != $this->mInterwiki) {
609  // This probably shouldn't even happen. ohh man, oh yuck.
610  // But for interwiki transclusion it sometimes does.
611  // Shit. Shit shit shit.
612  //
613  // Use the canonical namespaces if possible to try to
614  // resolve a foreign namespace.
615  if (isset($wgCanonicalNamespaceNames[$this->mNamespace])) {
616  return $wgCanonicalNamespaceNames[$this->mNamespace];
617  }
618  }
619  return $wgContLang->getNsText($this->mNamespace);
620  }
$mNamespace
Definition: Title.php:57
+ 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 2463 of file Title.php.

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

Referenced by getParentCategoryTree().

2464  {
2465  global $wgContLang;
2466 
2467  $titlekey = $this->getArticleId();
2468  $dbr = wfGetDB(DB_SLAVE);
2469  $categorylinks = $dbr->tableName('categorylinks');
2470 
2471  # NEW SQL
2472  $sql = "SELECT * FROM $categorylinks"
2473  . " WHERE cl_from='$titlekey'"
2474  . " AND cl_from <> '0'"
2475  . " ORDER BY cl_sortkey";
2476 
2477  $res = $dbr->query($sql) ;
2478 
2479  if ($dbr->numRows($res) > 0) {
2480  while ($x = $dbr->fetchObject($res)) {
2481  //$data[] = Title::newFromText($wgContLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to);
2482  $data[$wgContLang->getNSText(NS_CATEGORY) . ':' . $x->cl_to] = $this->getFullText();
2483  }
2484  $dbr->freeResult($res) ;
2485  } else {
2486  $data = '';
2487  }
2488  return $data;
2489  }
foreach($_POST as $key=> $value) $res
getFullText()
Get the prefixed title with spaces, plus any fragment (part beginning with &#39;#&#39;)
Definition: Title.php:727
$x
Definition: complexTest.php:9
$data
Definition: bench.php:6
+ 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 2496 of file Title.php.

References $current, getParentCategories(), and newFromText().

2497  {
2498  $parents = $this->getParentCategories();
2499 
2500  if ($parents != '') {
2501  foreach ($parents as $parent => $current) {
2502  if (array_key_exists($parent, $children)) {
2503  # Circular reference
2504  $stack[$parent] = array();
2505  } else {
2506  $nt = Title::newFromText($parent);
2507  if ($nt) {
2508  $stack[$parent] = $nt->getParentCategoryTree($children + array($parent => 1));
2509  }
2510  }
2511  }
2512  return $stack;
2513  } else {
2514  return array();
2515  }
2516  }
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:124
getParentCategories()
Get categories to which this Title belongs and return an array of categories&#39; names.
Definition: Title.php:2463
+ 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 580 of file Title.php.

References $mUrlform.

581  {
582  return $this->mUrlform;
583  }
$mUrlform
Definition: Title.php:55

◆ 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 699 of file Title.php.

References $s, and prefix().

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

700  {
701  $s = $this->prefix($this->mDbkeyform);
702  $s = str_replace(' ', '_', $s);
703  return $s;
704  }
prefix($name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object. ...
Definition: Title.php:1725
$s
Definition: pwgen.php:45
+ 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 711 of file Title.php.

References $mPrefixedText, $s, and prefix().

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

712  {
713  if (empty($this->mPrefixedText)) { // FIXME: bad usage of empty() ?
714  $s = $this->prefix($this->mTextform);
715  $s = str_replace('_', ' ', $s);
716  $this->mPrefixedText = $s;
717  }
718  return $this->mPrefixedText;
719  }
prefix($name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object. ...
Definition: Title.php:1725
$s
Definition: pwgen.php:45
$mPrefixedText
Definition: Title.php:68
+ 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 786 of file Title.php.

References $s, and prefix().

787  {
788  $s = $this->prefix($this->mDbkeyform);
789  $s = str_replace(' ', '_', $s);
790 
791  $s = wfUrlencode($s) ;
792 
793  # Cleaning up URL to make it look nice -- is this safe?
794  $s = str_replace('%28', '(', $s);
795  $s = str_replace('%29', ')', $s);
796 
797  return $s;
798  }
prefix($name)
Prefix some arbitrary text with the namespace or interwiki prefix of this object. ...
Definition: Title.php:1725
$s
Definition: pwgen.php:45
+ 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 2536 of file Title.php.

2537  {
2538  $dbr = wfGetDB(DB_SLAVE);
2539  return $dbr->selectField(
2540  'revision',
2541  'rev_id',
2542  'rev_page=' . intval($this->getArticleId()) .
2543  ' AND rev_id<' . intval($revision) . ' ORDER BY rev_id DESC'
2544  );
2545  }

◆ 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 1584 of file Title.php.

References $action, exists(), and loadRestrictions().

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

1585  {
1586  if ($this->exists()) {
1587  if (!$this->mRestrictionsLoaded) {
1588  $this->loadRestrictions();
1589  }
1590  return isset($this->mRestrictions[$action])
1591  ? $this->mRestrictions[$action]
1592  : array();
1593  } else {
1594  return array();
1595  }
1596  }
$action
exists()
Check if page exists.
Definition: Title.php:2601
loadRestrictions($oldFashionedRestrictions=null)
Definition: Title.php:1549
+ 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 1330 of file Title.php.

Referenced by isValidCssJsSubpage().

1331  {
1332  $subpage = explode('/', $this->mTextform);
1333  $subpage = $subpage[ count($subpage) - 1 ];
1334  return(str_replace(array( '.css', '.js' ), array( '', '' ), $subpage));
1335  }
+ 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 2066 of file Title.php.

References $urls, and getInternalURL().

Referenced by purgeSquid().

2067  {
2068  global $wgContLang;
2069 
2070  $urls = array(
2071  $this->getInternalURL(),
2072  $this->getInternalURL('action=history')
2073  );
2074 
2075  // purge variant urls as well
2076  if ($wgContLang->hasVariants()) {
2077  $variants = $wgContLang->getVariants();
2078  foreach ($variants as $vCode) {
2079  if ($vCode == $wgContLang->getCode()) {
2080  continue;
2081  } // we don't want default variant
2082  $urls[] = $this->getInternalURL('', $vCode);
2083  }
2084  }
2085 
2086  return $urls;
2087  }
$urls
Definition: croninfo.php:28
getInternalURL($query='', $variant=false)
Get the URL form for an internal link.
Definition: Title.php:953
+ 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 759 of file Title.php.

Referenced by getSubpageUrlForm().

760  {
761  global $wgNamespacesWithSubpages;
762  if (isset($wgNamespacesWithSubpages[ $this->mNamespace ]) && $wgNamespacesWithSubpages[ $this->mNamespace ]) {
763  $parts = explode('/', $this->mTextform);
764  return($parts[ count($parts) - 1 ]);
765  } else {
766  return($this->mTextform);
767  }
768  }
+ 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 774 of file Title.php.

References $text, getSubpageText(), and up().

775  {
776  $text = $this->getSubpageText();
777  $text = wfUrlencode(str_replace(' ', '_', $text));
778  $text = str_replace('%28', '(', str_replace('%29', ')', $text)); # Clean up the URL; per below, this might not be safe
779  return($text);
780  }
getSubpageText()
Get the lowest-level subpage name, i.e.
Definition: Title.php:759
up()
Definition: up.php:2
$text
Definition: errorreport.php:18
+ 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 2015 of file Title.php.

References PHPMailer\PHPMailer\$options, and getLinksTo().

2016  {
2017  return $this->getLinksTo($options, 'templatelinks', 'tl');
2018  }
getLinksTo($options='', $table='pagelinks', $prefix='pl')
Get a Title object associated with the talk page of this article.
Definition: Title.php:1971
+ 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 572 of file Title.php.

References $mTextform.

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

573  {
574  return $this->mTextform;
575  }
$mTextform
All member variables should be considered private Please use the accessor functions.
Definition: Title.php:54
+ Here is the caller graph for this function:

◆ getTouched()

Title::getTouched ( )

Get the last touched timestamp.

Definition at line 2637 of file Title.php.

References getDBkey(), and getNamespace().

2638  {
2639  $dbr = wfGetDB(DB_SLAVE);
2640  $touched = $dbr->selectField(
2641  'page',
2642  'page_touched',
2643  array(
2644  'page_namespace' => $this->getNamespace(),
2645  'page_title' => $this->getDBkey()
2646  ),
2647  __METHOD__
2648  );
2649  return $touched;
2650  }
getDBkey()
Get the main part with underscores.
Definition: Title.php:588
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
+ 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 373 of file Title.php.

References $lc, $t, and $title.

Referenced by getIndexTitle().

374  {
375  global $wgContLang;
376 
377  $lc = SearchEngine::legalSearchChars() . '&#;';
378  $t = $wgContLang->stripForSearch($title);
379  $t = preg_replace("/[^{$lc}]+/", ' ', $t);
380  $t = $wgContLang->lc($t);
381 
382  # Handle 's, s'
383  $t = preg_replace("/([{$lc}]+)'s( |$)/", "\\1 \\1's ", $t);
384  $t = preg_replace("/([{$lc}]+)s'( |$)/", "\\1s ", $t);
385 
386  $t = preg_replace("/\\s+/", ' ', $t);
387 
388  if ($ns == NS_IMAGE) {
389  $t = preg_replace("/ (png|gif|jpg|jpeg|ogg)$/", "", $t);
390  }
391  return trim($t);
392  }
$lc
Definition: date.php:267
+ 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 1688 of file Title.php.

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

1689  {
1690  global $wgUseFileCache;
1691 
1692  if (wfReadOnly()) {
1693  return;
1694  }
1695 
1696  $dbw = wfGetDB(DB_MASTER);
1697  $success = $dbw->update(
1698  'page',
1699  array( /* SET */
1700  'page_touched' => $dbw->timestamp()
1701  ),
1702  array( /* WHERE */
1703  'page_namespace' => $this->getNamespace() ,
1704  'page_title' => $this->getDBkey()
1705  ),
1706  'Title::invalidateCache'
1707  );
1708 
1709  if ($wgUseFileCache) {
1710  $cache = new HTMLFileCache($this);
1711  @unlink($cache->fileCacheName());
1712  }
1713 
1714  return $success;
1715  }
getDBkey()
Get the main part with underscores.
Definition: Title.php:588
$success
Definition: Utf8Test.php:86
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
+ 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 2612 of file Title.php.

References $mDbkeyform, isExternal(), and NS_SPECIAL.

2613  {
2614  return $this->isExternal() || (0 == $this->mNamespace && "" == $this->mDbkeyform)
2615  || NS_SPECIAL == $this->mNamespace;
2616  }
isExternal()
Is this Title interwiki?
Definition: Title.php:990
const NS_SPECIAL
Definition: Title.php:16
$mDbkeyform
Definition: Title.php:56
+ 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 1370 of file Title.php.

References getCascadeProtectionSources().

1371  {
1372  list($sources, $restrictions) = $this->getCascadeProtectionSources(false);
1373  return ($sources > 0);
1374  }
getCascadeProtectionSources($get_pages=true)
Cascading protection: Get the source of any cascading restrictions on this page.
Definition: Title.php:1384
+ 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 1310 of file Title.php.

Referenced by isValidCssJsSubpage(), and userCan().

1311  {
1312  return (NS_USER == $this->mNamespace and preg_match("/\\/.*\\.(?:css|js)$/", $this->mTextform));
1313  }
+ 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 1340 of file Title.php.

1341  {
1342  return (NS_USER == $this->mNamespace and preg_match("/\\/.*\\.css$/", $this->mTextform));
1343  }

◆ isDeleted()

Title::isDeleted ( )

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

Returns
int the number of archived revisions

Definition at line 1602 of file Title.php.

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

1603  {
1604  $fname = 'Title::isDeleted';
1605  if ($this->getNamespace() < 0) {
1606  $n = 0;
1607  } else {
1608  $dbr = wfGetDB(DB_SLAVE);
1609  $n = $dbr->selectField('archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
1610  'ar_title' => $this->getDBkey() ), $fname);
1611  if ($this->getNamespace() == NS_IMAGE) {
1612  $n += $dbr->selectField(
1613  'filearchive',
1614  'COUNT(*)',
1615  array( 'fa_name' => $this->getDBkey() ),
1616  $fname
1617  );
1618  }
1619  }
1620  return (int) $n;
1621  }
getDBkey()
Get the main part with underscores.
Definition: Title.php:588
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
$n
Definition: RandomTest.php:85
+ Here is the call graph for this function:

◆ isExternal()

Title::isExternal ( )

Is this Title interwiki?

Returns
boolean

Definition at line 990 of file Title.php.

Referenced by getLocalURL(), and isAlwaysKnown().

991  {
992  return ('' != $this->mInterwiki);
993  }
+ 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 1348 of file Title.php.

1349  {
1350  return (NS_USER == $this->mNamespace and preg_match("/\\/.*\\.js$/", $this->mTextform));
1351  }

◆ 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 520 of file Title.php.

References $interwikiCache, and getInterwikiLink().

521  {
522  if ($this->mInterwiki != '') {
523  # Make sure key is loaded into cache
524  $this->getInterwikiLink($this->mInterwiki);
525  $k = wfMemcKey('interwiki', $this->mInterwiki);
526  return (bool) (Title::$interwikiCache[$k]->iw_local);
527  } else {
528  return true;
529  }
530  }
getInterwikiLink($key)
Returns the URL associated with an interwiki prefix.
Definition: Title.php:415
static $interwikiCache
Definition: Title.php:42
+ 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 1028 of file Title.php.

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

1029  {
1030  global $wgRestrictionLevels;
1031 
1032  # Special pages have inherent protection
1033  if ($this->getNamespace() == NS_SPECIAL) {
1034  return true;
1035  }
1036 
1037  # Check regular protection levels
1038  if ($action == 'edit' || $action == '') {
1039  $r = $this->getRestrictions('edit');
1040  foreach ($wgRestrictionLevels as $level) {
1041  if (in_array($level, $r) && $level != '') {
1042  return(true);
1043  }
1044  }
1045  }
1046 
1047  if ($action == 'move' || $action == '') {
1048  $r = $this->getRestrictions('move');
1049  foreach ($wgRestrictionLevels as $level) {
1050  if (in_array($level, $r) && $level != '') {
1051  return(true);
1052  }
1053  }
1054  }
1055 
1056  return false;
1057  }
$action
$r
Definition: example_031.php:79
const NS_SPECIAL
Definition: Title.php:16
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
getRestrictions($action)
Accessor/initialisation for mRestrictions.
Definition: Title.php:1584
+ 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 1001 of file Title.php.

References $action, exists(), and getRestrictions().

1002  {
1003  if ($this->exists()) {
1004  $restrictions = $this->getRestrictions($action);
1005  if (count($restrictions) > 0) {
1006  foreach ($restrictions as $restriction) {
1007  if (strtolower($restriction) != 'autoconfirmed') {
1008  return false;
1009  }
1010  }
1011  } else {
1012  # Not protected
1013  return false;
1014  }
1015  return true;
1016  } else {
1017  # If it doesn't exist, it can't be protected
1018  return false;
1019  }
1020  }
$action
exists()
Check if page exists.
Definition: Title.php:2601
getRestrictions($action)
Accessor/initialisation for mRestrictions.
Definition: Title.php:1584
+ 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 2723 of file Title.php.

References $name, getDBkey(), getNamespace(), and NS_SPECIAL.

Referenced by userCanRead().

2724  {
2725  if ($this->getNamespace() == NS_SPECIAL) {
2726  list($thisName, /* $subpage */ ) = SpecialPage::resolveAliasWithSubpage($this->getDBkey());
2727  if ($name == $thisName) {
2728  return true;
2729  }
2730  }
2731  return false;
2732  }
getDBkey()
Get the main part with underscores.
Definition: Title.php:588
const NS_SPECIAL
Definition: Title.php:16
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
+ 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 1295 of file Title.php.

References getText().

1296  {
1297  global $wgNamespacesWithSubpages;
1298 
1299  if (isset($wgNamespacesWithSubpages[ $this->mNamespace ])) {
1300  return (strpos($this->getText(), '/') !== false && $wgNamespacesWithSubpages[ $this->mNamespace ] == true);
1301  } else {
1302  return false;
1303  }
1304  }
getText()
Simple accessors.
Definition: Title.php:572
+ 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 538 of file Title.php.

References $interwikiCache, and getInterwikiLink().

539  {
540  if ($this->mInterwiki == '') {
541  return false;
542  }
543  # Make sure key is loaded into cache
544  $this->getInterwikiLink($this->mInterwiki);
545  $k = wfMemcKey('interwiki', $this->mInterwiki);
546  return (bool) (Title::$interwikiCache[$k]->iw_trans);
547  }
getInterwikiLink($key)
Returns the URL associated with an interwiki prefix.
Definition: Title.php:415
static $interwikiCache
Definition: Title.php:42
+ 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 1318 of file Title.php.

References getSkinFromCssJsSubpage(), and isCssJsSubpage().

1319  {
1320  if ($this->isCssJsSubpage()) {
1321  $skinNames = Skin::getSkinNames();
1322  return array_key_exists($this->getSkinFromCssJsSubpage(), $skinNames);
1323  } else {
1324  return false;
1325  }
1326  }
isCssJsSubpage()
Is this a .css or .js subpage of a user page?
Definition: Title.php:1310
getSkinFromCssJsSubpage()
Trim down a .css or .js subpage title to get the corresponding skin name.
Definition: Title.php:1330
+ 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 2117 of file Title.php.

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

Referenced by moveTo().

2118  {
2119  if (!$this or !$nt) {
2120  return 'badtitletext';
2121  }
2122  if ($this->equals($nt)) {
2123  return 'selfmove';
2124  }
2125  if (!$this->isMovable() || !$nt->isMovable()) {
2126  return 'immobile_namespace';
2127  }
2128 
2129  $oldid = $this->getArticleID();
2130  $newid = $nt->getArticleID();
2131 
2132  if (strlen($nt->getDBkey()) < 1) {
2133  return 'articleexists';
2134  }
2135  if (('' == $this->getDBkey()) ||
2136  (!$oldid) ||
2137  ('' == $nt->getDBkey())) {
2138  return 'badarticleerror';
2139  }
2140 
2141  if ($auth && (
2142  !$this->userCan('edit') || !$nt->userCan('edit') ||
2143  !$this->userCan('move') || !$nt->userCan('move')
2144  )) {
2145  return 'protectedpage';
2146  }
2147 
2148  # The move is allowed only if (1) the target doesn't exist, or
2149  # (2) the target is a redirect to the source, and has no history
2150  # (so we can undo bad moves right after they're done).
2151 
2152  if (0 != $newid) { # Target exists; check for validity
2153  if (!$this->isValidMoveTarget($nt)) {
2154  return 'articleexists';
2155  }
2156  }
2157  return true;
2158  }
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:1630
isValidMoveTarget($nt)
Checks if $this can be moved to a given Title.
Definition: Title.php:2401
exists()
Check if page exists.
Definition: Title.php:2601
$auth
Definition: fileserver.php:48
getDBkey()
Get the main part with underscores.
Definition: Title.php:588
userCan($action, $doExpensiveQueries=true)
Can $wgUser perform $action on this page?
Definition: Title.php:1100
equals($title)
Compare with another title.
Definition: Title.php:2589
+ 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 2401 of file Title.php.

References $id, $m, $row, $text, getPrefixedDBkey(), and newFromText().

Referenced by isValidMoveOperation().

2402  {
2403  $fname = 'Title::isValidMoveTarget';
2404  $dbw = wfGetDB(DB_MASTER);
2405 
2406  # Is it a redirect?
2407  $id = $nt->getArticleID();
2408  $obj = $dbw->selectRow(
2409  array( 'page', 'revision', 'text'),
2410  array( 'page_is_redirect','old_text','old_flags' ),
2411  array( 'page_id' => $id, 'page_latest=rev_id', 'rev_text_id=old_id' ),
2412  $fname,
2413  'FOR UPDATE'
2414  );
2415 
2416  if (!$obj || 0 == $obj->page_is_redirect) {
2417  # Not a redirect
2418  wfDebug(__METHOD__ . ": not a redirect\n");
2419  return false;
2420  }
2421  $text = Revision::getRevisionText($obj);
2422 
2423  # Does the redirect point to the source?
2424  # Or is it a broken self-redirect, usually caused by namespace collisions?
2425  $m = array();
2426  if (preg_match("/\\[\\[\\s*([^\\]\\|]*)]]/", $text, $m)) {
2427  $redirTitle = Title::newFromText($m[1]);
2428  if (!is_object($redirTitle) ||
2429  ($redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() &&
2430  $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey())) {
2431  wfDebug(__METHOD__ . ": redirect points to other page\n");
2432  return false;
2433  }
2434  } else {
2435  # Fail safe
2436  wfDebug(__METHOD__ . ": failsafe\n");
2437  return false;
2438  }
2439 
2440  # Does the article have a history?
2441  $row = $dbw->selectRow(
2442  array( 'page', 'revision'),
2443  array( 'rev_id' ),
2444  array( 'page_namespace' => $nt->getNamespace(),
2445  'page_title' => $nt->getDBkey(),
2446  'page_id=rev_page AND page_latest != rev_id'
2447  ),
2448  $fname,
2449  'FOR UPDATE'
2450  );
2451 
2452  # Return true if there was no history
2453  return $row === false;
2454  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:124
$text
Definition: errorreport.php:18
$row
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:699
+ 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 355 of file Title.php.

Referenced by Parser\magicLinkCallback(), and secureAndSplit().

356  {
357  global $wgLegalTitleChars;
358 
359  $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
360 
361  return $wgLegalTitleChars;
362  }
+ Here is the caller graph for this function:

◆ loadRestrictions()

Title::loadRestrictions (   $oldFashionedRestrictions = null)

Definition at line 1549 of file Title.php.

References $res, and loadRestrictionsFromRow().

Referenced by areRestrictionsCascading(), and getRestrictions().

1550  {
1551  if (!$this->mRestrictionsLoaded) {
1552  $dbr = wfGetDB(DB_SLAVE);
1553 
1554  $res = $dbr->select(
1555  'page_restrictions',
1556  '*',
1557  array( 'pr_page' => $this->getArticleId() ),
1558  __METHOD__
1559  );
1560 
1561  $this->loadRestrictionsFromRow($res, $oldFashionedRestrictions);
1562  }
1563  }
loadRestrictionsFromRow($res, $oldFashionedRestrictions=null)
Loads a string into mRestrictions array.
Definition: Title.php:1487
foreach($_POST as $key=> $value) $res
+ 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 1487 of file Title.php.

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

Referenced by loadRestrictions().

1488  {
1489  $dbr = wfGetDb(DB_SLAVE);
1490 
1491  $this->mRestrictions['edit'] = array();
1492  $this->mRestrictions['move'] = array();
1493 
1494  # Backwards-compatibility: also load the restrictions from the page record (old format).
1495 
1496  if ($oldFashionedRestrictions == null) {
1497  $oldFashionedRestrictions = $dbr->selectField('page', 'page_restrictions', array( 'page_id' => $this->getArticleId() ), __METHOD__);
1498  }
1499 
1500  if ($oldFashionedRestrictions != '') {
1501  foreach (explode(':', trim($oldFashionedRestrictions)) as $restrict) {
1502  $temp = explode('=', trim($restrict));
1503  if (count($temp) == 1) {
1504  // old old format should be treated as edit/move restriction
1505  $this->mRestrictions["edit"] = explode(',', trim($temp[0]));
1506  $this->mRestrictions["move"] = explode(',', trim($temp[0]));
1507  } else {
1508  $this->mRestrictions[$temp[0]] = explode(',', trim($temp[1]));
1509  }
1510  }
1511 
1512  $this->mOldRestrictions = true;
1513  $this->mCascadeRestriction = false;
1514  $this->mRestrictionsExpiry = Block::decodeExpiry('');
1515  }
1516 
1517  if ($dbr->numRows($res)) {
1518  # Current system - load second to make them override.
1519  $now = wfTimestampNow();
1520  $purgeExpired = false;
1521 
1522  while ($row = $dbr->fetchObject($res)) {
1523  # Cycle through all the restrictions.
1524 
1525  // This code should be refactored, now that it's being used more generally,
1526  // But I don't really see any harm in leaving it in Block for now -werdna
1527  $expiry = Block::decodeExpiry($row->pr_expiry);
1528 
1529  // Only apply the restrictions if they haven't expired!
1530  if (!$expiry || $expiry > $now) {
1531  $this->mRestrictionsExpiry = $expiry;
1532  $this->mRestrictions[$row->pr_type] = explode(',', trim($row->pr_level));
1533 
1534  $this->mCascadeRestriction |= $row->pr_cascade;
1535  } else {
1536  // Trigger a lazy purge of expired restrictions
1537  $purgeExpired = true;
1538  }
1539  }
1540 
1541  if ($purgeExpired) {
1543  }
1544  }
1545 
1546  $this->mRestrictionsLoaded = true;
1547  }
static purgeExpiredRestrictions()
Purge expired restrictions from the page_restrictions table.
Definition: Title.php:1568
foreach($_POST as $key=> $value) $res
$row
+ 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 400 of file Title.php.

References $n, and $title.

Referenced by Parser\fetchScaryTemplateMaybeFromCache(), makeTitleSafe(), and nameOf().

401  {
402  global $wgContLang;
403 
404  $n = $wgContLang->getNsText($ns);
405  return $n == '' ? $title : "$n:$title";
406  }
$n
Definition: RandomTest.php:85
+ 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 253 of file Title.php.

References $t, and $title.

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

254  {
255  $t = new Title();
256  $t->mInterwiki = '';
257  $t->mFragment = '';
258  $t->mNamespace = intval($ns);
259  $t->mDbkeyform = str_replace(' ', '_', $title);
260  $t->mArticleID = ($ns >= 0) ? -1 : 0;
261  $t->mUrlform = wfUrlencode($t->mDbkeyform);
262  $t->mTextform = str_replace('_', ' ', $title);
263  return $t;
264  }
Title class.
Definition: Title.php:36
+ 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 275 of file Title.php.

References $t, $title, and makeName().

276  {
277  $t = new Title();
278  $t->mDbkeyform = Title::makeName($ns, $title);
279  if ($t->secureAndSplit()) {
280  return $t;
281  } else {
282  return null;
283  }
284  }
Title class.
Definition: Title.php:36
static makeName($ns, $title)
Definition: Title.php:400
+ 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 2103 of file Title.php.

References moveTo().

2104  {
2105  return $this->moveTo($nt, false);
2106  }
moveTo(&$nt, $auth=true, $reason='')
Move a title to a new location.
Definition: Title.php:2167
+ 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 2241 of file Title.php.

Referenced by moveTo().

2242  {
2243  global $wgUseSquid;
2244  $fname = 'Title::moveOverExistingRedirect';
2245  $comment = wfMsgForContent('1movedto2_redir', $this->getPrefixedText(), $nt->getPrefixedText());
2246 
2247  if ($reason) {
2248  $comment .= ": $reason";
2249  }
2250 
2251  $now = wfTimestampNow();
2252  $newid = $nt->getArticleID();
2253  $oldid = $this->getArticleID();
2254  $dbw = wfGetDB(DB_MASTER);
2255  $linkCache = &LinkCache::singleton();
2256 
2257  # Delete the old redirect. We don't save it to history since
2258  # by definition if we've got here it's rather uninteresting.
2259  # We have to remove it so that the next step doesn't trigger
2260  # a conflict on the unique namespace+title index...
2261  $dbw->delete('page', array( 'page_id' => $newid ), $fname);
2262 
2263  # Save a null revision in the page's history notifying of the move
2264  $nullRevision = Revision::newNullRevision($dbw, $oldid, $comment, true);
2265  $nullRevId = $nullRevision->insertOn($dbw);
2266 
2267  # Change the name of the target page:
2268  $dbw->update(
2269  'page',
2270  /* SET */
2271  array(
2272  'page_touched' => $dbw->timestamp($now),
2273  'page_namespace' => $nt->getNamespace(),
2274  'page_title' => $nt->getDBkey(),
2275  'page_latest' => $nullRevId,
2276  ),
2277  /* WHERE */
2278  array( 'page_id' => $oldid ),
2279  $fname
2280  );
2281  $linkCache->clearLink($nt->getPrefixedDBkey());
2282 
2283  # Recreate the redirect, this time in the other direction.
2284  $mwRedir = MagicWord::get('redirect');
2285  $redirectText = $mwRedir->getSynonym(0) . ' [[' . $nt->getPrefixedText() . "]]\n";
2286  $redirectArticle = new Article($this);
2287  $newid = $redirectArticle->insertOn($dbw);
2288  $redirectRevision = new Revision(array(
2289  'page' => $newid,
2290  'comment' => $comment,
2291  'text' => $redirectText ));
2292  $redirectRevision->insertOn($dbw);
2293  $redirectArticle->updateRevisionOn($dbw, $redirectRevision, 0);
2294  $linkCache->clearLink($this->getPrefixedDBkey());
2295 
2296  # Log the move
2297  $log = new LogPage('move');
2298  $log->addEntry('move_redir', $this, $reason, array( 1 => $nt->getPrefixedText() ));
2299 
2300  # Now, we record the link from the redirect to the new title.
2301  # It should have no other outgoing links...
2302  $dbw->delete('pagelinks', array( 'pl_from' => $newid ), $fname);
2303  $dbw->insert(
2304  'pagelinks',
2305  array(
2306  'pl_from' => $newid,
2307  'pl_namespace' => $nt->getNamespace(),
2308  'pl_title' => $nt->getDbKey() ),
2309  $fname
2310  );
2311 
2312  # Purge squid
2313  if ($wgUseSquid) {
2314  $urls = array_merge($nt->getSquidURLs(), $this->getSquidURLs());
2315  $u = new SquidUpdate($urls);
2316  $u->doUpdate();
2317  }
2318  }
getSquidURLs()
Get a list of URLs to purge from the Squid cache when this page changes.
Definition: Title.php:2066
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:1630
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:711
$log
Definition: sabredav.php:21
$urls
Definition: croninfo.php:28
get(string $class_name)
$comment
Definition: buildRTE.php:83
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:699
+ 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 2167 of file Title.php.

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

Referenced by moveNoAuth().

2168  {
2169  $err = $this->isValidMoveOperation($nt, $auth);
2170  if (is_string($err)) {
2171  return $err;
2172  }
2173 
2174  $pageid = $this->getArticleID();
2175  if ($nt->exists()) {
2176  $this->moveOverExistingRedirect($nt, $reason);
2177  $pageCountChange = 0;
2178  } else { # Target didn't exist, do normal move.
2179  $this->moveToNewTitle($nt, $reason);
2180  $pageCountChange = 1;
2181  }
2182  $redirid = $this->getArticleID();
2183 
2184  # Fixing category links (those without piped 'alternate' names) to be sorted under the new title
2185  $dbw = wfGetDB(DB_MASTER);
2186  $categorylinks = $dbw->tableName('categorylinks');
2187  $sql = "UPDATE $categorylinks SET cl_sortkey=" . $dbw->addQuotes($nt->getPrefixedText()) .
2188  " WHERE cl_from=" . $dbw->addQuotes($pageid) .
2189  " AND cl_sortkey=" . $dbw->addQuotes($this->getPrefixedText());
2190  $dbw->query($sql, 'SpecialMovepage::doSubmit');
2191 
2192  # Update watchlists
2193 
2194  $oldnamespace = $this->getNamespace() & ~1;
2195  $newnamespace = $nt->getNamespace() & ~1;
2196  $oldtitle = $this->getDBkey();
2197  $newtitle = $nt->getDBkey();
2198 
2199  if ($oldnamespace != $newnamespace || $oldtitle != $newtitle) {
2200  WatchedItem::duplicateEntries($this, $nt);
2201  }
2202 
2203  # Update search engine
2204  $u = new SearchUpdate($pageid, $nt->getPrefixedDBkey());
2205  $u->doUpdate();
2206  $u = new SearchUpdate($redirid, $this->getPrefixedDBkey(), '');
2207  $u->doUpdate();
2208 
2209  # Update site_stats
2210  if ($this->isContentPage() && !$nt->isContentPage()) {
2211  # No longer a content page
2212  # Not viewed, edited, removing
2213  $u = new SiteStatsUpdate(0, 1, -1, $pageCountChange);
2214  } elseif (!$this->isContentPage() && $nt->isContentPage()) {
2215  # Now a content page
2216  # Not viewed, edited, adding
2217  $u = new SiteStatsUpdate(0, 1, +1, $pageCountChange);
2218  } elseif ($pageCountChange) {
2219  # Redirect added
2220  $u = new SiteStatsUpdate(0, 0, 0, 1);
2221  } else {
2222  # Nothing special
2223  $u = false;
2224  }
2225  if ($u) {
2226  $u->doUpdate();
2227  }
2228 
2229  global $wgUser;
2230  wfRunHooks('TitleMoveComplete', array( &$this, &$nt, &$wgUser, $pageid, $redirid ));
2231  return true;
2232  }
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:1630
$auth
Definition: fileserver.php:48
moveOverExistingRedirect(&$nt, $reason='')
Move page to a title which is at present a redirect to the source page.
Definition: Title.php:2241
isValidMoveOperation(&$nt, $auth=true)
Check whether a given move operation would be valid.
Definition: Title.php:2117
+ 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 2324 of file Title.php.

References $comment, $log, ILIAS\GlobalScreen\get(), getArticleID(), getPrefixedDBkey(), getPrefixedText(), and purgeSquid().

2325  {
2326  global $wgUseSquid;
2327  $fname = 'MovePageForm::moveToNewTitle';
2328  $comment = wfMsgForContent('1movedto2', $this->getPrefixedText(), $nt->getPrefixedText());
2329  if ($reason) {
2330  $comment .= ": $reason";
2331  }
2332 
2333  $newid = $nt->getArticleID();
2334  $oldid = $this->getArticleID();
2335  $dbw = wfGetDB(DB_MASTER);
2336  $now = $dbw->timestamp();
2337  $linkCache = &LinkCache::singleton();
2338 
2339  # Save a null revision in the page's history notifying of the move
2340  $nullRevision = Revision::newNullRevision($dbw, $oldid, $comment, true);
2341  $nullRevId = $nullRevision->insertOn($dbw);
2342 
2343  # Rename cur entry
2344  $dbw->update(
2345  'page',
2346  /* SET */
2347  array(
2348  'page_touched' => $now,
2349  'page_namespace' => $nt->getNamespace(),
2350  'page_title' => $nt->getDBkey(),
2351  'page_latest' => $nullRevId,
2352  ),
2353  /* WHERE */
2354  array( 'page_id' => $oldid ),
2355  $fname
2356  );
2357 
2358  $linkCache->clearLink($nt->getPrefixedDBkey());
2359 
2360  # Insert redirect
2361  $mwRedir = MagicWord::get('redirect');
2362  $redirectText = $mwRedir->getSynonym(0) . ' [[' . $nt->getPrefixedText() . "]]\n";
2363  $redirectArticle = new Article($this);
2364  $newid = $redirectArticle->insertOn($dbw);
2365  $redirectRevision = new Revision(array(
2366  'page' => $newid,
2367  'comment' => $comment,
2368  'text' => $redirectText ));
2369  $redirectRevision->insertOn($dbw);
2370  $redirectArticle->updateRevisionOn($dbw, $redirectRevision, 0);
2371  $linkCache->clearLink($this->getPrefixedDBkey());
2372 
2373  # Log the move
2374  $log = new LogPage('move');
2375  $log->addEntry('move', $this, $reason, array( 1 => $nt->getPrefixedText()));
2376 
2377  # Purge caches as per article creation
2378  Article::onArticleCreate($nt);
2379 
2380  # Record the just-created redirect's linking to the page
2381  $dbw->insert(
2382  'pagelinks',
2383  array(
2384  'pl_from' => $newid,
2385  'pl_namespace' => $nt->getNamespace(),
2386  'pl_title' => $nt->getDBkey() ),
2387  $fname
2388  );
2389 
2390  # Purge old title from squid
2391  # The new title, and links to the new title, are purged in Article::onArticleCreate()
2392  $this->purgeSquid();
2393  }
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:1630
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:711
$log
Definition: sabredav.php:21
get(string $class_name)
$comment
Definition: buildRTE.php:83
purgeSquid()
Definition: Title.php:2089
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:699
+ 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 public

Definition at line 337 of file Title.php.

References $id, $n, $s, and makeName().

338  {
339  $fname = 'Title::nameOf';
340  $dbr = wfGetDB(DB_SLAVE);
341 
342  $s = $dbr->selectRow('page', array( 'page_namespace','page_title' ), array( 'page_id' => $id ), $fname);
343  if ($s === false) {
344  return null;
345  }
346 
347  $n = Title::makeName($s->page_namespace, $s->page_title);
348  return $n;
349  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$s
Definition: pwgen.php:45
static makeName($ns, $title)
Definition: Title.php:400
$n
Definition: RandomTest.php:85
+ 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 102 of file Title.php.

References $key, and $t.

Referenced by Parser\fetchScaryTemplateMaybeFromCache().

103  {
104  $t = new Title();
105  $t->mDbkeyform = $key;
106  if ($t->secureAndSplit()) {
107  return $t;
108  } else {
109  return null;
110  }
111  }
Title class.
Definition: Title.php:36
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ 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 204 of file Title.php.

References $id, $row, $title, and makeTitle().

205  {
206  $fname = 'Title::newFromID';
207  $dbr = wfGetDB(DB_SLAVE);
208  $row = $dbr->selectRow(
209  'page',
210  array( 'page_namespace', 'page_title' ),
211  array( 'page_id' => $id ),
212  $fname
213  );
214  if ($row !== false) {
215  $title = Title::makeTitle($row->page_namespace, $row->page_title);
216  } else {
217  $title = null;
218  }
219  return $title;
220  }
if(!array_key_exists('StateId', $_REQUEST)) $id
$row
static & makeTitle($ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:253
+ 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 225 of file Title.php.

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

226  {
227  $dbr = wfGetDB(DB_SLAVE);
228  $res = $dbr->select(
229  'page',
230  array( 'page_namespace', 'page_title' ),
231  'page_id IN (' . $dbr->makeList($ids) . ')',
232  __METHOD__
233  );
234 
235  $titles = array();
236  while ($row = $dbr->fetchObject($res)) {
237  $titles[] = Title::makeTitle($row->page_namespace, $row->page_title);
238  }
239  return $titles;
240  }
foreach($_POST as $key=> $value) $res
$row
static & makeTitle($ns, $title)
Create a new Title from a namespace index and a DB key.
Definition: Title.php:253
+ 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 301 of file Title.php.

References $m, $text, ILIAS\GlobalScreen\get(), and newFromText().

Referenced by Parser\createAssocArgs().

302  {
303  $mwRedir = MagicWord::get('redirect');
304  $rt = null;
305  if ($mwRedir->matchStart($text)) {
306  $m = array();
307  if (preg_match('/\[{2}(.*?)(?:\||\]{2})/', $text, $m)) {
308  # categories are escaped using : for example one can enter:
309  # #REDIRECT [[:Category:Music]]. Need to remove it.
310  if (substr($m[1], 0, 1) == ':') {
311  # We don't want to keep the ':'
312  $m[1] = substr($m[1], 1);
313  }
314 
315  $rt = Title::newFromText($m[1]);
316  # Disallow redirects to Special:Userlogout
317  if (!is_null($rt) && $rt->isSpecial('Userlogout')) {
318  $rt = null;
319  }
320  }
321  }
322  return $rt;
323  }
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:124
get(string $class_name)
$text
Definition: errorreport.php:18
+ Here is the call graph for this function:
+ Here is the caller 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 124 of file Title.php.

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

Referenced by Parser\createAssocArgs(), Parser\fetchScaryTemplateMaybeFromCache(), getParentCategoryTree(), isValidMoveTarget(), Parser\magicLinkCallback(), newFromRedirect(), newMainPage(), and ilWikiUtil\processInternalLinks().

125  {
126  if (is_object($text)) {
127  throw new MWException('Title::newFromText given an object');
128  }
129 
138  if ($defaultNamespace == NS_MAIN && isset(Title::$titleCache[$text])) {
139  return Title::$titleCache[$text];
140  }
141 
145  $filteredText = Sanitizer::decodeCharReferences($text);
146 
147  $t = new Title();
148  $t->mDbkeyform = str_replace(' ', '_', $filteredText);
149  $t->mDefaultNamespace = $defaultNamespace;
150 
151  static $cachedcount = 0 ;
152  if ($t->secureAndSplit()) {
153  if ($defaultNamespace == NS_MAIN) {
154  if ($cachedcount >= MW_TITLECACHE_MAX) {
155  # Avoid memory leaks on mass operations...
156  Title::$titleCache = array();
157  $cachedcount = 0;
158  }
159  $cachedcount++;
161  }
162  return $t;
163  } else {
164  $ret = null;
165  return $ret;
166  }
167  }
const NS_MAIN(!class_exists('UtfNormal'))
See title.txt.
Definition: Title.php:15
Title class.
Definition: Title.php:36
static decodeCharReferences($text)
Decode any character references, numeric or named entities, in the text and return a UTF-8 string...
Definition: Sanitizer.php:1018
const MW_TITLECACHE_MAX
Definition: Title.php:25
static $titleCache
Static cache variables.
Definition: Title.php:41
$text
Definition: errorreport.php:18
$ret
Definition: parser.php:6
+ 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 175 of file Title.php.

References $t, and $url.

176  {
177  global $wgLegalTitleChars;
178  $t = new Title();
179 
180  # For compatibility with old buggy URLs. "+" is usually not valid in titles,
181  # but some URLs used it as a space replacement and they still come
182  # from some external search tools.
183  if (strpos($wgLegalTitleChars, '+') === false) {
184  $url = str_replace('+', ' ', $url);
185  }
186 
187  $t->mDbkeyform = str_replace(' ', '_', $url);
188  if ($t->secureAndSplit()) {
189  return $t;
190  } else {
191  return null;
192  }
193  }
Title class.
Definition: Title.php:36
$url

◆ newMainPage()

static Title::newMainPage ( )
static

Create a new Title for the Main Page.

Returns
Title the new object

Definition at line 290 of file Title.php.

References newFromText().

291  {
292  return Title::newFromText(wfMsgForContent('mainpage'));
293  }
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:124
+ 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 2525 of file Title.php.

2526  {
2527  return array( 'page_namespace' => $this->mNamespace, 'page_title' => $this->mDbkeyform );
2528  }

◆ prefix()

Title::prefix (   $name)

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 1725 of file Title.php.

References $name, and getNsText().

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

1726  {
1727  $p = '';
1728  if ('' != $this->mInterwiki) {
1729  $p = $this->mInterwiki . ':';
1730  }
1731  if (0 != $this->mNamespace) {
1732  $p .= $this->getNsText() . ':';
1733  }
1734  return $p . $name;
1735  }
getNsText()
Get the namespace text.
Definition: Title.php:604
+ 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 1568 of file Title.php.

Referenced by getCascadeProtectionSources(), and loadRestrictionsFromRow().

1569  {
1570  $dbw = wfGetDB(DB_MASTER);
1571  $dbw->delete(
1572  'page_restrictions',
1573  array( 'pr_expiry < ' . $dbw->addQuotes($dbw->timestamp()) ),
1574  __METHOD__
1575  );
1576  }
+ Here is the caller graph for this function:

◆ purgeSquid()

Title::purgeSquid ( )

Definition at line 2089 of file Title.php.

References $urls, and getSquidURLs().

Referenced by moveToNewTitle().

2090  {
2091  global $wgUseSquid;
2092  if ($wgUseSquid) {
2093  $urls = $this->getSquidURLs();
2094  $u = new SquidUpdate($urls);
2095  $u->doUpdate();
2096  }
2097  }
getSquidURLs()
Get a list of URLs to purge from the Squid cache when this page changes.
Definition: Title.php:2066
$urls
Definition: croninfo.php:28
+ 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 1089 of file Title.php.

References $action, and userCan().

1090  {
1091  return $this->userCan($action, false);
1092  }
$action
userCan($action, $doExpensiveQueries=true)
Can $wgUser perform $action on this page?
Definition: Title.php:1100
+ 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 1670 of file Title.php.

References getPrefixedDBkey().

1671  {
1672  $linkCache = &LinkCache::singleton();
1673  $linkCache->clearBadLink($this->getPrefixedDBkey());
1674 
1675  if (0 == $newid) {
1676  $this->mArticleID = -1;
1677  } else {
1678  $this->mArticleID = $newid;
1679  }
1680  $this->mRestrictionsLoaded = false;
1681  $this->mRestrictions = array();
1682  }
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:699
+ 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 1747 of file Title.php.

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

1748  {
1749  global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks;
1750 
1751  # Initialisation
1752  static $rxTc = false;
1753  if (!$rxTc) {
1754  # % is needed as well
1755  $rxTc = '/[^' . Title::legalChars() . ']|%[0-9A-Fa-f]{2}/S';
1756  }
1757 
1758  $this->mInterwiki = $this->mFragment = '';
1759  $this->mNamespace = $this->mDefaultNamespace; # Usually NS_MAIN
1760 
1761  $dbkey = $this->mDbkeyform;
1762 
1763  # Strip Unicode bidi override characters.
1764  # Sometimes they slip into cut-n-pasted page titles, where the
1765  # override chars get included in list displays.
1766  $dbkey = str_replace("\xE2\x80\x8E", '', $dbkey); // 200E LEFT-TO-RIGHT MARK
1767  $dbkey = str_replace("\xE2\x80\x8F", '', $dbkey); // 200F RIGHT-TO-LEFT MARK
1768 
1769  # Clean up whitespace
1770  #
1771  $dbkey = preg_replace('/[ _]+/', '_', $dbkey);
1772  $dbkey = trim($dbkey, '_');
1773 
1774  if ('' == $dbkey) {
1775  return false;
1776  }
1777 
1778  if (false !== strpos($dbkey, UTF8_REPLACEMENT)) {
1779  # Contained illegal UTF-8 sequences or forbidden Unicode chars.
1780  return false;
1781  }
1782 
1783  $this->mDbkeyform = $dbkey;
1784 
1785  # Initial colon indicates main namespace rather than specified default
1786  # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
1787  if (':' == $dbkey[0]) {
1788  $this->mNamespace = NS_MAIN;
1789  $dbkey = substr($dbkey, 1); # remove the colon but continue processing
1790  $dbkey = trim($dbkey, '_'); # remove any subsequent whitespace
1791  }
1792 
1793  # Namespace or interwiki prefix
1794  $firstPass = true;
1795  do {
1796  $m = array();
1797  if (preg_match("/^(.+?)_*:_*(.*)$/S", $dbkey, $m)) {
1798  $p = $m[1];
1799  if ($ns = $wgContLang->getNsIndex($p)) {
1800  # Ordinary namespace
1801  $dbkey = $m[2];
1802  $this->mNamespace = $ns;
1803  } elseif ($this->getInterwikiLink($p)) {
1804  if (!$firstPass) {
1805  # Can't make a local interwiki link to an interwiki link.
1806  # That's just crazy!
1807  return false;
1808  }
1809 
1810  # Interwiki link
1811  $dbkey = $m[2];
1812  $this->mInterwiki = $wgContLang->lc($p);
1813 
1814  # Redundant interwiki prefix to the local wiki
1815  if (0 == strcasecmp($this->mInterwiki, $wgLocalInterwiki)) {
1816  if ($dbkey == '') {
1817  # Can't have an empty self-link
1818  return false;
1819  }
1820  $this->mInterwiki = '';
1821  $firstPass = false;
1822  # Do another namespace split...
1823  continue;
1824  }
1825 
1826  # If there's an initial colon after the interwiki, that also
1827  # resets the default namespace
1828  if ($dbkey !== '' && $dbkey[0] == ':') {
1829  $this->mNamespace = NS_MAIN;
1830  $dbkey = substr($dbkey, 1);
1831  }
1832  }
1833  # If there's no recognized interwiki or namespace,
1834  # then let the colon expression be part of the title.
1835  }
1836  break;
1837  } while (true);
1838 
1839  # We already know that some pages won't be in the database!
1840  #
1841  if ('' != $this->mInterwiki || NS_SPECIAL == $this->mNamespace) {
1842  $this->mArticleID = 0;
1843  }
1844  $fragment = strstr($dbkey, '#');
1845  if (false !== $fragment) {
1846  $this->setFragment($fragment);
1847  $dbkey = substr($dbkey, 0, strlen($dbkey) - strlen($fragment));
1848  # remove whitespace again: prevents "Foo_bar_#"
1849  # becoming "Foo_bar_"
1850  $dbkey = preg_replace('/_*$/', '', $dbkey);
1851  }
1852 
1853  # Reject illegal characters.
1854  #
1855  if (preg_match($rxTc, $dbkey)) {
1856  return false;
1857  }
1858 
1864  if (strpos($dbkey, '.') !== false &&
1865  ($dbkey === '.' || $dbkey === '..' ||
1866  strpos($dbkey, './') === 0 ||
1867  strpos($dbkey, '../') === 0 ||
1868  strpos($dbkey, '/./') !== false ||
1869  strpos($dbkey, '/../') !== false)) {
1870  return false;
1871  }
1872 
1876  if (strpos($dbkey, '~~~') !== false) {
1877  return false;
1878  }
1879 
1887  if (($this->mNamespace != NS_SPECIAL && strlen($dbkey) > 255) ||
1888  strlen($dbkey) > 512) {
1889  return false;
1890  }
1891 
1900  if ($wgCapitalLinks && $this->mInterwiki == '') {
1901  $dbkey = $wgContLang->ucfirst($dbkey);
1902  }
1903 
1909  if ($dbkey == '' &&
1910  $this->mInterwiki == '' &&
1911  $this->mNamespace != NS_MAIN) {
1912  return false;
1913  }
1914 
1915  // Any remaining initial :s are illegal.
1916  if ($dbkey !== '' && ':' == $dbkey[0]) {
1917  return false;
1918  }
1919 
1920  # Fill fields
1921  $this->mDbkeyform = $dbkey;
1922  $this->mUrlform = ilWikiUtil::wfUrlencode($dbkey);
1923 
1924  $this->mTextform = str_replace('_', ' ', $dbkey);
1925 
1926  return true;
1927  }
setFragment($fragment)
Set the fragment for this title This is kind of bad, since except for this rarely-used function...
Definition: Title.php:1938
const NS_MAIN(!class_exists('UtfNormal'))
See title.txt.
Definition: Title.php:15
getInterwikiLink($key)
Returns the URL associated with an interwiki prefix.
Definition: Title.php:415
$mDefaultNamespace
Definition: Title.php:69
const NS_SPECIAL
Definition: Title.php:16
const UTF8_REPLACEMENT
Definition: UtfNormal.php:68
$mDbkeyform
Definition: Title.php:56
static legalChars()
Get a regex character class describing the legal characters in a link.
Definition: Title.php:355
static wfUrlencode($s)
From GlobalFunctions.php.
+ 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 1938 of file Title.php.

Referenced by secureAndSplit().

1939  {
1940  $this->mFragment = str_replace('_', ' ', substr($fragment, 1));
1941  }
+ 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 2623 of file Title.php.

References getNamespace().

2624  {
2625  $u = new HTMLCacheUpdate($this, 'pagelinks');
2626  $u->doUpdate();
2627 
2628  if ($this->getNamespace() == NS_CATEGORY) {
2629  $u = new HTMLCacheUpdate($this, 'categorylinks');
2630  $u->doUpdate();
2631  }
2632  }
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
+ Here is the call graph for this function:

◆ trackbackRDF()

Title::trackbackRDF ( )

Definition at line 2660 of file Title.php.

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

2661  {
2662  $url = htmlspecialchars($this->getFullURL());
2663  $title = htmlspecialchars($this->getText());
2664  $tburl = $this->trackbackURL();
2665 
2666  return "
2667 <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
2668  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
2669  xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">
2670 <rdf:Description
2671  rdf:about=\"$url\"
2672  dc:identifier=\"$url\"
2673  dc:title=\"$title\"
2674  trackback:ping=\"$tburl\" />
2675 </rdf:RDF>";
2676  }
getText()
Simple accessors.
Definition: Title.php:572
getFullURL($query='', $variant=false)
Get a real URL referring to this title, with interwiki link and fragment.
Definition: Title.php:809
trackbackURL()
Definition: Title.php:2652
$url
+ Here is the call graph for this function:

◆ trackbackURL()

Title::trackbackURL ( )

Definition at line 2652 of file Title.php.

Referenced by trackbackRDF().

2653  {
2654  global $wgTitle, $wgScriptPath, $wgServer;
2655 
2656  return "$wgServer$wgScriptPath/trackback.php?article="
2657  . htmlspecialchars(urlencode($wgTitle->getPrefixedDBkey()));
2658  }
+ 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 1100 of file Title.php.

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

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

1101  {
1102  $fname = 'Title::userCan';
1103  wfProfileIn($fname);
1104 
1105  global $wgUser, $wgNamespaceProtection;
1106 
1107  $result = null;
1108  wfRunHooks('userCan', array( &$this, &$wgUser, $action, &$result ));
1109  if ($result !== null) {
1110  wfProfileOut($fname);
1111  return $result;
1112  }
1113 
1114  if (NS_SPECIAL == $this->mNamespace) {
1115  wfProfileOut($fname);
1116  return false;
1117  }
1118 
1119  if (array_key_exists($this->mNamespace, $wgNamespaceProtection)) {
1120  $nsProt = $wgNamespaceProtection[ $this->mNamespace ];
1121  if (!is_array($nsProt)) {
1122  $nsProt = array($nsProt);
1123  }
1124  foreach ($nsProt as $right) {
1125  if ('' != $right && !$wgUser->isAllowed($right)) {
1126  wfProfileOut($fname);
1127  return false;
1128  }
1129  }
1130  }
1131 
1132  if ($this->mDbkeyform == '_') {
1133  # FIXME: Is this necessary? Shouldn't be allowed anyway...
1134  wfProfileOut($fname);
1135  return false;
1136  }
1137 
1138  # protect css/js subpages of user pages
1139  # XXX: this might be better using restrictions
1140  # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working
1141  if ($this->isCssJsSubpage()
1142  && !$wgUser->isAllowed('editinterface')
1143  && !preg_match('/^' . preg_quote($wgUser->getName(), '/') . '\//', $this->mTextform)) {
1144  wfProfileOut($fname);
1145  return false;
1146  }
1147 
1148  if ($doExpensiveQueries && !$this->isCssJsSubpage()) {
1149  # We /could/ use the protection level on the source page, but it's fairly ugly
1150  # as we have to establish a precedence hierarchy for pages included by multiple
1151  # cascade-protected pages. So just restrict it to people with 'protect' permission,
1152  # as they could remove the protection anyway.
1153  list($cascadingSources, $restrictions) = $this->getCascadeProtectionSources();
1154  # Cascading protection depends on more than this page...
1155  # Several cascading protected pages may include this page...
1156  # Check each cascading level
1157  # This is only for protection restrictions, not for all actions
1158  if ($cascadingSources > 0 && isset($restrictions[$action])) {
1159  foreach ($restrictions[$action] as $right) {
1160  $right = ($right == 'sysop') ? 'protect' : $right;
1161  if ('' != $right && !$wgUser->isAllowed($right)) {
1162  wfProfileOut($fname);
1163  return false;
1164  }
1165  }
1166  }
1167  }
1168 
1169  foreach ($this->getRestrictions($action) as $right) {
1170  // Backwards compatibility, rewrite sysop -> protect
1171  if ($right == 'sysop') {
1172  $right = 'protect';
1173  }
1174  if ('' != $right && !$wgUser->isAllowed($right)) {
1175  wfProfileOut($fname);
1176  return false;
1177  }
1178  }
1179 
1180  if ($action == 'move' &&
1181  !($this->isMovable() && $wgUser->isAllowed('move'))) {
1182  wfProfileOut($fname);
1183  return false;
1184  }
1185 
1186  if ($action == 'create') {
1187  if (($this->isTalkPage() && !$wgUser->isAllowed('createtalk')) ||
1188  (!$this->isTalkPage() && !$wgUser->isAllowed('createpage'))) {
1189  wfProfileOut($fname);
1190  return false;
1191  }
1192  }
1193 
1194  wfProfileOut($fname);
1195  return true;
1196  }
$mNamespace
Definition: Title.php:57
$result
$action
isCssJsSubpage()
Is this a .css or .js subpage of a user page?
Definition: Title.php:1310
const NS_SPECIAL
Definition: Title.php:16
getCascadeProtectionSources($get_pages=true)
Cascading protection: Get the source of any cascading restrictions on this page.
Definition: Title.php:1384
getRestrictions($action)
Accessor/initialisation for mRestrictions.
Definition: Title.php:1584
+ 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 1213 of file Title.php.

References userCan().

1214  {
1215  return $this->userCan('create', $doExpensiveQueries);
1216  }
userCan($action, $doExpensiveQueries=true)
Can $wgUser perform $action on this page?
Definition: Title.php:1100
+ 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 1203 of file Title.php.

References userCan().

1204  {
1205  return $this->userCan('edit', $doExpensiveQueries);
1206  }
userCan($action, $doExpensiveQueries=true)
Can $wgUser perform $action on this page?
Definition: Title.php:1100
+ 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 1359 of file Title.php.

1360  {
1361  global $wgUser;
1362  return ($wgUser->isAllowed('editinterface') or preg_match('/^' . preg_quote($wgUser->getName(), '/') . '\//', $this->mTextform));
1363  }

◆ userCanMove()

Title::userCanMove (   $doExpensiveQueries = true)

Can $wgUser move this page?

Returns
boolean
Deprecated:
use userCan('move')

Definition at line 1223 of file Title.php.

References userCan().

1224  {
1225  return $this->userCan('move', $doExpensiveQueries);
1226  }
userCan($action, $doExpensiveQueries=true)
Can $wgUser perform $action on this page?
Definition: Title.php:1100
+ 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 1244 of file Title.php.

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

1245  {
1246  global $wgUser;
1247 
1248  $result = null;
1249  wfRunHooks('userCan', array( &$this, &$wgUser, 'read', &$result ));
1250  if ($result !== null) {
1251  return $result;
1252  }
1253 
1254  if ($wgUser->isAllowed('read')) {
1255  return true;
1256  } else {
1257  global $wgWhitelistRead;
1258 
1263  if ($this->isSpecial('Userlogin') || $this->isSpecial('Resetpass')) {
1264  return true;
1265  }
1266 
1268  $name = $this->getPrefixedText();
1269  if ($wgWhitelistRead && in_array($name, $wgWhitelistRead)) {
1270  return true;
1271  }
1272 
1273  # Compatibility with old settings
1274  if ($wgWhitelistRead && $this->getNamespace() == NS_MAIN) {
1275  if (in_array(':' . $name, $wgWhitelistRead)) {
1276  return true;
1277  }
1278  }
1279  }
1280  return false;
1281  }
isSpecial($name)
Returns true if this title resolves to the named special page.
Definition: Title.php:2723
const NS_MAIN(!class_exists('UtfNormal'))
See title.txt.
Definition: Title.php:15
$result
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:711
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:596
+ Here is the call graph for this function:

◆ userIsWatching()

Title::userIsWatching ( )

Is $wgUser is watching this page?

Returns
boolean

Definition at line 1063 of file Title.php.

References $mWatched, and NS_SPECIAL.

1064  {
1065  global $wgUser;
1066 
1067  if (is_null($this->mWatched)) {
1068  if (NS_SPECIAL == $this->mNamespace || !$wgUser->isLoggedIn()) {
1069  $this->mWatched = false;
1070  } else {
1071  $this->mWatched = $wgUser->isWatched($this);
1072  }
1073  }
1074  return $this->mWatched;
1075  }
const NS_SPECIAL
Definition: Title.php:16
$mWatched
Definition: Title.php:71

Field Documentation

◆ $interwikiCache

Title::$interwikiCache = array()
staticprivate

Definition at line 42 of file Title.php.

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

◆ $mArticleID

Title::$mArticleID

Definition at line 60 of file Title.php.

Referenced by getArticleID().

◆ $mCascadeRestriction

Title::$mCascadeRestriction

Definition at line 63 of file Title.php.

Referenced by areRestrictionsCascading().

◆ $mCascadeRestrictionSources

Title::$mCascadeRestrictionSources

Definition at line 66 of file Title.php.

◆ $mDbkeyform

Title::$mDbkeyform

Definition at line 56 of file Title.php.

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

◆ $mDefaultNamespace

Title::$mDefaultNamespace

Definition at line 69 of file Title.php.

Referenced by getDefaultNamespace(), and secureAndSplit().

◆ $mFragment

Title::$mFragment

Definition at line 59 of file Title.php.

Referenced by getFragment(), and getFullText().

◆ $mHasCascadingRestrictions

Title::$mHasCascadingRestrictions

Definition at line 65 of file Title.php.

◆ $mInterwiki

Title::$mInterwiki

Definition at line 58 of file Title.php.

Referenced by getInterwiki().

◆ $mLatestID

Title::$mLatestID

Definition at line 61 of file Title.php.

Referenced by getLatestRevID().

◆ $mNamespace

Title::$mNamespace

Definition at line 57 of file Title.php.

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

◆ $mPrefixedText

Title::$mPrefixedText

Definition at line 68 of file Title.php.

Referenced by getPrefixedText().

◆ $mRestrictions

Title::$mRestrictions

Definition at line 62 of file Title.php.

◆ $mRestrictionsExpiry

Title::$mRestrictionsExpiry

Definition at line 64 of file Title.php.

◆ $mRestrictionsLoaded

Title::$mRestrictionsLoaded

Definition at line 67 of file Title.php.

◆ $mTextform

Title::$mTextform

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

#+

Definition at line 54 of file Title.php.

Referenced by getText().

◆ $mUrlform

Title::$mUrlform

Definition at line 55 of file Title.php.

Referenced by getPartialURL().

◆ $mWatched

Title::$mWatched

Definition at line 71 of file Title.php.

Referenced by userIsWatching().

◆ $titleCache

Title::$titleCache = array()
staticprivate

Static cache variables.

Definition at line 41 of file Title.php.

Referenced by newFromText().


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