scribunto_engine ) ) { $parser->scribunto_engine = self::newDefaultEngine( array( 'parser' => $parser ) ); $parser->scribunto_engine->setTitle( $parser->getTitle() ); } return $parser->scribunto_engine; } /** * Check if an engine instance is present in the given parser */ public static function isParserEnginePresent( $parser ) { return !empty( $parser->scribunto_engine ); } /** * Remove the current engine instance from the parser */ public static function resetParserEngine( $parser ) { $parser->scribunto_engine = null; } } /** * An exception class which represents an error in the script. This does not * normally abort the request, instead it is caught and shown to the user. */ class ScribuntoException extends MWException { var $messageName, $messageArgs, $params; function __construct( $messageName, $params = array() ) { if ( isset( $params['args'] ) ) { $this->messageArgs = $params['args']; } else { $this->messageArgs = array(); } if ( isset( $params['module'] ) && isset( $params['line'] ) ) { $codeLocation = false; if ( isset( $params['title'] ) ) { $moduleTitle = Title::newFromText( $params['module'] ); if ( $moduleTitle && $moduleTitle->equals( $params['title'] ) ) { $codeLocation = wfMsg( 'scribunto-line', $params['line'] ); } } if ( $codeLocation === false ) { $codeLocation = wfMsg( 'scribunto-module-line', $params['module'], $params['line'] ); } } else { $codeLocation = '[UNKNOWN]'; } array_unshift( $this->messageArgs, $codeLocation ); $msg = wfMsgExt( $messageName, array(), $this->messageArgs ); parent::__construct( $msg ); $this->messageName = $messageName; $this->params = $params; } public function getMessageName() { return $this->messageName; } public function toStatus() { $args = array_merge( array( $this->messageName ), $this->messageArgs ); $status = call_user_func_array( array( 'Status', 'newFatal' ), $args ); $status->scribunto_error = $this; return $status; } /** * Get the backtrace as HTML, or false if there is none available. */ public function getScriptTraceHtml( $options = array() ) { return false; } }