예제 #1
0
	/**
	 * Purges cache for all the pages where the script is used.
	 */
	public static function purgeCache( &$article, &$editInfo, $changed ) {
		global $wgDeferredUpdateList;

		if( $article->mTitle->getNamespace() == NS_MODULE ) {
			// Invalidate the script cache
			WSInterpreter::invalidateModule( $article->mTitle );
			
			// Invalidate caches of articles which include the script
			$wgDeferredUpdateList[] = new HTMLCacheUpdate( $article->mTitle, 'scriptlinks' );
		}

		return true;
	}
예제 #2
0
	public static function invokeCodeParser( $code, $module, $method = 'parse' ) {
		global $wgScriptsParserClass, $wgScriptsLimits;

		if( !self::$mCodeParser ) {
			self::$mCodeParser = new $wgScriptsParserClass();
		}

		if( self::$mCodeParser->needsScanner() ) {
			$input = new WSScanner( $module, $code );
		} else {
			$input = $code;
		}

		return self::$mCodeParser->$method( $input, $module, $wgScriptsLimits['tokens'] );
	}
예제 #3
0
	public static function validateScript( $editor, $text, $section, &$error ) {
		global $wgUser;
		$title = $editor->mTitle;

		if( $title->getNamespace() == NS_MODULE ) {
			$errors = WSInterpreter::getSyntaxErrors( $title->getText(), $text );
			if( !$errors ) {
				return true;
			}

			$errmsg = wfMsgExt( 'wikiscripts-error', array( 'parsemag' ), array( count( $errors ) ) );
			$errlines = '* ' . implode( "\n* ", array_map( 'wfEscapeWikiText', $errors ) );
			$error = <<<HTML
<div class="errorbox">
{$errmsg}
{$errlines}
</div>
<br clear="all" />
HTML;

			return true;
		}
		
		return true;
	}