예제 #1
0
 /**
  * Setup Rich Text Editor by loading needed JS/CSS files and adding hook(s)
  *
  * @author Inez KorczyDski, Macbre
  */
 public static function init(&$form)
 {
     global $wgOut, $wgHooks, $wgAllInOne, $wgRequest;
     wfProfileIn(__METHOD__);
     RTE::log('init');
     // save reference to Title object of currently edited page
     self::$title = $form->mTitle;
     // check 'useeditor' URL param, user settings...
     self::checkEditorConditions();
     // add global JS variables
     $wgHooks['MakeGlobalVariablesScript'][] = 'RTE::makeGlobalVariablesScript';
     // should CK editor be disabled?
     if (self::$useWysiwyg === false) {
         RTE::log('fallback to MW editor');
         wfProfileOut(__METHOD__);
         return true;
     }
     // devmode
     self::$devMode = $wgRequest->getBool('allinone', $wgAllInOne) === false;
     // add RTE javascript files
     // scripts loaded by edit page layout
     // add RTE css file
     $wgOut->addExtensionStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/RTE/css/RTE.scss'));
     // parse wikitext of edited page and add extra fields to editform
     $wgHooks['EditPage::showEditForm:fields'][] = 'RTE::init2';
     // add CSS class to <body> tag
     $wgHooks['SkinGetPageClasses'][] = 'RTE::addBodyClass';
     // remove default editor toolbar (RT #78393)
     $wgHooks['EditPageBeforeEditToolbar'][] = 'RTE::removeDefaultToolbar';
     // add fake form used by MW suggest in CK dialogs
     $wgHooks['SkinAfterBottomScripts'][] = 'RTE::onSkinAfterBottomScripts';
     // adds fallback for non-JS users (RT #20324)
     self::addNoScriptFallback();
     wfProfileOut(__METHOD__);
     return true;
 }