diff --git a/400_xowa/src/gplx/core/lists/hashs/Hash_adp__int.java b/400_xowa/src/gplx/core/lists/hashs/Hash_adp__int.java index d6129ff9c..d3b9a1dfc 100644 --- a/400_xowa/src/gplx/core/lists/hashs/Hash_adp__int.java +++ b/400_xowa/src/gplx/core/lists/hashs/Hash_adp__int.java @@ -18,7 +18,7 @@ along with this program. If not, see . package gplx.core.lists.hashs; import gplx.*; import gplx.core.*; import gplx.core.lists.*; import gplx.core.primitives.*; public class Hash_adp__int { - private final Hash_adp hash = Hash_adp_.New(); + private final Ordered_hash hash = Ordered_hash_.New(); private final Int_obj_ref tmp_key = Int_obj_ref.New_neg1(); public void Clear() {hash.Clear();} public int Len() {return hash.Count();} @@ -28,4 +28,5 @@ public class Hash_adp__int { public void Add(Int_obj_ref key, Object obj) {hash.Add(key, obj);} public void Add_if_dupe_use_1st(int key, Object obj) {hash.Add_if_dupe_use_1st(Int_obj_ref.New(key), obj);} public void Add_if_dupe_use_nth(Int_obj_ref key, Object obj) {hash.Add_if_dupe_use_nth(key, obj);} + public Hash_adp__int Add_as_bry(int key, String val) {hash.Add(Int_obj_ref.New(key), Bry_.new_u8(val)); return this;} } diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwLinker.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwLinker.java index 7f2cf9baf..33cd99dd9 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwLinker.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwLinker.java @@ -222,7 +222,7 @@ public class XomwLinker { // global $wgContLang; // // // First we check whether the namespace exists or not. -// if ( MWNamespace::exists( $namespace ) ) { +// if ( XomwNamespace::exists( $namespace ) ) { // if ( $namespace == NS_MAIN ) { // $name = $context->msg( 'blanknamespace' )->text(); // } else { @@ -608,8 +608,8 @@ public class XomwLinker { // ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs // So we don't need to pass it here in $query. However, the URL for the // zoom icon still needs it, so we make a unique query for it. See bug 14771 -// byte[] url = $title->getLocalURL($query); - byte[] url = Bry_.Empty; + byte[] url = title.getLocalURL(query); +// byte[] url = Bry_.Empty; // if ($page) { // $url = wfAppendQuery($url, [ 'page' => $page ]); // } @@ -1256,7 +1256,7 @@ public class XomwLinker { // function ( $match ) use ( $title, $local, $wikiId ) { // global $wgContLang; // -// $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|'; +// $medians = '(?:' . preg_quote( XomwNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|'; // $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):'; // // $comment = $match[0]; diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwMediaWikiServices.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwMediaWikiServices.java index 8bf312911..d9bbff42e 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwMediaWikiServices.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwMediaWikiServices.java @@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; +import gplx.xowa.mediawiki.languages.*; import gplx.xowa.mediawiki.includes.title.*; /** * MediaWikiServices is the service locator for the application scope of MediaWiki. @@ -564,14 +565,15 @@ public class XomwMediaWikiServices { // public function getLinkRenderer() { // return $this->getService( 'LinkRenderer' ); // } -// -// /** -// * @since 1.28 -// * @return TitleFormatter -// */ -// public function getTitleFormatter() { -// return $this->getService( 'TitleFormatter' ); -// } + + /** + * @since 1.28 + * @return TitleFormatter + */ + public XomwMediaWikiTitleCodec getTitleFormatter() { + // return $this->getService( 'TitleFormatter' ); + return titleParser; + } /** * @since 1.28 @@ -581,7 +583,7 @@ public class XomwMediaWikiServices { // return $this->getService( 'TitleParser' ); return titleParser; } - private XomwMediaWikiTitleCodec titleParser = new XomwMediaWikiTitleCodec(); + private XomwMediaWikiTitleCodec titleParser = new XomwMediaWikiTitleCodec(new XomwLanguage()); // /** // * @since 1.28 diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwNamespace.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwNamespace.java new file mode 100644 index 000000000..f1392e036 --- /dev/null +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwNamespace.java @@ -0,0 +1,502 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012 gnosygnu@gmail.com + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . +*/ +package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; +import gplx.core.lists.hashs.*; +public class XomwNamespace { +// +// /** +// * These namespaces should always be first-letter capitalized, now and +// * forevermore. Historically, they could've probably been lowercased too, +// * but some things are just too ingrained now. :) +// */ +// private static $alwaysCapitalizedNamespaces = [ NS_SPECIAL, NS_USER, NS_MEDIAWIKI ]; +// +// /** +// * Throw an exception when trying to get the subject or talk page +// * for a given namespace where it does not make sense. +// * Special namespaces are defined in includes/Defines.php and have +// * a value below 0 (ex: NS_SPECIAL = -1 , NS_MEDIA = -2) +// * +// * @param int $index +// * @param String $method +// * +// * @throws MWException +// * @return boolean +// */ +// private static function isMethodValidFor($index, $method) { +// if ($index < NS_MAIN) { +// throw new MWException("$method does not make any sense for given namespace $index"); +// } +// return true; +// } +// +// /** +// * Can pages in the given namespace be moved? +// * +// * @param int $index Namespace index +// * @return boolean +// */ +// public static function isMovable($index) { +// global $wgAllowImageMoving; +// +// $result = !($index < NS_MAIN || ($index == NS_FILE && !$wgAllowImageMoving)); +// +// /** +// * @since 1.20 +// */ +// Hooks::run('NamespaceIsMovable', [ $index, &$result ]); +// +// return $result; +// } +// +// /** +// * Is the given namespace is a subject (non-talk) namespace? +// * +// * @param int $index Namespace index +// * @return boolean +// * @since 1.19 +// */ +// public static function isSubject($index) { +// return !self::isTalk($index); +// } +// +// /** +// * Is the given namespace a talk namespace? +// * +// * @param int $index Namespace index +// * @return boolean +// */ +// public static function isTalk($index) { +// return $index > NS_MAIN +// && $index % 2; +// } +// +// /** +// * Get the talk namespace index for a given namespace +// * +// * @param int $index Namespace index +// * @return int +// */ +// public static function getTalk($index) { +// self::isMethodValidFor($index, __METHOD__); +// return self::isTalk($index) +// ? $index +// : $index + 1; +// } +// +// /** +// * Get the subject namespace index for a given namespace +// * Special namespaces (NS_MEDIA, NS_SPECIAL) are always the subject. +// * +// * @param int $index Namespace index +// * @return int +// */ +// public static function getSubject($index) { +// # Handle special namespaces +// if ($index < NS_MAIN) { +// return $index; +// } +// +// return self::isTalk($index) +// ? $index - 1 +// : $index; +// } +// +// /** +// * Get the associated namespace. +// * For talk namespaces, returns the subject (non-talk) namespace +// * For subject (non-talk) namespaces, returns the talk namespace +// * +// * @param int $index Namespace index +// * @return int|null If no associated namespace could be found +// */ +// public static function getAssociated($index) { +// self::isMethodValidFor($index, __METHOD__); +// +// if (self::isSubject($index)) { +// return self::getTalk($index); +// } elseif (self::isTalk($index)) { +// return self::getSubject($index); +// } else { +// return null; +// } +// } +// +// /** +// * Returns whether the specified namespace exists +// * +// * @param int $index +// * +// * @return boolean +// * @since 1.19 +// */ +// public static function exists($index) { +// $nslist = self::getCanonicalNamespaces(); +// return isset($nslist[$index]); +// } +// +// /** +// * Returns whether the specified namespaces are the same namespace +// * +// * @note It's possible that in the future we may start using something +// * other than just namespace indexes. Under that circumstance making use +// * of this function rather than directly doing comparison will make +// * sure that code will not potentially break. +// * +// * @param int $ns1 The first namespace index +// * @param int $ns2 The second namespace index +// * +// * @return boolean +// * @since 1.19 +// */ +// public static function equals($ns1, $ns2) { +// return $ns1 == $ns2; +// } +// +// /** +// * Returns whether the specified namespaces share the same subject. +// * eg: NS_USER and NS_USER wil return true, as well +// * NS_USER and NS_USER_TALK will return true. +// * +// * @param int $ns1 The first namespace index +// * @param int $ns2 The second namespace index +// * +// * @return boolean +// * @since 1.19 +// */ +// public static function subjectEquals($ns1, $ns2) { +// return self::getSubject($ns1) == self::getSubject($ns2); +// } + + /** + * Returns array of all defined namespaces with their canonical + * (English) names. + * + * @param boolean $rebuild Rebuild namespace list (default = false). Used for testing. + * + * @return array + * @since 1.17 + */ + private static Hash_adp__int namespaces = null; + public static Hash_adp__int getCanonicalNamespaces() {return getCanonicalNamespaces(false);} + public static Hash_adp__int getCanonicalNamespaces(boolean rebuild) { + if (namespaces == null || rebuild) { +// global $wgExtraNamespaces, $wgCanonicalNamespaceNames; + namespaces = XomwSetup.wgCanonicalNamespaceNames; + namespaces.Add_as_bry(XomwDefines.NS_MAIN, ""); + +// // Add extension namespaces +// $namespaces += ExtensionRegistry::getInstance()->getAttribute('ExtensionNamespaces'); +// if (is_array($wgExtraNamespaces)) { +// $namespaces += $wgExtraNamespaces; +// } +// Hooks::run('CanonicalNamespaces', [ &$namespaces ]); + } + return namespaces; + } + +// /** +// * Returns the canonical (English) name for a given index +// * +// * @param int $index Namespace index +// * @return String|boolean If no canonical definition. +// */ +// public static function getCanonicalName($index) { +// $nslist = self::getCanonicalNamespaces(); +// if (isset($nslist[$index])) { +// return $nslist[$index]; +// } else { +// return false; +// } +// } +// +// /** +// * Returns the index for a given canonical name, or NULL +// * The input *must* be converted to lower case first +// * +// * @param String $name Namespace name +// * @return int +// */ +// public static function getCanonicalIndex($name) { +// static $xNamespaces = false; +// if ($xNamespaces == false) { +// $xNamespaces = []; +// foreach (self::getCanonicalNamespaces() as $i => $text) { +// $xNamespaces[strtolower($text)] = $i; +// } +// } +// if (array_key_exists($name, $xNamespaces)) { +// return $xNamespaces[$name]; +// } else { +// return null; +// } +// } +// +// /** +// * Returns an array of the namespaces (by integer id) that exist on the +// * wiki. Used primarily by the api in help documentation. +// * @return array +// */ +// public static function getValidNamespaces() { +// static $mValidNamespaces = null; +// +// if (is_null($mValidNamespaces)) { +// foreach (array_keys(self::getCanonicalNamespaces()) as $ns) { +// if ($ns >= 0) { +// $mValidNamespaces[] = $ns; +// } +// } +// // T109137: sort numerically +// sort($mValidNamespaces, SORT_NUMERIC); +// } +// +// return $mValidNamespaces; +// } +// +// /** +// * Can this namespace ever have a talk namespace? +// * +// * @param int $index Namespace index +// * @return boolean +// */ +// public static function canTalk($index) { +// return $index >= NS_MAIN; +// } +// +// /** +// * Does this namespace contain content, for the purposes of calculating +// * statistics, etc? +// * +// * @param int $index Index to check +// * @return boolean +// */ +// public static function isContent($index) { +// global $wgContentNamespaces; +// return $index == NS_MAIN || in_array($index, $wgContentNamespaces); +// } +// +// /** +// * Might pages in this namespace require the use of the Signature button on +// * the edit toolbar? +// * +// * @param int $index Index to check +// * @return boolean +// */ +// public static function wantSignatures($index) { +// global $wgExtraSignatureNamespaces; +// return self::isTalk($index) || in_array($index, $wgExtraSignatureNamespaces); +// } +// +// /** +// * Can pages in a namespace be watched? +// * +// * @param int $index +// * @return boolean +// */ +// public static function isWatchable($index) { +// return $index >= NS_MAIN; +// } +// +// /** +// * Does the namespace allow subpages? +// * +// * @param int $index Index to check +// * @return boolean +// */ +// public static function hasSubpages($index) { +// global $wgNamespacesWithSubpages; +// return !empty($wgNamespacesWithSubpages[$index]); +// } +// +// /** +// * Get a list of all namespace indices which are considered to contain content +// * @return array Array of namespace indices +// */ +// public static function getContentNamespaces() { +// global $wgContentNamespaces; +// if (!is_array($wgContentNamespaces) || $wgContentNamespaces == []) { +// return [ NS_MAIN ]; +// } elseif (!in_array(NS_MAIN, $wgContentNamespaces)) { +// // always force NS_MAIN to be part of array (to match the algorithm used by isContent) +// return array_merge([ NS_MAIN ], $wgContentNamespaces); +// } else { +// return $wgContentNamespaces; +// } +// } +// +// /** +// * List all namespace indices which are considered subject, aka not a talk +// * or special namespace. See also XomwNamespace::isSubject +// * +// * @return array Array of namespace indices +// */ +// public static function getSubjectNamespaces() { +// return array_filter( +// XomwNamespace::getValidNamespaces(), +// 'XomwNamespace::isSubject' +// ); +// } +// +// /** +// * List all namespace indices which are considered talks, aka not a subject +// * or special namespace. See also XomwNamespace::isTalk +// * +// * @return array Array of namespace indices +// */ +// public static function getTalkNamespaces() { +// return array_filter( +// XomwNamespace::getValidNamespaces(), +// 'XomwNamespace::isTalk' +// ); +// } +// +// /** +// * Is the namespace first-letter capitalized? +// * +// * @param int $index Index to check +// * @return boolean +// */ +// public static function isCapitalized($index) { +// global $wgCapitalLinks, $wgCapitalLinkOverrides; +// // Turn NS_MEDIA into NS_FILE +// $index = $index == NS_MEDIA ? NS_FILE : $index; +// +// // Make sure to get the subject of our namespace +// $index = self::getSubject($index); +// +// // Some namespaces are special and should always be upper case +// if (in_array($index, self::$alwaysCapitalizedNamespaces)) { +// return true; +// } +// if (isset($wgCapitalLinkOverrides[$index])) { +// // $wgCapitalLinkOverrides is explicitly set +// return $wgCapitalLinkOverrides[$index]; +// } +// // Default to the global setting +// return $wgCapitalLinks; +// } +// +// /** +// * Does the namespace (potentially) have different aliases for different +// * genders. Not all languages make a distinction here. +// * +// * @since 1.18 +// * @param int $index Index to check +// * @return boolean +// */ +// public static function hasGenderDistinction($index) { +// return $index == NS_USER || $index == NS_USER_TALK; +// } +// +// /** +// * It is not possible to use pages from this namespace as template? +// * +// * @since 1.20 +// * @param int $index Index to check +// * @return boolean +// */ +// public static function isNonincludable($index) { +// global $wgNonincludableNamespaces; +// return $wgNonincludableNamespaces && in_array($index, $wgNonincludableNamespaces); +// } +// +// /** +// * Get the default content model for a namespace +// * This does not mean that all pages in that namespace have the model +// * +// * @since 1.21 +// * @param int $index Index to check +// * @return null|String Default model name for the given namespace, if set +// */ +// public static function getNamespaceContentModel($index) { +// global $wgNamespaceContentModels; +// return isset($wgNamespaceContentModels[$index]) +// ? $wgNamespaceContentModels[$index] +// : null; +// } +// +// /** +// * Determine which restriction levels it makes sense to use in a namespace, +// * optionally filtered by a user's rights. +// * +// * @since 1.23 +// * @param int $index Index to check +// * @param User $user User to check +// * @return array +// */ +// public static function getRestrictionLevels($index, User $user = null) { +// global $wgNamespaceProtection, $wgRestrictionLevels; +// +// if (!isset($wgNamespaceProtection[$index])) { +// // All levels are valid if there's no namespace restriction. +// // But still filter by user, if necessary +// $levels = $wgRestrictionLevels; +// if ($user) { +// $levels = array_values(array_filter($levels, function ($level) use ($user) { +// $right = $level; +// if ($right == 'sysop') { +// $right = 'editprotected'; // BC +// } +// if ($right == 'autoconfirmed') { +// $right = 'editsemiprotected'; // BC +// } +// return ($right == '' || $user->isAllowed($right)); +// })); +// } +// return $levels; +// } +// +// // First, get the list of groups that can edit this namespace. +// $namespaceGroups = []; +// $combine = 'array_merge'; +// foreach ((array)$wgNamespaceProtection[$index] as $right) { +// if ($right == 'sysop') { +// $right = 'editprotected'; // BC +// } +// if ($right == 'autoconfirmed') { +// $right = 'editsemiprotected'; // BC +// } +// if ($right != '') { +// $namespaceGroups = call_user_func($combine, $namespaceGroups, +// User::getGroupsWithPermission($right)); +// $combine = 'array_intersect'; +// } +// } +// +// // Now, keep only those restriction levels where there is at least one +// // group that can edit the namespace but would be blocked by the +// // restriction. +// $usableLevels = [ '' ]; +// foreach ($wgRestrictionLevels as $level) { +// $right = $level; +// if ($right == 'sysop') { +// $right = 'editprotected'; // BC +// } +// if ($right == 'autoconfirmed') { +// $right = 'editsemiprotected'; // BC +// } +// if ($right != '' && (!$user || $user->isAllowed($right)) && +// array_diff($namespaceGroups, User::getGroupsWithPermission($right)) +// ) { +// $usableLevels[] = $level; +// } +// } +// +// return $usableLevels; +// } +} diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwSetup.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwSetup.java new file mode 100644 index 000000000..3ce27987e --- /dev/null +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwSetup.java @@ -0,0 +1,900 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012 gnosygnu@gmail.com + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . +*/ +package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; +import gplx.core.lists.hashs.*; +/** +* Include most things that are needed to make MediaWiki work. +* +* This file is included by WebStart.php and doMaintenance.php so that both +* web and maintenance scripts share a final set up phase to include necessary +* files and create global Object variables. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* http://www.gnu.org/copyleft/gpl.html +* +* @file +*/ +public class XomwSetup { +// /** +// * This file is not a valid entry point, perform no further processing unless +// * MEDIAWIKI is defined +// */ +// if ( !defined( 'MEDIAWIKI' ) ) { +// exit( 1 ); +// } +// +// $fname = 'Setup.php'; +// $ps_setup = Profiler::instance()->scopedProfileIn( $fname ); +// +// // Load queued extensions +// ExtensionRegistry::getInstance()->loadFromQueue(); +// // Don't let any other extensions load +// ExtensionRegistry::getInstance()->finish(); +// +// // Check to see if we are at the file scope +// if ( !isset( $wgVersion ) ) { +// echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n"; +// die( 1 ); +// } +// +// mb_internal_encoding( 'UTF-8' ); +// +// // Set various default paths sensibly... +// $ps_default = Profiler::instance()->scopedProfileIn( $fname . '-defaults' ); +// +// if ( $wgScript === false ) { +// $wgScript = "$wgScriptPath/index.php"; +// } +// if ( $wgLoadScript === false ) { +// $wgLoadScript = "$wgScriptPath/load.php"; +// } +// +// if ( $wgArticlePath === false ) { +// if ( $wgUsePathInfo ) { +// $wgArticlePath = "$wgScript/$1"; +// } else { +// $wgArticlePath = "$wgScript?title=$1"; +// } +// } +// +// if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) { +// // 'view' is assumed the default action path everywhere in the code +// // but is rarely filled in $wgActionPaths +// $wgActionPaths['view'] = $wgArticlePath; +// } +// +// if ( $wgResourceBasePath === null ) { +// $wgResourceBasePath = $wgScriptPath; +// } +// if ( $wgStylePath === false ) { +// $wgStylePath = "$wgResourceBasePath/skins"; +// } +// if ( $wgLocalStylePath === false ) { +// // Avoid wgResourceBasePath here since that may point to a different domain (e.g. CDN) +// $wgLocalStylePath = "$wgScriptPath/skins"; +// } +// if ( $wgExtensionAssetsPath === false ) { +// $wgExtensionAssetsPath = "$wgResourceBasePath/extensions"; +// } +// +// if ( $wgLogo === false ) { +// $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png"; +// } +// +// if ( $wgUploadPath === false ) { +// $wgUploadPath = "$wgScriptPath/images"; +// } +// if ( $wgUploadDirectory === false ) { +// $wgUploadDirectory = "$IP/images"; +// } +// if ( $wgReadOnlyFile === false ) { +// $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR"; +// } +// if ( $wgFileCacheDirectory === false ) { +// $wgFileCacheDirectory = "{$wgUploadDirectory}/cache"; +// } +// if ( $wgDeletedDirectory === false ) { +// $wgDeletedDirectory = "{$wgUploadDirectory}/deleted"; +// } +// +// if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) { +// $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo"; +// } +// +// if ( $wgEnableParserCache === false ) { +// $wgParserCacheType = CACHE_NONE; +// } +// +// // Fix path to icon images after they were moved in 1.24 +// if ( $wgRightsIcon ) { +// $wgRightsIcon = str_replace( +// "{$wgStylePath}/common/images/", +// "{$wgResourceBasePath}/resources/assets/licenses/", +// $wgRightsIcon +// ); +// } +// +// if ( isset( $wgFooterIcons['copyright']['copyright'] ) +// && $wgFooterIcons['copyright']['copyright'] === [] +// ) { +// if ( $wgRightsIcon || $wgRightsText ) { +// $wgFooterIcons['copyright']['copyright'] = [ +// 'url' => $wgRightsUrl, +// 'src' => $wgRightsIcon, +// 'alt' => $wgRightsText, +// ]; +// } +// } +// +// if ( isset( $wgFooterIcons['poweredby'] ) +// && isset( $wgFooterIcons['poweredby']['mediawiki'] ) +// && $wgFooterIcons['poweredby']['mediawiki']['src'] === null +// ) { +// $wgFooterIcons['poweredby']['mediawiki']['src'] = +// "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png"; +// $wgFooterIcons['poweredby']['mediawiki']['srcset'] = +// "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " . +// "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x"; +// } +// +// /** +// * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a +// * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure. +// * +// * Note that this is the definition of editinterface and it can be granted to +// * all users if desired. +// */ +// $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; +// +// /** +// * The canonical names of namespaces 6 and 7 are, as of v1.14, "File" +// * and "File_talk". The old names "Image" and "Image_talk" are +// * retained as aliases for backwards compatibility. +// */ +// $wgNamespaceAliases['Image'] = NS_FILE; +// $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; +// +// /** +// * Initialise $wgLockManagers to include basic FS version +// */ +// $wgLockManagers[] = [ +// 'name' => 'fsLockManager', +// 'class' => 'FSLockManager', +// 'lockDirectory' => "{$wgUploadDirectory}/lockdir", +// ]; +// $wgLockManagers[] = [ +// 'name' => 'nullLockManager', +// 'class' => 'NullLockManager', +// ]; +// +// /** +// * Initialise $wgLocalFileRepo from backwards-compatible settings +// */ +// if ( !$wgLocalFileRepo ) { +// $wgLocalFileRepo = [ +// 'class' => 'LocalRepo', +// 'name' => 'local', +// 'directory' => $wgUploadDirectory, +// 'scriptDirUrl' => $wgScriptPath, +// 'scriptExtension' => '.php', +// 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath, +// 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0, +// 'thumbScriptUrl' => $wgThumbnailScriptPath, +// 'transformVia404' => !$wgGenerateThumbnailOnParse, +// 'deletedDir' => $wgDeletedDirectory, +// 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0 +// ]; +// } +// /** +// * Initialise shared repo from backwards-compatible settings +// */ +// if ( $wgUseSharedUploads ) { +// if ( $wgSharedUploadDBname ) { +// $wgForeignFileRepos[] = [ +// 'class' => 'ForeignDBRepo', +// 'name' => 'shared', +// 'directory' => $wgSharedUploadDirectory, +// 'url' => $wgSharedUploadPath, +// 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0, +// 'thumbScriptUrl' => $wgSharedThumbnailScriptPath, +// 'transformVia404' => !$wgGenerateThumbnailOnParse, +// 'dbType' => $wgDBtype, +// 'dbServer' => $wgDBserver, +// 'dbUser' => $wgDBuser, +// 'dbPassword' => $wgDBpassword, +// 'dbName' => $wgSharedUploadDBname, +// 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT, +// 'tablePrefix' => $wgSharedUploadDBprefix, +// 'hasSharedCache' => $wgCacheSharedUploads, +// 'descBaseUrl' => $wgRepositoryBaseUrl, +// 'fetchDescription' => $wgFetchCommonsDescriptions, +// ]; +// } else { +// $wgForeignFileRepos[] = [ +// 'class' => 'FileRepo', +// 'name' => 'shared', +// 'directory' => $wgSharedUploadDirectory, +// 'url' => $wgSharedUploadPath, +// 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0, +// 'thumbScriptUrl' => $wgSharedThumbnailScriptPath, +// 'transformVia404' => !$wgGenerateThumbnailOnParse, +// 'descBaseUrl' => $wgRepositoryBaseUrl, +// 'fetchDescription' => $wgFetchCommonsDescriptions, +// ]; +// } +// } +// if ( $wgUseInstantCommons ) { +// $wgForeignFileRepos[] = [ +// 'class' => 'ForeignAPIRepo', +// 'name' => 'wikimediacommons', +// 'apibase' => 'https://commons.wikimedia.org/w/api.php', +// 'url' => 'https://upload.wikimedia.org/wikipedia/commons', +// 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb', +// 'hashLevels' => 2, +// 'transformVia404' => true, +// 'fetchDescription' => true, +// 'descriptionCacheExpiry' => 43200, +// 'apiThumbCacheExpiry' => 0, +// ]; +// } +// /* +// * Add on default file backend config for file repos. +// * FileBackendGroup will handle initializing the backends. +// */ +// if ( !isset( $wgLocalFileRepo['backend'] ) ) { +// $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend'; +// } +// foreach ( $wgForeignFileRepos as &$repo ) { +// if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) { +// $repo['directory'] = $wgUploadDirectory; // b/c +// } +// if ( !isset( $repo['backend'] ) ) { +// $repo['backend'] = $repo['name'] . '-backend'; +// } +// } +// unset( $repo ); // no global pollution; destroy reference +// +// $rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 ); +// if ( $wgRCFilterByAge ) { +// // Trim down $wgRCLinkDays so that it only lists links which are valid +// // as determined by $wgRCMaxAge. +// // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link. +// sort( $wgRCLinkDays ); +// +// // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed +// for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) { +// // @codingStandardsIgnoreEnd +// if ( $wgRCLinkDays[$i] >= $rcMaxAgeDays ) { +// $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false ); +// break; +// } +// } +// } +// // Ensure that default user options are not invalid, since that breaks Special:Preferences +// $wgDefaultUserOptions['rcdays'] = min( +// $wgDefaultUserOptions['rcdays'], +// ceil( $rcMaxAgeDays ) +// ); +// $wgDefaultUserOptions['watchlistdays'] = min( +// $wgDefaultUserOptions['watchlistdays'], +// ceil( $rcMaxAgeDays ) +// ); +// unset( $rcMaxAgeDays ); +// +// if ( $wgSkipSkin ) { +// $wgSkipSkins[] = $wgSkipSkin; +// } +// +// $wgSkipSkins[] = 'fallback'; +// $wgSkipSkins[] = 'apioutput'; +// +// if ( $wgLocalInterwiki ) { +// array_unshift( $wgLocalInterwikis, $wgLocalInterwiki ); +// } +// +// // Set default shared prefix +// if ( $wgSharedPrefix === false ) { +// $wgSharedPrefix = $wgDBprefix; +// } +// +// // Set default shared schema +// if ( $wgSharedSchema === false ) { +// $wgSharedSchema = $wgDBmwschema; +// } +// +// if ( !$wgCookiePrefix ) { +// if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) { +// $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix; +// } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) { +// $wgCookiePrefix = $wgSharedDB; +// } elseif ( $wgDBprefix ) { +// $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix; +// } else { +// $wgCookiePrefix = $wgDBname; +// } +// } +// $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' ); +// +// if ( $wgEnableEmail ) { +// $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist; +// } else { +// // Disable all other email settings automatically if $wgEnableEmail +// // is set to false. - bug 63678 +// $wgAllowHTMLEmail = false; +// $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway +// $wgEnableUserEmail = false; +// $wgEnotifFromEditor = false; +// $wgEnotifImpersonal = false; +// $wgEnotifMaxRecips = 0; +// $wgEnotifMinorEdits = false; +// $wgEnotifRevealEditorAddress = false; +// $wgEnotifUseRealName = false; +// $wgEnotifUserTalk = false; +// $wgEnotifWatchlist = false; +// unset( $wgGroupPermissions['user']['sendemail'] ); +// $wgUseEnotif = false; +// $wgUserEmailUseReplyTo = false; +// $wgUsersNotifiedOnAllChanges = []; +// } +// +// if ( $wgMetaNamespace === false ) { +// $wgMetaNamespace = str_replace( ' ', '_', $wgSitename ); +// } +// +// // Default value is 2000 or the suhosin limit if it is between 1 and 2000 +// if ( $wgResourceLoaderMaxQueryLength === false ) { +// $suhosinMaxValueLength = (int)ini_get( 'suhosin.get.max_value_length' ); +// if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) { +// $wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength; +// } else { +// $wgResourceLoaderMaxQueryLength = 2000; +// } +// unset( $suhosinMaxValueLength ); +// } +// +// // Ensure the minimum chunk size is less than PHP upload limits or the maximum +// // upload size. +// $wgMinUploadChunkSize = min( +// $wgMinUploadChunkSize, +// UploadBase::getMaxUploadSize( 'file' ), +// UploadBase::getMaxPhpUploadSize(), +// ( wfShorthandToInteger( +// ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ), +// PHP_INT_MAX +// ) ?: PHP_INT_MAX ) - 1024 // Leave some room for other POST parameters +// ); + + /** + * Definitions of the NS_ constants are in Defines.php + * @private + */ + public static Hash_adp__int wgCanonicalNamespaceNames = new Hash_adp__int() + .Add_as_bry(XomwDefines.NS_MEDIA , "Media") + .Add_as_bry(XomwDefines.NS_SPECIAL , "Special") + .Add_as_bry(XomwDefines.NS_TALK , "Talk") + .Add_as_bry(XomwDefines.NS_USER , "User") + .Add_as_bry(XomwDefines.NS_USER_TALK , "User_talk") + .Add_as_bry(XomwDefines.NS_PROJECT , "Project") + .Add_as_bry(XomwDefines.NS_PROJECT_TALK , "Project_talk") + .Add_as_bry(XomwDefines.NS_FILE , "File") + .Add_as_bry(XomwDefines.NS_FILE_TALK , "File_talk") + .Add_as_bry(XomwDefines.NS_MEDIAWIKI , "MediaWiki") + .Add_as_bry(XomwDefines.NS_MEDIAWIKI_TALK , "MediaWiki_talk") + .Add_as_bry(XomwDefines.NS_TEMPLATE , "Template") + .Add_as_bry(XomwDefines.NS_TEMPLATE_TALK , "Template_talk") + .Add_as_bry(XomwDefines.NS_HELP , "Help") + .Add_as_bry(XomwDefines.NS_HELP_TALK , "Help_talk") + .Add_as_bry(XomwDefines.NS_CATEGORY , "Category") + .Add_as_bry(XomwDefines.NS_CATEGORY_TALK , "Category_talk") + ; + +// /// @todo UGLY UGLY +// if ( is_array( $wgExtraNamespaces ) ) { +// $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces; +// } +// +// // These are now the same, always +// // To determine the user language, use $wgLang->getCode() +// $wgContLanguageCode = $wgLanguageCode; +// +// // Easy to forget to falsify $wgDebugToolbar for static caches. +// // If file cache or CDN cache is on, just disable this (DWIMD). +// if ( $wgUseFileCache || $wgUseSquid ) { +// $wgDebugToolbar = false; +// } +// +// // We always output HTML5 since 1.22, overriding these is no longer supported +// // we set them here for extensions that depend on its value. +// $wgHtml5 = true; +// $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml'; +// $wgJsMimeType = 'text/javascript'; +// +// // Blacklisted file extensions shouldn't appear on the "allowed" list +// $wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) ); +// +// if ( $wgInvalidateCacheOnLocalSettingsChange ) { +// MediaWiki\suppressWarnings(); +// $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) ); +// MediaWiki\restoreWarnings(); +// } +// +// if ( $wgNewUserLog ) { +// // Add a new log type +// $wgLogTypes[] = 'newusers'; +// $wgLogNames['newusers'] = 'newuserlogpage'; +// $wgLogHeaders['newusers'] = 'newuserlogpagetext'; +// $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter'; +// $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter'; +// $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter'; +// $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter'; +// $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter'; +// } +// +// if ( $wgPageLanguageUseDB ) { +// $wgLogTypes[] = 'pagelang'; +// $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter'; +// } +// +// if ( $wgCookieSecure === 'detect' ) { +// $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' ); +// } +// +// if ( $wgProfileOnly ) { +// $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile; +// $wgDebugLogFile = ''; +// } +// +// // Backwards compatibility with old password limits +// if ( $wgMinimalPasswordLength !== false ) { +// $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength; +// } +// +// if ( $wgMaximalPasswordLength !== false ) { +// $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength; +// } +// +// // Backwards compatibility warning +// if ( !$wgSessionsInObjectCache ) { +// wfDeprecated( '$wgSessionsInObjectCache = false', '1.27' ); +// if ( $wgSessionHandler ) { +// wfDeprecated( '$wgSessionsHandler', '1.27' ); +// } +// $cacheType = get_class( ObjectCache::getInstance( $wgSessionCacheType ) ); +// wfDebugLog( +// 'caches', +// "Session data will be stored in \"$cacheType\" cache with " . +// "expiry $wgObjectCacheSessionExpiry seconds" +// ); +// } +// $wgSessionsInObjectCache = true; +// +// if ( $wgPHPSessionHandling !== 'enable' && +// $wgPHPSessionHandling !== 'warn' && +// $wgPHPSessionHandling !== 'disable' +// ) { +// $wgPHPSessionHandling = 'warn'; +// } +// if ( defined( 'MW_NO_SESSION' ) ) { +// // If the entry point wants no session, force 'disable' here unless they +// // specifically set it to the (undocumented) 'warn'. +// $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable'; +// } +// +// Profiler::instance()->scopedProfileOut( $ps_default ); +// +// // Disable MWDebug for command line mode, this prevents MWDebug from eating up +// // all the memory from logging SQL queries on maintenance scripts +// global $wgCommandLineMode; +// if ( $wgDebugToolbar && !$wgCommandLineMode ) { +// MWDebug::init(); +// } +// +// // Reset the global service locator, so any services that have already been created will be +// // re-created while taking into account any custom settings and extensions. +// MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' ); +// +// if ( $wgSharedDB && $wgSharedTables ) { +// // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections) +// MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases( +// array_fill_keys( +// $wgSharedTables, +// [ +// 'dbname' => $wgSharedDB, +// 'schema' => $wgSharedSchema, +// 'prefix' => $wgSharedPrefix +// ] +// ) +// ); +// } +// +// // Define a constant that indicates that the bootstrapping of the service locator +// // is complete. +// define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 ); +// +// // Install a header callback to prevent caching of responses with cookies (T127993) +// if ( !$wgCommandLineMode ) { +// header_register_callback( function () { +// $headers = []; +// foreach ( headers_list() as $header ) { +// list( $name, $value ) = explode( ':', $header, 2 ); +// $headers[strtolower( trim( $name ) )][] = trim( $value ); +// } +// +// if ( isset( $headers['set-cookie'] ) ) { +// $cacheControl = isset( $headers['cache-control'] ) +// ? implode( ', ', $headers['cache-control'] ) +// : ''; +// +// if ( !preg_match( '/(?:^|,)\s*(?:private|no-cache|no-store)\s*(?:$|,)/i', $cacheControl ) ) { +// header( 'Expires: Thu, 01 Jan 1970 00:00:00 GMT' ); +// header( 'Cache-Control: private, max-age=0, s-maxage=0' ); +// MediaWiki\Logger\LoggerFactory::getInstance( 'cache-cookies' )->warning( +// 'Cookies set on {url} with Cache-Control "{cache-control}"', [ +// 'url' => WebRequest::getGlobalRequestURL(), +// 'cookies' => $headers['set-cookie'], +// 'cache-control' => $cacheControl ?: '', +// ] +// ); +// } +// } +// } ); +// } +// +// MWExceptionHandler::installHandler(); +// +// require_once "$IP/includes/compat/normal/UtfNormalUtil.php"; +// +// $ps_validation = Profiler::instance()->scopedProfileIn( $fname . '-validation' ); +// +// // T48998: Bail out early if $wgArticlePath is non-absolute +// foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) { +// if ( $$varName && !preg_match( '/^(https?:\/\/|\/)/', $$varName ) ) { +// throw new FatalError( +// "If you use a relative URL for \$$varName, it must start " . +// 'with a slash (/).

See ' . +// "" . +// "https://www.mediawiki.org/wiki/Manual:\$$varName." +// ); +// } +// } +// +// Profiler::instance()->scopedProfileOut( $ps_validation ); +// +// $ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' ); +// +// if ( $wgCanonicalServer === false ) { +// $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP ); +// } +// +// // Set server name +// $serverParts = wfParseUrl( $wgCanonicalServer ); +// if ( $wgServerName !== false ) { +// wfWarn( '$wgServerName should be derived from $wgCanonicalServer, ' +// . 'not customized. Overwriting $wgServerName.' ); +// } +// $wgServerName = $serverParts['host']; +// unset( $serverParts ); +// +// // Set defaults for configuration variables +// // that are derived from the server name by default +// // Note: $wgEmergencyContact and $wgPasswordSender may be false or empty String (T104142) +// if ( !$wgEmergencyContact ) { +// $wgEmergencyContact = 'wikiadmin@' . $wgServerName; +// } +// if ( !$wgPasswordSender ) { +// $wgPasswordSender = 'apache@' . $wgServerName; +// } +// if ( !$wgNoReplyAddress ) { +// $wgNoReplyAddress = $wgPasswordSender; +// } +// +// if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) { +// $wgSecureLogin = false; +// wfWarn( 'Secure login was enabled on a server that only supports ' +// . 'HTTP or HTTPS. Disabling secure login.' ); +// } +// +// $wgVirtualRestConfig['global']['domain'] = $wgCanonicalServer; +// +// // Now that GlobalFunctions is loaded, set defaults that depend on it. +// if ( $wgTmpDirectory === false ) { +// $wgTmpDirectory = wfTempDir(); +// } +// +// // We don't use counters anymore. Left here for extensions still +// // expecting this to exist. Should be removed sometime 1.26 or later. +// if ( !isset( $wgDisableCounters ) ) { +// $wgDisableCounters = true; +// } +// +// if ( $wgMainWANCache === false ) { +// // Setup a WAN cache from $wgMainCacheType with no relayer. +// // Sites using multiple datacenters can configure a relayer. +// $wgMainWANCache = 'mediawiki-main-default'; +// $wgWANObjectCaches[$wgMainWANCache] = [ +// 'class' => 'WANObjectCache', +// 'cacheId' => $wgMainCacheType, +// 'channels' => [ 'purge' => 'wancache-main-default-purge' ] +// ]; +// } +// +// Profiler::instance()->scopedProfileOut( $ps_default2 ); +// +// $ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc1' ); +// +// // Raise the memory limit if it's too low +// wfMemoryLimit(); +// +// /** +// * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+ +// * that happens whenever you use a date function without the timezone being +// * explicitly set. Inspired by phpMyAdmin's treatment of the problem. +// */ +// if ( is_null( $wgLocaltimezone ) ) { +// MediaWiki\suppressWarnings(); +// $wgLocaltimezone = date_default_timezone_get(); +// MediaWiki\restoreWarnings(); +// } +// +// date_default_timezone_set( $wgLocaltimezone ); +// if ( is_null( $wgLocalTZoffset ) ) { +// $wgLocalTZoffset = date( 'Z' ) / 60; +// } +// // The part after the System| is ignored, but rest of MW fills it +// // out as the local offset. +// $wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset"; +// +// if ( !$wgDBerrorLogTZ ) { +// $wgDBerrorLogTZ = $wgLocaltimezone; +// } +// +// // initialize the request Object in $wgRequest +// $wgRequest = RequestContext::getMain()->getRequest(); // BackCompat +// // Set user IP/agent information for causal consistency purposes +// MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [ +// 'IPAddress' => $wgRequest->getIP(), +// 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ), +// 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' ) +// ] ); +// +// // Useful debug output +// if ( $wgCommandLineMode ) { +// wfDebug( "\n\nStart command line script $self\n" ); +// } else { +// $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n"; +// +// if ( $wgDebugPrintHttpHeaders ) { +// $debug .= "HTTP HEADERS:\n"; +// +// foreach ( $wgRequest->getAllHeaders() as $name => $value ) { +// $debug .= "$name: $value\n"; +// } +// } +// wfDebug( $debug ); +// } +// +// Profiler::instance()->scopedProfileOut( $ps_misc ); +// $ps_memcached = Profiler::instance()->scopedProfileIn( $fname . '-memcached' ); +// +// $wgMemc = wfGetMainCache(); +// $messageMemc = wfGetMessageCacheStorage(); +// $parserMemc = wfGetParserCacheStorage(); +// +// wfDebugLog( 'caches', +// 'cluster: ' . get_class( $wgMemc ) . +// ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) . +// ', stash: ' . $wgMainStash . +// ', message: ' . get_class( $messageMemc ) . +// ', parser: ' . get_class( $parserMemc ) . +// ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) ) +// ); +// +// Profiler::instance()->scopedProfileOut( $ps_memcached ); +// +// // Most of the config is out, some might want to run hooks here. +// Hooks::run( 'SetupAfterCache' ); +// +// $ps_globals = Profiler::instance()->scopedProfileIn( $fname . '-globals' ); +// +// /** +// * @var Language $wgContLang +// */ +// $wgContLang = Language::factory( $wgLanguageCode ); +// $wgContLang->initContLang(); +// +// // Now that variant lists may be available... +// $wgRequest->interpolateTitle(); +// +// if ( !is_object( $wgAuth ) ) { +// $wgAuth = new MediaWiki\Auth\AuthManagerAuthPlugin; +// Hooks::run( 'AuthPluginSetup', [ &$wgAuth ] ); +// } +// if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) { +// MediaWiki\Auth\AuthManager::singleton()->forcePrimaryAuthenticationProviders( [ +// new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [ +// 'authoritative' => false, +// ] ), +// new MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider( $wgAuth ), +// new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [ +// 'authoritative' => true, +// ] ), +// ], '$wgAuth is ' . get_class( $wgAuth ) ); +// } +// +// // Set up the session +// $ps_session = Profiler::instance()->scopedProfileIn( $fname . '-session' ); +// /** +// * @var MediaWiki\Session\SessionId|null $wgInitialSessionId The persistent +// * session ID (if any) loaded at startup +// */ +// $wgInitialSessionId = null; +// if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { +// // If session.auto_start is there, we can't touch session name +// if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) { +// session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' ); +// } +// +// // Create the SessionManager singleton and set up our session handler, +// // unless we're specifically asked not to. +// if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) { +// MediaWiki\Session\PHPSessionHandler::install( +// MediaWiki\Session\SessionManager::singleton() +// ); +// } +// +// // Initialize the session +// try { +// $session = MediaWiki\Session\SessionManager::getGlobalSession(); +// } catch ( OverflowException $ex ) { +// if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) { +// // The exception is because the request had multiple possible +// // sessions tied for top priority. Report this to the user. +// $list = []; +// foreach ( $ex->sessionInfos as $info ) { +// $list[] = $info->getProvider()->describe( $wgContLang ); +// } +// $list = $wgContLang->listToText( $list ); +// throw new HttpError( 400, +// Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $wgContLang )->plain() +// ); +// } +// +// // Not the one we want, rethrow +// throw $ex; +// } +// +// if ( $session->isPersistent() ) { +// $wgInitialSessionId = $session->getSessionId(); +// } +// +// $session->renew(); +// if ( MediaWiki\Session\PHPSessionHandler::isEnabled() && +// ( $session->isPersistent() || $session->shouldRememberUser() ) +// ) { +// // Start the PHP-session for backwards compatibility +// session_id( $session->getId() ); +// MediaWiki\quietCall( 'session_start' ); +// } +// +// unset( $session ); +// } else { +// // Even if we didn't set up a global Session, still install our session +// // handler unless specifically requested not to. +// if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) { +// MediaWiki\Session\PHPSessionHandler::install( +// MediaWiki\Session\SessionManager::singleton() +// ); +// } +// } +// Profiler::instance()->scopedProfileOut( $ps_session ); +// +// /** +// * @var User $wgUser +// */ +// $wgUser = RequestContext::getMain()->getUser(); // BackCompat +// +// /** +// * @var Language $wgLang +// */ +// $wgLang = new StubUserLang; +// +// /** +// * @var OutputPage $wgOut +// */ +// $wgOut = RequestContext::getMain()->getOutput(); // BackCompat +// +// /** +// * @var Parser $wgParser +// */ +// $wgParser = new StubObject( 'wgParser', function () { +// return MediaWikiServices::getInstance()->getParser(); +// } ); +// +// /** +// * @var Title $wgTitle +// */ +// $wgTitle = null; +// +// Profiler::instance()->scopedProfileOut( $ps_globals ); +// $ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' ); +// +// // Extension setup functions +// // Entries should be added to this variable during the inclusion +// // of the extension file. This allows the extension to perform +// // any necessary initialisation in the fully initialised environment +// foreach ( $wgExtensionFunctions as $func ) { +// // Allow closures in PHP 5.3+ +// if ( is_object( $func ) && $func instanceof Closure ) { +// $profName = $fname . '-extensions-closure'; +// } elseif ( is_array( $func ) ) { +// if ( is_object( $func[0] ) ) { +// $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1]; +// } else { +// $profName = $fname . '-extensions-' . implode( '::', $func ); +// } +// } else { +// $profName = $fname . '-extensions-' . strval( $func ); +// } +// +// $ps_ext_func = Profiler::instance()->scopedProfileIn( $profName ); +// call_user_func( $func ); +// Profiler::instance()->scopedProfileOut( $ps_ext_func ); +// } +// +// // If the session user has a 0 id but a valid name, that means we need to +// // autocreate it. +// if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { +// $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser(); +// if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) { +// $ps_autocreate = Profiler::instance()->scopedProfileIn( $fname . '-autocreate' ); +// $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser( +// $sessionUser, +// MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION, +// true +// ); +// Profiler::instance()->scopedProfileOut( $ps_autocreate ); +// \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [ +// 'event' => 'autocreate', +// 'status' => $res, +// ] ); +// unset( $res ); +// } +// unset( $sessionUser ); +// } +// +// if ( !$wgCommandLineMode ) { +// Pingback::schedulePingback(); +// } +// +// $wgFullyInitialised = true; +// +// Profiler::instance()->scopedProfileOut( $ps_extensions ); +// Profiler::instance()->scopedProfileOut( $ps_setup ); +} diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwTitle.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwTitle.java index 94e03c822..4c8811f29 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwTitle.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/XomwTitle.java @@ -158,19 +158,19 @@ public class XomwTitle { // /** @var boolean Would deleting this page be a big deletion? */ // private $mIsBigDeletion = null; // // @} -// -// /** -// * 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 using TitleValue -// * and the associated services when possible. -// * -// * @return TitleFormatter -// */ -// private static function getTitleFormatter() { -// return MediaWikiServices::getInstance().getTitleFormatter(); -// } -// + + /** + * 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 using TitleValue + * and the associated services when possible. + * + * @return TitleFormatter + */ + private static XomwMediaWikiTitleCodec getTitleFormatter() { + return XomwMediaWikiServices.getInstance().getTitleFormatter(); + } + // /** // * B/C kludge: provide an InterwikiLookup for use by Title. // * Ideally, Title would have no methods that need this. @@ -533,7 +533,7 @@ public class XomwTitle { // * @return Title|null The new Object, or null on an error // */ // public static function makeTitleSafe($ns, $title, $fragment = Bry_.Empty, $interwiki = Bry_.Empty) { -// if (!MWNamespace::exists($ns)) { +// if (!XomwNamespace::exists($ns)) { // return null; // } // @@ -728,7 +728,7 @@ public class XomwTitle { // global $wgContLang; // // if ($canonicalNamespace) { -// $namespace = MWNamespace::getCanonicalName($ns); +// $namespace = XomwNamespace::getCanonicalName($ns); // } else { // $namespace = $wgContLang.getNsText($ns); // } @@ -970,32 +970,32 @@ public class XomwTitle { // this.mContentModel = $model; // this.mForcedContentModel = true; // } -// -// /** -// * Get the namespace text -// * -// * @return String|false Namespace text -// */ -// public function getNsText() { -// if (this.isExternal()) { + + /** + * Get the namespace text + * + * @return String|false Namespace text + */ + public byte[] getNsText() { + if (this.isExternal()) { // // 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 namespace. -// if (MWNamespace::exists(this.mNamespace)) { -// return MWNamespace::getCanonicalName(this.mNamespace); +// if (XomwNamespace::exists(this.mNamespace)) { +// return XomwNamespace::getCanonicalName(this.mNamespace); // } -// } -// + } + // try { -// $formatter = self::getTitleFormatter(); -// return $formatter.getNamespaceName(this.mNamespace, this.mDbkeyform); + XomwMediaWikiTitleCodec formatter = getTitleFormatter(); + return formatter.getNamespaceName(this.mNamespace, this.mDbkeyform); // } catch (InvalidArgumentException $ex) { // wfDebug(__METHOD__ . ': ' . $ex.getMessage() . "\n"); // return false; // } -// } -// + } + // /** // * Get the namespace text of the subject (rather than talk) page // * @@ -1003,7 +1003,7 @@ public class XomwTitle { // */ // public function getSubjectNsText() { // global $wgContLang; -// return $wgContLang.getNsText(MWNamespace::getSubject(this.mNamespace)); +// return $wgContLang.getNsText(XomwNamespace::getSubject(this.mNamespace)); // } // // /** @@ -1013,7 +1013,7 @@ public class XomwTitle { // */ // public function getTalkNsText() { // global $wgContLang; -// return $wgContLang.getNsText(MWNamespace::getTalk(this.mNamespace)); +// return $wgContLang.getNsText(XomwNamespace::getTalk(this.mNamespace)); // } // // /** @@ -1022,7 +1022,7 @@ public class XomwTitle { // * @return boolean // */ // public function canTalk() { -// return MWNamespace::canTalk(this.mNamespace); +// return XomwNamespace::canTalk(this.mNamespace); // } // // /** @@ -1040,7 +1040,7 @@ public class XomwTitle { // * @return boolean // */ // public function isWatchable() { -// return !this.isExternal() && MWNamespace::isWatchable(this.getNamespace()); +// return !this.isExternal() && XomwNamespace::isWatchable(this.getNamespace()); // } // // /** @@ -1098,7 +1098,7 @@ public class XomwTitle { // * @since 1.19 // */ // public function inNamespace($ns) { -// return MWNamespace::equals(this.getNamespace(), $ns); +// return XomwNamespace::equals(this.getNamespace(), $ns); // } // // /** @@ -1137,7 +1137,7 @@ public class XomwTitle { // * @return boolean // */ // public function hasSubjectNamespace($ns) { -// return MWNamespace::subjectEquals(this.getNamespace(), $ns); +// return XomwNamespace::subjectEquals(this.getNamespace(), $ns); // } // // /** @@ -1148,7 +1148,7 @@ public class XomwTitle { // * @return boolean // */ // public function isContentPage() { -// return MWNamespace::isContent(this.getNamespace()); +// return XomwNamespace::isContent(this.getNamespace()); // } // // /** @@ -1158,7 +1158,7 @@ public class XomwTitle { // * @return boolean // */ // public function isMovable() { -// if (!MWNamespace::isMovable(this.getNamespace()) || this.isExternal()) { +// if (!XomwNamespace::isMovable(this.getNamespace()) || this.isExternal()) { // // Interwiki title or immovable namespace. Hooks don't get to override here // return false; // } @@ -1188,7 +1188,7 @@ public class XomwTitle { // * @return boolean // */ // public function isSubpage() { -// return MWNamespace::hasSubpages(this.mNamespace) +// return XomwNamespace::hasSubpages(this.mNamespace) // ? strpos(this.getText(), '/') != false // : false; // } @@ -1288,7 +1288,7 @@ public class XomwTitle { // * @return boolean // */ // public function isTalkPage() { -// return MWNamespace::isTalk(this.getNamespace()); +// return XomwNamespace::isTalk(this.getNamespace()); // } // // /** @@ -1297,7 +1297,7 @@ public class XomwTitle { // * @return Title The Object for the talk page // */ // public function getTalkPage() { -// return Title::makeTitle(MWNamespace::getTalk(this.getNamespace()), this.getDBkey()); +// return Title::makeTitle(XomwNamespace::getTalk(this.getNamespace()), this.getDBkey()); // } // // /** @@ -1308,7 +1308,7 @@ public class XomwTitle { // */ // public function getSubjectPage() { // // Is this the same title? -// $subjectNS = MWNamespace::getSubject(this.getNamespace()); +// $subjectNS = XomwNamespace::getSubject(this.getNamespace()); // if (this.getNamespace() == $subjectNS) { // return this; // } @@ -1422,9 +1422,9 @@ public class XomwTitle { // p = this.mInterwiki . ':'; // } -// if (0 != this.mNamespace) { -// p .= this.getNsText() . ':'; -// } + if (0 != this.mNamespace) { + p = Bry_.Add(p, this.getNsText(), Byte_ascii.Colon_bry); + } return Bry_.Add(p, name); } @@ -1491,7 +1491,7 @@ public class XomwTitle { // * @since 1.20 // */ // public function getRootText() { -// if (!MWNamespace::hasSubpages(this.mNamespace)) { +// if (!XomwNamespace::hasSubpages(this.mNamespace)) { // return this.getText(); // } // @@ -1526,7 +1526,7 @@ public class XomwTitle { // * @return String Base name // */ // public function getBaseText() { -// if (!MWNamespace::hasSubpages(this.mNamespace)) { +// if (!XomwNamespace::hasSubpages(this.mNamespace)) { // return this.getText(); // } // @@ -1566,7 +1566,7 @@ public class XomwTitle { // * @return String Subpage name // */ // public function getSubpageText() { -// if (!MWNamespace::hasSubpages(this.mNamespace)) { +// if (!XomwNamespace::hasSubpages(this.mNamespace)) { // return this.mTextform; // } // $parts = explode('/', this.mTextform); @@ -2259,7 +2259,7 @@ public class XomwTitle { // } // } elseif ($action == 'move') { // // Check for immobile pages -// if (!MWNamespace::isMovable(this.mNamespace)) { +// if (!XomwNamespace::isMovable(this.mNamespace)) { // // Specific message for this case // $errors[] = [ 'immobile-source-namespace', this.getNsText() ]; // } elseif (!this.isMovable()) { @@ -2267,7 +2267,7 @@ public class XomwTitle { // $errors[] = [ 'immobile-source-page' ]; // } // } elseif ($action == 'move-target') { -// if (!MWNamespace::isMovable(this.mNamespace)) { +// if (!XomwNamespace::isMovable(this.mNamespace)) { // $errors[] = [ 'immobile-target-namespace', this.getNsText() ]; // } elseif (!this.isMovable()) { // $errors[] = [ 'immobile-target-page' ]; @@ -3068,7 +3068,7 @@ public class XomwTitle { // * @return boolean // */ // public function hasSubpages() { -// if (!MWNamespace::hasSubpages(this.mNamespace)) { +// if (!XomwNamespace::hasSubpages(this.mNamespace)) { // // Duh // return false; // } @@ -3096,7 +3096,7 @@ public class XomwTitle { // * doesn't allow subpages // */ // public function getSubpages($limit = -1) { -// if (!MWNamespace::hasSubpages(this.getNamespace())) { +// if (!XomwNamespace::hasSubpages(this.getNamespace())) { // return []; // } // @@ -3335,7 +3335,7 @@ public class XomwTitle { // public static function capitalize($text, $ns = NS_MAIN) { // global $wgContLang; // -// if (MWNamespace::isCapitalized($ns)) { +// if (XomwNamespace::isCapitalized($ns)) { // return $wgContLang.ucfirst($text); // } else { // return $text; @@ -3718,14 +3718,14 @@ public class XomwTitle { // ]; // } // // Do the source and target namespaces support subpages? -// if (!MWNamespace::hasSubpages(this.getNamespace())) { +// if (!XomwNamespace::hasSubpages(this.getNamespace())) { // return [ -// [ 'namespace-nosubpages', MWNamespace::getCanonicalName(this.getNamespace()) ], +// [ 'namespace-nosubpages', XomwNamespace::getCanonicalName(this.getNamespace()) ], // ]; // } -// if (!MWNamespace::hasSubpages($nt.getNamespace())) { +// if (!XomwNamespace::hasSubpages($nt.getNamespace())) { // return [ -// [ 'namespace-nosubpages', MWNamespace::getCanonicalName($nt.getNamespace()) ], +// [ 'namespace-nosubpages', XomwNamespace::getCanonicalName($nt.getNamespace()) ], // ]; // } // @@ -4502,11 +4502,11 @@ public class XomwTitle { // public function getNamespaceKey($prepend = 'nstab-') { // global $wgContLang; // // Gets the subject namespace if this title -// $namespace = MWNamespace::getSubject(this.getNamespace()); +// $namespace = XomwNamespace::getSubject(this.getNamespace()); // // Checks if canonical namespace name exists for namespace -// if (MWNamespace::exists(this.getNamespace())) { +// if (XomwNamespace::exists(this.getNamespace())) { // // Uses canonical namespace name -// $namespaceKey = MWNamespace::getCanonicalName($namespace); +// $namespaceKey = XomwNamespace::getCanonicalName($namespace); // } else { // // Uses text of namespace // $namespaceKey = this.getSubjectNsText(); @@ -4603,7 +4603,7 @@ public class XomwTitle { // global $wgExemptFromUserRobotsControl; // // $bannedNamespaces = is_null($wgExemptFromUserRobotsControl) -// ? MWNamespace::getContentNamespaces() +// ? XomwNamespace::getContentNamespaces() // : $wgExemptFromUserRobotsControl; // // return !in_array(this.mNamespace, $bannedNamespaces); @@ -4771,7 +4771,7 @@ public class XomwTitle { // } // } // -// if (MWNamespace::hasSubpages(this.getNamespace())) { +// if (XomwNamespace::hasSubpages(this.getNamespace())) { // // Optional notice for page itself and any parent page // $parts = explode('/', this.getDBkey()); // $editnotice_base = $editnotice_ns; diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/filerepo/XomwFileRepo.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/filerepo/XomwFileRepo.java index a0e9ead1c..28191650e 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/filerepo/XomwFileRepo.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/filerepo/XomwFileRepo.java @@ -161,7 +161,7 @@ public class XomwFileRepo { // // Optional settings that have a default // this.initialCapital = isset(info['initialCapital']) // ? info['initialCapital'] -// : MWNamespace::isCapitalized(NS_FILE); +// : XomwNamespace::isCapitalized(NS_FILE); // this.url = isset(info['url']) // ? info['url'] // : false; // a subclass may set the URL (e.g. ForeignAPIRepo) @@ -622,7 +622,7 @@ public class XomwFileRepo { */ public byte[] getNameFromTitle(XomwTitle title) { // global wgContLang; -// if (this.initialCapital != MWNamespace::isCapitalized(NS_FILE)) { +// if (this.initialCapital != XomwNamespace::isCapitalized(NS_FILE)) { // name = title.getUserCaseDBKey(); // if (this.initialCapital) { // name = wgContLang.ucfirst(name); diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/linkers/Xomw_link_renderer.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/linkers/Xomw_link_renderer.java index f544de680..63775fc97 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/linkers/Xomw_link_renderer.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/linkers/Xomw_link_renderer.java @@ -200,7 +200,7 @@ public class Xomw_link_renderer { // Page is a redirect // return 'mw-redirect'; // } -// elseif ($this->stubThreshold > 0 && MWNamespace::isContent($target->getNamespace()) +// elseif ($this->stubThreshold > 0 && XomwNamespace::isContent($target->getNamespace()) // && $this->linkCache->getGoodLinkFieldObj($target, 'length') < $this->stubThreshold // ) { // Page is a stub diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwMediaTransformOutput.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwMediaTransformOutput.java index 8e8519825..81d0548a5 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwMediaTransformOutput.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwMediaTransformOutput.java @@ -260,7 +260,6 @@ public abstract class XomwMediaTransformOutput { // } attribs.Clear(); -// 'href' => $this->file->getTitle()->getLocalURL( $query ), attribs.Add_many(Gfh_atr_.Bry__href, this.file.getTitle().getLocalURL(query)); attribs.Add_many(Gfh_atr_.Bry__class, Bry__class__image); if (title != null) { diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwThumbnailImage.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwThumbnailImage.java index 684a5f1ef..ab8536058 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwThumbnailImage.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/media/XomwThumbnailImage.java @@ -182,7 +182,7 @@ public class XomwThumbnailImage extends XomwMediaTransformOutput { private final } } - if (!Php_utl_.empty(options.no_dimensions)) { + if (Php_utl_.empty(options.no_dimensions)) { attribs.Add_many(Gfh_atr_.Bry__width, Int_.To_bry(width)); attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height)); } diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/lnkis/Xomw_lnki_wkr__file__tst.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/lnkis/Xomw_lnki_wkr__file__tst.java index 20946b41c..c2ea9b2e9 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/lnkis/Xomw_lnki_wkr__file__tst.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/lnkis/Xomw_lnki_wkr__file__tst.java @@ -23,16 +23,17 @@ public class Xomw_lnki_wkr__file__tst { private final Xomw_lnki_wkr__fxt fxt = new Xomw_lnki_wkr__fxt(); @Before public void init() { fxt.Clear(); - fxt.Init__file("A.png", 300, 200); + fxt.Init__file("File:A.png", 300, 200); } @Test public void Plain() { - fxt.Test__to_html("[[File:A.png]]", "A.png"); + fxt.Test__to_html("[[File:A.png]]", "A.png"); } @Test public void Thumb() { - fxt.Test__to_html("[[File:A.png|thumb]]", "
A.png
"); + // TODO.XO:message=enlarge + fxt.Test__to_html("[[File:A.png|thumb]]", "
A.png
"); } @Test public void Size() { - fxt.Test__to_html("[[File:A.png|123x456px]]", "A.png"); + fxt.Test__to_html("[[File:A.png|123x456px]]", "A.png"); } @Test public void fitBoxWidth() { // COMMENT:"Height is the relative smaller dimension, so scale width accordingly" @@ -43,7 +44,7 @@ public class Xomw_lnki_wkr__file__tst { // EX_2: view is 120,80 (1.5:1) // - dimensions are either (a) 120,60 or (b) 160,80 // - use (a) 120,60 - fxt.Init__file("A.png", 200, 100); + fxt.Init__file("File:A.png", 200, 100); fxt.Test__to_html__has("[[File:A.png|120x40px]]", "/80px-A.png"); fxt.Test__to_html__has("[[File:A.png|120x80px]]", "/120px-A.png"); } diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/prepros/Xomw_frame_wkr.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/prepros/Xomw_frame_wkr.java index 98c94ffba..85f458206 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/prepros/Xomw_frame_wkr.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/parsers/prepros/Xomw_frame_wkr.java @@ -292,7 +292,7 @@ package gplx.xowa.mediawiki.includes.parsers.prepros; import gplx.*; import gplx // ); // } // } -// } elseif (MWNamespace::isNonincludable(title->getNamespace())) { +// } elseif (XomwNamespace::isNonincludable(title->getNamespace())) { // found = false; // access denied // wfDebug(__METHOD__ . ": template inclusion denied for " . // title->getPrefixedDBkey() . "\n"); diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/title/XomwMediaWikiTitleCodec.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/title/XomwMediaWikiTitleCodec.java index 664c8dbc2..411ac7790 100644 --- a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/title/XomwMediaWikiTitleCodec.java +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/includes/title/XomwMediaWikiTitleCodec.java @@ -16,13 +16,14 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package gplx.xowa.mediawiki.includes.title; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; +import gplx.xowa.mediawiki.languages.*; import gplx.xowa.mediawiki.includes.utls.*; public class XomwMediaWikiTitleCodec { -// /** -// * @var Language -// */ -// protected $language; -// + /** + * @var Language + */ + private XomwLanguage language; + // /** // * @var GenderCache // */ @@ -34,46 +35,50 @@ public class XomwMediaWikiTitleCodec { // protected $localInterwikis; // // /** -// * @param Language $language The language Object to use for localizing namespace names. +// * @param Language language The language Object to use for localizing namespace names. // * @param GenderCache $genderCache The gender cache for generating gendered namespace names // * @param String[]|String $localInterwikis // */ -// public function __construct(Language $language, GenderCache $genderCache, +// public function __construct(Language language, GenderCache $genderCache, // $localInterwikis = [] // ) { -// $this->language = $language; +// $this->language = language; // $this->genderCache = $genderCache; // $this->localInterwikis = (array)$localInterwikis; // } -// -// /** -// * @see TitleFormatter::getNamespaceName() -// * -// * @param int $namespace -// * @param String $text -// * -// * @throws InvalidArgumentException If the namespace is invalid -// * @return String -// */ -// public function getNamespaceName($namespace, $text) { + public XomwMediaWikiTitleCodec(XomwLanguage language) { + this.language = language; + } + + /** + * @see TitleFormatter::getNamespaceName() + * + * @param int $namespace + * @param String $text + * + * @throws InvalidArgumentException If the namespace is invalid + * @return String + */ + public byte[] getNamespaceName(int ns, byte[] text) { + byte[] name = null; // if ($this->language->needsGenderDistinction() && -// MWNamespace::hasGenderDistinction($namespace) +// XomwNamespace::hasGenderDistinction($namespace) // ) { // // // NOTE: we are assuming here that the title text is a user name! // $gender = $this->genderCache->getGenderOf($text, __METHOD__); // $name = $this->language->getGenderNsText($namespace, $gender); // } else { -// $name = $this->language->getNsText($namespace); + name = language.getNsText(ns); // } // // if ($name === false) { // throw new InvalidArgumentException('Unknown namespace ID: ' . $namespace); // } -// -// return $name; -// } -// + + return name; + } + // /** // * @see TitleFormatter::formatTitle() // * diff --git a/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/languages/XomwLanguage.java b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/languages/XomwLanguage.java new file mode 100644 index 000000000..cdd86d96e --- /dev/null +++ b/gplx.xowa.mediawiki/src/gplx/xowa/mediawiki/languages/XomwLanguage.java @@ -0,0 +1,4920 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012 gnosygnu@gmail.com + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +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 . +*/ +package gplx.xowa.mediawiki.languages; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; +import gplx.core.lists.hashs.*; +import gplx.xowa.mediawiki.includes.*; +public class XomwLanguage { +// /** +// * @var LanguageConverter +// */ +// public $mConverter; +// +// public $mVariants, $mCode, $mLoaded = false; +// public $mMagicExtensions = [], $mMagicHookDone = false; +// private $mHtmlCode = null, $mParentLanguage = false; +// +// public $dateFormatStrings = []; +// public $mExtendedSpecialPageAliases; +// +// /** @var array|null */ + private Hash_adp__int namespaceNames; +// protected $mNamespaceIds, $namespaceAliases; +// +// /** +// * ReplacementArray Object caches +// */ +// public $transformData = []; +// +// /** +// * @var LocalisationCache +// */ +// static public $dataCache; +// +// static public $mLangObjCache = []; +// +// static public $mWeekdayMsgs = [ +// 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', +// 'friday', 'saturday' +// ]; +// +// static public $mWeekdayAbbrevMsgs = [ +// 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' +// ]; +// +// static public $mMonthMsgs = [ +// 'january', 'february', 'march', 'april', 'may_long', 'june', +// 'july', 'august', 'september', 'october', 'november', +// 'december' +// ]; +// static public $mMonthGenMsgs = [ +// 'january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', +// 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', +// 'december-gen' +// ]; +// static public $mMonthAbbrevMsgs = [ +// 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', +// 'sep', 'oct', 'nov', 'dec' +// ]; +// +// static public $mIranianCalendarMonthMsgs = [ +// 'iranian-calendar-m1', 'iranian-calendar-m2', 'iranian-calendar-m3', +// 'iranian-calendar-m4', 'iranian-calendar-m5', 'iranian-calendar-m6', +// 'iranian-calendar-m7', 'iranian-calendar-m8', 'iranian-calendar-m9', +// 'iranian-calendar-m10', 'iranian-calendar-m11', 'iranian-calendar-m12' +// ]; +// +// static public $mHebrewCalendarMonthMsgs = [ +// 'hebrew-calendar-m1', 'hebrew-calendar-m2', 'hebrew-calendar-m3', +// 'hebrew-calendar-m4', 'hebrew-calendar-m5', 'hebrew-calendar-m6', +// 'hebrew-calendar-m7', 'hebrew-calendar-m8', 'hebrew-calendar-m9', +// 'hebrew-calendar-m10', 'hebrew-calendar-m11', 'hebrew-calendar-m12', +// 'hebrew-calendar-m6a', 'hebrew-calendar-m6b' +// ]; +// +// static public $mHebrewCalendarMonthGenMsgs = [ +// 'hebrew-calendar-m1-gen', 'hebrew-calendar-m2-gen', 'hebrew-calendar-m3-gen', +// 'hebrew-calendar-m4-gen', 'hebrew-calendar-m5-gen', 'hebrew-calendar-m6-gen', +// 'hebrew-calendar-m7-gen', 'hebrew-calendar-m8-gen', 'hebrew-calendar-m9-gen', +// 'hebrew-calendar-m10-gen', 'hebrew-calendar-m11-gen', 'hebrew-calendar-m12-gen', +// 'hebrew-calendar-m6a-gen', 'hebrew-calendar-m6b-gen' +// ]; +// +// static public $mHijriCalendarMonthMsgs = [ +// 'hijri-calendar-m1', 'hijri-calendar-m2', 'hijri-calendar-m3', +// 'hijri-calendar-m4', 'hijri-calendar-m5', 'hijri-calendar-m6', +// 'hijri-calendar-m7', 'hijri-calendar-m8', 'hijri-calendar-m9', +// 'hijri-calendar-m10', 'hijri-calendar-m11', 'hijri-calendar-m12' +// ]; +// +// /** +// * @since 1.20 +// * @var array +// */ +// static public $durationIntervals = [ +// 'millennia' => 31556952000, +// 'centuries' => 3155695200, +// 'decades' => 315569520, +// 'years' => 31556952, // 86400 * (365 + (24 * 3 + 25) / 400) +// 'weeks' => 604800, +// 'days' => 86400, +// 'hours' => 3600, +// 'minutes' => 60, +// 'seconds' => 1, +// ]; +// +// /** +// * Cache for language fallbacks. +// * @see Language::getFallbacksIncludingSiteLanguage +// * @since 1.21 +// * @var array +// */ +// static private $fallbackLanguageCache = []; +// +// /** +// * Cache for grammar rules data +// * @var MapCacheLRU|null +// */ +// static private $grammarTransformations; +// +// /** +// * Cache for language names +// * @var HashBagOStuff|null +// */ +// static private $languageNameCache; +// +// /** +// * Unicode directional formatting characters, for embedBidi() +// */ +// static private $lre = "\xE2\x80\xAA"; // U+202A LEFT-TO-RIGHT EMBEDDING +// static private $rle = "\xE2\x80\xAB"; // U+202B RIGHT-TO-LEFT EMBEDDING +// static private $pdf = "\xE2\x80\xAC"; // U+202C POP DIRECTIONAL FORMATTING +// +// /** +// * Directionality test regex for embedBidi(). Matches the first strong directionality codepoint: +// * - in group 1 if it is LTR +// * - in group 2 if it is RTL +// * Does not match if there is no strong directionality codepoint. +// * +// * The form is '/(?:([strong ltr codepoint])|([strong rtl codepoint]))/u' . +// * +// * Generated by UnicodeJS (see tools/strongDir) from the UCD; see +// * https://git.wikimedia.org/summary/unicodejs.git . +// */ +// // @codingStandardsIgnoreStart +// // @codeCoverageIgnoreStart +// static private $strongDirRegex = '/(?:([\x{41}-\x{5a}\x{61}-\x{7a}\x{aa}\x{b5}\x{ba}\x{c0}-\x{d6}\x{d8}-\x{f6}\x{f8}-\x{2b8}\x{2bb}-\x{2c1}\x{2d0}\x{2d1}\x{2e0}-\x{2e4}\x{2ee}\x{370}-\x{373}\x{376}\x{377}\x{37a}-\x{37d}\x{37f}\x{386}\x{388} +// -\x{38a}\x{38c}\x{38e}-\x{3a1}\x{3a3}-\x{3f5}\x{3f7}-\x{482}\x{48a}-\x{52f}\x{531}-\x{556}\x{559}-\x{55f}\x{561}-\x{587}\x{589}\x{903}-\x{939}\x{93b}\x{93d}-\x{940}\x{949}-\x{94c}\x{94e}-\x{950}\x{958}-\x{961}\x{964} +// -\x{980}\x{982}\x{983}\x{985}-\x{98c}\x{98f}\x{990}\x{993}-\x{9a8}\x{9aa}-\x{9b0}\x{9b2}\x{9b6}-\x{9b9}\x{9bd}-\x{9c0}\x{9c7}\x{9c8}\x{9cb}\x{9cc}\x{9ce}\x{9d7}\x{9dc}\x{9dd}\x{9df}-\x{9e1}\x{9e6}-\x{9f1}\x{9f4}-\x{9fa}\x{a03}\x{a05} +// -\x{a0a}\x{a0f}\x{a10}\x{a13}-\x{a28}\x{a2a}-\x{a30}\x{a32}\x{a33}\x{a35}\x{a36}\x{a38}\x{a39}\x{a3e}-\x{a40}\x{a59}-\x{a5c}\x{a5e}\x{a66}-\x{a6f}\x{a72}-\x{a74}\x{a83}\x{a85}-\x{a8d}\x{a8f}-\x{a91}\x{a93}-\x{aa8}\x{aaa}-\x{ab0}\x{ab2}\x{ab3}\x{ab5} +// -\x{ab9}\x{abd}-\x{ac0}\x{ac9}\x{acb}\x{acc}\x{ad0}\x{ae0}\x{ae1}\x{ae6}-\x{af0}\x{af9}\x{b02}\x{b03}\x{b05}-\x{b0c}\x{b0f}\x{b10}\x{b13}-\x{b28}\x{b2a}-\x{b30}\x{b32}\x{b33}\x{b35}-\x{b39}\x{b3d}\x{b3e}\x{b40}\x{b47}\x{b48}\x{b4b}\x{b4c}\x{b57}\x{b5c}\x{b5d}\x{b5f} +// -\x{b61}\x{b66}-\x{b77}\x{b83}\x{b85}-\x{b8a}\x{b8e}-\x{b90}\x{b92}-\x{b95}\x{b99}\x{b9a}\x{b9c}\x{b9e}\x{b9f}\x{ba3}\x{ba4}\x{ba8}-\x{baa}\x{bae}-\x{bb9}\x{bbe}\x{bbf}\x{bc1}\x{bc2}\x{bc6}-\x{bc8}\x{bca}-\x{bcc}\x{bd0}\x{bd7}\x{be6}-\x{bf2}\x{c01}-\x{c03}\x{c05}-\x{c0c}\x{c0e} +// -\x{c10}\x{c12}-\x{c28}\x{c2a}-\x{c39}\x{c3d}\x{c41}-\x{c44}\x{c58}-\x{c5a}\x{c60}\x{c61}\x{c66}-\x{c6f}\x{c7f}\x{c82}\x{c83}\x{c85}-\x{c8c}\x{c8e}-\x{c90}\x{c92}-\x{ca8}\x{caa}-\x{cb3}\x{cb5}-\x{cb9}\x{cbd}-\x{cc4}\x{cc6}-\x{cc8}\x{cca}\x{ccb}\x{cd5}\x{cd6}\x{cde}\x{ce0}\x{ce1}\x{ce6} +// -\x{cef}\x{cf1}\x{cf2}\x{d02}\x{d03}\x{d05}-\x{d0c}\x{d0e}-\x{d10}\x{d12}-\x{d3a}\x{d3d}-\x{d40}\x{d46}-\x{d48}\x{d4a}-\x{d4c}\x{d4e}\x{d57}\x{d5f}-\x{d61}\x{d66}-\x{d75}\x{d79}-\x{d7f}\x{d82}\x{d83}\x{d85}-\x{d96}\x{d9a}-\x{db1}\x{db3}-\x{dbb}\x{dbd}\x{dc0}-\x{dc6}\x{dcf}-\x{dd1}\x{dd8} +// -\x{ddf}\x{de6}-\x{def}\x{df2}-\x{df4}\x{e01}-\x{e30}\x{e32}\x{e33}\x{e40}-\x{e46}\x{e4f}-\x{e5b}\x{e81}\x{e82}\x{e84}\x{e87}\x{e88}\x{e8a}\x{e8d}\x{e94}-\x{e97}\x{e99}-\x{e9f}\x{ea1}-\x{ea3}\x{ea5}\x{ea7}\x{eaa}\x{eab}\x{ead}-\x{eb0}\x{eb2}\x{eb3}\x{ebd}\x{ec0}-\x{ec4}\x{ec6}\x{ed0} +// -\x{ed9}\x{edc}-\x{edf}\x{f00}-\x{f17}\x{f1a}-\x{f34}\x{f36}\x{f38}\x{f3e}-\x{f47}\x{f49}-\x{f6c}\x{f7f}\x{f85}\x{f88}-\x{f8c}\x{fbe}-\x{fc5}\x{fc7}-\x{fcc}\x{fce}-\x{fda}\x{1000}-\x{102c}\x{1031}\x{1038}\x{103b}\x{103c}\x{103f}-\x{1057}\x{105a}-\x{105d}\x{1061}-\x{1070}\x{1075} +// -\x{1081}\x{1083}\x{1084}\x{1087}-\x{108c}\x{108e}-\x{109c}\x{109e}-\x{10c5}\x{10c7}\x{10cd}\x{10d0}-\x{1248}\x{124a}-\x{124d}\x{1250}-\x{1256}\x{1258}\x{125a}-\x{125d}\x{1260}-\x{1288}\x{128a}-\x{128d}\x{1290}-\x{12b0}\x{12b2}-\x{12b5}\x{12b8}-\x{12be}\x{12c0}\x{12c2} +// -\x{12c5}\x{12c8}-\x{12d6}\x{12d8}-\x{1310}\x{1312}-\x{1315}\x{1318}-\x{135a}\x{1360}-\x{137c}\x{1380}-\x{138f}\x{13a0}-\x{13f5}\x{13f8}-\x{13fd}\x{1401}-\x{167f}\x{1681}-\x{169a}\x{16a0}-\x{16f8}\x{1700}-\x{170c}\x{170e}-\x{1711}\x{1720}-\x{1731}\x{1735}\x{1736}\x{1740} +// -\x{1751}\x{1760}-\x{176c}\x{176e}-\x{1770}\x{1780}-\x{17b3}\x{17b6}\x{17be}-\x{17c5}\x{17c7}\x{17c8}\x{17d4}-\x{17da}\x{17dc}\x{17e0}-\x{17e9}\x{1810}-\x{1819}\x{1820}-\x{1877}\x{1880}-\x{18a8}\x{18aa}\x{18b0}-\x{18f5}\x{1900}-\x{191e}\x{1923}-\x{1926}\x{1929} +// -\x{192b}\x{1930}\x{1931}\x{1933}-\x{1938}\x{1946}-\x{196d}\x{1970}-\x{1974}\x{1980}-\x{19ab}\x{19b0}-\x{19c9}\x{19d0}-\x{19da}\x{1a00}-\x{1a16}\x{1a19}\x{1a1a}\x{1a1e}-\x{1a55}\x{1a57}\x{1a61}\x{1a63}\x{1a64}\x{1a6d}-\x{1a72}\x{1a80}-\x{1a89}\x{1a90}-\x{1a99}\x{1aa0} +// -\x{1aad}\x{1b04}-\x{1b33}\x{1b35}\x{1b3b}\x{1b3d}-\x{1b41}\x{1b43}-\x{1b4b}\x{1b50}-\x{1b6a}\x{1b74}-\x{1b7c}\x{1b82}-\x{1ba1}\x{1ba6}\x{1ba7}\x{1baa}\x{1bae}-\x{1be5}\x{1be7}\x{1bea}-\x{1bec}\x{1bee}\x{1bf2}\x{1bf3}\x{1bfc}-\x{1c2b}\x{1c34}\x{1c35}\x{1c3b} +// -\x{1c49}\x{1c4d}-\x{1c7f}\x{1cc0}-\x{1cc7}\x{1cd3}\x{1ce1}\x{1ce9}-\x{1cec}\x{1cee}-\x{1cf3}\x{1cf5}\x{1cf6}\x{1d00}-\x{1dbf}\x{1e00}-\x{1f15}\x{1f18}-\x{1f1d}\x{1f20}-\x{1f45}\x{1f48}-\x{1f4d}\x{1f50}-\x{1f57}\x{1f59}\x{1f5b}\x{1f5d}\x{1f5f}-\x{1f7d}\x{1f80} +// -\x{1fb4}\x{1fb6}-\x{1fbc}\x{1fbe}\x{1fc2}-\x{1fc4}\x{1fc6}-\x{1fcc}\x{1fd0}-\x{1fd3}\x{1fd6}-\x{1fdb}\x{1fe0}-\x{1fec}\x{1ff2}-\x{1ff4}\x{1ff6}-\x{1ffc}\x{200e}\x{2071}\x{207f}\x{2090}-\x{209c}\x{2102}\x{2107}\x{210a}-\x{2113}\x{2115}\x{2119}-\x{211d}\x{2124}\x{2126}\x{2128}\x{212a} +// -\x{212d}\x{212f}-\x{2139}\x{213c}-\x{213f}\x{2145}-\x{2149}\x{214e}\x{214f}\x{2160}-\x{2188}\x{2336}-\x{237a}\x{2395}\x{249c}-\x{24e9}\x{26ac}\x{2800}-\x{28ff}\x{2c00}-\x{2c2e}\x{2c30}-\x{2c5e}\x{2c60}-\x{2ce4}\x{2ceb}-\x{2cee}\x{2cf2}\x{2cf3}\x{2d00}-\x{2d25}\x{2d27}\x{2d2d}\x{2d30} +// -\x{2d67}\x{2d6f}\x{2d70}\x{2d80}-\x{2d96}\x{2da0}-\x{2da6}\x{2da8}-\x{2dae}\x{2db0}-\x{2db6}\x{2db8}-\x{2dbe}\x{2dc0}-\x{2dc6}\x{2dc8}-\x{2dce}\x{2dd0}-\x{2dd6}\x{2dd8}-\x{2dde}\x{3005}-\x{3007}\x{3021}-\x{3029}\x{302e}\x{302f}\x{3031}-\x{3035}\x{3038}-\x{303c}\x{3041}-\x{3096}\x{309d} +// -\x{309f}\x{30a1}-\x{30fa}\x{30fc}-\x{30ff}\x{3105}-\x{312d}\x{3131}-\x{318e}\x{3190}-\x{31ba}\x{31f0}-\x{321c}\x{3220}-\x{324f}\x{3260}-\x{327b}\x{327f}-\x{32b0}\x{32c0}-\x{32cb}\x{32d0}-\x{32fe}\x{3300}-\x{3376}\x{337b}-\x{33dd}\x{33e0}-\x{33fe}\x{3400}-\x{4db5}\x{4e00}-\x{9fd5}\x{a000} +// -\x{a48c}\x{a4d0}-\x{a60c}\x{a610}-\x{a62b}\x{a640}-\x{a66e}\x{a680}-\x{a69d}\x{a6a0}-\x{a6ef}\x{a6f2}-\x{a6f7}\x{a722}-\x{a787}\x{a789}-\x{a7ad}\x{a7b0}-\x{a7b7}\x{a7f7}-\x{a801}\x{a803}-\x{a805}\x{a807}-\x{a80a}\x{a80c}-\x{a824}\x{a827}\x{a830}-\x{a837}\x{a840}-\x{a873}\x{a880}-\x{a8c3}\x{a8ce} +// -\x{a8d9}\x{a8f2}-\x{a8fd}\x{a900}-\x{a925}\x{a92e}-\x{a946}\x{a952}\x{a953}\x{a95f}-\x{a97c}\x{a983}-\x{a9b2}\x{a9b4}\x{a9b5}\x{a9ba}\x{a9bb}\x{a9bd}-\x{a9cd}\x{a9cf}-\x{a9d9}\x{a9de}-\x{a9e4}\x{a9e6}-\x{a9fe}\x{aa00}-\x{aa28}\x{aa2f}\x{aa30}\x{aa33}\x{aa34}\x{aa40}-\x{aa42}\x{aa44} +// -\x{aa4b}\x{aa4d}\x{aa50}-\x{aa59}\x{aa5c}-\x{aa7b}\x{aa7d}-\x{aaaf}\x{aab1}\x{aab5}\x{aab6}\x{aab9}-\x{aabd}\x{aac0}\x{aac2}\x{aadb}-\x{aaeb}\x{aaee}-\x{aaf5}\x{ab01}-\x{ab06}\x{ab09}-\x{ab0e}\x{ab11}-\x{ab16}\x{ab20}-\x{ab26}\x{ab28}-\x{ab2e}\x{ab30}-\x{ab65}\x{ab70}-\x{abe4}\x{abe6}\x{abe7}\x{abe9} +// -\x{abec}\x{abf0}-\x{abf9}\x{ac00}-\x{d7a3}\x{d7b0}-\x{d7c6}\x{d7cb}-\x{d7fb}\x{e000}-\x{fa6d}\x{fa70}-\x{fad9}\x{fb00}-\x{fb06}\x{fb13}-\x{fb17}\x{ff21}-\x{ff3a}\x{ff41}-\x{ff5a}\x{ff66}-\x{ffbe}\x{ffc2}-\x{ffc7}\x{ffca}-\x{ffcf}\x{ffd2}-\x{ffd7}\x{ffda}-\x{ffdc}\x{10000}-\x{1000b}\x{1000d}-\x{10026}\x{10028} +// -\x{1003a}\x{1003c}\x{1003d}\x{1003f}-\x{1004d}\x{10050}-\x{1005d}\x{10080}-\x{100fa}\x{10100}\x{10102}\x{10107}-\x{10133}\x{10137}-\x{1013f}\x{101d0}-\x{101fc}\x{10280}-\x{1029c}\x{102a0}-\x{102d0}\x{10300}-\x{10323}\x{10330}-\x{1034a}\x{10350}-\x{10375}\x{10380}-\x{1039d}\x{1039f}-\x{103c3}\x{103c8}-\x{103d5}\x{10400} +// -\x{1049d}\x{104a0}-\x{104a9}\x{10500}-\x{10527}\x{10530}-\x{10563}\x{1056f}\x{10600}-\x{10736}\x{10740}-\x{10755}\x{10760}-\x{10767}\x{11000}\x{11002}-\x{11037}\x{11047}-\x{1104d}\x{11066}-\x{1106f}\x{11082}-\x{110b2}\x{110b7}\x{110b8}\x{110bb}-\x{110c1}\x{110d0}-\x{110e8}\x{110f0}-\x{110f9}\x{11103}-\x{11126}\x{1112c}\x{11136} +// -\x{11143}\x{11150}-\x{11172}\x{11174}-\x{11176}\x{11182}-\x{111b5}\x{111bf}-\x{111c9}\x{111cd}\x{111d0}-\x{111df}\x{111e1}-\x{111f4}\x{11200}-\x{11211}\x{11213}-\x{1122e}\x{11232}\x{11233}\x{11235}\x{11238}-\x{1123d}\x{11280}-\x{11286}\x{11288}\x{1128a}-\x{1128d}\x{1128f}-\x{1129d}\x{1129f}-\x{112a9}\x{112b0}-\x{112de}\x{112e0} +// -\x{112e2}\x{112f0}-\x{112f9}\x{11302}\x{11303}\x{11305}-\x{1130c}\x{1130f}\x{11310}\x{11313}-\x{11328}\x{1132a}-\x{11330}\x{11332}\x{11333}\x{11335}-\x{11339}\x{1133d}-\x{1133f}\x{11341}-\x{11344}\x{11347}\x{11348}\x{1134b}-\x{1134d}\x{11350}\x{11357}\x{1135d}-\x{11363}\x{11480}-\x{114b2}\x{114b9}\x{114bb}-\x{114be}\x{114c1}\x{114c4} +// -\x{114c7}\x{114d0}-\x{114d9}\x{11580}-\x{115b1}\x{115b8}-\x{115bb}\x{115be}\x{115c1}-\x{115db}\x{11600}-\x{11632}\x{1163b}\x{1163c}\x{1163e}\x{11641}-\x{11644}\x{11650}-\x{11659}\x{11680}-\x{116aa}\x{116ac}\x{116ae}\x{116af}\x{116b6}\x{116c0}-\x{116c9}\x{11700}-\x{11719}\x{11720}\x{11721}\x{11726}\x{11730}-\x{1173f}\x{118a0} +// -\x{118f2}\x{118ff}\x{11ac0}-\x{11af8}\x{12000}-\x{12399}\x{12400}-\x{1246e}\x{12470}-\x{12474}\x{12480}-\x{12543}\x{13000}-\x{1342e}\x{14400}-\x{14646}\x{16800}-\x{16a38}\x{16a40}-\x{16a5e}\x{16a60}-\x{16a69}\x{16a6e}\x{16a6f}\x{16ad0}-\x{16aed}\x{16af5}\x{16b00}-\x{16b2f}\x{16b37}-\x{16b45}\x{16b50}-\x{16b59}\x{16b5b} +// -\x{16b61}\x{16b63}-\x{16b77}\x{16b7d}-\x{16b8f}\x{16f00}-\x{16f44}\x{16f50}-\x{16f7e}\x{16f93}-\x{16f9f}\x{1b000}\x{1b001}\x{1bc00}-\x{1bc6a}\x{1bc70}-\x{1bc7c}\x{1bc80}-\x{1bc88}\x{1bc90}-\x{1bc99}\x{1bc9c}\x{1bc9f}\x{1d000}-\x{1d0f5}\x{1d100}-\x{1d126}\x{1d129}-\x{1d166}\x{1d16a}-\x{1d172}\x{1d183}\x{1d184}\x{1d18c} +// -\x{1d1a9}\x{1d1ae}-\x{1d1e8}\x{1d360}-\x{1d371}\x{1d400}-\x{1d454}\x{1d456}-\x{1d49c}\x{1d49e}\x{1d49f}\x{1d4a2}\x{1d4a5}\x{1d4a6}\x{1d4a9}-\x{1d4ac}\x{1d4ae}-\x{1d4b9}\x{1d4bb}\x{1d4bd}-\x{1d4c3}\x{1d4c5}-\x{1d505}\x{1d507}-\x{1d50a}\x{1d50d}-\x{1d514}\x{1d516}-\x{1d51c}\x{1d51e}-\x{1d539}\x{1d53b}-\x{1d53e}\x{1d540} +// -\x{1d544}\x{1d546}\x{1d54a}-\x{1d550}\x{1d552}-\x{1d6a5}\x{1d6a8}-\x{1d6da}\x{1d6dc}-\x{1d714}\x{1d716}-\x{1d74e}\x{1d750}-\x{1d788}\x{1d78a}-\x{1d7c2}\x{1d7c4}-\x{1d7cb}\x{1d800}-\x{1d9ff}\x{1da37}-\x{1da3a}\x{1da6d}-\x{1da74}\x{1da76}-\x{1da83}\x{1da85}-\x{1da8b}\x{1f110}-\x{1f12e}\x{1f130}-\x{1f169}\x{1f170} +// -\x{1f19a}\x{1f1e6}-\x{1f202}\x{1f210}-\x{1f23a}\x{1f240}-\x{1f248}\x{1f250}\x{1f251}\x{20000}-\x{2a6d6}\x{2a700}-\x{2b734}\x{2b740}-\x{2b81d}\x{2b820}-\x{2cea1}\x{2f800}-\x{2fa1d}\x{f0000}-\x{ffffd}\x{100000}-\x{10fffd}])|([\x{590}\x{5be}\x{5c0}\x{5c3}\x{5c6}\x{5c8}-\x{5ff}\x{7c0}-\x{7ea}\x{7f4}\x{7f5}\x{7fa} +// -\x{815}\x{81a}\x{824}\x{828}\x{82e}-\x{858}\x{85c}-\x{89f}\x{200f}\x{fb1d}\x{fb1f}-\x{fb28}\x{fb2a}-\x{fb4f}\x{10800}-\x{1091e}\x{10920}-\x{10a00}\x{10a04}\x{10a07}-\x{10a0b}\x{10a10}-\x{10a37}\x{10a3b}-\x{10a3e}\x{10a40}-\x{10ae4}\x{10ae7}-\x{10b38}\x{10b40}-\x{10e5f}\x{10e7f}-\x{10fff}\x{1e800}-\x{1e8cf}\x{1e8d7} +// -\x{1edff}\x{1ef00}-\x{1efff}\x{608}\x{60b}\x{60d}\x{61b}-\x{64a}\x{66d}-\x{66f}\x{671}-\x{6d5}\x{6e5}\x{6e6}\x{6ee}\x{6ef}\x{6fa}-\x{710}\x{712}-\x{72f}\x{74b}-\x{7a5}\x{7b1}-\x{7bf}\x{8a0}-\x{8e2}\x{fb50}-\x{fd3d}\x{fd40}-\x{fdcf}\x{fdf0}-\x{fdfc}\x{fdfe}\x{fdff}\x{fe70}-\x{fefe}\x{1ee00}-\x{1eeef}\x{1eef2}-\x{1eeff}]))/u'; +// // @codeCoverageIgnoreEnd +// // @codingStandardsIgnoreEnd +// +// /** +// * Get a cached or new language Object for a given language code +// * @param String $code +// * @return Language +// */ +// static function factory($code) { +// global $wgDummyLanguageCodes, $wgLangObjCacheSize; +// +// if (isset($wgDummyLanguageCodes[$code])) { +// $code = $wgDummyLanguageCodes[$code]; +// } +// +// // get the language Object to process +// $langObj = isset(self::$mLangObjCache[$code]) +// ? self::$mLangObjCache[$code] +// : self::newFromCode($code); +// +// // merge the language Object in to get it up front in the cache +// self::$mLangObjCache = array_merge([ $code => $langObj ], self::$mLangObjCache); +// // get rid of the oldest ones in case we have an overflow +// self::$mLangObjCache = array_slice(self::$mLangObjCache, 0, $wgLangObjCacheSize, true); +// +// return $langObj; +// } +// +// /** +// * Create a language Object for a given language code +// * @param String $code +// * @throws MWException +// * @return Language +// */ +// protected static function newFromCode($code) { +// if (!Language::isValidCode($code)) { +// throw new MWException("Invalid language code \"$code\""); +// } +// +// if (!Language::isValidBuiltInCode($code)) { +// // It's not possible to customise this code with class files, so +// // just return a Language Object. This is to support uselang= hacks. +// $lang = new Language; +// $lang->setCode($code); +// return $lang; +// } +// +// // Check if there is a language class for the code +// $class = self::classFromCode($code); +// if (class_exists($class)) { +// $lang = new $class; +// return $lang; +// } +// +// // Keep trying the fallback list until we find an existing class +// $fallbacks = Language::getFallbacksFor($code); +// foreach ($fallbacks as $fallbackCode) { +// if (!Language::isValidBuiltInCode($fallbackCode)) { +// throw new MWException("Invalid fallback '$fallbackCode' in fallback sequence for '$code'"); +// } +// +// $class = self::classFromCode($fallbackCode); +// if (class_exists($class)) { +// $lang = new $class; +// $lang->setCode($code); +// return $lang; +// } +// } +// +// throw new MWException("Invalid fallback sequence for language '$code'"); +// } +// +// /** +// * Checks whether any localisation is available for that language tag +// * in MediaWiki (MessagesXx.php exists). +// * +// * @param String $code Language tag (in lower case) +// * @return boolean Whether language is supported +// * @since 1.21 +// */ +// public static function isSupportedLanguage($code) { +// if (!self::isValidBuiltInCode($code)) { +// return false; +// } +// +// if ($code === 'qqq') { +// return false; +// } +// +// return is_readable(self::getMessagesFileName($code)) || +// is_readable(self::getJsonMessagesFileName($code)); +// } +// +// /** +// * Returns true if a language code String is a well-formed language tag +// * according to RFC 5646. +// * This function only checks well-formedness; it doesn't check that +// * language, script or variant codes actually exist in the repositories. +// * +// * Based on regexes by Mark Davis of the Unicode Consortium: +// * http://unicode.org/repos/cldr/trunk/tools/java/org/unicode/cldr/util/data/langtagRegex.txt +// * +// * @param String $code +// * @param boolean $lenient Whether to allow '_' as separator. The default is only '-'. +// * +// * @return boolean +// * @since 1.21 +// */ +// public static function isWellFormedLanguageTag($code, $lenient = false) { +// $alpha = '[a-z]'; +// $digit = '[0-9]'; +// $alphanum = '[a-z0-9]'; +// $x = 'x'; # private use singleton +// $singleton = '[a-wy-z]'; # other singleton +// $s = $lenient ? '[-_]' : '-'; +// +// $language = "$alpha{2,8}|$alpha{2,3}$s$alpha{3}"; +// $script = "$alpha{4}"; # ISO 15924 +// $region = "(?:$alpha{2}|$digit{3})"; # ISO 3166-1 alpha-2 or UN M.49 +// $variant = "(?:$alphanum{5,8}|$digit$alphanum{3})"; +// $extension = "$singleton(?:$s$alphanum{2,8})+"; +// $privateUse = "$x(?:$s$alphanum{1,8})+"; +// +// # Define certain grandfathered codes, since otherwise the regex is pretty useless. +// # Since these are limited, this is safe even later changes to the registry -- +// # the only oddity is that it might change the type of the tag, and thus +// # the results from the capturing groups. +// # https://www.iana.org/assignments/language-subtag-registry +// +// $grandfathered = "en{$s}GB{$s}oed" +// . "|i{$s}(?:ami|bnn|default|enochian|hak|klingon|lux|mingo|navajo|pwn|tao|tay|tsu)" +// . "|no{$s}(?:bok|nyn)" +// . "|sgn{$s}(?:BE{$s}(?:fr|nl)|CH{$s}de)" +// . "|zh{$s}min{$s}nan"; +// +// $variantList = "$variant(?:$s$variant)*"; +// $extensionList = "$extension(?:$s$extension)*"; +// +// $langtag = "(?:($language)" +// . "(?:$s$script)?" +// . "(?:$s$region)?" +// . "(?:$s$variantList)?" +// . "(?:$s$extensionList)?" +// . "(?:$s$privateUse)?)"; +// +// # The final breakdown, with capturing groups for each of these components +// # The variants, extensions, grandfathered, and private-use may have interior '-' +// +// $root = "^(?:$langtag|$privateUse|$grandfathered)$"; +// +// return (boolean)preg_match("/$root/", strtolower($code)); +// } +// +// /** +// * Returns true if a language code String is of a valid form, whether or +// * not it exists. This includes codes which are used solely for +// * customisation via the MediaWiki namespace. +// * +// * @param String $code +// * +// * @return boolean +// */ +// public static function isValidCode($code) { +// static $cache = []; +// if (!isset($cache[$code])) { +// // People think language codes are html safe, so enforce it. +// // Ideally we should only allow a-zA-Z0-9- +// // but, .+ and other chars are often used for {{int:}} hacks +// // see bugs T39564, T39587, T38938 +// $cache[$code] = +// // Protect against path traversal +// strcspn($code, ":/\\\000&<>'\"") === strlen($code) +// && !preg_match(MediaWikiTitleCodec::getTitleInvalidRegex(), $code); +// } +// return $cache[$code]; +// } +// +// /** +// * Returns true if a language code is of a valid form for the purposes of +// * @gplx.Internal protected customisation of MediaWiki, via Messages*.php or *.json. +// * +// * @param String $code +// * +// * @throws MWException +// * @since 1.18 +// * @return boolean +// */ +// public static function isValidBuiltInCode($code) { +// +// if (!is_string($code)) { +// if (is_object($code)) { +// $addmsg = " of class " . get_class($code); +// } else { +// $addmsg = ''; +// } +// $type = gettype($code); +// throw new MWException(__METHOD__ . " must be passed a String, $type given$addmsg"); +// } +// +// return (boolean)preg_match('/^[a-z0-9-]{2,}$/', $code); +// } +// +// /** +// * Returns true if a language code is an IETF tag known to MediaWiki. +// * +// * @param String $tag +// * +// * @since 1.21 +// * @return boolean +// */ +// public static function isKnownLanguageTag($tag) { +// // Quick escape for invalid input to avoid exceptions down the line +// // when code tries to process tags which are not valid at all. +// if (!self::isValidBuiltInCode($tag)) { +// return false; +// } +// +// if (isset(MediaWiki\Languages\Data\Names::$names[$tag]) +// || self::fetchLanguageName($tag, $tag) !== '' +// ) { +// return true; +// } +// +// return false; +// } +// +// /** +// * Get the LocalisationCache instance +// * +// * @return LocalisationCache +// */ +// public static function getLocalisationCache() { +// if (is_null(self::$dataCache)) { +// global $wgLocalisationCacheConf; +// $class = $wgLocalisationCacheConf['class']; +// self::$dataCache = new $class($wgLocalisationCacheConf); +// } +// return self::$dataCache; +// } +// +// function __construct() { +// this.mConverter = new FakeConverter($this); +// // Set the code to the name of the descendant +// if (get_class($this) == 'Language') { +// this.mCode = 'en'; +// } else { +// this.mCode = str_replace('_', '-', strtolower(substr(get_class($this), 8))); +// } +// self::getLocalisationCache(); +// } +// +// /** +// * Reduce memory usage +// */ +// function __destruct() { +// foreach ($this as $name => $value) { +// unset(this.$name); +// } +// } +// +// /** +// * Hook which will be called if this is the content language. +// * Descendants can use this to register hook functions or modify globals +// */ +// function initContLang() { +// } +// +// /** +// * @return array +// * @since 1.19 +// */ +// public function getFallbackLanguages() { +// return self::getFallbacksFor(this.mCode); +// } +// +// /** +// * Exports $wgBookstoreListEn +// * @return array +// */ +// public function getBookstoreList() { +// return self::$dataCache->getItem(this.mCode, 'bookstoreList'); +// } + + /** + * Returns an array of localised namespaces indexed by their numbers. If the namespace is not + * available in localised form, it will be included in English. + * + * @return array + */ + public Hash_adp__int getNamespaces() { + if (this.namespaceNames == null) { +// global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces; +// + Hash_adp__int validNamespaces = XomwNamespace.getCanonicalNamespaces(); +// +// this.namespaceNames = $wgExtraNamespaces + +// self::$dataCache->getItem(this.mCode, 'namespaceNames'); +// this.namespaceNames += $validNamespaces; + this.namespaceNames = validNamespaces; + +// this.namespaceNames[NS_PROJECT] = $wgMetaNamespace; +// if ($wgMetaNamespaceTalk) { +// this.namespaceNames[NS_PROJECT_TALK] = $wgMetaNamespaceTalk; +// } else { +// $talk = this.namespaceNames[NS_PROJECT_TALK]; +// this.namespaceNames[NS_PROJECT_TALK] = +// this.fixVariableInNamespace($talk); +// } +// +// # Sometimes a language will be localised but not actually exist on this wiki. +// foreach (this.namespaceNames as $key => $text) { +// if (!isset($validNamespaces[$key])) { +// unset(this.namespaceNames[$key]); +// } +// } +// +// # The above mixing may leave namespaces out of canonical order. +// # Re-order by namespace ID number... +// ksort(this.namespaceNames); +// +// Hooks::run('LanguageGetNamespaces', [ &this.namespaceNames ]); + } + + return this.namespaceNames; + } + +// /** +// * Arbitrarily set all of the namespace names at once. Mainly used for testing +// * @param array $namespaces Array of namespaces (id => name) +// */ +// public function setNamespaces(array $namespaces) { +// this.namespaceNames = $namespaces; +// this.mNamespaceIds = null; +// } +// +// /** +// * Resets all of the namespace caches. Mainly used for testing +// */ +// public function resetNamespaces() { +// this.namespaceNames = null; +// this.mNamespaceIds = null; +// this.namespaceAliases = null; +// } +// +// /** +// * A convenience function that returns getNamespaces() with spaces instead of underscores +// * in values. Useful for producing output to be displayed e.g. in `