[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/docs/ -> title.txt (source)

   1  title.txt
   2  
   3  The MediaWiki software's "Title" class represents article titles, which are used
   4  for many purposes: as the human-readable text title of the article, in the URL
   5  used to access the article, the wikitext link to the article, the key into the
   6  article database, and so on. The class in instantiated from one of these forms
   7  and can be queried for the others, and for other attributes of the title. This
   8  is intended to be an immutable "value" class, so there are no mutator functions.
   9  
  10  To get a new instance, call Title::newFromText(). Once instantiated, the
  11  non-static accessor methods can be used, such as getText(), getDBkey(),
  12  getNamespace(), etc. Note that Title::newFromText() may return false if the text
  13  is illegal according to the rules below.
  14  
  15  The prefix rules: a title consists of an optional interwiki prefix (such as "m:"
  16  for meta or "de:" for German), followed by an optional namespace, followed by
  17  the remainder of the title. Both interwiki prefixes and namespace prefixes have
  18  the same rules: they contain only letters, digits, space, and underscore, must
  19  start with a letter, are case insensitive, and spaces and underscores are
  20  interchangeable. Prefixes end with a ":". A prefix is only recognized if it is
  21  one of those specifically allowed by the software. For example, "de:name" is a
  22  link to the article "name" in the German Wikipedia, because "de" is recognized
  23  as one of the allowable interwikis. The title "talk:name" is a link to the
  24  article "name" in the "talk" namespace of the current wiki, because "talk" is a
  25  recognized namespace. Both may be present, and if so, the interwiki must
  26  come first, for example, "m:talk:name". If a title begins with a colon as its
  27  first character, no prefixes are scanned for, and the colon is just removed.
  28  Note that because of these rules, it is possible to have articles with colons in
  29  their names. "E. Coli 0157:H7" is a valid title, as is "2001: A Space Odyssey",
  30  because "E. Coli 0157" and "2001" are not valid interwikis or namespaces.
  31  
  32  It is not possible to have an article whose bare name includes a namespace or
  33  interwiki prefix.
  34  
  35  An initial colon in a title listed in wiki text may however suppress special
  36  handling for interlanguage links, image links, and category links. It is also
  37  used to indicate the main namespace in template inclusions.
  38  
  39  Once prefixes have been stripped, the rest of the title processed this way:
  40  
  41  * Spaces and underscores are treated as equivalent and each  is converted to the
  42    other in the appropriate context (underscore in URL and database keys, spaces
  43    in plain text).
  44  * Multiple consecutive spaces are converted to a single space.
  45  * Leading or trailing space is removed.
  46  * If $wgCapitalLinks is enabled (the default), the first letter is  capitalised,
  47    using the capitalisation function of the content language object.
  48  * The unicode characters LRM (U+200E) and RLM (U+200F) are silently stripped.
  49  * Invalid UTF-8 sequences or instances of the replacement character (U+FFFD) are
  50    considered illegal.
  51  * A percent sign followed by two hexadecimal characters is illegal
  52  * Anything that looks like an XML/HTML character reference is illegal
  53  * Any character not matched by the $wgLegalTitleChars regex is illegal
  54  * Zero-length titles (after whitespace stripping) are illegal
  55  
  56  All titles except special pages must be less than 255 bytes when encoded with
  57  UTF-8, because that is the size of the database field. Special page titles may
  58  be up to 512 bytes.
  59  
  60  Note that Unicode Normal Form C (NFC) is enforced by MediaWiki's user interface
  61  input functions, and so titles will typically be in this form.
  62  
  63  getArticleID() needs some explanation: for "internal" articles, it should return
  64  the "page_id" field if the article exists, else it returns 0. For all external
  65  articles it returns 0. All of the IDs for all instances of Title created during
  66  a request are cached, so they can be looked up quickly while rendering wiki text
  67  with lots of internal links. See linkcache.txt.


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1