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 ) ) {
59 $parser->scribunto_engine->setTitle( $parser->getTitle() );
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() ) {
104 $docPage = $docTitle->getPrefixedText();
107 $docPage = str_replace(
'\\$1',
'(.+)', preg_quote( $docPage,
'/' ) );
108 if ( preg_match(
"/^$docPage$/",
$title->getPrefixedText(), $m ) ) {
110 return $forModule !==
null;
123 $docPage =
wfMessage(
'scribunto-doc-page-name',
$title->getText() )->inContentLanguage();
124 if ( $docPage->isDisabled() ) {
157 if ( isset(
$params[
'args'] ) ) {
158 $this->messageArgs =
$params[
'args'];
160 $this->messageArgs = [];
163 $codeLocation =
false;
164 if ( isset(
$params[
'title'] ) ) {
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 );
197 $status->scribunto_error = $this;