mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Wikibase: Reorganize Wikibase classes; add some basic support for formatters [#593]
This commit is contained in:
parent
7971f71dc3
commit
a453ebd4cb
@ -13,9 +13,9 @@
|
||||
<classpathentry exported="true" kind="lib" path="lib/vnu.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/Saxon-HE-9.9.1-2.jar"/>
|
||||
<classpathentry exported="true" kind="src" path="/luaj_xowa"/>
|
||||
<classpathentry kind="lib" path="lib/utils-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bcprov-jdk15on-164.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gnu-crypto.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jacksum.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/utils-1.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/bcprov-jdk15on-164.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/gnu-crypto.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jacksum.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Common.DataValues; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.*; import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Common.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.DataValues.*;
|
||||
// REF.MW:https://github.com/DataValues/Common/blob/master/src/DataValues/MonolingualTextValue.php
|
||||
public class MonolingualTextValue implements DataValue {
|
||||
/**
|
||||
* @var String
|
||||
*/
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* @var String
|
||||
*/
|
||||
private String text;
|
||||
/**
|
||||
* @param String languageCode
|
||||
* @param String String text
|
||||
*
|
||||
* @throws IllegalValueException
|
||||
*/
|
||||
public MonolingualTextValue(String languageCode, String text) {
|
||||
// if ( !is_string( languageCode ) || languageCode === '' ) {
|
||||
// throw new IllegalValueException( 'languageCode must be a non-empty String' );
|
||||
// }
|
||||
// if ( !is_string( String text ) ) {
|
||||
// throw new IllegalValueException( 'String text must be a String' );
|
||||
// }
|
||||
this.languageCode = languageCode;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @see Serializable::serialize
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// public function serialize() {
|
||||
// return serialize( [ this.languageCode, this.text ] );
|
||||
// }
|
||||
// /**
|
||||
// * @see Serializable::unserialize
|
||||
// *
|
||||
// * @param String $value
|
||||
// */
|
||||
// public function unserialize( $value ) {
|
||||
// list( languageCode, String text ) = unserialize( $value );
|
||||
// this.__construct( languageCode, String text );
|
||||
// }
|
||||
// /**
|
||||
// * @see DataValue::getType
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// public static function getType() {
|
||||
// return 'monolingualtext';
|
||||
// }
|
||||
// /**
|
||||
// * @see DataValue::getSortKey
|
||||
// *
|
||||
// * @return String
|
||||
// */
|
||||
// public function getSortKey() {
|
||||
// // TODO: we might want to re-think this key. Perhaps the language should simply be omitted.
|
||||
// return this.languageCode . this.text;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @see DataValue::getValue
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public Object getValue() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public String getLanguageCode() {
|
||||
return this.languageCode;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @see DataValue::getArrayValue
|
||||
// *
|
||||
// * @return String[]
|
||||
// */
|
||||
// public function getArrayValue() {
|
||||
// return [
|
||||
// 'text' => this.text,
|
||||
// 'language' => this.languageCode,
|
||||
// ];
|
||||
// }
|
||||
// /**
|
||||
// * Constructs a new instance from the provided data. Required for @see DataValueDeserializer.
|
||||
// * This is expected to round-trip with @see getArrayValue.
|
||||
// *
|
||||
// * @deprecated since 1.0.0. Static DataValue::newFromArray constructors like this are
|
||||
// * underspecified (not in the DataValue interface), and misleadingly named (should be named
|
||||
// * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer.
|
||||
// *
|
||||
// * @param mixed $data Warning! Even if this is expected to be a value as returned by
|
||||
// * @see getArrayValue, callers of this specific newFromArray implementation can not guarantee
|
||||
// * this. This is not even guaranteed to be an array!
|
||||
// *
|
||||
// * @throws IllegalValueException if $data is not in the expected format. Subclasses of
|
||||
// * InvalidArgumentException are expected and properly handled by @see DataValueDeserializer.
|
||||
// * @return self
|
||||
// */
|
||||
// public static function newFromArray( $data ) {
|
||||
// self::requireArrayFields( $data, [ 'language', 'text' ] );
|
||||
// return new static( $data['language'], $data['text'] );
|
||||
// }
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.DataValues.DataValues; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.*;
|
||||
// REF.MW:https://github.com/DataValues/DataValues/blob/master/src/DataValues/DataValue.php
|
||||
/**
|
||||
* Interface for objects that represent a single data value.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
public interface DataValue { // extends Hashable, Comparable, Serializable, Immutable
|
||||
/**
|
||||
* Returns the identifier of the datavalues type.
|
||||
*
|
||||
* This is not to be confused with the DataType provided by the DataTypes extension.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
// public static function getType();
|
||||
|
||||
/**
|
||||
* Returns a key that can be used to sort the data value with.
|
||||
* It can be either numeric or a String.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @return String|float|int
|
||||
*/
|
||||
// Object getSortKey();
|
||||
|
||||
/**
|
||||
* Returns the value contained by the DataValue. If this value is not simple and
|
||||
* does not have it's own type that represents it, the DataValue itself will be returned.
|
||||
* In essence, this method returns the "simplest" representation of the value.
|
||||
*
|
||||
* Example:
|
||||
* - NumberValue returns a float or integer
|
||||
* - MediaWikiTitleValue returns a Title Object
|
||||
* - QuantityValue returns itself
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
Object getValue();
|
||||
|
||||
/**
|
||||
* Returns the value in a form suitable for an array serialization.
|
||||
*
|
||||
* For simple values (ie a String) the return value will be equal to that of {@see getValue}.
|
||||
*
|
||||
* Complex DataValues can provide a nicer implementation though, for instance a
|
||||
* geographical coordinate value could provide an array with keys latitude,
|
||||
* longitude and altitude, each pointing to a simple float value.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
// Object getArrayValue();
|
||||
|
||||
/**
|
||||
* Returns the whole DataValue in array form.
|
||||
*
|
||||
* The array contains:
|
||||
* - value: mixed, same as the result of {@see getArrayValue}
|
||||
* - type: String, same as the result of {@see getType}
|
||||
*
|
||||
* This is sufficient for unserialization in a factory.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
// Object toArray();
|
||||
|
||||
/**
|
||||
* Returns a deep copy of the Object.
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @return DataValue
|
||||
*/
|
||||
// DataValue getCopy();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.DataValues.DataValues; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.*;
|
||||
// REF.MW:https://github.com/DataValues/DataValues/blob/master/src/DataValues/IllegalValueException.php
|
||||
// extends https://www.php.net/manual/en/class.invalidargumentexception.php
|
||||
public class IllegalValueException {
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Interfaces.ValueFormatters; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.*; import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Interfaces.*;
|
||||
// REF: https://github.com/DataValues/Interfaces/blob/master/src/ValueFormatters/ValueFormatter.php
|
||||
public interface ValueFormatter {
|
||||
// public static final String OPT_LANG = "lang";
|
||||
/**
|
||||
* @since 0.1
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FormattingException
|
||||
* @throws \InvalidArgumentException when value is of wrong type or out of accepted range/pattern
|
||||
*/
|
||||
Object format(Object val);
|
||||
}
|
@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.config; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.client.config; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.stores.*;
|
||||
public class WikibaseClientDefault {
|
||||
private final Hash_adp_bry settingCache = Hash_adp_bry.cs();
|
@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.client.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*;
|
||||
import gplx.xowa.mediawiki.*;
|
||||
public class Wbase_client {
|
||||
private Wbase_repo_linker repoLinker;
|
@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.client.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*;
|
||||
import gplx.xowa.mediawiki.*;
|
||||
// https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/client/includes/RepoLinker.php
|
||||
public class Wbase_repo_linker {
|
@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.client.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*;
|
||||
public class Wbase_settings {
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public byte[] getSetting(String key) {return getSetting(Bry_.new_u8(key));}
|
@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.*;
|
||||
import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.stores.*;
|
||||
public class Wbase_entity_accessor {
|
||||
private final Wbase_doc_mgr entity_mgr;
|
@ -13,9 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.*;
|
||||
import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.stores.*;
|
||||
import gplx.xowa.xtns.wbases.mediawiki.lib.includes.Store.*; import gplx.xowa.xtns.wbases.mediawiki.client.config.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Store.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.config.*;
|
||||
public class WikibaseLanguageIndependentLuaBindings {
|
||||
private final EntityRetrievingTermLookup termLookup;
|
||||
private final WikibaseClientDefault settings = WikibaseClientDefault.New();
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Formatters; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Interfaces.ValueFormatters.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Common.DataValues.*;
|
||||
// REF.MW:https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/lib/includes/Formatters/MonolingualHtmlFormatter.php
|
||||
public class MonolingualHtmlFormatter implements ValueFormatter {
|
||||
/**
|
||||
* @var LanguageNameLookup
|
||||
*/
|
||||
// private String languageNameLookup;
|
||||
// public MonolingualHtmlFormatter(LanguageNameLookup languageNameLookup ) {
|
||||
// this.languageNameLookup = languageNameLookup;
|
||||
// }
|
||||
/**
|
||||
* @see ValueFormatter::format
|
||||
*
|
||||
* @param MonolingualTextValue $value
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @return String HTML
|
||||
*/
|
||||
public Object format(Object val) {
|
||||
// if ( !( $value instanceof MonolingualTextValue ) ) {
|
||||
// throw new InvalidArgumentException( 'Data value type mismatch. Expected a MonolingualTextValue.' );
|
||||
// }
|
||||
// MonolingualTextValue monolingualVal = ((MonolingualTextValue)val);
|
||||
// String text = monolingualVal.getText();
|
||||
// String languageCode = monolingualVal.getLanguageCode();
|
||||
//// $languageName = this.languageNameLookup->getName($languageCode);
|
||||
// return wfMessage("wikibase-monolingualtext",
|
||||
// wfEscapeWikiText(text),
|
||||
// wfEscapeWikiText(languageCode),
|
||||
// wfEscapeWikiText(languageName)
|
||||
// ).parse();
|
||||
// "wikibase-monolingualtext": "<span lang=\"$2\" class=\"wb-monolingualtext-value\">$1</span> <span class=\"wb-monolingualtext-language-name\" dir=\"auto\">($3)</span>",
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Formatters; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Interfaces.ValueFormatters.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Common.DataValues.*;
|
||||
// REF.MW:https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/lib/includes/Formatters/MonolingualTextFormatter.php
|
||||
public class MonolingualTextFormatter implements ValueFormatter {
|
||||
/**
|
||||
* @see ValueFormatter::format
|
||||
*
|
||||
* @param MonolingualTextValue $value
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @return String Text
|
||||
*/
|
||||
public Object format(Object val) {
|
||||
// if (!Type_.Eq_by_obj(val, typeof(MonolingualTextValue))) {
|
||||
// throw new InvalidArgumentException( 'Data value type mismatch. Expected a MonolingualTextValue.' );
|
||||
// }
|
||||
return ((MonolingualTextValue)val).getText();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Formatters; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
|
||||
import gplx.xowa.xtns.wbases.claims.enums.*;
|
||||
// REF.MW: https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/lib/includes/Formatters/SnakFormat.php
|
||||
public class SnakFormat {
|
||||
/**
|
||||
* Get the format to fallback to, in case a given format is not available.
|
||||
*
|
||||
* @param String $format One of the SnakFormatter::FORMAT_... constants.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @return String One of the SnakFormatter::FORMAT_* constants.
|
||||
*/
|
||||
public Wbase_enum_itm getFallbackFormat(Wbase_enum_itm format) {
|
||||
switch (format.Tid()) {
|
||||
case SnakFormatterFormat.Tid__plain:
|
||||
break;
|
||||
}
|
||||
throw Err_.new_wo_type("");
|
||||
}
|
||||
|
||||
|
||||
// public function getFallbackFormat( $format ) {
|
||||
// switch ( $format ) {
|
||||
// case SnakFormatter::FORMAT_HTML:
|
||||
// case SnakFormatter::FORMAT_HTML_DIFF:
|
||||
// case SnakFormatter::FORMAT_HTML_VERBOSE:
|
||||
// return SnakFormatter::FORMAT_HTML;
|
||||
// case SnakFormatter::FORMAT_HTML_VERBOSE_PREVIEW:
|
||||
// return SnakFormatter::FORMAT_HTML_VERBOSE;
|
||||
// case SnakFormatter::FORMAT_WIKI:
|
||||
// case SnakFormatter::FORMAT_PLAIN:
|
||||
// return $format;
|
||||
// }
|
||||
// throw new InvalidArgumentException( 'Unsupported output format: ' . $format );
|
||||
// }
|
||||
public Wbase_enum_itm getBaseFormat(Wbase_enum_itm format) {
|
||||
switch (format.Tid()) {
|
||||
case SnakFormatterFormat.Tid__plain:
|
||||
break;
|
||||
}
|
||||
throw Err_.new_wo_type("");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Formatters; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
|
||||
import gplx.xowa.xtns.wbases.claims.enums.*;
|
||||
// REF.MW: https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/lib/includes/Formatters/SnakFormatter.php
|
||||
public class SnakFormatterFormat {
|
||||
public static final byte
|
||||
Tid__plain = 1
|
||||
, Tid__wiki = 2
|
||||
, Tid__html = 3
|
||||
, Tid__html_diff = 4
|
||||
, Tid__html_verbose = 5
|
||||
, Tid__html_verbose_preview = 6
|
||||
;
|
||||
public static final Wbase_enum_hash Reg = new Wbase_enum_hash("snak_format", 6);
|
||||
public static final Wbase_enum_itm
|
||||
Itm__plain = Reg.Add(Tid__plain , "text/plain")
|
||||
, Itm__wiki = Reg.Add(Tid__wiki , "text/x-wiki")
|
||||
, Itm__html = Reg.Add(Tid__html , "text/html")
|
||||
, Itm__html_diff = Reg.Add(Tid__html_diff , "text/html; disposition=diff")
|
||||
, Itm__html_verbose = Reg.Add(Tid__html_verbose , "text/html; disposition=verbose")
|
||||
, Itm__html_verbose_preview = Reg.Add(Tid__html_verbose_preview , "text/html; disposition=verbose-preview")
|
||||
;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Formatters; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
|
||||
import gplx.xowa.xtns.wbases.claims.enums.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.DataValues.Interfaces.ValueFormatters.*;
|
||||
public class WikibaseValueFormatterBuilder {
|
||||
private final SnakFormat snakFormat = new SnakFormat();
|
||||
|
||||
/**
|
||||
* @param String $format The desired target format, see SnakFormatter::FORMAT_XXX
|
||||
*
|
||||
* @return MonolingualHtmlFormatter|MonolingualWikitextFormatter|MonolingualTextFormatter
|
||||
*/
|
||||
public ValueFormatter newMonolingualFormatter(Wbase_enum_itm format) {
|
||||
switch (snakFormat.getBaseFormat(format).Tid()) {
|
||||
case SnakFormatterFormat.Tid__html:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// public function newMonolingualFormatter( $format ) {
|
||||
// switch ( $this->snakFormat->getBaseFormat( $format ) ) {
|
||||
// case SnakFormatter::FORMAT_HTML:
|
||||
// return new MonolingualHtmlFormatter( $this->languageNameLookup );
|
||||
// case SnakFormatter::FORMAT_WIKI:
|
||||
// return new MonolingualWikitextFormatter();
|
||||
// default:
|
||||
// return new MonolingualTextFormatter();
|
||||
// }
|
||||
// }
|
||||
}
|
@ -13,8 +13,9 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.lib.includes.Store; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.lib.*; import gplx.xowa.xtns.wbases.mediawiki.lib.includes.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Store; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.stores.*;
|
||||
import gplx.xowa.xtns.wbases.*;
|
||||
public class EntityRetrievingTermLookup {
|
||||
private final Wbase_doc_mgr entity_mgr;
|
||||
public EntityRetrievingTermLookup(Wbase_doc_mgr entity_mgr) {
|
@ -13,7 +13,7 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.repo.includes.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.repo.*; import gplx.xowa.xtns.wbases.mediawiki.repo.includes.*;
|
||||
package gplx.xowa.mediawiki.extensions.Wikibase.repo.includes.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.repo.*; import gplx.xowa.mediawiki.extensions.Wikibase.repo.includes.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.qargs.*; import gplx.xowa.xtns.wbases.stores.*; import gplx.xowa.xtns.wbases.core.*;
|
||||
public class Wbase_entityPage implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
@ -18,7 +18,7 @@ import gplx.xowa.users.history.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.specials.*;
|
||||
import gplx.xowa.specials.*;
|
||||
import gplx.xowa.specials.allPages.*; import gplx.xowa.specials.nearby.*; import gplx.xowa.specials.statistics.*; import gplx.xowa.xtns.translates.*; import gplx.xowa.specials.movePage.*;
|
||||
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.addons.wikis.imports.*; import gplx.xowa.specials.xowa.diags.*; import gplx.xowa.xtns.wbases.mediawiki.repo.includes.specials.*; import gplx.xowa.specials.xowa.errors.*;
|
||||
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.addons.wikis.imports.*; import gplx.xowa.specials.xowa.diags.*; import gplx.xowa.mediawiki.extensions.Wikibase.repo.includes.specials.*; import gplx.xowa.specials.xowa.errors.*;
|
||||
import gplx.xowa.xtns.wbases.specials.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.specials.mgrs.*; import gplx.xowa.addons.wikis.searchs.specials.*;
|
||||
|
@ -17,7 +17,7 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.langs.jsons.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.parsers.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.stores.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.scribunto.*;
|
||||
public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
private final Scrib_core core;
|
||||
private Wbase_doc_mgr entity_mgr;
|
||||
@ -206,6 +206,8 @@ public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
}
|
||||
public boolean FormatValue(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
/*
|
||||
String rv = Wdata_prop_val_visitor_.Render_snaks(core.Wiki(), core.Page().Url_bry_safe(), args.Pull_kv_ary_safe(0));
|
||||
return rslt.Init_obj(rv);
|
||||
public function formatValues( $snaksSerialization ) {
|
||||
$this->checkType( 'formatValues', 1, $snaksSerialization, 'table' );
|
||||
try {
|
||||
|
@ -21,7 +21,7 @@ import gplx.xowa.langs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.htmls.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.apps.apis.xowa.xtns.*; import gplx.xowa.apps.apis.xowa.html.*; import gplx.xowa.users.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.parsers.*; import gplx.xowa.xtns.wbases.pfuncs.*; import gplx.xowa.xtns.wbases.hwtrs.*; import gplx.xowa.xtns.wbases.stores.*;
|
||||
import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto.*;
|
||||
import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.scribunto.*;
|
||||
public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
private final Xoae_app app;
|
||||
private final Wdata_prop_val_visitor prop_val_visitor;
|
||||
|
Loading…
Reference in New Issue
Block a user