Xomw: Add more implementation for XomwMessage

pull/620/head
gnosygnu 7 years ago
parent 67787c720a
commit 3023353154

@ -4071,14 +4071,14 @@ public class XomwDefaultSettings {
// * intermixed, could place NS_MAIN and NS_PROJECT namespaces in this array.
// */
// $wgExtraSignatureNamespaces = [];
//
// /**
// * Max number of redirects to follow when resolving redirects.
// * 1 means only the first redirect is followed (default behavior).
// * 0 or less means no redirects are followed.
// */
// $wgMaxRedirects = 1;
//
/**
* Max number of redirects to follow when resolving redirects.
* 1 means only the first redirect is followed (default behavior).
* 0 or less means no redirects are followed.
*/
public static final int wgMaxRedirects = 1;
// /**
// * Array of invalid page redirect targets.
// * Attempting to create a redirect to any of the pages in this array

@ -15,6 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
import gplx.xowa.mediawiki.languages.*;
import gplx.xowa.mediawiki.includes.content.*;
/**
* The Message cls provides methods which fulfil two basic services:
* - fetching interfaceIsUserLang messages
@ -59,7 +60,7 @@ import gplx.xowa.mediawiki.languages.*;
*
* @code
* wfMessage( 'welcome-to' )
* -> $wgSitename )
* ->prmsVar( $wgSitename )
* ->text();
* @endcode
*
@ -162,6 +163,8 @@ public class XomwMessage {
/** Transform {{..}} constructs, HTML-escape the result */
private static final int FORMAT_ESCAPED = 4; // 'escaped';
private static final int FORMAT_NULL = 5;
/**
* Mapping from Message::listParam() types to Language methods.
* @var array
@ -192,10 +195,10 @@ public class XomwMessage {
* @var String The message key. If $keysToTry has more than one element,
* this may change to one of the keys to try when fetching the message text.
*/
private String key;
private byte[] key;
/**
* @var String... List of keys to try when fetching the message.
* @var String[] List of keys to try when fetching the message.
*/
private String[] keysToTry;
@ -223,7 +226,7 @@ public class XomwMessage {
/**
* @var Content Content Object representing the message.
*/
// protected $content = null;
// private XomwContent content = null;
/**
* @var String
@ -246,18 +249,18 @@ public class XomwMessage {
// * @param String|String[]|MessageSpecifier key Message key, or array of
// * message keys to try and use the first non-empty message for, or a
// * MessageSpecifier to copy from.
// * @param array $params Message parameters.
// * @param array $prmsVar Message parameters.
// * @param Language $language [optional] Language to use (defaults to current user language).
// * @throws InvalidArgumentException
// */
// public function __construct( key, $params = [], Language $language = null ) {
// public function __construct( key, $prmsVar = [], Language $language = null ) {
// if ( key instanceof MessageSpecifier ) {
// if ( $params ) {
// if ( $prmsVar ) {
// throw new InvalidArgumentException(
// '$params must be empty if key is a MessageSpecifier'
// '$prmsVar must be empty if key is a MessageSpecifier'
// );
// }
// $params = key->getParams();
// $prmsVar = key->getParams();
// key = key->getKey();
// }
//
@ -273,7 +276,7 @@ public class XomwMessage {
//
// $this->key = reset( $this->keysToTry );
//
// $this->parameters = array_values( $params );
// $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;
@ -398,14 +401,14 @@ public class XomwMessage {
// * @return Message
// */
// public static function newFromKey( key /*...*/ ) {
// $params = func_get_args();
// array_shift( $params );
// return new self( key, $params );
// $prmsVar = func_get_args();
// array_shift( $prmsVar );
// return new self( key, $prmsVar );
// }
//
// /**
// * Transform a MessageSpecifier or a primitive value used interchangeably with
// * specifiers (a message key String, or a key + params array) into a proper Message.
// * specifiers (a message key String, or a key + prmsVar array) into a proper Message.
// *
// * Also accepts a MessageSpecifier inside an array: that's not considered a valid format
// * but is an easy error to make due to how StatusValue stores messages internally.
@ -417,10 +420,10 @@ public class XomwMessage {
// * @since 1.27
// */
// public static function newFromSpecifier( $value ) {
// $params = [];
// $prmsVar = [];
// if ( is_array( $value ) ) {
// $params = $value;
// $value = array_shift( $params );
// $prmsVar = $value;
// $value = array_shift( $prmsVar );
// }
//
// if ( $value instanceof Message ) { // Message, RawMessage, ApiMessage, etc
@ -428,7 +431,7 @@ public class XomwMessage {
// } elseif ( $value instanceof MessageSpecifier ) {
// $message = new Message( $value );
// } elseif ( is_string( $value ) ) {
// $message = new Message( $value, $params );
// $message = new Message( $value, $prmsVar );
// } else {
// throw new InvalidArgumentException( __METHOD__ . ': invalid argument type '
// . gettype( $value ) );
@ -498,7 +501,7 @@ public class XomwMessage {
// *
// * @return Message $this
// */
// public function params( /*...*/ ) {
// public function prmsVar( /*...*/ ) {
// $args = func_get_args();
//
// // If $args has only one entry and it's an array, then it's either a
@ -530,17 +533,17 @@ public class XomwMessage {
// *
// * @since 1.17
// *
// * @param mixed $params,... Raw parameters as strings, or a single argument that is
// * @param mixed $prmsVar,... Raw parameters as strings, or a single argument that is
// * an array of raw parameters.
// *
// * @return Message $this
// */
// public function rawParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::rawParam( $param );
// }
// return $this;
@ -558,11 +561,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function numParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::numParam( $param );
// }
// return $this;
@ -580,11 +583,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function durationParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::durationParam( $param );
// }
// return $this;
@ -602,11 +605,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function expiryParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::expiryParam( $param );
// }
// return $this;
@ -624,11 +627,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function timeperiodParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::timeperiodParam( $param );
// }
// return $this;
@ -646,11 +649,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function sizeParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::sizeParam( $param );
// }
// return $this;
@ -668,11 +671,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function bitrateParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::bitrateParam( $param );
// }
// return $this;
@ -692,11 +695,11 @@ public class XomwMessage {
// * @return Message $this
// */
// public function plaintextParams( /*...*/ ) {
// $params = func_get_args();
// if ( isset( $params[0] ) && is_array( $params[0] ) ) {
// $params = $params[0];
// $prmsVar = func_get_args();
// if ( isset( $prmsVar[0] ) && is_array( $prmsVar[0] ) ) {
// $prmsVar = $prmsVar[0];
// }
// foreach ( $params as $param ) {
// foreach ( $prmsVar as $param ) {
// $this->parameters[] = self::plaintextParam( $param );
// }
// return $this;
@ -814,81 +817,84 @@ public class XomwMessage {
// $this->title = title;
// return $this;
// }
//
// /**
// * Returns the message as a Content Object.
// *
// * @return Content
// */
// public function content() {
// if ( !$this->content ) {
// $this->content = new MessageContent( $this );
// }
//
// return $this->content;
// }
//
// /**
// * Returns the message parsed from wikitext to HTML.
// *
// * @since 1.17
// *
// * @param String|null $format One of the FORMAT_* constants. Null means use whatever was used
// * the last time (this is for B/C and should be avoided).
// *
// * @return String HTML
// */
// public function toString( $format = null ) {
// if ( $format === null ) {
// $ex = new LogicException( __METHOD__ . ' using implicit format: ' . $this->format );
// \MediaWiki\Logger\LoggerFactory::getInstance( 'message-format' )->warning(
// $ex->getMessage(), [ 'exception' => $ex, 'format' => $this->format, 'key' => $this->key ] );
// $format = $this->format;
// }
// $String = $this->fetchMessage();
//
// if ( $String === false ) {
// // Err on the side of safety, ensure that the output
// // is always html safe in the event the message key is
// // missing, since in that case its highly likely the
// // message key is user-controlled.
// // '⧼' is used instead of '<' to side-step any
// // double-escaping issues.
// // (Keep synchronised with mw.Message#toString in JS.)
// return '⧼' . htmlspecialchars( $this->key ) . '⧽';
/**
* Returns the message as a Content Object.
*
* @return Content
*/
public XomwContent contentFunc() {
// if (this.content == null) {
// this.content = new XomwMessageContent(this);
// }
//
// # Replace $* with a list of parameters for &uselang=qqx.
// if ( strpos( $String, '$*' ) !== false ) {
// $paramlist = '';
// if ( $this->parameters !== [] ) {
// $paramlist = ': $' . implode( ', $', range( 1, count( $this->parameters ) ) );
// return this.content;
throw Err_.new_unimplemented();
}
/**
* Returns the message parsed from wikitext to HTML.
*
* @since 1.17
*
* @param String|null $format One of the FORMAT_* constants. Null means use whatever was used
* the last time (this is for B/C and should be avoided).
*
* @return String HTML
*/
// 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);
public byte[] toString(int format) {
if (format == FORMAT_NULL) {
Gfo_usr_dlg_.Instance.Warn_many("", "", "toString import implicit.*; format=~{0} key=~{1}", format, key);
format = this.format;
}
// byte[] s = this.fetchMessage();
byte[] s = Bry_.Empty;
if (s == null) {
// Err on the side of safety, ensure that the output
// is always html safe in the event the message key is
// missing, since in that case its highly likely the
// message key is user-controlled.
// LeftPointingCurvedAngleBracket is used instead of '<' to side-step any
// double-escaping issues.
// (Keep synchronised with mw.Message#toString in JS.)
return Bry_.Escape_html(Bry_.Add(LeftPointingCurvedAngleBracket, key, LeftPointingCurvedAngleBracket));
}
// // Replace $* with a list of parameters for &uselang=qqx.
// if (strpos(s, "$*") != false) {
// String paramlist = "";
// if (this.parameters != []) {
// paramlist = ": $" . implode(", $", range(1, count(this.parameters)));
// }
// $String = str_replace( '$*', $paramlist, $String );
// s = str_replace("$*", paramlist, s);
// }
//
// # Replace parameters before text parsing
// $String = $this->replaceParameters( $String, 'before', $format );
//
// # Maybe transform using the full parser
// if ( $format === self::FORMAT_PARSE ) {
// $String = $this->parseText( $String );
// $String = Parser::stripOuterParagraph( $String );
// } elseif ( $format === self::FORMAT_BLOCK_PARSE ) {
// $String = $this->parseText( $String );
// } elseif ( $format === self::FORMAT_TEXT ) {
// $String = $this->transformText( $String );
// } elseif ( $format === self::FORMAT_ESCAPED ) {
// $String = $this->transformText( $String );
// $String = htmlspecialchars( $String, ENT_QUOTES, 'UTF-8', false );
// // Replace parameters before text parsing
// s = this.replaceParameters(s, "before", format);
//
// // Maybe transform using the full parser
// if (format == XomwMessage.FORMAT_PARSE) {
// s = this.parseText(s);
// s = Parser::stripOuterParagraph(s);
// } elseif (format == XomwMessage.FORMAT_BLOCK_PARSE) {
// s = this.parseText(s);
// } elseif (format == XomwMessage.FORMAT_TEXT) {
// s = this.transformText(s);
// } elseif (format == XomwMessage.FORMAT_ESCAPED) {
// s = this.transformText(s);
// s = htmlspecialchars(s, ENT_QUOTES, "UTF-8", false);
// }
//
// # Raw parameter replacement
// $String = $this->replaceParameters( $String, 'after', $format );
//
// return $String;
// }
//
// // Raw parameter replacement
// s = this.replaceParameters(s, "after", format);
return s;
}
// /**
// * Magic method implementation of the above (for PHP >= 5.2.0), so we can do, eg:
// * $foo = new Message( key );
@ -927,19 +933,19 @@ public class XomwMessage {
// $this->format = self::FORMAT_PARSE;
// return $this->toString( self::FORMAT_PARSE );
// }
//
// /**
// * Returns the message text. {{-transformation is done.
// *
// * @since 1.17
// *
// * @return String Unescaped message text.
// */
// public function text() {
// $this->format = self::FORMAT_TEXT;
// return $this->toString( self::FORMAT_TEXT );
// }
//
/**
* Returns the message text. {{-transformation is done.
*
* @since 1.17
*
* @return String Unescaped message text.
*/
public byte[] textMw() {
this.format = XomwMessage.FORMAT_TEXT;
return this.toString(XomwMessage.FORMAT_TEXT);
}
// /**
// * Returns the message text as-is, only parameters are substituted.
// *
@ -1155,8 +1161,8 @@ public class XomwMessage {
// if ( isset( $param['raw'] ) ) {
// return [ 'after', $param['raw'] ];
// } elseif ( isset( $param['num'] ) ) {
// // Replace number params always in before step for now.
// // No support for combined raw and num params
// // Replace number prmsVar always in before step for now.
// // No support for combined raw and num prmsVar
// return [ 'before', $this->getLanguage()->formatNum( $param['num'] ) ];
// } elseif ( isset( $param['duration'] ) ) {
// return [ 'before', $this->getLanguage()->formatDuration( $param['duration'] ) ];
@ -1304,16 +1310,16 @@ public class XomwMessage {
// /**
// * Formats a list of parameters as a concatenated String.
// * @since 1.29
// * @param array $params
// * @param array $prmsVar
// * @param String $listType
// * @param String $format One of the FORMAT_* constants.
// * @return array Array with the parameter type (either "before" or "after") and the value.
// */
// protected function formatListParam( array $params, $listType, $format ) {
// protected function formatListParam( array $prmsVar, $listType, $format ) {
// if ( !isset( self::$listTypeMap[$listType] ) ) {
// $warning = 'Invalid list type for message "' . $this->getKey() . '": '
// . htmlspecialchars( $listType )
// . ' (params are ' . htmlspecialchars( serialize( $params ) ) . ')';
// . ' (prmsVar are ' . htmlspecialchars( serialize( $prmsVar ) ) . ')';
// trigger_error( $warning, E_USER_WARNING );
// $e = new Exception;
// wfDebugLog( 'Bug58676', $warning . "\n" . $e->getTraceAsString() );
@ -1322,7 +1328,7 @@ public class XomwMessage {
// $func = self::$listTypeMap[$listType];
//
// // Handle an empty list sensibly
// if ( !$params ) {
// if ( !$prmsVar ) {
// return [ 'before', $this->getLanguage()->$func( [] ) ];
// }
//
@ -1330,7 +1336,7 @@ public class XomwMessage {
// $types = [];
// $vars = [];
// $list = [];
// foreach ( $params as $n => $p ) {
// foreach ( $prmsVar as $n => $p ) {
// list( $type, $value ) = $this->extractParam( $p, $format );
// $types[$type] = true;
// $list[] = $value;
@ -1347,6 +1353,6 @@ public class XomwMessage {
// // 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, $params ), $format );
// return $this->extractParam( new RawMessage( $vars, $prmsVar ), $format );
// }
}

@ -26,7 +26,7 @@ import gplx.xowa.mediawiki.includes.parsers.*;
*
* @ingroup Content
*/
abstract class XomwAbstractContent implements XomwContent {
public abstract class XomwAbstractContent implements XomwContent {
/**
* Name of the content model this Content Object represents.
* Use with CONTENT_MODEL_XXX constants
@ -117,160 +117,164 @@ abstract class XomwAbstractContent implements XomwContent {
return this.getContentHandler().isSupportedFormat(format);
}
// /**
// * @since 1.21
// *
// * @param String $format The serialization format to check.
// *
// * @throws MWException If the format is not supported by this content handler.
// */
// protected function checkFormat($format) {
// if (!this.isSupportedFormat($format)) {
// throw new MWException(
// "Format $format is not supported for content model " .
// this.getModel()
// );
// }
// }
//
// /**
// * @since 1.21
// *
// * @param String $format
// *
// * @return String
// *
// * @see Content::serialize
// */
// public function serialize($format = null) {
// return this.getContentHandler().serializeContent($this, $format);
// }
//
// /**
// * @since 1.21
// *
// * @return boolean
// *
// * @see Content::isEmpty
// */
// public function isEmpty() {
// return this.getSize() === 0;
// }
//
// /**
// * Subclasses may override this to implement (light weight) validation.
// *
// * @since 1.21
// *
// * @return boolean Always true.
// *
// * @see Content::isValid
// */
// public function isValid() {
// return true;
// }
//
// /**
// * @since 1.21
// *
// * @param Content $that
// *
// * @return boolean
// *
// * @see Content::equals
// */
// public function equals(Content $that = null) {
// if (is_null($that)) {
// return false;
// }
//
// if ($that === $this) {
// return true;
// }
//
// if ($that.getModel() !== this.getModel()) {
// return false;
// }
//
// return this.getNativeData() === $that.getNativeData();
// }
//
// /**
// * Returns a list of DataUpdate objects for recording information about this
// * Content in some secondary data store.
// *
// * This default implementation returns a LinksUpdate Object and calls the
// * SecondaryDataUpdates hook.
// *
// * Subclasses may override this to determine the secondary data updates more
// * efficiently, preferably without the need to generate a parser output Object.
// * They should however make sure to call SecondaryDataUpdates to give extensions
// * a chance to inject additional updates.
// *
// * @since 1.21
// *
// * @param Title $title
// * @param Content $old
// * @param boolean $recursive
// * @param ParserOutput $parserOutput
// *
// * @return DataUpdate[]
// *
// * @see Content::getSecondaryDataUpdates()
// */
// public function getSecondaryDataUpdates(Title $title, Content $old = null,
// $recursive = true, ParserOutput $parserOutput = null
/**
* @since 1.21
*
* @param String $format The serialization format to check.
*
* @throws MWException If the format is not supported by this content handler.
*/
public void checkFormat(String format) {
if (!this.isSupportedFormat(format)) {
throw new XomwMWException(
"Format " + format + " is not supported for content model " +
this.getModel()
);
}
}
/**
* @since 1.21
*
* @param String $format
*
* @return String
*
* @see Content::serialize
*/
public String serialize(String format) {
// return this.getContentHandler().serializeContent(this, format);
throw Err_.new_unimplemented();
}
/**
* @since 1.21
*
* @return boolean
*
* @see Content::isEmpty
*/
public boolean isEmpty() {
return this.getSize() == 0;
}
/**
* Subclasses @Override may this to implement (light weight) validation.
*
* @since 1.21
*
* @return boolean Always true.
*
* @see Content::isValid
*/
@gplx.Virtual public boolean isValid() {
return true;
}
/**
* @since 1.21
*
* @param Content that
*
* @return boolean
*
* @see Content::equals
*/
public boolean equals(XomwContent that) {
if (that == null) {
return false;
}
if (that == this) {
return true;
}
if (that.getModel() != this.getModel()) {
return false;
}
return this.getNativeData() == that.getNativeData();
}
/**
* Returns a list of DataUpdate objects for recording information about this
* Content in some secondary data store.
*
* This default implementation returns a LinksUpdate Object and calls the
* SecondaryDataUpdates hook.
*
* Subclasses @Override may this to determine the secondary data updates more
* efficiently, preferably without the need to generate a parser output Object.
* They should however make sure to call SecondaryDataUpdates to give extensions
* a chance to inject additional updates.
*
* @since 1.21
*
* @param Title $title
* @param Content $old
* @param boolean $recursive
* @param ParserOutput parserOutput
*
* @return DataUpdate[]
*
* @see Content::getSecondaryDataUpdates()
*/
// recursive=true
// public XomwDataUpdate[] getSecondaryDataUpdates(Title title, Content old,
// boolean recursive, ParserOutput parserOutput
// ) {
// if ($parserOutput === null) {
// $parserOutput = this.getParserOutput($title, null, null, false);
// if (parserOutput == null) {
// parserOutput = this.getParserOutput(title, null, null, false);
// }
//
// $updates = [
// new LinksUpdate($title, $parserOutput, $recursive)
// ];
// XomwDataUpdate[] updates = new XomwDataUpdate[] {
// new LinksUpdate(title, parserOutput, recursive)
// };
//
// Hooks::run('SecondaryDataUpdates', [ $title, $old, $recursive, $parserOutput, &$updates ]);
// Hooks::run('SecondaryDataUpdates', [ $title, $old, $recursive, parserOutput, &$updates ]);
//
// return $updates;
// return updates;
// }
//
// /**
// * @since 1.21
// *
// * @return Title[]|null
// *
// * @see Content::getRedirectChain
// */
// public function getRedirectChain() {
// global $wgMaxRedirects;
// $title = this.getRedirectTarget();
// if (is_null($title)) {
/**
* @since 1.21
*
* @return Title[]|null
*
* @see Content::getRedirectChain
*/
public XomwTitle[] getRedirectChain() {
// XomwTitle title = this.getRedirectTarget();
// if (title == null) {
// return null;
// }
// // recursive check to follow double redirects
// $recurse = $wgMaxRedirects;
// $titles = [ $title ];
// while (--$recurse > 0) {
// if ($title.isRedirect()) {
// $page = WikiPage::factory($title);
// int recurse = XomwDefaultSettings.wgMaxRedirects;
//
// List_adp titles = List_adp_.New_by_many(title);
// while (--recurse > 0) {
// XomwTitle newtitle = null;
// if (title.isRedirect()) {
// $page = WikiPage::factory(title);
// $newtitle = $page.getRedirectTarget();
// } else {
// break;
// }
// // Redirects to some special pages are not permitted
// if ($newtitle instanceof Title && $newtitle.isValidRedirectTarget()) {
// if (Type_adp_.Eq_typeSafe(newtitle, typeof(XomwTitle)) && newtitle.isValidRedirectTarget()) {
// // The new title passes the checks, so make that our current
// // title so that further recursion can be checked
// $title = $newtitle;
// $titles[] = $newtitle;
// title = newtitle;
// titles.Add(newtitle);
// } else {
// break;
// }
// }
//
// return $titles;
// }
//
// return (XomwTitle[])titles.To_ary_and_clear(typeof(XomwTitle));
throw Err_.new_unimplemented();
}
// /**
// * Subclasses that implement redirects should override this.
// *
@ -307,7 +311,7 @@ abstract class XomwAbstractContent implements XomwContent {
// * @see Content::isRedirect
// */
// public function isRedirect() {
// return this.getRedirectTarget() !== null;
// return this.getRedirectTarget() != null;
// }
//
// /**
@ -400,34 +404,34 @@ abstract class XomwAbstractContent implements XomwContent {
// * @since 1.21
// *
// * @param WikiPage $page
// * @param ParserOutput $parserOutput
// * @param ParserOutput parserOutput
// *
// * @return LinksDeletionUpdate[]
// *
// * @see Content::getDeletionUpdates
// */
// public function getDeletionUpdates(WikiPage $page, ParserOutput $parserOutput = null) {
// public function getDeletionUpdates(WikiPage $page, ParserOutput parserOutput = null) {
// return [
// new LinksDeletionUpdate($page),
// ];
// }
//
// /**
// * This default implementation always returns false. Subclasses may override
// * this to supply matching logic.
// *
// * @since 1.21
// *
// * @param MagicWord $word
// *
// * @return boolean Always false.
// *
// * @see Content::matchMagicWord
// */
// public function matchMagicWord(MagicWord $word) {
// return false;
// }
//
/**
* This default implementation always returns false. Subclasses @Override may
* this to supply matching logic.
*
* @since 1.21
*
* @param MagicWord $word
*
* @return boolean Always false.
*
* @see Content::matchMagicWord
*/
@gplx.Virtual public boolean matchMagicWord(XomwMagicWord word) {
return false;
}
// /**
// * This super implementation calls the hook ConvertContent to enable custom conversions.
// * Subclasses may override this to implement conversion for "their" content model.
@ -440,12 +444,12 @@ abstract class XomwAbstractContent implements XomwContent {
// * @see Content::convert()
// */
// public function convert($toModel, $lossy = '') {
// if (this.getModel() === $toModel) {
// if (this.getModel() == $toModel) {
// // nothing to do, shorten out.
// return $this;
// }
//
// $lossy = ($lossy === 'lossy'); // String flag, convert to boolean for convenience
// $lossy = ($lossy == 'lossy'); // String flag, convert to boolean for convenience
// $result = false;
//
// Hooks::run('ConvertContent', [ $this, $toModel, $lossy, &$result ]);
@ -476,7 +480,7 @@ abstract class XomwAbstractContent implements XomwContent {
// public function getParserOutput(Title $title, $revId = null,
// ParserOptions $options = null, $generateHtml = true
// ) {
// if ($options === null) {
// if ($options == null) {
// $options = this.getContentHandler().makeParserOptions('canonical');
// }
//
@ -534,14 +538,6 @@ abstract class XomwAbstractContent implements XomwContent {
public abstract int getSize();
public abstract byte[] serialize(byte[] format);
public abstract boolean isEmpty();
public abstract boolean isValid();
public abstract boolean equals(XomwContent that);
public abstract XomwContent copy();
public abstract boolean isCountable(boolean hasLinks);
@ -552,8 +548,6 @@ abstract class XomwAbstractContent implements XomwContent {
public abstract Object getSecondaryDataUpdates(XomwTitle title, XomwContent old,
boolean recursive, XomwParserOutput parserOutput);
public abstract XomwTitle[] getRedirectChain();
public abstract XomwTitle getRedirectTarget();
public abstract XomwTitle getUltimateRedirectTarget();
@ -577,7 +571,5 @@ abstract class XomwAbstractContent implements XomwContent {
public abstract Object getDeletionUpdates(Object page,
XomwParserOutput parserOutput);
public abstract boolean matchMagicWord(XomwMagicWord word);
public abstract XomwContent convert(byte[] toModel, byte[] lossy);
}

@ -25,7 +25,7 @@ import gplx.xowa.mediawiki.includes.parsers.*;
*
* @ingroup Content
*/
interface XomwContent {
public interface XomwContent {
/**
* @since 1.21
@ -161,7 +161,7 @@ interface XomwContent {
*
* @return String Serialized form of this Content Object.
*/
byte[] serialize(byte[] format);
String serialize(String format);
/**
* Returns true if this Content Object represents empty content.

@ -33,7 +33,7 @@ package gplx.xowa.mediawiki.includes.content; import gplx.*; import gplx.xowa.*;
*
* @ingroup Content
*/
abstract class XomwContentHandler {
public abstract class XomwContentHandler {
// /**
// * Convenience function for getting flat text from a Content Object. This
// * should only be used in the context of backwards compatibility with code

@ -1 +1 @@
add hindi and tibetan wikis
v4.5.0.1703: app_update

Loading…
Cancel
Save