/** * Check CK editor conditions (fallback to MW editor / switch to source mode) * * Handle useeditor URL param, user settings, current skin, edgecases... */ private static function checkEditorConditions() { global $wgRequest, $wgUser; wfProfileIn(__METHOD__); // check browser compatibility if (!self::isCompatibleBrowser()) { RTE::log('editor is disabled because of unsupported browser'); self::disableEditor('browser'); } // check useeditor URL param (wysiwyg / source / mediawiki) $useEditor = $wgRequest->getVal('useeditor', false); if (!empty($useEditor)) { RTE::log("useeditor = '{$useEditor}'"); switch ($useEditor) { case 'mediawiki': self::disableEditor('useeditor'); break; case 'source': self::setInitMode('source'); break; case 'wysiwyg': case 'visual': $forcedWysiwyg = true; self::setInitMode('wysiwyg'); break; } } // check namespaces global $wgWysiwygDisabledNamespaces, $wgWysiwygDisableOnTalk, $wgEnableSemanticMediaWikiExt; if (!empty($wgWysiwygDisabledNamespaces) && is_array($wgWysiwygDisabledNamespaces)) { if (in_array(self::$title->getNamespace(), $wgWysiwygDisabledNamespaces)) { self::disableEditor('disablednamespace'); } } else { if (self::$title->getNamespace() == NS_TEMPLATE || self::$title->getNamespace() == NS_MEDIAWIKI) { self::disableEditor('namespace'); } } if (!empty($wgWysiwygDisableOnTalk)) { if (self::$title->isTalkPage()) { self::disableEditor('talkpage'); } } // BugId: 11336 disable RTE on Special SMW namespaces if ($wgEnableSemanticMediaWikiExt && in_array(self::$title->getNamespace(), array(SMW_NS_PROPERTY, SF_NS_FORM, NS_CATEGORY, SMW_NS_CONCEPT))) { self::disableEditor('smw_namespace'); } // RT #10170: do not initialize for user JS/CSS subpages if (self::$title->isCssJsSubpage()) { RTE::log('editor is disabled on user JS/CSS subpages'); self::disableEditor('cssjssubpage'); } // check user preferences option $userOption = $wgUser->getOption('enablerichtext'); if ($userOption != true && empty($forcedWysiwyg)) { RTE::log('editor is disabled because of user preferences'); self::disableEditor('userpreferences'); } // check current skin - enable RTE only on Oasis $skinName = get_class(RequestContext::getMain()->getSkin()); if ($skinName != 'SkinOasis') { RTE::log("editor is disabled because skin {$skinName} is unsupported"); self::disableEditor('skin'); } // start in source when previewing from source mode $action = $wgRequest->getVal('action', 'view'); $mode = $wgRequest->getVal('RTEMode', false); if ($action == 'submit' && $mode == 'source') { RTE::log('POST triggered from source mode'); RTE::setInitMode('source'); } wfProfileOut(__METHOD__); }