r75198 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75197‎ | r75198 | r75199 >
Date:16:08, 22 October 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added support for ResourceLoader, and some Special:Upload fields that were added in MW 1.17
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php
@@ -76,6 +76,7 @@
7777 $this->mLicense = $request->getText( 'wpLicense' );
7878
7979
 80+ $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' );
8081 $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' )
8182 || $request->getCheck( 'wpUploadIgnoreWarning' );
8283 $this->mWatchthis = $request->getBool( 'wpWatchthis' );
@@ -934,7 +935,13 @@
935936 'section' => 'options',
936937 );
937938 }
 939+ $descriptor['wpDestFileWarningAck'] = array(
 940+ 'type' => 'hidden',
 941+ 'id' => 'wpDestFileWarningAck',
 942+ 'default' => $this->mDestWarningAck ? '1' : '',
 943+ );
938944
 945+
939946 return $descriptor;
940947
941948 }
@@ -945,57 +952,60 @@
946953 public function show() {
947954 $this->addUploadJS();
948955 parent::show();
949 - // disable $wgOut - we'll print out the page manually, taking the
950 - // body created by the form, plus the necessary Javascript files,
951 - // and turning them into an HTML page
952 - global $wgOut, $wgUser, $wgTitle, $wgJsMimeType,
953 - $wgLanguageCode, $wgStylePath, $wgStyleVersion,
954 - $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgContLang;
 956+ // disable $wgOut - we'll print out the page manually,
 957+ // taking the body created by the form, plus the necessary
 958+ // Javascript files, and turning them into an HTML page
 959+ global $wgOut, $wgUser, $wgTitle, $wgLanguageCode,
 960+ $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgContLang;
955961
956 - $wgOut->disable();
957 - $sk = $wgUser->getSkin();
958 - $sk->initPage( $wgOut ); // need to call this to set skin name correctly
959 - $wgTitle = SpecialPage::getTitleFor( 'Upload' );
960 - $skin_user_js = $sk->generateUserJs();
 962+ $wgOut->disable();
 963+ $sk = $wgUser->getSkin();
 964+ $sk->initPage( $wgOut ); // need to call this to set skin name correctly
 965+ $wgTitle = SpecialPage::getTitleFor( 'Upload' );
961966
962 - $user_js = <<<END
963 -<script type="{$wgJsMimeType}">
964 -$skin_user_js;
965 -</script>
 967+ if ( method_exists( $wgOut, 'addModules' ) ) {
 968+ $head_scripts = '';
 969+ $wgOut->addModules( array( 'mediawiki.legacy.edit', 'mediawiki.legacy.upload', 'mediawiki.legacy.wikibits', 'mediawiki.legacy.ajax', 'mediawiki.legacy.ajaxwatch' ) );
 970+ $body_scripts = $wgOut->getHeadScripts( $sk );
 971+ } else {
 972+ global $wgJsMimeType, $wgStylePath, $wgStyleVersion;
 973+ $vars_js = Skin::makeGlobalVariablesScript( array( 'skinname' => $sk->getSkinName() ) );
 974+ $head_scripts = <<<END
 975+$vars_js
 976+<script type="{$wgJsMimeType}" src="{$wgStylePath}/common/wikibits.js?$wgStyleVersion"></script>
 977+{$wgOut->getScript()}
 978+<script type="{$wgJsMimeType}" src="{$wgStylePath}/common/ajax.js?$wgStyleVersion"></script>
 979+<script type="{$wgJsMimeType}" src="{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion"></script>
966980
967981 END;
968 - $vars_js = Skin::makeGlobalVariablesScript( array( 'skinname' => $sk->getSkinName() ) );
969 - $wikibits_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/wikibits.js?$wgStyleVersion\"></script>";
970 - $ajax_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>";
971 - $ajaxwatch_include = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>";
972 - $text = <<<END
 982+ $body_scripts = '';
 983+ }
 984+
 985+ $text = <<<END
973986 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
974987 <html xmlns="{$wgXhtmlDefaultNamespace}"
975988 END;
976 - foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
977 - $text .= "xmlns:{$tag}=\"{$ns}\" ";
978 - }
979 - $dir = $wgContLang->isRTL() ? "rtl" : "ltr";
980 - $text .= "xml:lang=\"{$wgLanguageCode}\" lang=\"{$wgLanguageCode}\" dir=\"{$dir}\">";
 989+ foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
 990+ $text .= "xmlns:{$tag}=\"{$ns}\" ";
 991+ }
 992+ $dir = $wgContLang->isRTL() ? "rtl" : "ltr";
 993+ $text .= "xml:lang=\"{$wgLanguageCode}\" lang=\"{$wgLanguageCode}\" dir=\"{$dir}\">";
981994
982 - $text .= <<<END
 995+ $text .= <<<END
983996
984997 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
985998 <head>
986 -$vars_js
987 -$wikibits_include
988 -{$wgOut->getScript()}
989 -$ajax_include
990 -$ajaxwatch_include
 999+$head_scripts
9911000 </head>
9921001 <body>
9931002 {$wgOut->getHTML()}
 1003+$body_scripts
9941004 </body>
9951005 </html>
9961006
9971007
9981008 END;
999 -print $text;
 1009+ print $text;
10001010 }
10011011
10021012 /**
@@ -1006,6 +1016,7 @@
10071017 */
10081018 protected function addUploadJS( $autofill = true ) {
10091019 global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
 1020+ global $wgStrictFileExtensions;
10101021 global $wgEnableFirefogg, $wgEnableJS2system;
10111022 global $wgOut;
10121023
@@ -1018,19 +1029,24 @@
10191030 'wgEnableFirefogg' => (bool)$wgEnableFirefogg,
10201031 'wgUploadAutoFill' => (bool)$autofill,
10211032 'wgUploadSourceIds' => $this->mSourceIds,
 1033+ 'wgStrictFileExtensions' => $wgStrictFileExtensions,
 1034+ 'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ),
10221035 );
10231036
10241037 $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
1025 -
1026 - // For <charinsert> support; not provided by js2 yet
1027 - $wgOut->addScriptFile( 'edit.js' );
1028 -
1029 - if ( $wgEnableJS2system ) {
1030 - // JS2 upload scripts
1031 - $wgOut->addScriptClass( 'uploadPage' );
1032 - } else {
1033 - // Legacy upload javascript
1034 - $wgOut->addScriptFile( 'upload.js' );
 1038+
 1039+ // MW < 1.17
 1040+ if ( ! class_exists( 'ResourceLoader' ) ) {
 1041+ // For <charinsert> support; not provided by js2 yet
 1042+ $wgOut->addScriptFile( 'edit.js' );
 1043+
 1044+ if ( $wgEnableJS2system ) {
 1045+ // JS2 upload scripts
 1046+ $wgOut->addScriptClass( 'uploadPage' );
 1047+ } else {
 1048+ // Legacy upload javascript
 1049+ $wgOut->addScriptFile( 'upload.js' );
 1050+ }
10351051 }
10361052 }
10371053

Status & tagging log