mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Xomw: Add some implementation for XomwHooks [#632]
This commit is contained in:
parent
bd71db3ed6
commit
db73b4302d
@ -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
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
|
package gplx.xowa.mediawiki; import gplx.*;
|
||||||
import gplx.core.strings.*;
|
import gplx.core.strings.*;
|
||||||
public class XophpArray_ {
|
public class XophpArray_ {
|
||||||
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
|
// REF.PHP:https://www.php.net/manual/en/function.array-merge.php
|
||||||
@ -156,6 +156,7 @@ public class XophpArray_ {
|
|||||||
public static boolean array_key_exists(String key, XophpArray array) {return array.Has(key);}
|
public static boolean array_key_exists(String key, XophpArray array) {return array.Has(key);}
|
||||||
public static boolean array_key_exists(int key, XophpArray array) {return array.Has(Int_.To_str(key));}
|
public static boolean array_key_exists(int key, XophpArray array) {return array.Has(Int_.To_str(key));}
|
||||||
|
|
||||||
|
public static void unset(XophpArray array, String s) {array.unset(s);}
|
||||||
public static void unset(XophpArray array, int i) {array.unset(i);}
|
public static void unset(XophpArray array, int i) {array.unset(i);}
|
||||||
public static void unset(Ordered_hash array, Object key) {
|
public static void unset(Ordered_hash array, Object key) {
|
||||||
array.Del(key);
|
array.Del(key);
|
||||||
@ -171,7 +172,7 @@ public class XophpArray_ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// REF.PHP:https://www.php.net/manual/en/function.array-map.php
|
// REF.PHP:https://www.php.net/manual/en/function.array-map.php
|
||||||
public static XophpArray array_map(XophpCallbackOwner callback_owner, String method, XophpArray array) {
|
public static XophpArray array_map(XophpCallableOwner callback_owner, String method, XophpArray array) {
|
||||||
XophpArray rv = XophpArray.New();
|
XophpArray rv = XophpArray.New();
|
||||||
int len = array.count();
|
int len = array.count();
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
@ -208,7 +209,7 @@ public class XophpArray_ {
|
|||||||
public static Object array_pop(XophpArray array) {return array.pop();}
|
public static Object array_pop(XophpArray array) {return array.pop();}
|
||||||
public static boolean isset(XophpArray array, int key) {return XophpObject_.isset_obj(array.Get_at(key));}
|
public static boolean isset(XophpArray array, int key) {return XophpObject_.isset_obj(array.Get_at(key));}
|
||||||
public static boolean isset(XophpArray array, String key) {return XophpObject_.isset_obj(array.Get_by(key));}
|
public static boolean isset(XophpArray array, String key) {return XophpObject_.isset_obj(array.Get_by(key));}
|
||||||
public static boolean is_array(XophpArray array) {return array != null;}
|
public static boolean is_array(Object array) {return array != null;}
|
||||||
|
|
||||||
// REF.PHP: https://www.php.net/manual/en/function.in-array.php
|
// REF.PHP: https://www.php.net/manual/en/function.in-array.php
|
||||||
public static boolean in_array(Object needle, XophpArray haystack) {return in_array(needle, haystack, false);}
|
public static boolean in_array(Object needle, XophpArray haystack) {return in_array(needle, haystack, false);}
|
||||||
|
10
400_xowa/src/gplx/xowa/mediawiki/XophpCallable.java
Normal file
10
400_xowa/src/gplx/xowa/mediawiki/XophpCallable.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package gplx.xowa.mediawiki;
|
||||||
|
|
||||||
|
public class XophpCallable {
|
||||||
|
public XophpCallable(XophpCallableOwner owner, String methodName) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.methodName = methodName;
|
||||||
|
}
|
||||||
|
public XophpCallableOwner Owner() {return owner;} private final XophpCallableOwner owner;
|
||||||
|
public String MethodName() {return methodName;} private final String methodName;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
XOWA: the XOWA Offline Wiki Application
|
XOWA: the XOWA Offline Wiki Application
|
||||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||||
|
|
||||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
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.
|
or alternatively under the terms of the Apache License Version 2.0.
|
||||||
@ -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
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
|
package gplx.xowa.mediawiki;
|
||||||
public interface XophpCallbackOwner {
|
public interface XophpCallableOwner {
|
||||||
Object Callback(String method, Object... args);
|
Object Callback(String method, Object... args);
|
||||||
}
|
}
|
8
400_xowa/src/gplx/xowa/mediawiki/XophpCallable_.java
Normal file
8
400_xowa/src/gplx/xowa/mediawiki/XophpCallable_.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package gplx.xowa.mediawiki;
|
||||||
|
|
||||||
|
public class XophpCallable_ {
|
||||||
|
// REF.PHP: https://www.php.net/manual/en/function.call-user-func-array.phphttps://www.php.net/manual/en/function.call-user-func-array.php
|
||||||
|
public static Object call_user_func_array(XophpCallable callback, XophpArray param_arr) {
|
||||||
|
return callback.Owner().Callback(callback.MethodName(), param_arr);
|
||||||
|
}
|
||||||
|
}
|
22
400_xowa/src/gplx/xowa/mediawiki/XophpFatalError.java
Normal file
22
400_xowa/src/gplx/xowa/mediawiki/XophpFatalError.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
XOWA: the XOWA Offline Wiki Application
|
||||||
|
Copyright (C) 2012-2020 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;
|
||||||
|
|
||||||
|
public class XophpFatalError extends XophpError {
|
||||||
|
public XophpFatalError(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -13,13 +13,13 @@ 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
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
|
package gplx.xowa.mediawiki; import gplx.*;
|
||||||
import gplx.core.btries.*;
|
import gplx.core.btries.*;
|
||||||
import gplx.core.intls.*;
|
import gplx.core.intls.*;
|
||||||
import gplx.objects.strings.unicodes.*;
|
import gplx.objects.strings.unicodes.*;
|
||||||
import gplx.core.primitives.*;
|
import gplx.core.primitives.*;
|
||||||
import gplx.objects.strings.bfrs.*;
|
import gplx.objects.strings.bfrs.*;
|
||||||
public class XophpString_ implements XophpCallbackOwner {
|
public class XophpString_ implements XophpCallableOwner {
|
||||||
public static final String False = null;
|
public static final String False = null;
|
||||||
public static boolean is_true (String s) {return s != null;} // handles code like "if ($var)" where var is an Object;
|
public static boolean is_true (String s) {return s != null;} // handles code like "if ($var)" where var is an Object;
|
||||||
public static boolean is_false(String s) {return s == null;}
|
public static boolean is_false(String s) {return s == null;}
|
||||||
@ -573,5 +573,5 @@ public class XophpString_ implements XophpCallbackOwner {
|
|||||||
throw Err_.new_unhandled_default(method);
|
throw Err_.new_unhandled_default(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static final XophpCallbackOwner Callback_owner = new XophpString_();
|
public static final XophpCallableOwner Callback_owner = new XophpString_();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
XOWA: the XOWA Offline Wiki Application
|
XOWA: the XOWA Offline Wiki Application
|
||||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||||
|
|
||||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
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.
|
or alternatively under the terms of the Apache License Version 2.0.
|
||||||
@ -13,178 +13,242 @@ 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
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
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.*;
|
package gplx.xowa.mediawiki.includes;
|
||||||
|
// MW.SRC:1.33.1
|
||||||
|
|
||||||
|
import gplx.xowa.mediawiki.*;
|
||||||
|
/*
|
||||||
|
TODO:
|
||||||
|
* $wgHooks
|
||||||
|
* array_shift
|
||||||
|
* Closure?
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks cl+ass.
|
* Hooks class.
|
||||||
*
|
*
|
||||||
* Used to supersede $wgHooks, because globals are EVIL.
|
* Used to supersede $wgHooks, because globals are EVIL.
|
||||||
*
|
*
|
||||||
* @since 1.18
|
* @since 1.18
|
||||||
*/
|
*/
|
||||||
public class XomwHooks {
|
public class XomwHooks {
|
||||||
// /**
|
/**
|
||||||
// * Array of events mapped to an array of callbacks to be run
|
* Array of events mapped to an array of callbacks to be run
|
||||||
// * when that event is triggered.
|
* when that event is triggered.
|
||||||
// */
|
*/
|
||||||
// protected static $handlers = [];
|
protected static XophpArray handlers = XophpArray.New();
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Attach an event handler to a given hook.
|
* Attach an event handler to a given hook.
|
||||||
// *
|
*
|
||||||
// * @param String $name Name of hook
|
* @param string $name Name of hook
|
||||||
// * @param callable $callback Callback function to attach
|
* @param callable $callback Callback function to attach
|
||||||
// *
|
*
|
||||||
// * @since 1.18
|
* @since 1.18
|
||||||
// */
|
*/
|
||||||
// public static function register( $name, $callback ) {
|
public static void register(String name, XophpCallable callback) {
|
||||||
// if ( !isset( self::$handlers[$name] ) ) {
|
handlers.Get_by_ary(name).Add(callback);
|
||||||
// self::$handlers[$name] = [];
|
}
|
||||||
// }
|
|
||||||
//
|
/**
|
||||||
// self::$handlers[$name][] = $callback;
|
* Clears hooks registered via Hooks::register(). Does not touch $wgHooks.
|
||||||
// }
|
* This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
|
||||||
//
|
*
|
||||||
// /**
|
* @param string $name The name of the hook to clear.
|
||||||
// * Clears hooks registered via Hooks::register(). Does not touch $wgHooks.
|
*
|
||||||
// * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
|
* @since 1.21
|
||||||
// *
|
* @throws MWException If not in testing mode.
|
||||||
// * @param String $name The name of the hook to clear.
|
* @codeCoverageIgnore
|
||||||
// *
|
*/
|
||||||
// * @since 1.21
|
public static void clear(String name) {
|
||||||
// * @throws MWException If not in testing mode.
|
|
||||||
// */
|
|
||||||
// public static function clear( $name ) {
|
|
||||||
// if (!defined('MW_PHPUNIT_TEST') && !defined('MW_PARSER_TEST')) {
|
// if (!defined('MW_PHPUNIT_TEST') && !defined('MW_PARSER_TEST')) {
|
||||||
// throw new MWException('Cannot reset hooks in operation.');
|
// throw new MWException('Cannot reset hooks in operation.');
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// unset( self::$handlers[$name] );
|
XophpArray_.unset(handlers, name);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * Returns true if a hook has a function registered to it.
|
* Returns true if a hook has a function registered to it.
|
||||||
// * The function may have been registered either via Hooks::register or in $wgHooks.
|
* The function may have been registered either via Hooks::register or in $wgHooks.
|
||||||
// *
|
*
|
||||||
// * @since 1.18
|
* @since 1.18
|
||||||
// *
|
*
|
||||||
// * @param String $name Name of hook
|
* @param string $name Name of hook
|
||||||
// * @return boolean True if the hook has a function registered to it
|
* @return bool True if the hook has a function registered to it
|
||||||
// */
|
*/
|
||||||
// public static function isRegistered( $name ) {
|
public static boolean isRegistered(String name) {
|
||||||
// global $wgHooks;
|
// global $wgHooks;
|
||||||
// return !empty( $wgHooks[$name] ) || !empty( self::$handlers[$name] );
|
// return !XophpArray_.empty($wgHooks[$name]) || !XophpArray_.empty(handlers[$name]);
|
||||||
// }
|
return false;
|
||||||
//
|
}
|
||||||
// /**
|
|
||||||
// * Returns an array of all the event functions attached to a hook
|
/**
|
||||||
// * This combines functions registered via Hooks::register and with $wgHooks.
|
* Returns an array of all the event functions attached to a hook
|
||||||
// *
|
* This combines functions registered via Hooks::register and with $wgHooks.
|
||||||
// * @since 1.18
|
*
|
||||||
// *
|
* @since 1.18
|
||||||
// * @param String $name Name of the hook
|
*
|
||||||
// * @return array
|
* @param string $name Name of the hook
|
||||||
// */
|
* @return array
|
||||||
// public static function getHandlers( $name ) {
|
*/
|
||||||
|
public static XophpArray getHandlers(String name) {
|
||||||
// global $wgHooks;
|
// global $wgHooks;
|
||||||
//
|
|
||||||
// if ( !self::isRegistered( $name ) ) {
|
if (!isRegistered(name)) {
|
||||||
// return [];
|
return XophpArray.New();
|
||||||
// } elseif ( !isset( self::$handlers[$name] ) ) {
|
// } else if (!XophpArray_.isset(handlers, name)) {
|
||||||
// return $wgHooks[$name];
|
// return $wgHooks[name];
|
||||||
// } elseif ( !isset( $wgHooks[$name] ) ) {
|
// } else if (!isset($wgHooks[name])) {
|
||||||
// return self::$handlers[$name];
|
// return handlers[name];
|
||||||
|
} else {
|
||||||
|
// return XophpArray_.array_merge(handlers.Get_by_ary(name), $wgHooks[name]);
|
||||||
|
return XophpArray_.array_merge(handlers.Get_by_ary(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $event Event name
|
||||||
|
* @param array|callable hook
|
||||||
|
* @param array $args Array of parameters passed to hook functions
|
||||||
|
* @param string|null $deprecatedVersion [optional]
|
||||||
|
* @param string &$fname [optional] Readable name of hook [returned]
|
||||||
|
* @return null|string|bool
|
||||||
|
*/
|
||||||
|
private static String callHook(String event, Object hookObj, XophpArray args) {return callHook(event, hookObj, args, null, null);}
|
||||||
|
private static String callHook(String event, Object hookObj, XophpArray args, String deprecatedVersion) {return callHook(event, hookObj, args, deprecatedVersion, null);}
|
||||||
|
private static String callHook(String event, Object hookObj, XophpArray args, String deprecatedVersion,
|
||||||
|
String fname
|
||||||
|
) {
|
||||||
|
XophpArray hook;
|
||||||
|
// Turn non-array values into an array. (Can't use casting because of objects.)
|
||||||
|
if (!XophpArray_.is_array(hookObj)) {
|
||||||
|
hook = XophpArray.New(hookObj);
|
||||||
|
}
|
||||||
|
else { // XO: cast it to XophpArray
|
||||||
|
hook = (XophpArray)hookObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (!array_filter(hook)) {
|
||||||
|
// Either array is empty or it's an array filled with null/false/empty.
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (is_array(hook[0])) {
|
||||||
|
// First element is an array, meaning the developer intended
|
||||||
|
// the first element to be a callback. Merge it in so that
|
||||||
|
// processing can be uniform.
|
||||||
|
// hook = array_merge(hook[0], array_slice(hook, 1));
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hook can be: a function, an object, an array of $function and
|
||||||
|
* $data, an array of just a function, an array of object and
|
||||||
|
* method, or an array of object, method, and data.
|
||||||
|
*/
|
||||||
|
if (XophpType_.instance_of(hook.Get_at(0), XophpCallable.class)) { // XophpClosure
|
||||||
|
// $fname = "hook-" + event + "-closure";
|
||||||
|
// $callback = array_shift(hook);
|
||||||
|
} else if (XophpObject_.is_object(hook.Get_at_str(0))) {
|
||||||
|
// Object object = XophpArray_.array_shift(hook);
|
||||||
|
// Object method = XophpArray_.array_shift(hook);
|
||||||
|
|
||||||
|
// If no method was specified, default to on$event.
|
||||||
|
// if ($method === null) {
|
||||||
|
// $method = "on" + event;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $fname = get_class($object) . '::' . $method;
|
||||||
|
// $callback = [ $object, $method ];
|
||||||
|
// } else if (is_string(hook[0])) {
|
||||||
|
// $fname = $callback = array_shift(hook);
|
||||||
// } else {
|
// } else {
|
||||||
// return array_merge( self::$handlers[$name], $wgHooks[$name] );
|
// throw new MWException('Unknown datatype in hooks for ' . $event . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run autoloader (workaround for call_user_func_array bug)
|
||||||
|
// and throw error if not callable.
|
||||||
|
// if (!is_callable($callback)) {
|
||||||
|
// throw new MWException('Invalid callback ' . $fname . ' in hooks for ' . $event . "\n");
|
||||||
// }
|
// }
|
||||||
// }
|
|
||||||
//
|
// mark hook as deprecated, if deprecation version is specified
|
||||||
|
if (deprecatedVersion != null) {
|
||||||
|
// wfDeprecated("$event hook (used in $fname)", deprecatedVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
XophpCallable callback = null;
|
||||||
|
|
||||||
|
// Call the hook.
|
||||||
|
XophpArray hook_args = XophpArray_.array_merge(hook, args);
|
||||||
|
return (String)XophpCallable_.call_user_func_array(callback, hook_args);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Call hook functions defined in Hooks::register and $wgHooks.
|
||||||
|
*
|
||||||
|
* For the given hook event, fetch the array of hook events and
|
||||||
|
* process them. Determine the proper callback for each hook and
|
||||||
|
* then call the actual hook using the appropriate arguments.
|
||||||
|
* Finally, process the return value and return/throw accordingly.
|
||||||
|
*
|
||||||
|
* For hook event that are not abortable through a handler's return value,
|
||||||
|
* use runWithoutAbort() instead.
|
||||||
|
*
|
||||||
|
* @param string $event Event name
|
||||||
|
* @param array $args Array of parameters passed to hook functions
|
||||||
|
* @param string|null $deprecatedVersion [optional] Mark hook as deprecated with version number
|
||||||
|
* @return bool True if no handler aborted the hook
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
* @throws FatalError
|
||||||
|
* @throws MWException
|
||||||
|
* @since 1.22 A hook function is not required to return a value for
|
||||||
|
* processing to continue. Not returning a value (or explicitly
|
||||||
|
* returning null) is equivalent to returning true.
|
||||||
|
*/
|
||||||
|
public static boolean run(String event) {return run(event, XophpArray.New(), null);}
|
||||||
|
public static boolean run(String event, XophpArray args) {return run(event, args, null);}
|
||||||
|
public static boolean run(String event, XophpArray args, String deprecatedVersion) {
|
||||||
|
XophpArray handlers = getHandlers(event);
|
||||||
|
for (int i = 0; i < handlers.count(); i++) {
|
||||||
|
XophpCallable hook = (XophpCallable)handlers.Get_at(i);
|
||||||
|
Object retval = callHook(event, hook, args, deprecatedVersion);
|
||||||
|
if (retval == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the return value.
|
||||||
|
if (XophpString_.is_string(retval)) {
|
||||||
|
// String returned means error.
|
||||||
|
throw new XophpFatalError((String)retval);
|
||||||
|
} else if (XophpObject_.is_false(retval)) {
|
||||||
|
// False was returned. Stop processing, but no error.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Call hook functions defined in Hooks::register and $wgHooks.
|
// * Call hook functions defined in Hooks::register and $wgHooks.
|
||||||
// *
|
// *
|
||||||
// * For a certain hook event, fetch the array of hook events and
|
// * @param string $event Event name
|
||||||
// * process them. Determine the proper callback for each hook and
|
|
||||||
// * then call the actual hook using the appropriate arguments.
|
|
||||||
// * Finally, process the return value and return/throw accordingly.
|
|
||||||
// *
|
|
||||||
// * @param String $event Event name
|
|
||||||
// * @param array $args Array of parameters passed to hook functions
|
// * @param array $args Array of parameters passed to hook functions
|
||||||
// * @param String|null $deprecatedVersion Optionally, mark hook as deprecated with version number
|
// * @param string|null $deprecatedVersion [optional] Mark hook as deprecated with version number
|
||||||
// * @return boolean True if no handler aborted the hook
|
// * @return bool Always true
|
||||||
// *
|
// * @throws MWException If a callback is invalid, unknown
|
||||||
// * @throws Exception
|
// * @throws UnexpectedValueException If a callback returns an abort value.
|
||||||
// * @throws FatalError
|
// * @since 1.30
|
||||||
// * @throws MWException
|
|
||||||
// * @since 1.22 A hook function is not required to return a value for
|
|
||||||
// * processing to continue. Not returning a value (or explicitly
|
|
||||||
// * returning null) is equivalent to returning true.
|
|
||||||
// */
|
// */
|
||||||
// public static function run( $event, array $args = [], $deprecatedVersion = null ) {
|
// public static function runWithoutAbort($event, array $args = [], $deprecatedVersion = null) {
|
||||||
// foreach ( self::getHandlers( $event ) as $hook ) {
|
// foreach (getHandlers($event) as hook) {
|
||||||
// // Turn non-array values into an array. (Can't use casting because of objects.)
|
// $fname = null;
|
||||||
// if ( !is_array( $hook ) ) {
|
// retval = callHook($event, hook, $args, $deprecatedVersion, $fname);
|
||||||
// $hook = [ $hook ];
|
// if (retval !== null && retval !== true) {
|
||||||
// }
|
// throw new UnexpectedValueException("Invalid return from $fname for unabortable $event.");
|
||||||
//
|
|
||||||
// if ( !array_filter( $hook ) ) {
|
|
||||||
// // Either array is empty or it's an array filled with null/false/empty.
|
|
||||||
// continue;
|
|
||||||
// } elseif ( is_array( $hook[0] ) ) {
|
|
||||||
// // First element is an array, meaning the developer intended
|
|
||||||
// // the first element to be a callback. Merge it in so that
|
|
||||||
// // processing can be uniform.
|
|
||||||
// $hook = array_merge( $hook[0], array_slice( $hook, 1 ) );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * $hook can be: a function, an Object, an array of $function and
|
|
||||||
// * $data, an array of just a function, an array of Object and
|
|
||||||
// * method, or an array of Object, method, and data.
|
|
||||||
// */
|
|
||||||
// if ( $hook[0] instanceof Closure ) {
|
|
||||||
// $func = "hook-$event-closure";
|
|
||||||
// $callback = array_shift( $hook );
|
|
||||||
// } elseif ( is_object( $hook[0] ) ) {
|
|
||||||
// $Object = array_shift( $hook );
|
|
||||||
// $method = array_shift( $hook );
|
|
||||||
//
|
|
||||||
// // If no method was specified, default to on$event.
|
|
||||||
// if ( $method === null ) {
|
|
||||||
// $method = "on$event";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// $func = get_class( $Object ) . '::' . $method;
|
|
||||||
// $callback = [ $Object, $method ];
|
|
||||||
// } elseif ( is_string( $hook[0] ) ) {
|
|
||||||
// $func = $callback = array_shift( $hook );
|
|
||||||
// } else {
|
|
||||||
// throw new MWException( 'Unknown datatype in hooks for ' . $event . "\n" );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Run autoloader (workaround for call_user_func_array bug)
|
|
||||||
// // and throw error if not callable.
|
|
||||||
// if ( !is_callable( $callback ) ) {
|
|
||||||
// throw new MWException( 'Invalid callback ' . $func . ' in hooks for ' . $event . "\n" );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // mark hook as deprecated, if deprecation version is specified
|
|
||||||
// if ( $deprecatedVersion !== null ) {
|
|
||||||
// wfDeprecated( "$event hook (used in $func)", $deprecatedVersion );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Call the hook.
|
|
||||||
// $hook_args = array_merge( $hook, $args );
|
|
||||||
// $retval = call_user_func_array( $callback, $hook_args );
|
|
||||||
//
|
|
||||||
// // Process the return value.
|
|
||||||
// if ( is_string( $retval ) ) {
|
|
||||||
// // String returned means error.
|
|
||||||
// throw new FatalError( $retval );
|
|
||||||
// } elseif ( $retval === false ) {
|
|
||||||
// // False was returned. Stop processing, but no error.
|
|
||||||
// return false;
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
XOWA: the XOWA Offline Wiki Application
|
XOWA: the XOWA Offline Wiki Application
|
||||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||||
|
|
||||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
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.
|
or alternatively under the terms of the Apache License Version 2.0.
|
||||||
@ -13,10 +13,15 @@ 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
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
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.*;
|
package gplx.xowa.mediawiki.includes;
|
||||||
import gplx.xowa.mediawiki.languages.*;
|
// MW.SRC:1.33.1
|
||||||
import gplx.xowa.mediawiki.includes.interwiki.*;
|
|
||||||
import gplx.xowa.mediawiki.includes.title.*;
|
import gplx.xowa.mediawiki.XomwEnv;
|
||||||
|
import gplx.xowa.mediawiki.includes.interwiki.XomwInterwikiLookup;
|
||||||
|
import gplx.xowa.mediawiki.includes.title.XomwMediaWikiTitleCodec;
|
||||||
|
import gplx.xowa.mediawiki.includes.title.XomwTitleFormatter;
|
||||||
|
import gplx.xowa.mediawiki.languages.XomwLanguage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MediaWikiServices is the service locator for the application scope of MediaWiki.
|
* MediaWikiServices is the service locator for the application scope of MediaWiki.
|
||||||
* Its implemented as a simple configurable DI container.
|
* Its implemented as a simple configurable DI container.
|
||||||
@ -28,9 +33,9 @@ import gplx.xowa.mediawiki.includes.title.*;
|
|||||||
* or by calling defineService().
|
* or by calling defineService().
|
||||||
*
|
*
|
||||||
* @see docs/injection.txt for an overview of using dependency injection in the
|
* @see docs/injection.txt for an overview of using dependency injection in the
|
||||||
* MediaWiki code super.
|
* MediaWiki code base.
|
||||||
*/
|
*/
|
||||||
public class XomwMediaWikiServices {
|
public class XomwMediaWikiServices { // extends ServiceContainer
|
||||||
// XO.MW.SKIP:remove global getInstance(). See XomwEnv
|
// XO.MW.SKIP:remove global getInstance(). See XomwEnv
|
||||||
private final XomwMediaWikiTitleCodec titleParser;
|
private final XomwMediaWikiTitleCodec titleParser;
|
||||||
private final XomwInterwikiLookup interwikiLookup;
|
private final XomwInterwikiLookup interwikiLookup;
|
||||||
@ -42,6 +47,38 @@ public class XomwMediaWikiServices {
|
|||||||
this.titleParser = new XomwMediaWikiTitleCodec(this, language, localInterwikis);
|
this.titleParser = new XomwMediaWikiTitleCodec(this, language, localInterwikis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @var MediaWikiServices|null
|
||||||
|
// */
|
||||||
|
// private static $instance = null;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the global default instance of the top level service locator.
|
||||||
|
// *
|
||||||
|
// * @since 1.27
|
||||||
|
// *
|
||||||
|
// * The default instance is initialized using the service instantiator functions
|
||||||
|
// * defined in ServiceWiring.php.
|
||||||
|
// *
|
||||||
|
// * @note This should only be called by static functions! The instance returned here
|
||||||
|
// * should not be passed around! Objects that need access to a service should have
|
||||||
|
// * that service injected into the constructor, never a service locator!
|
||||||
|
// *
|
||||||
|
// * @return MediaWikiServices
|
||||||
|
// */
|
||||||
|
// public static function getInstance() {
|
||||||
|
// if ( self::$instance === null ) {
|
||||||
|
// // NOTE: constructing GlobalVarConfig here is not particularly pretty,
|
||||||
|
// // but some information from the global scope has to be injected here,
|
||||||
|
// // even if it's just a file name or database credentials to load
|
||||||
|
// // configuration from.
|
||||||
|
// $bootstrapConfig = new GlobalVarConfig();
|
||||||
|
// self::$instance = self::newInstance( $bootstrapConfig, 'load' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return self::$instance;
|
||||||
|
// }
|
||||||
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Replaces the global MediaWikiServices instance.
|
// * Replaces the global MediaWikiServices instance.
|
||||||
// *
|
// *
|
||||||
@ -51,9 +88,9 @@ public class XomwMediaWikiServices {
|
|||||||
// *
|
// *
|
||||||
// * @throws MWException if called outside of PHPUnit tests.
|
// * @throws MWException if called outside of PHPUnit tests.
|
||||||
// *
|
// *
|
||||||
// * @param MediaWikiServices $services The new MediaWikiServices Object.
|
// * @param MediaWikiServices $services The new MediaWikiServices object.
|
||||||
// *
|
// *
|
||||||
// * @return MediaWikiServices The old MediaWikiServices Object, so it can be restored later.
|
// * @return MediaWikiServices The old MediaWikiServices object, so it can be restored later.
|
||||||
// */
|
// */
|
||||||
// public static function forceGlobalInstance( MediaWikiServices $services ) {
|
// public static function forceGlobalInstance( MediaWikiServices $services ) {
|
||||||
// if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
|
// if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
|
||||||
@ -68,7 +105,7 @@ public class XomwMediaWikiServices {
|
|||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Creates a new instance of MediaWikiServices and sets it as the global default
|
// * Creates a new instance of MediaWikiServices and sets it as the global default
|
||||||
// * instance. getInstance() will return a different MediaWikiServices Object
|
// * instance. getInstance() will return a different MediaWikiServices object
|
||||||
// * after every call to resetGlobalInstance().
|
// * after every call to resetGlobalInstance().
|
||||||
// *
|
// *
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
@ -91,14 +128,14 @@ public class XomwMediaWikiServices {
|
|||||||
// * @see resetGlobalInstance()
|
// * @see resetGlobalInstance()
|
||||||
// * @see resetBetweenTest()
|
// * @see resetBetweenTest()
|
||||||
// *
|
// *
|
||||||
// * @param Config|null $bootstrapConfig The Config Object to be registered as the
|
// * @param Config|null $bootstrapConfig The Config object to be registered as the
|
||||||
// * 'BootstrapConfig' service. This has to contain at least the information
|
// * 'BootstrapConfig' service. This has to contain at least the information
|
||||||
// * needed to set up the 'ConfigFactory' service. If not given, the bootstrap
|
// * needed to set up the 'ConfigFactory' service. If not given, the bootstrap
|
||||||
// * config of the old instance of MediaWikiServices will be re-used. If there
|
// * config of the old instance of MediaWikiServices will be re-used. If there
|
||||||
// * was no previous instance, a new GlobalVarConfig Object will be used to
|
// * was no previous instance, a new GlobalVarConfig object will be used to
|
||||||
// * bootstrap the services.
|
// * bootstrap the services.
|
||||||
// *
|
// *
|
||||||
// * @param String $quick Set this to "quick" to allow expensive resources to be re-used.
|
// * @param string $quick Set this to "quick" to allow expensive resources to be re-used.
|
||||||
// * See SalvageableService for details.
|
// * See SalvageableService for details.
|
||||||
// *
|
// *
|
||||||
// * @throws MWException If called after MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in
|
// * @throws MWException If called after MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in
|
||||||
@ -162,10 +199,10 @@ public class XomwMediaWikiServices {
|
|||||||
// * given $bootstrapConfig. In particular, all wiring files defined in the
|
// * given $bootstrapConfig. In particular, all wiring files defined in the
|
||||||
// * ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called.
|
// * ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called.
|
||||||
// *
|
// *
|
||||||
// * @param Config|null $bootstrapConfig The Config Object to be registered as the
|
// * @param Config|null $bootstrapConfig The Config object to be registered as the
|
||||||
// * 'BootstrapConfig' service.
|
// * 'BootstrapConfig' service.
|
||||||
// *
|
// *
|
||||||
// * @param String $loadWiring set this to 'load' to load the wiring files specified
|
// * @param string $loadWiring set this to 'load' to load the wiring files specified
|
||||||
// * in the 'ServiceWiringFiles' setting in $bootstrapConfig.
|
// * in the 'ServiceWiringFiles' setting in $bootstrapConfig.
|
||||||
// *
|
// *
|
||||||
// * @return MediaWikiServices
|
// * @return MediaWikiServices
|
||||||
@ -250,8 +287,8 @@ public class XomwMediaWikiServices {
|
|||||||
// * should not be needed. It is provided to allow tests that pollute global service
|
// * should not be needed. It is provided to allow tests that pollute global service
|
||||||
// * instances to clean up.
|
// * instances to clean up.
|
||||||
// *
|
// *
|
||||||
// * @param String $name
|
// * @param string $name
|
||||||
// * @param boolean $destroy Whether the service instance should be destroyed if it exists.
|
// * @param bool $destroy Whether the service instance should be destroyed if it exists.
|
||||||
// * When set to false, any existing service instance will effectively be detached
|
// * When set to false, any existing service instance will effectively be detached
|
||||||
// * from the container.
|
// * from the container.
|
||||||
// *
|
// *
|
||||||
@ -284,7 +321,7 @@ public class XomwMediaWikiServices {
|
|||||||
// * defined here in the MediaWikiServices services class to have a central place
|
// * defined here in the MediaWikiServices services class to have a central place
|
||||||
// * for managing service bootstrapping and resetting.
|
// * for managing service bootstrapping and resetting.
|
||||||
// *
|
// *
|
||||||
// * @param String $method the name of the caller method, as given by __METHOD__.
|
// * @param string $method the name of the caller method, as given by __METHOD__.
|
||||||
// *
|
// *
|
||||||
// * @throws MWException if called outside bootstrap mode.
|
// * @throws MWException if called outside bootstrap mode.
|
||||||
// *
|
// *
|
||||||
@ -304,14 +341,14 @@ public class XomwMediaWikiServices {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @param Config $config The Config Object to be registered as the 'BootstrapConfig' service.
|
// * @param Config $config The Config object to be registered as the 'BootstrapConfig' service.
|
||||||
// * This has to contain at least the information needed to set up the 'ConfigFactory'
|
// * This has to contain at least the information needed to set up the 'ConfigFactory'
|
||||||
// * service.
|
// * service.
|
||||||
// */
|
// */
|
||||||
// public function __construct( Config $config ) {
|
// public function __construct( Config $config ) {
|
||||||
// parent::__construct();
|
// parent::__construct();
|
||||||
//
|
//
|
||||||
// // Register the given Config Object as the bootstrap config service.
|
// // Register the given Config object as the bootstrap config service.
|
||||||
// this.defineService( 'BootstrapConfig', function () use ( $config ) {
|
// this.defineService( 'BootstrapConfig', function () use ( $config ) {
|
||||||
// return $config;
|
// return $config;
|
||||||
// } );
|
// } );
|
||||||
@ -320,7 +357,39 @@ public class XomwMediaWikiServices {
|
|||||||
// // CONVENIENCE GETTERS ////////////////////////////////////////////////////
|
// // CONVENIENCE GETTERS ////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Returns the Config Object containing the bootstrap configuration.
|
// * @since 1.31
|
||||||
|
// * @return ActorMigration
|
||||||
|
// */
|
||||||
|
// public function getActorMigration() {
|
||||||
|
// return this.getService( 'ActorMigration' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return BlobStore
|
||||||
|
// */
|
||||||
|
// public function getBlobStore() {
|
||||||
|
// return this.getService( '_SqlBlobStore' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return BlobStoreFactory
|
||||||
|
// */
|
||||||
|
// public function getBlobStoreFactory() {
|
||||||
|
// return this.getService( 'BlobStoreFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.33
|
||||||
|
// * @return BlockRestrictionStore
|
||||||
|
// */
|
||||||
|
// public function getBlockRestrictionStore() : BlockRestrictionStore {
|
||||||
|
// return this.getService( 'BlockRestrictionStore' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the Config object containing the bootstrap configuration.
|
||||||
// * Bootstrap configuration would typically include database credentials
|
// * Bootstrap configuration would typically include database credentials
|
||||||
// * and other information that may be needed before the ConfigFactory
|
// * and other information that may be needed before the ConfigFactory
|
||||||
// * service can be instantiated.
|
// * service can be instantiated.
|
||||||
@ -337,6 +406,22 @@ public class XomwMediaWikiServices {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return NameTableStore
|
||||||
|
// */
|
||||||
|
// public function getChangeTagDefStore() {
|
||||||
|
// return this.getService( 'NameTableStoreFactory' )->getChangeTagDef();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return CommentStore
|
||||||
|
// */
|
||||||
|
// public function getCommentStore() {
|
||||||
|
// return this.getService( 'CommentStore' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
// * @since 1.27
|
// * @since 1.27
|
||||||
// * @return ConfigFactory
|
// * @return ConfigFactory
|
||||||
// */
|
// */
|
||||||
@ -345,95 +430,53 @@ public class XomwMediaWikiServices {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * Returns the Config Object that provides configuration for MediaWiki core.
|
// * @since 1.32
|
||||||
// * This may or may not be the same Object that is returned by getBootstrapConfig().
|
// * @return ConfigRepository
|
||||||
// *
|
|
||||||
// * @since 1.27
|
|
||||||
// * @return Config
|
|
||||||
// */
|
// */
|
||||||
// public function getMainConfig() {
|
// public function getConfigRepository() {
|
||||||
// return this.getService( 'MainConfig' );
|
// return this.getService( 'ConfigRepository' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.27
|
// * @since 1.29
|
||||||
// * @return SiteLookup
|
// * @return \ConfiguredReadOnlyMode
|
||||||
// */
|
// */
|
||||||
// public function getSiteLookup() {
|
// public function getConfiguredReadOnlyMode() {
|
||||||
// return this.getService( 'SiteLookup' );
|
// return this.getService( 'ConfiguredReadOnlyMode' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.27
|
// * @since 1.32
|
||||||
// * @return SiteStore
|
// * @return \Language
|
||||||
// */
|
// */
|
||||||
// public function getSiteStore() {
|
// public function getContentLanguage() {
|
||||||
// return this.getService( 'SiteStore' );
|
// return this.getService( 'ContentLanguage' );
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 1.28
|
|
||||||
* @return InterwikiLookup
|
|
||||||
*/
|
|
||||||
public XomwInterwikiLookup getInterwikiLookup() {
|
|
||||||
return interwikiLookup;
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @since 1.27
|
|
||||||
// * @return StatsdDataFactory
|
|
||||||
// */
|
|
||||||
// public function getStatsdDataFactory() {
|
|
||||||
// return this.getService( 'StatsdDataFactory' );
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.27
|
// * @since 1.31
|
||||||
// * @return EventRelayerGroup
|
// * @return NameTableStore
|
||||||
// */
|
// */
|
||||||
// public function getEventRelayerGroup() {
|
// public function getContentModelStore() {
|
||||||
// return this.getService( 'EventRelayerGroup' );
|
// return this.getService( 'NameTableStoreFactory' )->getContentModels();
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @since 1.27
|
|
||||||
// * @return SearchEngine
|
|
||||||
// */
|
|
||||||
// public function newSearchEngine() {
|
|
||||||
// // New engine Object every time, since they keep state
|
|
||||||
// return this.getService( 'SearchEngineFactory' )->create();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @since 1.27
|
|
||||||
// * @return SearchEngineFactory
|
|
||||||
// */
|
|
||||||
// public function getSearchEngineFactory() {
|
|
||||||
// return this.getService( 'SearchEngineFactory' );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @since 1.27
|
|
||||||
// * @return SearchEngineConfig
|
|
||||||
// */
|
|
||||||
// public function getSearchEngineConfig() {
|
|
||||||
// return this.getService( 'SearchEngineConfig' );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @since 1.27
|
|
||||||
// * @return SkinFactory
|
|
||||||
// */
|
|
||||||
// public function getSkinFactory() {
|
|
||||||
// return this.getService( 'SkinFactory' );
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
// * @return LBFactory
|
// * @return CryptHKDF
|
||||||
// */
|
// */
|
||||||
// public function getDBLoadBalancerFactory() {
|
// public function getCryptHKDF() {
|
||||||
// return this.getService( 'DBLoadBalancerFactory' );
|
// return this.getService( 'CryptHKDF' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.28
|
||||||
|
// * @deprecated since 1.32, use random_bytes()/random_int()
|
||||||
|
// * @return CryptRand
|
||||||
|
// */
|
||||||
|
// public function getCryptRand() {
|
||||||
|
// wfDeprecated( __METHOD__, '1.32' );
|
||||||
|
// return this.getService( 'CryptRand' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
@ -446,34 +489,121 @@ public class XomwMediaWikiServices {
|
|||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
// * @return WatchedItemStore
|
// * @return LBFactory
|
||||||
// */
|
// */
|
||||||
// public function getWatchedItemStore() {
|
// public function getDBLoadBalancerFactory() {
|
||||||
// return this.getService( 'WatchedItemStore' );
|
// return this.getService( 'DBLoadBalancerFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return EventRelayerGroup
|
||||||
|
// */
|
||||||
|
// public function getEventRelayerGroup() {
|
||||||
|
// return this.getService( 'EventRelayerGroup' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return \ExternalStoreFactory
|
||||||
|
// */
|
||||||
|
// public function getExternalStoreFactory() {
|
||||||
|
// return this.getService( 'ExternalStoreFactory' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
// * @return WatchedItemQueryService
|
// * @return GenderCache
|
||||||
// */
|
// */
|
||||||
// public function getWatchedItemQueryService() {
|
// public function getGenderCache() {
|
||||||
// return this.getService( 'WatchedItemQueryService' );
|
// return this.getService( 'GenderCache' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return HttpRequestFactory
|
||||||
|
// */
|
||||||
|
// public function getHttpRequestFactory() {
|
||||||
|
// return this.getService( 'HttpRequestFactory' );
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.28
|
||||||
|
* @return InterwikiLookup
|
||||||
|
*/
|
||||||
|
public XomwInterwikiLookup getInterwikiLookup() {
|
||||||
|
// return this.getService( 'InterwikiLookup' );
|
||||||
|
return interwikiLookup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @since 1.28
|
||||||
|
// * @return LinkCache
|
||||||
|
// */
|
||||||
|
// public function getLinkCache() {
|
||||||
|
// return this.getService( 'LinkCache' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * LinkRenderer instance that can be used
|
||||||
|
// * if no custom options are needed
|
||||||
|
// *
|
||||||
|
// * @since 1.28
|
||||||
|
// * @return LinkRenderer
|
||||||
|
// */
|
||||||
|
// public function getLinkRenderer() {
|
||||||
|
// return this.getService( 'LinkRenderer' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
// * @return CryptRand
|
// * @return LinkRendererFactory
|
||||||
// */
|
// */
|
||||||
// public function getCryptRand() {
|
// public function getLinkRendererFactory() {
|
||||||
// return this.getService( 'CryptRand' );
|
// return this.getService( 'LinkRendererFactory' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
// * @return CryptHKDF
|
// * @return \BagOStuff
|
||||||
// */
|
// */
|
||||||
// public function getCryptHKDF() {
|
// public function getLocalServerObjectCache() {
|
||||||
// return this.getService( 'CryptHKDF' );
|
// return this.getService( 'LocalServerObjectCache' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return MagicWordFactory
|
||||||
|
// */
|
||||||
|
// public function getMagicWordFactory() {
|
||||||
|
// return this.getService( 'MagicWordFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * Returns the Config object that provides configuration for MediaWiki core.
|
||||||
|
// * This may or may not be the same object that is returned by getBootstrapConfig().
|
||||||
|
// *
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return Config
|
||||||
|
// */
|
||||||
|
// public function getMainConfig() {
|
||||||
|
// return this.getService( 'MainConfig' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.28
|
||||||
|
// * @return \BagOStuff
|
||||||
|
// */
|
||||||
|
// public function getMainObjectStash() {
|
||||||
|
// return this.getService( 'MainObjectStash' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.28
|
||||||
|
// * @return \WANObjectCache
|
||||||
|
// */
|
||||||
|
// public function getMainWANObjectCache() {
|
||||||
|
// return this.getService( 'MainWANObjectCache' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
@ -493,11 +623,18 @@ public class XomwMediaWikiServices {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.32
|
||||||
// * @return ProxyLookup
|
// * @return NameTableStoreFactory
|
||||||
// */
|
// */
|
||||||
// public function getProxyLookup() {
|
// public function getNameTableStoreFactory() {
|
||||||
// return this.getService( 'ProxyLookup' );
|
// return this.getService( 'NameTableStoreFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @return OldRevisionImporter
|
||||||
|
// */
|
||||||
|
// public function getOldRevisionImporter() {
|
||||||
|
// return this.getService( 'OldRevisionImporter' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
@ -509,46 +646,213 @@ public class XomwMediaWikiServices {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.30
|
||||||
// * @return GenderCache
|
// * @return ParserCache
|
||||||
// */
|
// */
|
||||||
// public function getGenderCache() {
|
// public function getParserCache() {
|
||||||
// return this.getService( 'GenderCache' );
|
// return this.getService( 'ParserCache' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return ParserFactory
|
||||||
|
// */
|
||||||
|
// public function getParserFactory() {
|
||||||
|
// return this.getService( 'ParserFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return PasswordFactory
|
||||||
|
// */
|
||||||
|
// public function getPasswordFactory() {
|
||||||
|
// return this.getService( 'PasswordFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return StatsdDataFactoryInterface
|
||||||
|
// */
|
||||||
|
// public function getPerDbNameStatsdDataFactory() {
|
||||||
|
// return this.getService( 'PerDbNameStatsdDataFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.33
|
||||||
|
// * @return PermissionManager
|
||||||
|
// */
|
||||||
|
// public function getPermissionManager() {
|
||||||
|
// return this.getService( 'PermissionManager' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return PreferencesFactory
|
||||||
|
// */
|
||||||
|
// public function getPreferencesFactory() {
|
||||||
|
// return this.getService( 'PreferencesFactory' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.28
|
||||||
// * @return LinkCache
|
// * @return ProxyLookup
|
||||||
// */
|
// */
|
||||||
// public function getLinkCache() {
|
// public function getProxyLookup() {
|
||||||
// return this.getService( 'LinkCache' );
|
// return this.getService( 'ProxyLookup' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.29
|
||||||
// * @return LinkRendererFactory
|
// * @return \ReadOnlyMode
|
||||||
// */
|
// */
|
||||||
// public function getLinkRendererFactory() {
|
// public function getReadOnlyMode() {
|
||||||
// return this.getService( 'LinkRendererFactory' );
|
// return this.getService( 'ReadOnlyMode' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * LinkRenderer instance that can be used
|
// * @since 1.33
|
||||||
// * if no custom options are needed
|
// * @return ResourceLoader
|
||||||
// *
|
|
||||||
// * @since 1.28
|
|
||||||
// * @return LinkRenderer
|
|
||||||
// */
|
// */
|
||||||
// public function getLinkRenderer() {
|
// public function getResourceLoader() {
|
||||||
// return this.getService( 'LinkRenderer' );
|
// return this.getService( 'ResourceLoader' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return RevisionFactory
|
||||||
|
// */
|
||||||
|
// public function getRevisionFactory() {
|
||||||
|
// return this.getService( 'RevisionFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return RevisionLookup
|
||||||
|
// */
|
||||||
|
// public function getRevisionLookup() {
|
||||||
|
// return this.getService( 'RevisionLookup' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return RevisionRenderer
|
||||||
|
// */
|
||||||
|
// public function getRevisionRenderer() {
|
||||||
|
// return this.getService( 'RevisionRenderer' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return RevisionStore
|
||||||
|
// */
|
||||||
|
// public function getRevisionStore() {
|
||||||
|
// return this.getService( 'RevisionStore' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return RevisionStoreFactory
|
||||||
|
// */
|
||||||
|
// public function getRevisionStoreFactory() {
|
||||||
|
// return this.getService( 'RevisionStoreFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return SearchEngine
|
||||||
|
// */
|
||||||
|
// public function newSearchEngine() {
|
||||||
|
// // New engine object every time, since they keep state
|
||||||
|
// return this.getService( 'SearchEngineFactory' )->create();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return SearchEngineConfig
|
||||||
|
// */
|
||||||
|
// public function getSearchEngineConfig() {
|
||||||
|
// return this.getService( 'SearchEngineConfig' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return SearchEngineFactory
|
||||||
|
// */
|
||||||
|
// public function getSearchEngineFactory() {
|
||||||
|
// return this.getService( 'SearchEngineFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.30
|
||||||
|
// * @return CommandFactory
|
||||||
|
// */
|
||||||
|
// public function getShellCommandFactory() {
|
||||||
|
// return this.getService( 'ShellCommandFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return SiteLookup
|
||||||
|
// */
|
||||||
|
// public function getSiteLookup() {
|
||||||
|
// return this.getService( 'SiteLookup' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return SiteStore
|
||||||
|
// */
|
||||||
|
// public function getSiteStore() {
|
||||||
|
// return this.getService( 'SiteStore' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return SkinFactory
|
||||||
|
// */
|
||||||
|
// public function getSkinFactory() {
|
||||||
|
// return this.getService( 'SkinFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.33
|
||||||
|
// * @return SlotRoleRegistry
|
||||||
|
// */
|
||||||
|
// public function getSlotRoleRegistry() {
|
||||||
|
// return this.getService( 'SlotRoleRegistry' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return NameTableStore
|
||||||
|
// */
|
||||||
|
// public function getSlotRoleStore() {
|
||||||
|
// return this.getService( 'NameTableStoreFactory' )->getSlotRoles();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.32
|
||||||
|
// * @return SpecialPageFactory
|
||||||
|
// */
|
||||||
|
// public function getSpecialPageFactory() : SpecialPageFactory {
|
||||||
|
// return this.getService( 'SpecialPageFactory' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.27
|
||||||
|
// * @return IBufferingStatsdDataFactory
|
||||||
|
// */
|
||||||
|
// public function getStatsdDataFactory() {
|
||||||
|
// return this.getService( 'StatsdDataFactory' );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.28
|
* @since 1.28
|
||||||
* @return TitleFormatter
|
* @return TitleFormatter
|
||||||
*/
|
*/
|
||||||
public XomwMediaWikiTitleCodec getTitleFormatter() {
|
// public XomwTitleFormatter getTitleFormatter() {
|
||||||
// return this.getService( 'TitleFormatter' );
|
// return this.getService( 'TitleFormatter' );
|
||||||
|
public XomwMediaWikiTitleCodec getTitleFormatter() {
|
||||||
return titleParser;
|
return titleParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -556,33 +860,18 @@ public class XomwMediaWikiServices {
|
|||||||
* @since 1.28
|
* @since 1.28
|
||||||
* @return TitleParser
|
* @return TitleParser
|
||||||
*/
|
*/
|
||||||
public XomwMediaWikiTitleCodec getTitleParser() {
|
// public XomwTitleParser getTitleParser() {
|
||||||
// return this.getService( 'TitleParser' );
|
// return this.getService( 'TitleParser' );
|
||||||
|
public XomwMediaWikiTitleCodec getTitleParser() {
|
||||||
return titleParser;
|
return titleParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @since 1.28
|
// * @since 1.32
|
||||||
// * @return \BagOStuff
|
// * @return UploadRevisionImporter
|
||||||
// */
|
// */
|
||||||
// public function getMainObjectStash() {
|
// public function getUploadRevisionImporter() {
|
||||||
// return this.getService( 'MainObjectStash' );
|
// return this.getService( 'UploadRevisionImporter' );
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @since 1.28
|
|
||||||
// * @return \WANObjectCache
|
|
||||||
// */
|
|
||||||
// public function getMainWANObjectCache() {
|
|
||||||
// return this.getService( 'MainWANObjectCache' );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * @since 1.28
|
|
||||||
// * @return \BagOStuff
|
|
||||||
// */
|
|
||||||
// public function getLocalServerObjectCache() {
|
|
||||||
// return this.getService( 'LocalServerObjectCache' );
|
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
@ -593,9 +882,44 @@ public class XomwMediaWikiServices {
|
|||||||
// return this.getService( 'VirtualRESTServiceClient' );
|
// return this.getService( 'VirtualRESTServiceClient' );
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ///////////////////////////////////////////////////////////////////////////
|
// /**
|
||||||
// // NOTE: When adding a service getter here, don't forget to add a test
|
// * @since 1.28
|
||||||
// // case for it in MediaWikiServicesTest::provideGetters() and in
|
// * @return WatchedItemQueryService
|
||||||
// // MediaWikiServicesTest::provideGetService()!
|
// */
|
||||||
// ///////////////////////////////////////////////////////////////////////////
|
// public function getWatchedItemQueryService() {
|
||||||
|
// return this.getService( 'WatchedItemQueryService' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.28
|
||||||
|
// * @return WatchedItemStoreInterface
|
||||||
|
// */
|
||||||
|
// public function getWatchedItemStore() {
|
||||||
|
// return this.getService( 'WatchedItemStore' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return \OldRevisionImporter
|
||||||
|
// */
|
||||||
|
// public function getWikiRevisionOldRevisionImporter() {
|
||||||
|
// return this.getService( 'OldRevisionImporter' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return \OldRevisionImporter
|
||||||
|
// */
|
||||||
|
// public function getWikiRevisionOldRevisionImporterNoUpdates() {
|
||||||
|
// return this.getService( 'WikiRevisionOldRevisionImporterNoUpdates' );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * @since 1.31
|
||||||
|
// * @return \UploadRevisionImporter
|
||||||
|
// */
|
||||||
|
// public function getWikiRevisionUploadImporter() {
|
||||||
|
// return this.getService( 'UploadRevisionImporter' );
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4563,13 +4563,12 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
|
|||||||
|
|
||||||
// Hooks::run('ParserFetchTemplate',
|
// Hooks::run('ParserFetchTemplate',
|
||||||
// [ parser, title, rev, &text, &deps ]);
|
// [ parser, title, rev, &text, &deps ]);
|
||||||
|
|
||||||
if (XophpString_.is_false(text) || XophpString_.is_null(text)) {
|
if (XophpString_.is_false(text) || XophpString_.is_null(text)) {
|
||||||
text = XophpString_.False;
|
text = XophpString_.False;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (title.getNamespace() == XomwDefines.NS_MEDIAWIKI) {
|
} else if (title.getNamespace() == XomwDefines.NS_MEDIAWIKI) {
|
||||||
// message = wfMessage(MediaWikiServices::getInstance().getContentLanguage().
|
// message = XomwGlobalFunctions.wfMessage(MediaWikiServices.getInstance().getContentLanguage().
|
||||||
// lcfirst(title.getText())).inContentLanguage();
|
// lcfirst(title.getText())).inContentLanguage();
|
||||||
// if (!message.exists()) {
|
// if (!message.exists()) {
|
||||||
// text = false;
|
// text = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user