|
|
|
|
@@ -165,6 +165,9 @@ public class XomwMessage {
|
|
|
|
|
|
|
|
|
|
private static final int FORMAT_NULL = 5;
|
|
|
|
|
|
|
|
|
|
// private static final int PRM_TID_BEFORE = 1; // "before"
|
|
|
|
|
// private static final int PRM_TID_AFTER = 2; // "after"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mapping from Message::listParam() types to Language methods.
|
|
|
|
|
* @var array
|
|
|
|
|
@@ -268,20 +271,20 @@ public class XomwMessage {
|
|
|
|
|
// throw new InvalidArgumentException('key must be a String or an array');
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $this->keysToTry = (array)key;
|
|
|
|
|
// this.keysToTry = (array)key;
|
|
|
|
|
//
|
|
|
|
|
// if ( empty( $this->keysToTry ) ) {
|
|
|
|
|
// if (empty(this.keysToTry)) {
|
|
|
|
|
// throw new InvalidArgumentException('key must not be an empty list');
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $this->key = reset( $this->keysToTry );
|
|
|
|
|
// this.key = reset(this.keysToTry);
|
|
|
|
|
//
|
|
|
|
|
// $this->parameters = array_values( $prmsVar );
|
|
|
|
|
// this.parameters = array_values($prmsVar);
|
|
|
|
|
// // User language is only resolved in getLanguage(). This helps preserve the
|
|
|
|
|
// // semantic intent of "user language" across serialize() and unserialize().
|
|
|
|
|
// $this->language = $language ?: false;
|
|
|
|
|
// this.language = $language ?: false;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * @see Serializable::serialize()
|
|
|
|
|
// * @since 1.26
|
|
|
|
|
@@ -289,14 +292,14 @@ public class XomwMessage {
|
|
|
|
|
// */
|
|
|
|
|
// public function serialize() {
|
|
|
|
|
// return serialize([
|
|
|
|
|
// 'interfaceIsUserLang' => $this->interfaceIsUserLang,
|
|
|
|
|
// 'language' => $this->language ? $this->language->getCode() : false,
|
|
|
|
|
// 'key' => $this->key,
|
|
|
|
|
// 'keysToTry' => $this->keysToTry,
|
|
|
|
|
// 'parameters' => $this->parameters,
|
|
|
|
|
// 'format' => $this->format,
|
|
|
|
|
// 'useDatabase' => $this->useDatabase,
|
|
|
|
|
// 'title' => $this->title,
|
|
|
|
|
// 'interfaceIsUserLang' => this.interfaceIsUserLang,
|
|
|
|
|
// 'language' => this.language ? this.language->getCode() : false,
|
|
|
|
|
// 'key' => this.key,
|
|
|
|
|
// 'keysToTry' => this.keysToTry,
|
|
|
|
|
// 'parameters' => this.parameters,
|
|
|
|
|
// 'format' => this.format,
|
|
|
|
|
// 'useDatabase' => this.useDatabase,
|
|
|
|
|
// 'title' => this.title,
|
|
|
|
|
// ]);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -307,16 +310,16 @@ public class XomwMessage {
|
|
|
|
|
// */
|
|
|
|
|
// public function unserialize($serialized) {
|
|
|
|
|
// $data = unserialize($serialized);
|
|
|
|
|
// $this->interfaceIsUserLang = $data['interfaceIsUserLang'];
|
|
|
|
|
// $this->key = $data['key'];
|
|
|
|
|
// $this->keysToTry = $data['keysToTry'];
|
|
|
|
|
// $this->parameters = $data['parameters'];
|
|
|
|
|
// $this->format = $data['format'];
|
|
|
|
|
// $this->useDatabase = $data['useDatabase'];
|
|
|
|
|
// $this->language = $data['language'] ? Language::factory( $data['language'] ) : false;
|
|
|
|
|
// $this->title = $data['title'];
|
|
|
|
|
// this.interfaceIsUserLang = $data['interfaceIsUserLang'];
|
|
|
|
|
// this.key = $data['key'];
|
|
|
|
|
// this.keysToTry = $data['keysToTry'];
|
|
|
|
|
// this.parameters = $data['parameters'];
|
|
|
|
|
// this.format = $data['format'];
|
|
|
|
|
// this.useDatabase = $data['useDatabase'];
|
|
|
|
|
// this.language = $data['language'] ? Language::factory($data['language']) : false;
|
|
|
|
|
// this.title = $data['title'];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * @since 1.24
|
|
|
|
|
// *
|
|
|
|
|
@@ -324,7 +327,7 @@ public class XomwMessage {
|
|
|
|
|
// * constructor was a fallback list of keys to try.
|
|
|
|
|
// */
|
|
|
|
|
// public function isMultiKey() {
|
|
|
|
|
// return count( $this->keysToTry ) > 1;
|
|
|
|
|
// return count(this.keysToTry) > 1;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -334,7 +337,7 @@ public class XomwMessage {
|
|
|
|
|
// * in order of preference.
|
|
|
|
|
// */
|
|
|
|
|
// public function getKeysToTry() {
|
|
|
|
|
// return $this->keysToTry;
|
|
|
|
|
// return this.keysToTry;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -349,7 +352,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return String
|
|
|
|
|
// */
|
|
|
|
|
// public function getKey() {
|
|
|
|
|
// return $this->key;
|
|
|
|
|
// return this.key;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -360,7 +363,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return array
|
|
|
|
|
// */
|
|
|
|
|
// public function getParams() {
|
|
|
|
|
// return $this->parameters;
|
|
|
|
|
// return this.parameters;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -373,7 +376,7 @@ public class XomwMessage {
|
|
|
|
|
// */
|
|
|
|
|
// public function getFormat() {
|
|
|
|
|
// wfDeprecated(__METHOD__, '1.29');
|
|
|
|
|
// return $this->format;
|
|
|
|
|
// return this.format;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -385,7 +388,7 @@ public class XomwMessage {
|
|
|
|
|
// */
|
|
|
|
|
// public function getLanguage() {
|
|
|
|
|
// // Defaults to false which means current user language
|
|
|
|
|
// return $this->language ?: RequestContext::getMain()->getLanguage();
|
|
|
|
|
// return this.language ?: RequestContext::getMain()->getLanguage();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -479,12 +482,12 @@ public class XomwMessage {
|
|
|
|
|
// public function getTitle() {
|
|
|
|
|
// global $wgContLang, $wgForceUIMsgAsContentMsg;
|
|
|
|
|
//
|
|
|
|
|
// title = $this->key;
|
|
|
|
|
// title = this.key;
|
|
|
|
|
// if (
|
|
|
|
|
// !$this->language->equals( $wgContLang )
|
|
|
|
|
// && in_array( $this->key, (array)$wgForceUIMsgAsContentMsg )
|
|
|
|
|
// !this.language->equals($wgContLang)
|
|
|
|
|
// && in_array(this.key, (array)$wgForceUIMsgAsContentMsg)
|
|
|
|
|
// ) {
|
|
|
|
|
// $code = $this->language->getCode();
|
|
|
|
|
// $code = this.language->getCode();
|
|
|
|
|
// title .= '/' . $code;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -521,7 +524,7 @@ public class XomwMessage {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $this->parameters = array_merge( $this->parameters, array_values( $args ) );
|
|
|
|
|
// this.parameters = array_merge(this.parameters, array_values($args));
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -544,7 +547,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::rawParam( $param );
|
|
|
|
|
// this.parameters[] = self::rawParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -566,7 +569,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::numParam( $param );
|
|
|
|
|
// this.parameters[] = self::numParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -588,7 +591,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::durationParam( $param );
|
|
|
|
|
// this.parameters[] = self::durationParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -610,7 +613,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::expiryParam( $param );
|
|
|
|
|
// this.parameters[] = self::expiryParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -632,7 +635,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::timeperiodParam( $param );
|
|
|
|
|
// this.parameters[] = self::timeperiodParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -654,7 +657,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::sizeParam( $param );
|
|
|
|
|
// this.parameters[] = self::sizeParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -676,7 +679,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::bitrateParam( $param );
|
|
|
|
|
// this.parameters[] = self::bitrateParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -700,7 +703,7 @@ public class XomwMessage {
|
|
|
|
|
// $prmsVar = $prmsVar[0];
|
|
|
|
|
// }
|
|
|
|
|
// foreach ($prmsVar as $param) {
|
|
|
|
|
// $this->parameters[] = self::plaintextParam( $param );
|
|
|
|
|
// this.parameters[] = self::plaintextParam($param);
|
|
|
|
|
// }
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -715,9 +718,9 @@ public class XomwMessage {
|
|
|
|
|
// * @return Message $this
|
|
|
|
|
// */
|
|
|
|
|
// public function setContext(IContextSource $context) {
|
|
|
|
|
// $this->inLanguage( $context->getLanguage() );
|
|
|
|
|
// $this->title( $context->getTitle() );
|
|
|
|
|
// $this->interfaceIsUserLang = true;
|
|
|
|
|
// this.inLanguage($context->getLanguage());
|
|
|
|
|
// this.title($context->getTitle());
|
|
|
|
|
// this.interfaceIsUserLang = true;
|
|
|
|
|
//
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
@@ -735,21 +738,21 @@ public class XomwMessage {
|
|
|
|
|
// */
|
|
|
|
|
// public function inLanguage($lang) {
|
|
|
|
|
// if ($lang instanceof Language) {
|
|
|
|
|
// $this->language = $lang;
|
|
|
|
|
// this.language = $lang;
|
|
|
|
|
// } elseif (is_string($lang)) {
|
|
|
|
|
// if ( !$this->language instanceof Language || $this->language->getCode() != $lang ) {
|
|
|
|
|
// $this->language = Language::factory( $lang );
|
|
|
|
|
// if (!this.language instanceof Language || this.language->getCode() != $lang) {
|
|
|
|
|
// this.language = Language::factory($lang);
|
|
|
|
|
// }
|
|
|
|
|
// } elseif ($lang instanceof StubUserLang) {
|
|
|
|
|
// $this->language = false;
|
|
|
|
|
// this.language = false;
|
|
|
|
|
// } else {
|
|
|
|
|
// $type = gettype($lang);
|
|
|
|
|
// throw new MWException(__METHOD__ . " must be "
|
|
|
|
|
// . "passed a String or Language Object; $type given"
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// $this->message = null;
|
|
|
|
|
// $this->interfaceIsUserLang = false;
|
|
|
|
|
// this.message = null;
|
|
|
|
|
// this.interfaceIsUserLang = false;
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@@ -764,12 +767,12 @@ public class XomwMessage {
|
|
|
|
|
*/
|
|
|
|
|
public XomwMessage inContentLanguage() {
|
|
|
|
|
// global $wgForceUIMsgAsContentMsg;
|
|
|
|
|
// if ( in_array( $this->key, (array)$wgForceUIMsgAsContentMsg ) ) {
|
|
|
|
|
// if (in_array(this.key, (array)$wgForceUIMsgAsContentMsg)) {
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// global $wgContLang;
|
|
|
|
|
// $this->inLanguage( $wgContLang );
|
|
|
|
|
// this.inLanguage($wgContLang);
|
|
|
|
|
// return $this;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
@@ -785,7 +788,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return Message $this
|
|
|
|
|
// */
|
|
|
|
|
// public function setInterfaceMessageFlag($interfaceIsUserLang) {
|
|
|
|
|
// $this->interfaceIsUserLang = (boolean)$interfaceIsUserLang;
|
|
|
|
|
// this.interfaceIsUserLang = (boolean)$interfaceIsUserLang;
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -799,8 +802,8 @@ public class XomwMessage {
|
|
|
|
|
// * @return Message $this
|
|
|
|
|
// */
|
|
|
|
|
// public function useDatabase($useDatabase) {
|
|
|
|
|
// $this->useDatabase = (boolean)$useDatabase;
|
|
|
|
|
// $this->message = null;
|
|
|
|
|
// this.useDatabase = (boolean)$useDatabase;
|
|
|
|
|
// this.message = null;
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -814,7 +817,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return Message $this
|
|
|
|
|
// */
|
|
|
|
|
// public function title(title) {
|
|
|
|
|
// $this->title = title;
|
|
|
|
|
// this.title = title;
|
|
|
|
|
// return $this;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@@ -844,7 +847,7 @@ public class XomwMessage {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// NOTE: causes issues in C# source; E2A7BC; http://www.fileformat.info/info/unicode/char/29fc/index.htm
|
|
|
|
|
private static final byte[] LeftPointingCurvedAngleBracket = Bry_.New_by_ints(226, 167, 188);
|
|
|
|
|
private static final byte[] LeftPointingCurvedAngleBracket = gplx.core.encoders.Hex_utl_.Parse_hex_to_bry("E2A7BC");
|
|
|
|
|
public byte[] toString(int format) {
|
|
|
|
|
if (format == FORMAT_NULL) {
|
|
|
|
|
Gfo_usr_dlg_.Instance.Warn_many("", "", "toString import implicit.*; format=~{0} key=~{1}", format, key);
|
|
|
|
|
@@ -864,15 +867,15 @@ public class XomwMessage {
|
|
|
|
|
return Bry_.Escape_html(Bry_.Add(LeftPointingCurvedAngleBracket, key, LeftPointingCurvedAngleBracket));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// // Replace $* with a list of parameters for &uselang=qqx.
|
|
|
|
|
// if (strpos(s, "$*") != false) {
|
|
|
|
|
// Replace $* with a list of parameters for &uselang=qqx.
|
|
|
|
|
// if (XophpString.strpos(s, "$*") != false) {
|
|
|
|
|
// String paramlist = "";
|
|
|
|
|
// if (this.parameters != []) {
|
|
|
|
|
// paramlist = ": $" . implode(", $", range(1, count(this.parameters)));
|
|
|
|
|
// }
|
|
|
|
|
// s = str_replace("$*", paramlist, s);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// // Replace parameters before text parsing
|
|
|
|
|
// s = this.replaceParameters(s, "before", format);
|
|
|
|
|
//
|
|
|
|
|
@@ -909,16 +912,16 @@ public class XomwMessage {
|
|
|
|
|
// // trigger a fatal error if it does. So, catch any exceptions.
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// return $this->toString( self::FORMAT_PARSE );
|
|
|
|
|
// return this.toString(self::FORMAT_PARSE);
|
|
|
|
|
// } catch (Exception $ex) {
|
|
|
|
|
// try {
|
|
|
|
|
// trigger_error( "Exception caught in " . __METHOD__ . " (message " . $this->key . "): "
|
|
|
|
|
// trigger_error("Exception caught in " . __METHOD__ . " (message " . this.key . "): "
|
|
|
|
|
// . $ex, E_USER_WARNING);
|
|
|
|
|
// } catch (Exception $ex) {
|
|
|
|
|
// // Doh! Cause a fatal error after all?
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return '⧼' . htmlspecialchars( $this->key ) . '⧽';
|
|
|
|
|
// return '⧼' . htmlspecialchars(this.key) . '⧽';
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -930,8 +933,8 @@ public class XomwMessage {
|
|
|
|
|
// * @return String Parsed HTML.
|
|
|
|
|
// */
|
|
|
|
|
// public function parse() {
|
|
|
|
|
// $this->format = self::FORMAT_PARSE;
|
|
|
|
|
// return $this->toString( self::FORMAT_PARSE );
|
|
|
|
|
// this.format = self::FORMAT_PARSE;
|
|
|
|
|
// return this.toString(self::FORMAT_PARSE);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -954,8 +957,8 @@ public class XomwMessage {
|
|
|
|
|
// * @return String Unescaped untransformed message text.
|
|
|
|
|
// */
|
|
|
|
|
// public function plain() {
|
|
|
|
|
// $this->format = self::FORMAT_PLAIN;
|
|
|
|
|
// return $this->toString( self::FORMAT_PLAIN );
|
|
|
|
|
// this.format = self::FORMAT_PLAIN;
|
|
|
|
|
// return this.toString(self::FORMAT_PLAIN);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -966,8 +969,8 @@ public class XomwMessage {
|
|
|
|
|
// * @return String HTML
|
|
|
|
|
// */
|
|
|
|
|
// public function parseAsBlock() {
|
|
|
|
|
// $this->format = self::FORMAT_BLOCK_PARSE;
|
|
|
|
|
// return $this->toString( self::FORMAT_BLOCK_PARSE );
|
|
|
|
|
// this.format = self::FORMAT_BLOCK_PARSE;
|
|
|
|
|
// return this.toString(self::FORMAT_BLOCK_PARSE);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -979,8 +982,8 @@ public class XomwMessage {
|
|
|
|
|
// * @return String Escaped message text.
|
|
|
|
|
// */
|
|
|
|
|
// public function escaped() {
|
|
|
|
|
// $this->format = self::FORMAT_ESCAPED;
|
|
|
|
|
// return $this->toString( self::FORMAT_ESCAPED );
|
|
|
|
|
// this.format = self::FORMAT_ESCAPED;
|
|
|
|
|
// return this.toString(self::FORMAT_ESCAPED);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -991,7 +994,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return boolean
|
|
|
|
|
// */
|
|
|
|
|
// public function exists() {
|
|
|
|
|
// return $this->fetchMessage() !== false;
|
|
|
|
|
// return this.fetchMessage() !== false;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -1003,7 +1006,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return boolean
|
|
|
|
|
// */
|
|
|
|
|
// public function isBlank() {
|
|
|
|
|
// $message = $this->fetchMessage();
|
|
|
|
|
// $message = this.fetchMessage();
|
|
|
|
|
// return $message === false || $message === '';
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -1015,7 +1018,7 @@ public class XomwMessage {
|
|
|
|
|
// * @return boolean
|
|
|
|
|
// */
|
|
|
|
|
// public function isDisabled() {
|
|
|
|
|
// $message = $this->fetchMessage();
|
|
|
|
|
// $message = this.fetchMessage();
|
|
|
|
|
// return $message === false || $message === '' || $message === '-';
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -1122,64 +1125,66 @@ public class XomwMessage {
|
|
|
|
|
// }
|
|
|
|
|
// return [ 'list' => $list, 'type' => $type ];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Substitutes any parameters into the message text.
|
|
|
|
|
// *
|
|
|
|
|
// * @since 1.17
|
|
|
|
|
// *
|
|
|
|
|
// * @param String $message The message text.
|
|
|
|
|
// * @param String $type Either "before" or "after".
|
|
|
|
|
// * @param String $format One of the FORMAT_* constants.
|
|
|
|
|
// *
|
|
|
|
|
// * @return String
|
|
|
|
|
// */
|
|
|
|
|
// protected function replaceParameters( $message, $type = 'before', $format ) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Substitutes any parameters into the message text.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.17
|
|
|
|
|
*
|
|
|
|
|
* @param String $message The message text.
|
|
|
|
|
* @param String $type Either "before" or "after".
|
|
|
|
|
* @param String $format One of the FORMAT_* constants.
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
// DFLT:type="before"
|
|
|
|
|
// private byte[] replaceParameters(byte[] message, int prm_tid, int format) {
|
|
|
|
|
// $replacementKeys = [];
|
|
|
|
|
// foreach ( $this->parameters as $n => $param ) {
|
|
|
|
|
// list( $paramType, $value ) = $this->extractParam( $param, $format );
|
|
|
|
|
// foreach (this.parameters as $n => $param) {
|
|
|
|
|
// list($paramType, $value) = this.extractParam($param, $format);
|
|
|
|
|
// if ($type === $paramType) {
|
|
|
|
|
// $replacementKeys['$' . ($n + 1)] = $value;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// $message = strtr($message, $replacementKeys);
|
|
|
|
|
// return $message;
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * Extracts the parameter type and preprocessed the value if needed.
|
|
|
|
|
// *
|
|
|
|
|
// * @since 1.18
|
|
|
|
|
// *
|
|
|
|
|
// * @param mixed $param Parameter as defined in this cls.
|
|
|
|
|
// * @param String $format One of the FORMAT_* constants.
|
|
|
|
|
// *
|
|
|
|
|
// * @return array Array with the parameter type (either "before" or "after") and the value.
|
|
|
|
|
// */
|
|
|
|
|
// protected function extractParam( $param, $format ) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Extracts the parameter type and preprocessed the value if needed.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.18
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $param Parameter as defined in this cls.
|
|
|
|
|
* @param String $format One of the FORMAT_* constants.
|
|
|
|
|
*
|
|
|
|
|
* @return array Array with the parameter type (either "before" or "after") and the value.
|
|
|
|
|
*/
|
|
|
|
|
// private void extractParam(XomwMessageVal rv, Object param, int format) {
|
|
|
|
|
// if (is_array($param)) {
|
|
|
|
|
// if (isset($param['raw'])) {
|
|
|
|
|
// return [ 'after', $param['raw'] ];
|
|
|
|
|
// } elseif (isset($param['num'])) {
|
|
|
|
|
// // Replace number prmsVar always in before step for now.
|
|
|
|
|
// // No support for combined raw and num prmsVar
|
|
|
|
|
// return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->formatNum($param['num']) ];
|
|
|
|
|
// } elseif (isset($param['duration'])) {
|
|
|
|
|
// return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->formatDuration($param['duration']) ];
|
|
|
|
|
// } elseif (isset($param['expiry'])) {
|
|
|
|
|
// return [ 'before', $this->getLanguage()->formatExpiry( $param['expiry'] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->formatExpiry($param['expiry']) ];
|
|
|
|
|
// } elseif (isset($param['period'])) {
|
|
|
|
|
// return [ 'before', $this->getLanguage()->formatTimePeriod( $param['period'] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->formatTimePeriod($param['period']) ];
|
|
|
|
|
// } elseif (isset($param['size'])) {
|
|
|
|
|
// return [ 'before', $this->getLanguage()->formatSize( $param['size'] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->formatSize($param['size']) ];
|
|
|
|
|
// } elseif (isset($param['bitrate'])) {
|
|
|
|
|
// return [ 'before', $this->getLanguage()->formatBitrate( $param['bitrate'] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->formatBitrate($param['bitrate']) ];
|
|
|
|
|
// } elseif (isset($param['plaintext'])) {
|
|
|
|
|
// return [ 'after', $this->formatPlaintext( $param['plaintext'], $format ) ];
|
|
|
|
|
// return [ 'after', this.formatPlaintext($param['plaintext'], $format) ];
|
|
|
|
|
// } elseif (isset($param['list'])) {
|
|
|
|
|
// return $this->formatListParam( $param['list'], $param['type'], $format );
|
|
|
|
|
// return this.formatListParam($param['list'], $param['type'], $format);
|
|
|
|
|
// } else {
|
|
|
|
|
// $warning = 'Invalid parameter for message "' . $this->getKey() . '": ' .
|
|
|
|
|
// $warning = 'Invalid parameter for message "' . this.getKey() . '": ' .
|
|
|
|
|
// htmlspecialchars(serialize($param));
|
|
|
|
|
// trigger_error($warning, E_USER_WARNING);
|
|
|
|
|
// $e = new Exception;
|
|
|
|
|
@@ -1187,17 +1192,18 @@ public class XomwMessage {
|
|
|
|
|
//
|
|
|
|
|
// return [ 'before', '[INVALID]' ];
|
|
|
|
|
// }
|
|
|
|
|
// } elseif ( $param instanceof Message ) {
|
|
|
|
|
// }
|
|
|
|
|
// else if ($param instanceof Message) {
|
|
|
|
|
// // Match language, flags, etc. to the current message.
|
|
|
|
|
// $msg = clone $param;
|
|
|
|
|
// if ( $msg->language !== $this->language || $msg->useDatabase !== $this->useDatabase ) {
|
|
|
|
|
// if ($msg->language !== this.language || $msg->useDatabase !== this.useDatabase) {
|
|
|
|
|
// // Cache depends on these parameters
|
|
|
|
|
// $msg->message = null;
|
|
|
|
|
// }
|
|
|
|
|
// $msg->interfaceIsUserLang = $this->interfaceIsUserLang;
|
|
|
|
|
// $msg->language = $this->language;
|
|
|
|
|
// $msg->useDatabase = $this->useDatabase;
|
|
|
|
|
// $msg->title = $this->title;
|
|
|
|
|
// $msg->interfaceIsUserLang = this.interfaceIsUserLang;
|
|
|
|
|
// $msg->language = this.language;
|
|
|
|
|
// $msg->useDatabase = this.useDatabase;
|
|
|
|
|
// $msg->title = this.title;
|
|
|
|
|
//
|
|
|
|
|
// // DWIM
|
|
|
|
|
// if ($format === 'block-parse') {
|
|
|
|
|
@@ -1209,11 +1215,12 @@ public class XomwMessage {
|
|
|
|
|
// // then they'll get double escaped. If the message needs to be
|
|
|
|
|
// // escaped, it'll happen right here when we call toString().
|
|
|
|
|
// return [ 'after', $msg->toString($format) ];
|
|
|
|
|
// } else {
|
|
|
|
|
// return [ 'before', $param ];
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// rv.Set(PRM_TID_BEFORE, param);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * Wrapper for what ever method we use to parse wikitext.
|
|
|
|
|
// *
|
|
|
|
|
@@ -1226,10 +1233,10 @@ public class XomwMessage {
|
|
|
|
|
// protected function parseText($String) {
|
|
|
|
|
// $out = MessageCache::singleton()->parse(
|
|
|
|
|
// $String,
|
|
|
|
|
// $this->title,
|
|
|
|
|
// this.title,
|
|
|
|
|
// /*linestart*/true,
|
|
|
|
|
// $this->interfaceIsUserLang,
|
|
|
|
|
// $this->getLanguage()
|
|
|
|
|
// this.interfaceIsUserLang,
|
|
|
|
|
// this.getLanguage()
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// return $out instanceof ParserOutput ? $out->getText() : $out;
|
|
|
|
|
@@ -1247,9 +1254,9 @@ public class XomwMessage {
|
|
|
|
|
// protected function transformText($String) {
|
|
|
|
|
// return MessageCache::singleton()->transform(
|
|
|
|
|
// $String,
|
|
|
|
|
// $this->interfaceIsUserLang,
|
|
|
|
|
// $this->getLanguage(),
|
|
|
|
|
// $this->title
|
|
|
|
|
// this.interfaceIsUserLang,
|
|
|
|
|
// this.getLanguage(),
|
|
|
|
|
// this.title
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
@@ -1262,11 +1269,11 @@ public class XomwMessage {
|
|
|
|
|
// * @throws MWException If message key array is empty.
|
|
|
|
|
// */
|
|
|
|
|
// protected function fetchMessage() {
|
|
|
|
|
// if ( $this->message === null ) {
|
|
|
|
|
// if (this.message === null) {
|
|
|
|
|
// $cache = MessageCache::singleton();
|
|
|
|
|
//
|
|
|
|
|
// foreach ( $this->keysToTry as key ) {
|
|
|
|
|
// $message = $cache->get( key, $this->useDatabase, $this->getLanguage() );
|
|
|
|
|
// foreach (this.keysToTry as key) {
|
|
|
|
|
// $message = $cache->get(key, this.useDatabase, this.getLanguage());
|
|
|
|
|
// if ($message !== false && $message !== '') {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
@@ -1274,10 +1281,10 @@ public class XomwMessage {
|
|
|
|
|
//
|
|
|
|
|
// // NOTE: The constructor makes sure keysToTry isn't empty,
|
|
|
|
|
// // so we know that key and $message are initialized.
|
|
|
|
|
// $this->key = key;
|
|
|
|
|
// $this->message = $message;
|
|
|
|
|
// this.key = key;
|
|
|
|
|
// this.message = $message;
|
|
|
|
|
// }
|
|
|
|
|
// return $this->message;
|
|
|
|
|
// return this.message;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
@@ -1317,7 +1324,7 @@ public class XomwMessage {
|
|
|
|
|
// */
|
|
|
|
|
// protected function formatListParam(array $prmsVar, $listType, $format) {
|
|
|
|
|
// if (!isset(self::$listTypeMap[$listType])) {
|
|
|
|
|
// $warning = 'Invalid list type for message "' . $this->getKey() . '": '
|
|
|
|
|
// $warning = 'Invalid list type for message "' . this.getKey() . '": '
|
|
|
|
|
// . htmlspecialchars($listType)
|
|
|
|
|
// . ' (prmsVar are ' . htmlspecialchars(serialize($prmsVar)) . ')';
|
|
|
|
|
// trigger_error($warning, E_USER_WARNING);
|
|
|
|
|
@@ -1329,7 +1336,7 @@ public class XomwMessage {
|
|
|
|
|
//
|
|
|
|
|
// // Handle an empty list sensibly
|
|
|
|
|
// if (!$prmsVar) {
|
|
|
|
|
// return [ 'before', $this->getLanguage()->$func( [] ) ];
|
|
|
|
|
// return [ 'before', this.getLanguage()->$func([]) ];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // First, determine what kinds of list items we have
|
|
|
|
|
@@ -1337,7 +1344,7 @@ public class XomwMessage {
|
|
|
|
|
// $vars = [];
|
|
|
|
|
// $list = [];
|
|
|
|
|
// foreach ($prmsVar as $n => $p) {
|
|
|
|
|
// list( $type, $value ) = $this->extractParam( $p, $format );
|
|
|
|
|
// list($type, $value) = this.extractParam($p, $format);
|
|
|
|
|
// $types[$type] = true;
|
|
|
|
|
// $list[] = $value;
|
|
|
|
|
// $vars[] = '$' . ($n + 1);
|
|
|
|
|
@@ -1346,13 +1353,81 @@ public class XomwMessage {
|
|
|
|
|
// // Easy case: all are 'before' or 'after', so just join the
|
|
|
|
|
// // values and use the same type.
|
|
|
|
|
// if (count($types) === 1) {
|
|
|
|
|
// return [ key( $types ), $this->getLanguage()->$func( $list ) ];
|
|
|
|
|
// return [ key($types), this.getLanguage()->$func($list) ];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // Hard case: We need to process each value per its type, then
|
|
|
|
|
// // return the concatenated values as 'after'. We handle this by turning
|
|
|
|
|
// // the list into a RawMessage and processing that as a parameter.
|
|
|
|
|
// $vars = $this->getLanguage()->$func( $vars );
|
|
|
|
|
// return $this->extractParam( new RawMessage( $vars, $prmsVar ), $format );
|
|
|
|
|
// $vars = this.getLanguage()->$func($vars);
|
|
|
|
|
// return this.extractParam(new RawMessage($vars, $prmsVar), $format);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
class XomwMessageVal {
|
|
|
|
|
public int tid;
|
|
|
|
|
public Object val;
|
|
|
|
|
public void Set(int tid, Object val) {
|
|
|
|
|
this.tid = tid;
|
|
|
|
|
this.val = val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
abstract class XomwMessagePrm {
|
|
|
|
|
public XomwMessagePrm(int tid) {this.tid = tid;}
|
|
|
|
|
public int Tid() {return tid;} private int tid;
|
|
|
|
|
public static final int
|
|
|
|
|
Tid__raw = 0
|
|
|
|
|
, Tid__num = 1
|
|
|
|
|
, Tid__duration = 2
|
|
|
|
|
, Tid__expiry = 3
|
|
|
|
|
, Tid__period = 4
|
|
|
|
|
, Tid__size = 5
|
|
|
|
|
, Tid__bitrate = 6
|
|
|
|
|
, Tid__plaintext = 7
|
|
|
|
|
, Tid__list = 8
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_raw extends XomwMessagePrm { public byte[] raw;
|
|
|
|
|
public XomwMessagePrm_raw(byte[] raw) {super(Tid__raw);
|
|
|
|
|
this.raw = raw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_num extends XomwMessagePrm { public int num;
|
|
|
|
|
public XomwMessagePrm_num(int num) {super(Tid__num);
|
|
|
|
|
this.num = num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_duration extends XomwMessagePrm { public int duration;
|
|
|
|
|
public XomwMessagePrm_duration(int duration) {super(Tid__duration);
|
|
|
|
|
this.duration = duration;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_expiry extends XomwMessagePrm { public byte[] expiry;
|
|
|
|
|
public XomwMessagePrm_expiry(byte[] expiry) {super(Tid__expiry);
|
|
|
|
|
this.expiry = expiry;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_period extends XomwMessagePrm { public int period;
|
|
|
|
|
public XomwMessagePrm_period(int period) {super(Tid__period);
|
|
|
|
|
this.period = period;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_size extends XomwMessagePrm { public int size;
|
|
|
|
|
public XomwMessagePrm_size(int size) {super(Tid__size);
|
|
|
|
|
this.size = size;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_bitrate extends XomwMessagePrm { public int bitrate;
|
|
|
|
|
public XomwMessagePrm_bitrate(int bitrate) {super(Tid__bitrate);
|
|
|
|
|
this.bitrate = bitrate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_plaintext extends XomwMessagePrm { public byte[] plaintext;
|
|
|
|
|
public XomwMessagePrm_plaintext(byte[] plaintext) {super(Tid__plaintext);
|
|
|
|
|
this.plaintext = plaintext;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
class XomwMessagePrm_list extends XomwMessagePrm { public byte[][] list;
|
|
|
|
|
public XomwMessagePrm_list(byte[][] list) {super(Tid__list);
|
|
|
|
|
this.list = list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|