16 if ( isset( $options[
'factory'] ) ) {
17 return call_user_func( $options[
'factory'], $options );
19 $class = $options[
'class'];
20 return new $class( $options );
33 global $wgScribuntoDefaultEngine, $wgScribuntoEngineConf;
34 if ( !$wgScribuntoDefaultEngine ) {
36 'Scribunto extension is enabled but $wgScribuntoDefaultEngine is not set'
40 if ( !isset( $wgScribuntoEngineConf[$wgScribuntoDefaultEngine] ) ) {
41 throw new MWException(
'Invalid scripting engine is specified in $wgScribuntoDefaultEngine' );
43 $options = $extraOptions + $wgScribuntoEngineConf[$wgScribuntoDefaultEngine];
57 if ( empty( $parser->scribunto_engine ) ) {
61 return $parser->scribunto_engine;
71 return !empty( $parser->scribunto_engine );
79 if ( !empty( $parser->scribunto_engine ) ) {
80 $parser->scribunto_engine->destroy();
81 $parser->scribunto_engine =
null;
93 $docPage =
wfMessage(
'scribunto-doc-page-name' )->inContentLanguage();
94 if ( $docPage->isDisabled() ) {
100 $docTitle = Title::newFromText( $docPage->plain() );
104 $docPage = $docTitle->getPrefixedText();
107 $docPage = str_replace(
'\\$1',
'(.+)', preg_quote( $docPage,
'/' ) );
108 if ( preg_match(
"/^$docPage$/",
$title->getPrefixedText(), $m ) ) {
109 $forModule = Title::makeTitleSafe(
NS_MODULE, $m[1] );
110 return $forModule !==
null;
123 $docPage =
wfMessage(
'scribunto-doc-page-name',
$title->getText() )->inContentLanguage();
124 if ( $docPage->isDisabled() ) {
128 return Title::newFromText( $docPage->plain() );
157 if ( isset(
$params[
'args'] ) ) {
158 $this->messageArgs =
$params[
'args'];
160 $this->messageArgs = [];
163 $codeLocation =
false;
164 if ( isset(
$params[
'title'] ) ) {
165 $moduleTitle = Title::newFromText(
$params[
'module'] );
166 if ( $moduleTitle && $moduleTitle->equals(
$params[
'title'] ) ) {
167 $codeLocation =
wfMessage(
'scribunto-line',
$params[
'line'] )->inContentLanguage()->text();
170 if ( $codeLocation ===
false ) {
172 'scribunto-module-line',
175 )->inContentLanguage()->text();
178 $codeLocation =
'[UNKNOWN]';
180 array_unshift( $this->messageArgs, $codeLocation );
182 parent::__construct( $msg );
196 $status = Status::newFatal( $this->messageName, ...$this->messageArgs );
197 $status->scribunto_error = $this;
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
setTitle(Title $t=null)
Set the context title.
getTitle()
Accessor for the Title object.
An exception class which represents an error in the script.
__construct( $messageName, $params=[])
getScriptTraceHtml( $options=[])
Get the backtrace as HTML, or false if there is none available.
Static function collection for general extension support.
static newDefaultEngine( $extraOptions=[])
Create a new engine object with default parameters.
static isParserEnginePresent(Parser $parser)
Check if an engine instance is present in the given parser.
static newEngine( $options)
Create a new engine object with specified parameters.
static isDocPage(Title $title, Title &$forModule=null)
Test whether the page should be considered a documentation page.
static getDocPage(Title $title)
Return the Title for the documentation page.
static getParserEngine(Parser $parser)
Get an engine instance for the given parser, and cache it in the parser so that subsequent calls to t...
static resetParserEngine(Parser $parser)
Remove the current engine instance from the parser.
Represents a title within MediaWiki.