|
|
|
@ -15,14 +15,14 @@ GNU Affero General Public License for more details.
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
package gplx.xowa.mws; import gplx.*; import gplx.xowa.*;
|
|
|
|
|
import gplx.xowa.mws.utls.*;
|
|
|
|
|
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
|
|
|
|
|
import gplx.xowa.mediawiki.includes.utls.*;
|
|
|
|
|
/**
|
|
|
|
|
* Represents a title within MediaWiki.
|
|
|
|
|
* Optionally may contain an interwiki designation or name_space.
|
|
|
|
|
* Optionally may contain an interwiki designation or namespace.
|
|
|
|
|
* @note This class can fetch various kinds of data from the database;
|
|
|
|
|
* however, it does so inefficiently.
|
|
|
|
|
* @note Consider us_ing a TitleValue Object instead. TitleValue is more lightweight
|
|
|
|
|
* @note Consider using a TitleValue Object instead. TitleValue is more lightweight
|
|
|
|
|
* and does not rely on global state or the database.
|
|
|
|
|
*/
|
|
|
|
|
public class Xomw_Title {
|
|
|
|
@ -119,14 +119,14 @@ public class Xomw_Title {
|
|
|
|
|
// /** @var boolean Boolean for initialisation on demand */
|
|
|
|
|
// public $mRestrictionsLoaded = false;
|
|
|
|
|
//
|
|
|
|
|
// /** @var String Text form including name_space/interwiki, initialised on demand */
|
|
|
|
|
// /** @var String Text form including namespace/interwiki, initialised on demand */
|
|
|
|
|
// protected $mPrefixedText = null;
|
|
|
|
|
//
|
|
|
|
|
// /** @var mixed Cached value for getTitleProtection (create protection) */
|
|
|
|
|
// public $mTitleProtection;
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * @var int Namespace index when there is no name_space. Don't change the
|
|
|
|
|
// * @var int Namespace index when there is no namespace. Don't change the
|
|
|
|
|
// * following default, NS_MAIN is hardcoded in several places. See bug 696.
|
|
|
|
|
// * Zero except in {{transclusion}} tags.
|
|
|
|
|
// */
|
|
|
|
@ -161,7 +161,7 @@ public class Xomw_Title {
|
|
|
|
|
// /**
|
|
|
|
|
// * B/C kludge: provide a TitleParser for use by Title.
|
|
|
|
|
// * Ideally, Title would have no methods that need this.
|
|
|
|
|
// * Avoid usage of this singleton by us_ing TitleValue
|
|
|
|
|
// * Avoid usage of this singleton by using TitleValue
|
|
|
|
|
// * and the associated services when possible.
|
|
|
|
|
// *
|
|
|
|
|
// * @return TitleFormatter
|
|
|
|
@ -173,7 +173,7 @@ public class Xomw_Title {
|
|
|
|
|
// /**
|
|
|
|
|
// * B/C kludge: provide an InterwikiLookup for use by Title.
|
|
|
|
|
// * Ideally, Title would have no methods that need this.
|
|
|
|
|
// * Avoid usage of this singleton by us_ing TitleValue
|
|
|
|
|
// * Avoid usage of this singleton by using TitleValue
|
|
|
|
|
// * and the associated services when possible.
|
|
|
|
|
// *
|
|
|
|
|
// * @return InterwikiLookup
|
|
|
|
@ -192,7 +192,7 @@ public class Xomw_Title {
|
|
|
|
|
// * Create a new Title from a prefixed DB key
|
|
|
|
|
// *
|
|
|
|
|
// * @param String $key The database key, which has underscores
|
|
|
|
|
// * instead of spaces, possibly including name_space and
|
|
|
|
|
// * instead of spaces, possibly including namespace and
|
|
|
|
|
// * interwiki prefixes
|
|
|
|
|
// * @return Title|null Title, or null on an error
|
|
|
|
|
// */
|
|
|
|
@ -244,10 +244,10 @@ public class Xomw_Title {
|
|
|
|
|
// * codes any HTML entities in the text.
|
|
|
|
|
// *
|
|
|
|
|
// * @param String|int|null $text The link text; spaces, prefixes, and an
|
|
|
|
|
// * initial ':' indicating the main name_space are accepted.
|
|
|
|
|
// * @param int $defaultNamespace The name_space to use if none is specified
|
|
|
|
|
// * by a prefix. If you want to force a specific name_space even if
|
|
|
|
|
// * $text might begin with a name_space prefix, use makeTitle() or
|
|
|
|
|
// * initial ':' indicating the main namespace are accepted.
|
|
|
|
|
// * @param int $defaultNamespace The namespace to use if none is specified
|
|
|
|
|
// * by a prefix. If you want to force a specific namespace even if
|
|
|
|
|
// * $text might begin with a namespace prefix, use makeTitle() or
|
|
|
|
|
// * makeTitleSafe().
|
|
|
|
|
// * @throws InvalidArgumentException
|
|
|
|
|
// * @return Title|null Title or null on an error.
|
|
|
|
@ -489,13 +489,13 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Create a new Title from a name_space index and a DB key.
|
|
|
|
|
// * 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.
|
|
|
|
|
// *
|
|
|
|
|
// * @param int $ns The name_space of the article
|
|
|
|
|
// * @param int $ns The namespace of the article
|
|
|
|
|
// * @param String $title The unprefixed database key form
|
|
|
|
|
// * @param String $fragment The link fragment (after the "#")
|
|
|
|
|
// * @param String $interwiki The interwiki prefix
|
|
|
|
@ -515,11 +515,11 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Create a new Title from a name_space index and a DB key.
|
|
|
|
|
// * 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.
|
|
|
|
|
// *
|
|
|
|
|
// * @param int $ns The name_space of the article
|
|
|
|
|
// * @param int $ns The namespace of the article
|
|
|
|
|
// * @param String $title Database key form
|
|
|
|
|
// * @param String $fragment The link fragment (after the "#")
|
|
|
|
|
// * @param String $interwiki Interwiki prefix
|
|
|
|
@ -705,9 +705,9 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Make a prefixed DB key from a DB key and a name_space index
|
|
|
|
|
// * Make a prefixed DB key from a DB key and a namespace index
|
|
|
|
|
// *
|
|
|
|
|
// * @param int $ns Numerical representation of the name_space
|
|
|
|
|
// * @param int $ns Numerical representation of the namespace
|
|
|
|
|
// * @param String $title The DB key form the title
|
|
|
|
|
// * @param String $fragment The link fragment (after the "#")
|
|
|
|
|
// * @param String $interwiki The interwiki prefix
|
|
|
|
@ -721,11 +721,11 @@ public class Xomw_Title {
|
|
|
|
|
// global $wgContLang;
|
|
|
|
|
//
|
|
|
|
|
// if ($canonicalNamespace) {
|
|
|
|
|
// $name_space = MWNamespace::getCanonicalName($ns);
|
|
|
|
|
// $namespace = MWNamespace::getCanonicalName($ns);
|
|
|
|
|
// } else {
|
|
|
|
|
// $name_space = $wgContLang.getNsText($ns);
|
|
|
|
|
// $namespace = $wgContLang.getNsText($ns);
|
|
|
|
|
// }
|
|
|
|
|
// $name = $name_space == '' ? $title : "$name_space:$title";
|
|
|
|
|
// $name = $namespace == '' ? $title : "$namespace:$title";
|
|
|
|
|
// if (strval($interwiki) != '') {
|
|
|
|
|
// $name = "$interwiki:$name";
|
|
|
|
|
// }
|
|
|
|
@ -750,12 +750,12 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Callback for usort() to do title sorts by (name_space, title)
|
|
|
|
|
// * Callback for usort() to do title sorts by (namespace, title)
|
|
|
|
|
// *
|
|
|
|
|
// * @param LinkTarget $a
|
|
|
|
|
// * @param LinkTarget $b
|
|
|
|
|
// *
|
|
|
|
|
// * @return int Result of String comparison, or name_space comparison
|
|
|
|
|
// * @return int Result of String comparison, or namespace comparison
|
|
|
|
|
// */
|
|
|
|
|
// public static function compare(LinkTarget $a, LinkTarget $b) {
|
|
|
|
|
// if ($a.getNamespace() == $b.getNamespace()) {
|
|
|
|
@ -907,7 +907,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the name_space index, i.e. one of the NS_xxxx constants.
|
|
|
|
|
// * Get the namespace index, i.e. one of the NS_xxxx constants.
|
|
|
|
|
// *
|
|
|
|
|
// * @return int Namespace index
|
|
|
|
|
// */
|
|
|
|
@ -965,7 +965,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the name_space text
|
|
|
|
|
// * Get the namespace text
|
|
|
|
|
// *
|
|
|
|
|
// * @return String|false Namespace text
|
|
|
|
|
// */
|
|
|
|
@ -974,7 +974,7 @@ public class Xomw_Title {
|
|
|
|
|
// // This probably shouldn't even happen,
|
|
|
|
|
// // but for interwiki transclusion it sometimes does.
|
|
|
|
|
// // Use the canonical namespaces if possible to try to
|
|
|
|
|
// // resolve a foreign name_space.
|
|
|
|
|
// // resolve a foreign namespace.
|
|
|
|
|
// if (MWNamespace::exists($this.mNamespace)) {
|
|
|
|
|
// return MWNamespace::getCanonicalName($this.mNamespace);
|
|
|
|
|
// }
|
|
|
|
@ -990,7 +990,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the name_space text of the subject (rather than talk) page
|
|
|
|
|
// * Get the namespace text of the subject (rather than talk) page
|
|
|
|
|
// *
|
|
|
|
|
// * @return String Namespace text
|
|
|
|
|
// */
|
|
|
|
@ -1000,7 +1000,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the name_space text of the talk page
|
|
|
|
|
// * Get the namespace text of the talk page
|
|
|
|
|
// *
|
|
|
|
|
// * @return String Namespace text
|
|
|
|
|
// */
|
|
|
|
@ -1019,7 +1019,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Is this in a name_space that allows actual pages?
|
|
|
|
|
// * Is this in a namespace that allows actual pages?
|
|
|
|
|
// *
|
|
|
|
|
// * @return boolean
|
|
|
|
|
// */
|
|
|
|
@ -1081,12 +1081,12 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Returns true if the title is inside the specified name_space.
|
|
|
|
|
// * Returns true if the title is inside the specified namespace.
|
|
|
|
|
// *
|
|
|
|
|
// * Please make use of this instead of comparing to getNamespace()
|
|
|
|
|
// * This function is much more resistant to changes we may make
|
|
|
|
|
// * to namespaces than code that makes direct comparisons.
|
|
|
|
|
// * @param int $ns The name_space
|
|
|
|
|
// * @param int $ns The namespace
|
|
|
|
|
// * @return boolean
|
|
|
|
|
// * @since 1.19
|
|
|
|
|
// */
|
|
|
|
@ -1117,11 +1117,11 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Returns true if the title has the same subject name_space as the
|
|
|
|
|
// * name_space specified.
|
|
|
|
|
// * For example this method will take NS_USER and return true if name_space
|
|
|
|
|
// * Returns true if the title has the same subject namespace as the
|
|
|
|
|
// * namespace specified.
|
|
|
|
|
// * For example this method will take NS_USER and return true if namespace
|
|
|
|
|
// * is either NS_USER or NS_USER_TALK since both of them have NS_USER
|
|
|
|
|
// * as their subject name_space.
|
|
|
|
|
// * as their subject namespace.
|
|
|
|
|
// *
|
|
|
|
|
// * This is MUCH simpler than individually testing for equivalence
|
|
|
|
|
// * against both NS_USER and NS_USER_TALK, and is also forward compatible.
|
|
|
|
@ -1134,7 +1134,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Is this Title in a name_space which contains content?
|
|
|
|
|
// * Is this Title in a namespace which contains content?
|
|
|
|
|
// * In other words, is this a content page, for the purposes of calculating
|
|
|
|
|
// * statistics, etc?
|
|
|
|
|
// *
|
|
|
|
@ -1152,7 +1152,7 @@ public class Xomw_Title {
|
|
|
|
|
// */
|
|
|
|
|
// public function isMovable() {
|
|
|
|
|
// if (!MWNamespace::isMovable($this.getNamespace()) || $this.isExternal()) {
|
|
|
|
|
// // Interwiki title or immovable name_space. Hooks don't get to override here
|
|
|
|
|
// // Interwiki title or immovable namespace. Hooks don't get to override here
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
@ -1209,7 +1209,7 @@ public class Xomw_Title {
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Could this page contain custom CSS or JavaScript for the global UI.
|
|
|
|
|
// * This is generally true for pages in the MediaWiki name_space having CONTENT_MODEL_CSS
|
|
|
|
|
// * This is generally true for pages in the MediaWiki namespace having CONTENT_MODEL_CSS
|
|
|
|
|
// * or CONTENT_MODEL_JAVASCRIPT.
|
|
|
|
|
// *
|
|
|
|
|
// * This method does *not* return true for per-user JS/CSS. Use isCssJsSubpage()
|
|
|
|
@ -1328,9 +1328,9 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the default name_space index, for when there is no name_space
|
|
|
|
|
// * Get the default namespace index, for when there is no namespace
|
|
|
|
|
// *
|
|
|
|
|
// * @return int Default name_space index
|
|
|
|
|
// * @return int Default namespace index
|
|
|
|
|
// */
|
|
|
|
|
// public function getDefaultNamespace() {
|
|
|
|
|
// return $this.mDefaultNamespace;
|
|
|
|
@ -1402,7 +1402,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prefix some arbitrary text with the name_space or interwiki prefix
|
|
|
|
|
* Prefix some arbitrary text with the namespace or interwiki prefix
|
|
|
|
|
* of this Object
|
|
|
|
|
*
|
|
|
|
|
* @param String $name The text
|
|
|
|
@ -1424,7 +1424,7 @@ public class Xomw_Title {
|
|
|
|
|
* Get the prefixed database key form
|
|
|
|
|
*
|
|
|
|
|
* @return String The prefixed title, with underscores and
|
|
|
|
|
* any interwiki and name_space prefixes
|
|
|
|
|
* any interwiki and namespace prefixes
|
|
|
|
|
*/
|
|
|
|
|
public byte[] getPrefixedDBkey() {
|
|
|
|
|
byte[] s = this.prefix(this.mDbkeyform);
|
|
|
|
@ -1471,7 +1471,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the root page name text without a name_space, i.e. the leftmost part before any slashes
|
|
|
|
|
// * Get the root page name text without a namespace, i.e. the leftmost part before any slashes
|
|
|
|
|
// *
|
|
|
|
|
// * @par Example:
|
|
|
|
|
// * @code
|
|
|
|
@ -1507,7 +1507,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get the super page name without a name_space, i.e. the part before the subpage name
|
|
|
|
|
// * Get the super page name without a namespace, i.e. the part before the subpage name
|
|
|
|
|
// *
|
|
|
|
|
// * @par Example:
|
|
|
|
|
// * @code
|
|
|
|
@ -1705,13 +1705,13 @@ public class Xomw_Title {
|
|
|
|
|
//
|
|
|
|
|
// interwiki = self::getInterwikiLookup().fetch(this.mInterwiki);
|
|
|
|
|
// if (interwiki) {
|
|
|
|
|
// name_space = this.getNsText();
|
|
|
|
|
// if (name_space != '') {
|
|
|
|
|
// namespace = this.getNsText();
|
|
|
|
|
// if (namespace != '') {
|
|
|
|
|
// # Can this actually happen? Interwikis shouldn't be parsed.
|
|
|
|
|
// # Yes! It can in interwiki transclusion. But... it probably shouldn't.
|
|
|
|
|
// name_space .= ':';
|
|
|
|
|
// namespace .= ':';
|
|
|
|
|
// }
|
|
|
|
|
// url = interwiki.getURL(name_space . this.getDBkey());
|
|
|
|
|
// url = interwiki.getURL(namespace . this.getDBkey());
|
|
|
|
|
// url = wfAppendQuery(url, query);
|
|
|
|
|
// } else {
|
|
|
|
|
// byte[] dbkey = wfUrlencode(this.getPrefixedDBkey());
|
|
|
|
@ -1906,7 +1906,7 @@ public class Xomw_Title {
|
|
|
|
|
// * @param String $rigor One of (quick,full,secure)
|
|
|
|
|
// * - quick : does cheap permission checks from replica DBs (usable for GUI creation)
|
|
|
|
|
// * - full : does cheap and expensive checks possibly from a replica DB
|
|
|
|
|
// * - secure : does cheap and expensive checks, us_ing the master as needed
|
|
|
|
|
// * - secure : does cheap and expensive checks, using the master as needed
|
|
|
|
|
// * @param array $ignoreErrors Array of Strings Set this to a list of message keys
|
|
|
|
|
// * whose corresponding errors may be ignored.
|
|
|
|
|
// * @return array Array of arrays of the arguments to wfMessage to explain permissions problems.
|
|
|
|
@ -2111,7 +2111,7 @@ public class Xomw_Title {
|
|
|
|
|
// */
|
|
|
|
|
// private function checkCSSandJSPermissions($action, $user, $errors, $rigor, $short) {
|
|
|
|
|
// # Protect css/js subpages of user pages
|
|
|
|
|
// # XXX: this might be better us_ing restrictions
|
|
|
|
|
// # XXX: this might be better using restrictions
|
|
|
|
|
// # XXX: right 'editusercssjs' is deprecated, for backward compatibility only
|
|
|
|
|
// if ($action != 'patrol' && !$user.isAllowed('editusercssjs')) {
|
|
|
|
|
// if (preg_match('/^' . preg_quote($user.getName(), '/') . '\//', $this.mTextform)) {
|
|
|
|
@ -2251,14 +2251,14 @@ public class Xomw_Title {
|
|
|
|
|
// // Check for immobile pages
|
|
|
|
|
// if (!MWNamespace::isMovable($this.mNamespace)) {
|
|
|
|
|
// // Specific message for this case
|
|
|
|
|
// $errors[] = [ 'immobile-source-name_space', $this.getNsText() ];
|
|
|
|
|
// $errors[] = [ 'immobile-source-namespace', $this.getNsText() ];
|
|
|
|
|
// } elseif (!$this.isMovable()) {
|
|
|
|
|
// // Less specific message for rarer cases
|
|
|
|
|
// $errors[] = [ 'immobile-source-page' ];
|
|
|
|
|
// }
|
|
|
|
|
// } elseif ($action == 'move-target') {
|
|
|
|
|
// if (!MWNamespace::isMovable($this.mNamespace)) {
|
|
|
|
|
// $errors[] = [ 'immobile-target-name_space', $this.getNsText() ];
|
|
|
|
|
// $errors[] = [ 'immobile-target-namespace', $this.getNsText() ];
|
|
|
|
|
// } elseif (!$this.isMovable()) {
|
|
|
|
|
// $errors[] = [ 'immobile-target-page' ];
|
|
|
|
|
// }
|
|
|
|
@ -2362,7 +2362,7 @@ public class Xomw_Title {
|
|
|
|
|
// $whitelisted = true;
|
|
|
|
|
// } elseif ($this.getNamespace() == NS_MAIN) {
|
|
|
|
|
// # Old settings might have the title prefixed with
|
|
|
|
|
// # a colon for main-name_space pages
|
|
|
|
|
// # a colon for main-namespace pages
|
|
|
|
|
// if (in_array(':' . $name, $wgWhitelistRead)) {
|
|
|
|
|
// $whitelisted = true;
|
|
|
|
|
// }
|
|
|
|
@ -2440,7 +2440,7 @@ public class Xomw_Title {
|
|
|
|
|
// * @param String $rigor One of (quick,full,secure)
|
|
|
|
|
// * - quick : does cheap permission checks from replica DBs (usable for GUI creation)
|
|
|
|
|
// * - full : does cheap and expensive checks possibly from a replica DB
|
|
|
|
|
// * - secure : does cheap and expensive checks, us_ing the master as needed
|
|
|
|
|
// * - secure : does cheap and expensive checks, using the master as needed
|
|
|
|
|
// * @param boolean $short Set this to true to stop after the first permission error.
|
|
|
|
|
// * @return array Array of arrays of the arguments to wfMessage to explain permissions problems.
|
|
|
|
|
// */
|
|
|
|
@ -3082,7 +3082,7 @@ public class Xomw_Title {
|
|
|
|
|
// * Get all subpages of this page.
|
|
|
|
|
// *
|
|
|
|
|
// * @param int $limit Maximum number of subpages to fetch; -1 for no limit
|
|
|
|
|
// * @return TitleArray|array TitleArray, or empty array if this page's name_space
|
|
|
|
|
// * @return TitleArray|array TitleArray, or empty array if this page's namespace
|
|
|
|
|
// * doesn't allow subpages
|
|
|
|
|
// */
|
|
|
|
|
// public function getSubpages($limit = -1) {
|
|
|
|
@ -3316,7 +3316,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Capitalize a text String for a title if it belongs to a name_space that capitalizes
|
|
|
|
|
// * Capitalize a text String for a title if it belongs to a namespace that capitalizes
|
|
|
|
|
// *
|
|
|
|
|
// * @param String $text Containing title to capitalize
|
|
|
|
|
// * @param int $ns Namespace index, defaults to NS_MAIN
|
|
|
|
@ -3338,7 +3338,7 @@ public class Xomw_Title {
|
|
|
|
|
// * 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
|
|
|
|
|
// * name_space prefixes, sets the other forms, and canonicalizes
|
|
|
|
|
// * namespace prefixes, sets the other forms, and canonicalizes
|
|
|
|
|
// * everything.
|
|
|
|
|
// *
|
|
|
|
|
// * @throws MalformedTitleException On invalid titles
|
|
|
|
@ -3365,7 +3365,7 @@ public class Xomw_Title {
|
|
|
|
|
// $this.setFragment('#' . $parts['fragment']);
|
|
|
|
|
// $this.mInterwiki = $parts['interwiki'];
|
|
|
|
|
// $this.mLocalInterwiki = $parts['local_interwiki'];
|
|
|
|
|
// $this.mNamespace = $parts['name_space'];
|
|
|
|
|
// $this.mNamespace = $parts['namespace'];
|
|
|
|
|
// $this.mUserCaseDBKey = $parts['user_case_dbkey'];
|
|
|
|
|
//
|
|
|
|
|
// $this.mDbkeyform = $parts['dbkey'];
|
|
|
|
@ -3425,7 +3425,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Get an array of Title objects us_ing this Title as a template
|
|
|
|
|
// * 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!
|
|
|
|
@ -3710,12 +3710,12 @@ public class Xomw_Title {
|
|
|
|
|
// // Do the source and target namespaces support subpages?
|
|
|
|
|
// if (!MWNamespace::hasSubpages($this.getNamespace())) {
|
|
|
|
|
// return [
|
|
|
|
|
// [ 'name_space-nosubpages', MWNamespace::getCanonicalName($this.getNamespace()) ],
|
|
|
|
|
// [ 'namespace-nosubpages', MWNamespace::getCanonicalName($this.getNamespace()) ],
|
|
|
|
|
// ];
|
|
|
|
|
// }
|
|
|
|
|
// if (!MWNamespace::hasSubpages($nt.getNamespace())) {
|
|
|
|
|
// return [
|
|
|
|
|
// [ 'name_space-nosubpages', MWNamespace::getCanonicalName($nt.getNamespace()) ],
|
|
|
|
|
// [ 'namespace-nosubpages', MWNamespace::getCanonicalName($nt.getNamespace()) ],
|
|
|
|
|
// ];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
@ -3843,7 +3843,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
// $content = $rev.getContent();
|
|
|
|
|
// # Does the redirect point to the source?
|
|
|
|
|
// # Or is it a broken self-redirect, usually caused by name_space collisions?
|
|
|
|
|
// # Or is it a broken self-redirect, usually caused by namespace collisions?
|
|
|
|
|
// $redirTitle = $content ? $content.getRedirectTarget() : null;
|
|
|
|
|
//
|
|
|
|
|
// if ($redirTitle) {
|
|
|
|
@ -4489,17 +4489,17 @@ public class Xomw_Title {
|
|
|
|
|
// */
|
|
|
|
|
// public function getNamespaceKey($prepend = 'nstab-') {
|
|
|
|
|
// global $wgContLang;
|
|
|
|
|
// // Gets the subject name_space if this title
|
|
|
|
|
// $name_space = MWNamespace::getSubject($this.getNamespace());
|
|
|
|
|
// // Checks if canonical name_space name exists for name_space
|
|
|
|
|
// // Gets the subject namespace if this title
|
|
|
|
|
// $namespace = MWNamespace::getSubject($this.getNamespace());
|
|
|
|
|
// // Checks if canonical namespace name exists for namespace
|
|
|
|
|
// if (MWNamespace::exists($this.getNamespace())) {
|
|
|
|
|
// // Uses canonical name_space name
|
|
|
|
|
// $namespaceKey = MWNamespace::getCanonicalName($name_space);
|
|
|
|
|
// // Uses canonical namespace name
|
|
|
|
|
// $namespaceKey = MWNamespace::getCanonicalName($namespace);
|
|
|
|
|
// } else {
|
|
|
|
|
// // Uses text of name_space
|
|
|
|
|
// // Uses text of namespace
|
|
|
|
|
// $namespaceKey = $this.getSubjectNsText();
|
|
|
|
|
// }
|
|
|
|
|
// // Makes name_space key lowercase
|
|
|
|
|
// // Makes namespace key lowercase
|
|
|
|
|
// $namespaceKey = $wgContLang.lc($namespaceKey);
|
|
|
|
|
// // Uses main
|
|
|
|
|
// if ($namespaceKey == '') {
|
|
|
|
@ -4515,7 +4515,7 @@ public class Xomw_Title {
|
|
|
|
|
// /**
|
|
|
|
|
// * Get all extant redirects to this Title
|
|
|
|
|
// *
|
|
|
|
|
// * @param int|null $ns Single name_space to consider; null to consider all namespaces
|
|
|
|
|
// * @param int|null $ns Single namespace to consider; null to consider all namespaces
|
|
|
|
|
// * @return Title[] Array of Title redirects to this title
|
|
|
|
|
// */
|
|
|
|
|
// public function getRedirectsHere($ns = null) {
|
|
|
|
@ -4602,7 +4602,7 @@ public class Xomw_Title {
|
|
|
|
|
// * prefix. This will be fed to Collation::getSortKey() to get a
|
|
|
|
|
// * binary sortkey that can be used for actual sorting.
|
|
|
|
|
// *
|
|
|
|
|
// * @param String $prefix The prefix to be used, specified us_ing
|
|
|
|
|
// * @param String $prefix The prefix to be used, specified using
|
|
|
|
|
// * {{defaultsort:}} or like [[Category:Foo|prefix]]. Empty for no
|
|
|
|
|
// * prefix.
|
|
|
|
|
// * @return String
|
|
|
|
@ -4637,7 +4637,7 @@ public class Xomw_Title {
|
|
|
|
|
// global $wgPageLanguageUseDB;
|
|
|
|
|
//
|
|
|
|
|
// // check, if the page language could be saved in the database, and if so and
|
|
|
|
|
// // the value is not requested already, lookup the page language us_ing LinkCache
|
|
|
|
|
// // the value is not requested already, lookup the page language using LinkCache
|
|
|
|
|
// if ($wgPageLanguageUseDB && $this.mDbPageLanguage === false) {
|
|
|
|
|
// $linkCache = LinkCache::singleton();
|
|
|
|
|
// $linkCache.addLinkObj($this);
|
|
|
|
@ -4730,7 +4730,7 @@ public class Xomw_Title {
|
|
|
|
|
// /**
|
|
|
|
|
// * Get a list of rendered edit notices for this page.
|
|
|
|
|
// *
|
|
|
|
|
// * Array is keyed by the original message key, and values are rendered us_ing parseAsBlock, so
|
|
|
|
|
// * Array is keyed by the original message key, and values are rendered using parseAsBlock, so
|
|
|
|
|
// * they will already be wrapped in paragraphs.
|
|
|
|
|
// *
|
|
|
|
|
// * @since 1.21
|
|
|
|
@ -4740,7 +4740,7 @@ public class Xomw_Title {
|
|
|
|
|
// public function getEditNotices($oldid = 0) {
|
|
|
|
|
// $notices = [];
|
|
|
|
|
//
|
|
|
|
|
// // Optional notice for the entire name_space
|
|
|
|
|
// // Optional notice for the entire namespace
|
|
|
|
|
// $editnotice_ns = 'editnotice-' . $this.getNamespace();
|
|
|
|
|
// $msg = wfMessage($editnotice_ns);
|
|
|
|
|
// if ($msg.exists()) {
|
|
|
|
@ -4751,7 +4751,7 @@ public class Xomw_Title {
|
|
|
|
|
// 'div',
|
|
|
|
|
// [ 'class' => [
|
|
|
|
|
// 'mw-editnotice',
|
|
|
|
|
// 'mw-editnotice-name_space',
|
|
|
|
|
// 'mw-editnotice-namespace',
|
|
|
|
|
// Sanitizer::escapeClass("mw-$editnotice_ns")
|
|
|
|
|
// ] ],
|
|
|
|
|
// $html
|
|
|
|
@ -4782,7 +4782,7 @@ public class Xomw_Title {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // Even if there are no subpages in name_space, we still don't want "/" in MediaWiki message keys
|
|
|
|
|
// // Even if there are no subpages in namespace, we still don't want "/" in MediaWiki message keys
|
|
|
|
|
// $editnoticeText = $editnotice_ns . '-' . strtr($this.getDBkey(), '/', '-');
|
|
|
|
|
// $msg = wfMessage($editnoticeText);
|
|
|
|
|
// if ($msg.exists()) {
|