2012-01-28 16:22:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wikitext scripting infrastructure for MediaWiki: base classes.
|
|
|
|
* Copyright (C) 2012 Victor Vasiliev <vasilvv@gmail.com> et al
|
2018-10-29 13:33:03 +00:00
|
|
|
* https://www.mediawiki.org/
|
2012-01-28 16:22:18 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-04-06 05:04:30 +00:00
|
|
|
* Base class for all script engines. Includes all code
|
2012-01-28 16:22:18 +00:00
|
|
|
* not related to particular modules, like tracking links between
|
|
|
|
* modules or loading module texts.
|
|
|
|
*/
|
2012-04-06 05:04:30 +00:00
|
|
|
abstract class ScribuntoEngineBase {
|
2015-10-28 01:21:14 +00:00
|
|
|
|
|
|
|
// Flags for ScribuntoEngineBase::getResourceUsage()
|
2020-05-30 00:32:16 +00:00
|
|
|
public const CPU_SECONDS = 1;
|
|
|
|
public const MEM_PEAK_BYTES = 2;
|
2015-10-28 01:21:14 +00:00
|
|
|
|
2014-10-10 09:02:03 +00:00
|
|
|
/**
|
2019-12-22 02:14:03 +00:00
|
|
|
* @var Title|null
|
2014-10-10 09:02:03 +00:00
|
|
|
*/
|
2014-10-09 19:49:40 +00:00
|
|
|
protected $title;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $options;
|
|
|
|
|
|
|
|
/**
|
2019-12-22 02:14:03 +00:00
|
|
|
* @var (ScribuntoModuleBase|null)[]
|
2014-10-09 19:49:40 +00:00
|
|
|
*/
|
2017-06-15 17:19:00 +00:00
|
|
|
protected $modules = [];
|
2012-01-28 16:22:18 +00:00
|
|
|
|
2014-06-18 17:17:04 +00:00
|
|
|
/**
|
2019-12-22 02:14:03 +00:00
|
|
|
* @var Parser|null
|
2014-06-18 17:17:04 +00:00
|
|
|
*/
|
|
|
|
protected $parser;
|
|
|
|
|
2012-01-28 16:22:18 +00:00
|
|
|
/**
|
2012-04-04 06:10:32 +00:00
|
|
|
* Creates a new module object within this engine
|
2014-10-09 19:49:40 +00:00
|
|
|
*
|
|
|
|
* @param string $text
|
2014-10-10 09:02:03 +00:00
|
|
|
* @param string|bool $chunkName
|
2014-06-18 17:17:04 +00:00
|
|
|
* @return ScribuntoModuleBase
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
2012-04-05 07:58:02 +00:00
|
|
|
abstract protected function newModule( $text, $chunkName );
|
2012-01-28 16:22:18 +00:00
|
|
|
|
2012-07-14 04:23:42 +00:00
|
|
|
/**
|
|
|
|
* Run an interactive console request
|
|
|
|
*
|
2014-06-18 17:17:04 +00:00
|
|
|
* @param array $params Associative array. Options are:
|
2012-07-14 04:23:42 +00:00
|
|
|
* - title: The title object for the module being debugged
|
|
|
|
* - content: The text content of the module
|
2013-01-25 17:53:18 +00:00
|
|
|
* - prevQuestions: An array of previous "questions" used to establish the state
|
2012-07-14 04:23:42 +00:00
|
|
|
* - question: The current "question", a string script
|
|
|
|
*
|
|
|
|
* @return array containing:
|
|
|
|
* - print: The resulting print buffer
|
|
|
|
* - return: The resulting return value
|
|
|
|
*/
|
2018-11-09 19:31:08 +00:00
|
|
|
abstract public function runConsole( array $params );
|
2012-07-14 04:23:42 +00:00
|
|
|
|
2013-03-20 16:30:26 +00:00
|
|
|
/**
|
|
|
|
* Get software information for Special:Version
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param array &$software
|
2013-03-20 16:30:26 +00:00
|
|
|
*/
|
2014-10-09 19:49:40 +00:00
|
|
|
abstract public function getSoftwareInfo( array &$software );
|
2013-03-20 16:30:26 +00:00
|
|
|
|
2012-01-28 16:22:18 +00:00
|
|
|
/**
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param array $options Associative array of options:
|
2012-04-05 07:58:02 +00:00
|
|
|
* - parser: A Parser object
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
2014-10-09 19:49:40 +00:00
|
|
|
public function __construct( array $options ) {
|
2012-04-05 07:58:02 +00:00
|
|
|
$this->options = $options;
|
|
|
|
if ( isset( $options['parser'] ) ) {
|
|
|
|
$this->parser = $options['parser'];
|
|
|
|
}
|
2012-04-23 11:36:13 +00:00
|
|
|
if ( isset( $options['title'] ) ) {
|
|
|
|
$this->title = $options['title'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 11:43:44 +00:00
|
|
|
public function __destruct() {
|
2012-09-05 09:39:58 +00:00
|
|
|
$this->destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function destroy() {
|
|
|
|
// Break reference cycles
|
|
|
|
$this->parser = null;
|
|
|
|
$this->title = null;
|
2019-11-07 19:37:46 +00:00
|
|
|
$this->modules = [];
|
2012-09-05 09:39:58 +00:00
|
|
|
}
|
|
|
|
|
2014-06-18 17:17:04 +00:00
|
|
|
/**
|
|
|
|
* @param Title $title
|
|
|
|
*/
|
2012-04-23 11:36:13 +00:00
|
|
|
public function setTitle( $title ) {
|
|
|
|
$this->title = $title;
|
|
|
|
}
|
|
|
|
|
2014-06-18 17:17:04 +00:00
|
|
|
/**
|
|
|
|
* @return Title
|
|
|
|
*/
|
2012-04-23 11:36:13 +00:00
|
|
|
public function getTitle() {
|
|
|
|
return $this->title;
|
|
|
|
}
|
|
|
|
|
2017-03-20 02:59:23 +00:00
|
|
|
/**
|
|
|
|
* Get an element from the configuration array
|
|
|
|
*
|
|
|
|
* @param string $optionName
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getOption( $optionName ) {
|
2019-03-21 04:16:08 +00:00
|
|
|
return $this->options[$optionName] ?? null;
|
2017-03-20 02:59:23 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 23:34:35 +00:00
|
|
|
/**
|
2014-10-09 19:49:40 +00:00
|
|
|
* @param string $message
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param array $params
|
2012-06-15 23:34:35 +00:00
|
|
|
* @return ScribuntoException
|
|
|
|
*/
|
2017-06-15 17:19:00 +00:00
|
|
|
public function newException( $message, array $params = [] ) {
|
2012-04-23 11:36:13 +00:00
|
|
|
return new ScribuntoException( $message, $this->getDefaultExceptionParams() + $params );
|
|
|
|
}
|
|
|
|
|
2012-06-15 23:34:35 +00:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2012-04-23 11:36:13 +00:00
|
|
|
public function getDefaultExceptionParams() {
|
2017-06-15 17:19:00 +00:00
|
|
|
$params = [];
|
2012-04-23 11:36:13 +00:00
|
|
|
if ( $this->title ) {
|
|
|
|
$params['title'] = $this->title;
|
|
|
|
}
|
|
|
|
return $params;
|
2012-01-28 16:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-07 18:46:59 +00:00
|
|
|
* Load a module from some parser-defined template loading mechanism and
|
2012-04-05 07:58:02 +00:00
|
|
|
* register a parser output dependency.
|
|
|
|
*
|
2012-01-28 16:22:18 +00:00
|
|
|
* Does not initialize the module, i.e. do not expect it to complain if the module
|
Added more Lua environment features
Package library:
* Added a simulation of the Lua 5.1 package library.
* Removed mw.import(), replaced it with a package loader. Packages can be
retrieved from the wiki, using require('Module:Foo'), or from files
distributed with Scribunto, using require('foo'). The "Module:" prefix allows
for source compatibility with existing Lua code.
* Added a couple of libraries from LuaForge: luabit and stringtools.
* Made fetchModuleFromParser() return null on error instead of throwing an
exception, to more easily support the desired behaviour of the package loader,
which needs to return null on error.
* Renamed mw.setupEnvironment() to mw.setup() since it is setting up things
other than the environment now.
* In MWServer:handleRegisterLibrary(), remove the feature which interprets dots
in library names, since LuaSandbox doesn't support this.
Improved module isolation and related refactoring:
* Expose restricted versions of getfenv() and setfenv() to user Lua code.
Requires luasandbox r114952.
* Don't cache the export list returned by module execution for later function
calls. This breaks isolation of #invoke calls, since the local variables are
persistent.
* Removed ScribuntoFunctionBase and its children, since it doesn't really have
a purpose if it can't cache anything. Instead, invoke functions using a module
method called invoke().
* Removed Module::initialize(), replaced it with a validate() function. This is
a more elegant interface and works better with the new module caching scheme.
* Use a Status object for the return value of Engine::validate() instead of an
array. Use the formatting facilities of the Status class.
Other:
* Removed "too many returns" error, doesn't fit in with Lua conventions.
* Use the standalone engine by default, so that the extension will work without
configuration for more people.
* Added an accessor for $engine->interpreter
* Fix mw.clone() to correctly clone metatables
* If the standalone interpreter exits due to an error, there are some contexts
where the initial error will be caught and ignored, and the user will see the
error from checkValid() instead. In this case, rethrow the original error for
a more informative message.
* Load mw.lua into the initial standalone environment, to reduce code
duplication between mw.lua and MWServer.lua.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::handleCall() for functions
that return no results.
* Fixed a bug in encodeLuaVar() for strings with "\r". Added test case.
* In MWServer.lua, don't call error() for internal errors, instead just print
the error and exit. This avoids a protocol violation when an error is
encountered from within handleCall().
* Added lots of documentation. Lua doc comments are in LuaDoc format.
Change-Id: Ie2fd572c362bedf02f45d3fa5352a5280e034740
2012-04-18 03:46:18 +00:00
|
|
|
* text is garbage or has syntax error. Returns a module or null if it doesn't exist.
|
2012-04-05 07:58:02 +00:00
|
|
|
*
|
2014-06-18 17:17:04 +00:00
|
|
|
* @param Title $title The title of the module
|
2018-04-09 04:39:06 +00:00
|
|
|
* @return ScribuntoModuleBase|null
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
2018-11-09 19:31:08 +00:00
|
|
|
public function fetchModuleFromParser( Title $title ) {
|
2013-03-18 01:21:14 +00:00
|
|
|
$key = $title->getPrefixedDBkey();
|
|
|
|
if ( !array_key_exists( $key, $this->modules ) ) {
|
|
|
|
list( $text, $finalTitle ) = $this->parser->fetchTemplateAndTitle( $title );
|
|
|
|
if ( $text === false ) {
|
|
|
|
$this->modules[$key] = null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$finalKey = $finalTitle->getPrefixedDBkey();
|
|
|
|
if ( !isset( $this->modules[$finalKey] ) ) {
|
|
|
|
$this->modules[$finalKey] = $this->newModule( $text, $finalKey );
|
|
|
|
}
|
|
|
|
// Almost certainly $key === $finalKey, but just in case...
|
|
|
|
$this->modules[$key] = $this->modules[$finalKey];
|
2012-01-28 16:22:18 +00:00
|
|
|
}
|
2012-04-05 03:53:05 +00:00
|
|
|
return $this->modules[$key];
|
2012-01-28 16:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-07 18:46:59 +00:00
|
|
|
* Validates the script and returns a Status object containing the syntax
|
Added more Lua environment features
Package library:
* Added a simulation of the Lua 5.1 package library.
* Removed mw.import(), replaced it with a package loader. Packages can be
retrieved from the wiki, using require('Module:Foo'), or from files
distributed with Scribunto, using require('foo'). The "Module:" prefix allows
for source compatibility with existing Lua code.
* Added a couple of libraries from LuaForge: luabit and stringtools.
* Made fetchModuleFromParser() return null on error instead of throwing an
exception, to more easily support the desired behaviour of the package loader,
which needs to return null on error.
* Renamed mw.setupEnvironment() to mw.setup() since it is setting up things
other than the environment now.
* In MWServer:handleRegisterLibrary(), remove the feature which interprets dots
in library names, since LuaSandbox doesn't support this.
Improved module isolation and related refactoring:
* Expose restricted versions of getfenv() and setfenv() to user Lua code.
Requires luasandbox r114952.
* Don't cache the export list returned by module execution for later function
calls. This breaks isolation of #invoke calls, since the local variables are
persistent.
* Removed ScribuntoFunctionBase and its children, since it doesn't really have
a purpose if it can't cache anything. Instead, invoke functions using a module
method called invoke().
* Removed Module::initialize(), replaced it with a validate() function. This is
a more elegant interface and works better with the new module caching scheme.
* Use a Status object for the return value of Engine::validate() instead of an
array. Use the formatting facilities of the Status class.
Other:
* Removed "too many returns" error, doesn't fit in with Lua conventions.
* Use the standalone engine by default, so that the extension will work without
configuration for more people.
* Added an accessor for $engine->interpreter
* Fix mw.clone() to correctly clone metatables
* If the standalone interpreter exits due to an error, there are some contexts
where the initial error will be caught and ignored, and the user will see the
error from checkValid() instead. In this case, rethrow the original error for
a more informative message.
* Load mw.lua into the initial standalone environment, to reduce code
duplication between mw.lua and MWServer.lua.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::handleCall() for functions
that return no results.
* Fixed a bug in encodeLuaVar() for strings with "\r". Added test case.
* In MWServer.lua, don't call error() for internal errors, instead just print
the error and exit. This avoids a protocol violation when an error is
encountered from within handleCall().
* Added lots of documentation. Lua doc comments are in LuaDoc format.
Change-Id: Ie2fd572c362bedf02f45d3fa5352a5280e034740
2012-04-18 03:46:18 +00:00
|
|
|
* errors for the given code.
|
2014-07-07 18:46:59 +00:00
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param string $text
|
2014-10-10 09:02:03 +00:00
|
|
|
* @param string|bool $chunkName
|
Added more Lua environment features
Package library:
* Added a simulation of the Lua 5.1 package library.
* Removed mw.import(), replaced it with a package loader. Packages can be
retrieved from the wiki, using require('Module:Foo'), or from files
distributed with Scribunto, using require('foo'). The "Module:" prefix allows
for source compatibility with existing Lua code.
* Added a couple of libraries from LuaForge: luabit and stringtools.
* Made fetchModuleFromParser() return null on error instead of throwing an
exception, to more easily support the desired behaviour of the package loader,
which needs to return null on error.
* Renamed mw.setupEnvironment() to mw.setup() since it is setting up things
other than the environment now.
* In MWServer:handleRegisterLibrary(), remove the feature which interprets dots
in library names, since LuaSandbox doesn't support this.
Improved module isolation and related refactoring:
* Expose restricted versions of getfenv() and setfenv() to user Lua code.
Requires luasandbox r114952.
* Don't cache the export list returned by module execution for later function
calls. This breaks isolation of #invoke calls, since the local variables are
persistent.
* Removed ScribuntoFunctionBase and its children, since it doesn't really have
a purpose if it can't cache anything. Instead, invoke functions using a module
method called invoke().
* Removed Module::initialize(), replaced it with a validate() function. This is
a more elegant interface and works better with the new module caching scheme.
* Use a Status object for the return value of Engine::validate() instead of an
array. Use the formatting facilities of the Status class.
Other:
* Removed "too many returns" error, doesn't fit in with Lua conventions.
* Use the standalone engine by default, so that the extension will work without
configuration for more people.
* Added an accessor for $engine->interpreter
* Fix mw.clone() to correctly clone metatables
* If the standalone interpreter exits due to an error, there are some contexts
where the initial error will be caught and ignored, and the user will see the
error from checkValid() instead. In this case, rethrow the original error for
a more informative message.
* Load mw.lua into the initial standalone environment, to reduce code
duplication between mw.lua and MWServer.lua.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::handleCall() for functions
that return no results.
* Fixed a bug in encodeLuaVar() for strings with "\r". Added test case.
* In MWServer.lua, don't call error() for internal errors, instead just print
the error and exit. This avoids a protocol violation when an error is
encountered from within handleCall().
* Added lots of documentation. Lua doc comments are in LuaDoc format.
Change-Id: Ie2fd572c362bedf02f45d3fa5352a5280e034740
2012-04-18 03:46:18 +00:00
|
|
|
* @return Status
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
2018-11-09 19:31:08 +00:00
|
|
|
public function validate( $text, $chunkName = false ) {
|
2012-04-05 07:58:02 +00:00
|
|
|
$module = $this->newModule( $text, $chunkName );
|
Added more Lua environment features
Package library:
* Added a simulation of the Lua 5.1 package library.
* Removed mw.import(), replaced it with a package loader. Packages can be
retrieved from the wiki, using require('Module:Foo'), or from files
distributed with Scribunto, using require('foo'). The "Module:" prefix allows
for source compatibility with existing Lua code.
* Added a couple of libraries from LuaForge: luabit and stringtools.
* Made fetchModuleFromParser() return null on error instead of throwing an
exception, to more easily support the desired behaviour of the package loader,
which needs to return null on error.
* Renamed mw.setupEnvironment() to mw.setup() since it is setting up things
other than the environment now.
* In MWServer:handleRegisterLibrary(), remove the feature which interprets dots
in library names, since LuaSandbox doesn't support this.
Improved module isolation and related refactoring:
* Expose restricted versions of getfenv() and setfenv() to user Lua code.
Requires luasandbox r114952.
* Don't cache the export list returned by module execution for later function
calls. This breaks isolation of #invoke calls, since the local variables are
persistent.
* Removed ScribuntoFunctionBase and its children, since it doesn't really have
a purpose if it can't cache anything. Instead, invoke functions using a module
method called invoke().
* Removed Module::initialize(), replaced it with a validate() function. This is
a more elegant interface and works better with the new module caching scheme.
* Use a Status object for the return value of Engine::validate() instead of an
array. Use the formatting facilities of the Status class.
Other:
* Removed "too many returns" error, doesn't fit in with Lua conventions.
* Use the standalone engine by default, so that the extension will work without
configuration for more people.
* Added an accessor for $engine->interpreter
* Fix mw.clone() to correctly clone metatables
* If the standalone interpreter exits due to an error, there are some contexts
where the initial error will be caught and ignored, and the user will see the
error from checkValid() instead. In this case, rethrow the original error for
a more informative message.
* Load mw.lua into the initial standalone environment, to reduce code
duplication between mw.lua and MWServer.lua.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::handleCall() for functions
that return no results.
* Fixed a bug in encodeLuaVar() for strings with "\r". Added test case.
* In MWServer.lua, don't call error() for internal errors, instead just print
the error and exit. This avoids a protocol violation when an error is
encountered from within handleCall().
* Added lots of documentation. Lua doc comments are in LuaDoc format.
Change-Id: Ie2fd572c362bedf02f45d3fa5352a5280e034740
2012-04-18 03:46:18 +00:00
|
|
|
return $module->validate();
|
2012-01-28 16:22:18 +00:00
|
|
|
}
|
|
|
|
|
2015-10-28 01:21:14 +00:00
|
|
|
/**
|
|
|
|
* Get CPU and memory usage information, if the script engine
|
|
|
|
* provides it.
|
|
|
|
*
|
|
|
|
* If the script engine is capable of reporting CPU and memory usage
|
|
|
|
* data, it should override this implementation.
|
|
|
|
*
|
|
|
|
* @param int $resource One of ScribuntoEngineBase::CPU_SECONDS
|
|
|
|
* or ScribuntoEngineBase::MEM_PEAK_BYTES.
|
2018-04-09 04:39:06 +00:00
|
|
|
* @return float|int|false Resource usage for the specified resource
|
2015-10-28 01:21:14 +00:00
|
|
|
* or false if not available.
|
|
|
|
*/
|
|
|
|
public function getResourceUsage( $resource ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-28 16:22:18 +00:00
|
|
|
/**
|
2012-02-06 22:14:47 +00:00
|
|
|
* Get the language for GeSHi syntax highlighter.
|
2017-09-24 17:38:14 +00:00
|
|
|
* @return string|false
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
2018-11-09 19:31:08 +00:00
|
|
|
public function getGeSHiLanguage() {
|
2012-01-28 16:22:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 18:46:59 +00:00
|
|
|
|
2012-02-06 22:14:47 +00:00
|
|
|
/**
|
2012-04-05 07:58:02 +00:00
|
|
|
* Get the language for Ace code editor.
|
2017-09-24 17:38:14 +00:00
|
|
|
* @return string|false
|
2012-02-06 22:14:47 +00:00
|
|
|
*/
|
2018-11-09 19:31:08 +00:00
|
|
|
public function getCodeEditorLanguage() {
|
2012-02-06 22:14:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
2012-04-19 07:40:56 +00:00
|
|
|
|
2014-06-18 17:17:04 +00:00
|
|
|
/**
|
|
|
|
* @return Parser
|
|
|
|
*/
|
2012-04-19 07:40:56 +00:00
|
|
|
public function getParser() {
|
|
|
|
return $this->parser;
|
|
|
|
}
|
2013-02-14 17:38:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a list of all libraries supported by this engine
|
|
|
|
*
|
2014-09-26 18:11:21 +00:00
|
|
|
* The return value is an array with keys being the library name seen by
|
|
|
|
* the module and values being either a PHP class name or an array with the
|
|
|
|
* following elements:
|
|
|
|
* - class: (string) Class to load (required)
|
|
|
|
* - deferLoad: (bool) Library should not be loaded at startup; modules
|
|
|
|
* needing the library must request it (e.g. via 'require' in Lua)
|
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param string $engine script engine we're using (eg: lua)
|
|
|
|
* @param array $coreLibraries Array of core libraries we support
|
2013-02-14 17:38:03 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2017-06-15 17:19:00 +00:00
|
|
|
protected function getLibraries( $engine, array $coreLibraries = [] ) {
|
|
|
|
$extraLibraries = [];
|
|
|
|
Hooks::run( 'ScribuntoExternalLibraries', [ $engine, &$extraLibraries ] );
|
2013-02-14 17:38:03 +00:00
|
|
|
return $coreLibraries + $extraLibraries;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a list of all paths libraries can be in for this engine
|
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param string $engine script engine we're using (eg: lua)
|
|
|
|
* @param array $coreLibraryPaths Array of library paths to use by default
|
2013-02-14 17:38:03 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2017-06-15 17:19:00 +00:00
|
|
|
protected function getLibraryPaths( $engine, array $coreLibraryPaths = [] ) {
|
|
|
|
$extraLibraryPaths = [];
|
|
|
|
Hooks::run( 'ScribuntoExternalLibraryPaths', [ $engine, &$extraLibraryPaths ] );
|
2013-02-14 17:38:03 +00:00
|
|
|
return array_merge( $coreLibraryPaths, $extraLibraryPaths );
|
|
|
|
}
|
2013-03-14 12:42:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add limit report data to a ParserOutput object
|
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param ParserOutput $output ParserOutput object in which to add limit data
|
2013-03-14 12:42:42 +00:00
|
|
|
* @return null
|
|
|
|
*/
|
2015-06-26 16:37:34 +00:00
|
|
|
public function reportLimitData( ParserOutput $output ) {
|
2013-03-14 12:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Format limit report data
|
|
|
|
*
|
2017-09-24 17:38:14 +00:00
|
|
|
* @param string $key
|
|
|
|
* @param mixed &$value
|
|
|
|
* @param string &$report
|
|
|
|
* @param bool $isHTML
|
|
|
|
* @param bool $localize
|
2013-03-14 12:42:42 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2015-06-26 16:37:34 +00:00
|
|
|
public function formatLimitData( $key, &$value, &$report, $isHTML, $localize ) {
|
2013-03-14 12:42:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-01-28 16:22:18 +00:00
|
|
|
}
|