title.txt

来自「php 开发的内容管理系统」· 文本 代码 · 共 73 行

TXT
73
字号
title.txtThe MediaWiki software's "Title" class represents articletitles, which are used for many purposes: as the human-readabletext title of the article, in the URL used to access the article,the wikitext link to the article, the key into the articledatabase, and so on. The class in instantiated from one ofthese forms and can be queried for the others, and for otherattributes of the title. This is intended to be animmutable "value" class, so there are no mutator functions.To get a new instance, call one of the static factorymethods WikiTitle::newFromURL(), WikiTitle::newFromDBKey(),or WikiTitle::newFromText(). Once instantiated, theother non-static accessor methods can be used, such asgetText(), getDBKey(), getNamespace(), etc.The prefix rules: a title consists of an optional Interwikiprefix (such as "m:" for meta or "de:" for German), followedby an optional namespace, followed by the remainder of thetitle. Both Interwiki prefixes and namespace prefixes havethe same rules: they contain only letters, digits, space, andunderscore, must start with a letter, are case insensitive,and spaces and underscores are interchangeable.  Prefixes endwith a ":". A prefix is only recognized if it is one of thosespecifically allowed by the software. For example, "de:name"is a link to the article "name" in the German Wikipedia, because"de" is recognized as one of the allowable interwikis. Thetitle "talk:name" is a link to the article "name" in the "talk"namespace of the current wiki, because "talk" is a recognizednamespace. Both may be present, and if so, the interwiki mustcome first, for example, "m:talk:name". If a title begins witha colon as its first character, no prefixes are scanned for,and the colon is just removed. Note that because of theserules, it is possible to have articles with colons in theirnames. "E. Coli 0157:H7" is a valid title, as is "2001: A SpaceOdyssey", because "E. Coli 0157" and "2001" are not validinterwikis or namespaces. Likewise, ":de:name" is a link tothe article "de:name"--even though "de" is a valid interwiki,the initial colon stops all prefix matching.Character mapping rules: Once prefixes have been stripped, therest of the title processed this way: spaces and underscores aretreated as equivalent and each is converted to the other in theappropriate context (underscore in URL and database keys, spacesin plain text). "Extended" characters in the 0x80..0xFF rangeare allowed in all places, and are valid characters. They areencoded in URLs.  Other characters may be ASCII letters, digits,hyphen, comma, period, apostrophe, parentheses, and colon. Noother ASCII characters are allowed, and will be deleted if found(they will probably cause a browser to misinterpret the URL).Extended characters are _not_ urlencoded when used as text ordatabase keys.Character encoding rules: TODOCanonical forms: the canonical form of a title will always bereturned by the object. In this form, the first (and only thefirst) character of the namespace and title will be uppercased;the rest of the namespace will be lowercased, while the titlewill be left as is. The text form will use spaces, the URL andDBkey forms will use underscores. Interwiki prefixes are alllowercase. The namespace will use underscores when returnedalone; it will use spaces only when attached to the text title.getArticleID() needs some explanation: for "internal" articles,it should return the "cur_id" field if the article exists, elseit returns 0. For all external articles it returns 0. All ofthe IDs for all instances of Title created during a request arecached, so they can be looked up wuickly while rendering wikitext with lots of internal links.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?