- function ExternalEdit ( $article, $mode ) {
- global $wgInputEncoding;
- $this->mArticle =& $article;
- $this->mTitle =& $article->mTitle;
- $this->mCharset = $wgInputEncoding;
- $this->mMode = $mode;
+ /**
+ * Check whether external edit or diff should be used.
+ *
+ * @param $context IContextSource context to use
+ * @param $type String can be either 'edit' or 'diff'
+ * @return Bool
+ */
+ public static function useExternalEngine( IContextSource $context, $type ) {
+ global $wgUseExternalEditor;
+
+ if ( !$wgUseExternalEditor ) {
+ return false;
+ }
+
+ $pref = $type == 'diff' ? 'externaldiff' : 'externaleditor';
+ $request = $context->getRequest();
+
+ return !$request->getVal( 'internaledit' ) &&
+ ( $context->getUser()->getOption( $pref ) || $request->getVal( 'externaledit' ) );