Esempio n. 1
0
 /**
  * Purges cache for all the pages where the script is used.
  * @param $article Article
  * @param $editInfo
  * @param $changed
  * @return bool
  */
 public static function purgeCache(&$article, &$editInfo, $changed)
 {
     global $wgDeferredUpdateList, $wgParser;
     if ($article->getTitle()->getNamespace() == NS_MODULE) {
         // Invalidate the script cache
         $engine = Scripting::getEngine($wgParser);
         $engine->invalidateModuleCache($article->getTitle());
         // Invalidate caches of articles which include the script
         $wgDeferredUpdateList[] = new HTMLCacheUpdate($article->getTitle(), 'scriptlinks');
     }
     return true;
 }
Esempio n. 2
0
    public static function validateScript($editor, $text, $section, &$error)
    {
        global $wgUser, $wgParser;
        $title = $editor->mTitle;
        if ($title->getNamespace() == NS_MODULE) {
            $engine = Scripting::getEngine($wgParser);
            $errors = $engine->validate($text, $title);
            if (!$errors) {
                return true;
            }
            $errmsg = wfMsgExt('scripting-error', array('parsemag'), array(count($errors)));
            if (count($errors) == 1) {
                $errlines = ': ' . wfEscapeWikiText($errors[0]);
            } else {
                $errlines = '* ' . implode("\n* ", array_map('wfEscapeWikiText', $errors));
            }
            $error = <<<HTML
<div class="errorbox">
{$errmsg}
{$errlines}
</div>
<br clear="all" />
HTML;
            return true;
        }
        return true;
    }