Index: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php |
— | — | @@ -76,6 +76,7 @@ |
77 | 77 | $this->mLicense = $request->getText( 'wpLicense' ); |
78 | 78 | |
79 | 79 | |
| 80 | + $this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' ); |
80 | 81 | $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' ) |
81 | 82 | || $request->getCheck( 'wpUploadIgnoreWarning' ); |
82 | 83 | $this->mWatchthis = $request->getBool( 'wpWatchthis' ); |
— | — | @@ -934,7 +935,13 @@ |
935 | 936 | 'section' => 'options', |
936 | 937 | ); |
937 | 938 | } |
| 939 | + $descriptor['wpDestFileWarningAck'] = array( |
| 940 | + 'type' => 'hidden', |
| 941 | + 'id' => 'wpDestFileWarningAck', |
| 942 | + 'default' => $this->mDestWarningAck ? '1' : '', |
| 943 | + ); |
938 | 944 | |
| 945 | + |
939 | 946 | return $descriptor; |
940 | 947 | |
941 | 948 | } |
— | — | @@ -945,57 +952,60 @@ |
946 | 953 | public function show() { |
947 | 954 | $this->addUploadJS(); |
948 | 955 | 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; |
955 | 961 | |
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' ); |
961 | 966 | |
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> |
966 | 980 | |
967 | 981 | 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 |
973 | 986 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
974 | 987 | <html xmlns="{$wgXhtmlDefaultNamespace}" |
975 | 988 | 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}\">"; |
981 | 994 | |
982 | | - $text .= <<<END |
| 995 | + $text .= <<<END |
983 | 996 | |
984 | 997 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
985 | 998 | <head> |
986 | | -$vars_js |
987 | | -$wikibits_include |
988 | | -{$wgOut->getScript()} |
989 | | -$ajax_include |
990 | | -$ajaxwatch_include |
| 999 | +$head_scripts |
991 | 1000 | </head> |
992 | 1001 | <body> |
993 | 1002 | {$wgOut->getHTML()} |
| 1003 | +$body_scripts |
994 | 1004 | </body> |
995 | 1005 | </html> |
996 | 1006 | |
997 | 1007 | |
998 | 1008 | END; |
999 | | -print $text; |
| 1009 | + print $text; |
1000 | 1010 | } |
1001 | 1011 | |
1002 | 1012 | /** |
— | — | @@ -1006,6 +1016,7 @@ |
1007 | 1017 | */ |
1008 | 1018 | protected function addUploadJS( $autofill = true ) { |
1009 | 1019 | global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; |
| 1020 | + global $wgStrictFileExtensions; |
1010 | 1021 | global $wgEnableFirefogg, $wgEnableJS2system; |
1011 | 1022 | global $wgOut; |
1012 | 1023 | |
— | — | @@ -1018,19 +1029,24 @@ |
1019 | 1030 | 'wgEnableFirefogg' => (bool)$wgEnableFirefogg, |
1020 | 1031 | 'wgUploadAutoFill' => (bool)$autofill, |
1021 | 1032 | 'wgUploadSourceIds' => $this->mSourceIds, |
| 1033 | + 'wgStrictFileExtensions' => $wgStrictFileExtensions, |
| 1034 | + 'wgCapitalizeUploads' => MWNamespace::isCapitalized( NS_FILE ), |
1022 | 1035 | ); |
1023 | 1036 | |
1024 | 1037 | $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 | + } |
1035 | 1051 | } |
1036 | 1052 | } |
1037 | 1053 | |