Nischayn22 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/64520
Change subject: fixing opera bug
......................................................................
fixing opera bug
Change-Id: I0e96e29796054fe758fc33bee6bf3501f3893448
---
M UploadWizard.php
M UploadWizardHooks.php
M includes/specials/SpecialUploadWizard.php
3 files changed, 66 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/20/64520/1
diff --git a/UploadWizard.php b/UploadWizard.php
index 7f690eb..c116373 100644
--- a/UploadWizard.php
+++ b/UploadWizard.php
@@ -80,6 +80,7 @@
$wgHooks['CanonicalNamespaces'][] = 'UploadWizardHooks::canonicalNamespaces';
$wgHooks['LoadExtensionSchemaUpdates'][] = 'UploadWizardHooks::onSchemaUpdate';
$wgHooks['GetPreferences'][] = 'UploadWizardHooks::onGetPreferences';
+$wgHooks['MakeGlobalVariablesScript'][] =
'UploadWizardHooks::onMakeGlobalVariablesScript';
$wgAvailableRights[] = 'upwizcampaigns';
diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 7dc6fbf..3152e71 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -645,4 +645,66 @@
}
}
+ public static function onMakeGlobalVariablesScript( &$vars, $out ) {
+ global $wgSitename, $wgRequest;
+
+ $specialUW = new SpecialUploadWizard( $wgRequest );
+ $config = UploadWizardConfig::getConfig( $specialUW->campaign );
+
+ $labelPageContent = $specialUW->getPageContent(
$config['idFieldLabelPage'] );
+ if ( $labelPageContent !== false ) {
+ $config['idFieldLabel'] = $labelPageContent;
+ }
+ // UploadFromUrl parameter set to true only if the user is
allowed to upload a file from a URL which we need to check in our Javascript
implementation.
+ if ( UploadFromUrl::isEnabled() && UploadFromUrl::isAllowed(
$specialUW->getUser() ) === true ) {
+ $config['UploadFromUrl'] = true;
+ } else {
+ $config['UploadFromUrl'] = false;
+ }
+
+ $config['thanksLabel'] = $specialUW->getPageContent(
$config['thanksLabelPage'], true );
+
+ // Get the user's default license. This will usually be
'default', but
+ // can be a specific license like 'ownwork-cc-zero'.
+ $userDefaultLicense = $specialUW->getUser()->getOption(
'upwiz_deflicense' );
+
+ if ( $userDefaultLicense !== 'default' ) {
+ $licenseParts = explode( '-', $userDefaultLicense, 2 );
+ $userLicenseType = $licenseParts[0];
+ $userDefaultLicense = $licenseParts[1];
+
+ // Determine if the user's default license is valid for
this campaign
+ switch ( $config['ownWorkOption'] ) {
+ case "own":
+ $defaultInAllowedLicenses = in_array(
$userDefaultLicense, $config['licensesOwnWork']['licenses'] );
+ break;
+ case "notown":
+ $defaultInAllowedLicenses = in_array(
$userDefaultLicense, UploadWizardConfig::getThirdPartyLicenses() );
+ break;
+ case "choice":
+ $defaultInAllowedLicenses = ( in_array(
$userDefaultLicense, $config['licensesOwnWork']['licenses'] ) ||
+ in_array( $userDefaultLicense,
UploadWizardConfig::getThirdPartyLicenses() ) );
+ break;
+ }
+
+ if ( $defaultInAllowedLicenses ) {
+ if ( $userLicenseType === 'ownwork' ) {
+ $userLicenseGroup = 'licensesOwnWork';
+ } else {
+ $userLicenseGroup =
'licensesThirdParty';
+ }
+ $config[$userLicenseGroup]['defaults'] = array(
$userDefaultLicense );
+ $config['defaultLicenseType'] =
$userLicenseType;
+ }
+ }
+
+ if ( $config['enableChunked'] === 'opt-in' ) {
+ // Respect individual user's opt-in settings
+ $config['enableChunked'] =
(bool)$specialUW->getUser()->getOption( 'upwiz-chunked' );
+ }
+
+ $vars['UploadWizardConfig'] = $config;
+ $vars['wgSiteName'] = $wgSitename;
+ return true;
+ }
}
diff --git a/includes/specials/SpecialUploadWizard.php
b/includes/specials/SpecialUploadWizard.php
index 1e5125d..27bdd1a 100644
--- a/includes/specials/SpecialUploadWizard.php
+++ b/includes/specials/SpecialUploadWizard.php
@@ -19,7 +19,7 @@
* @since 1.2
* @var string|null
*/
- protected $campaign = null;
+ public $campaign = null;
// $request is the request (usually wgRequest)
// $par is everything in the URL after Special:UploadWizard. Not sure
what we can use it for
@@ -92,7 +92,7 @@
// global javascript variables
- $this->addJsVars( $subPage );
+// $this->addJsVars( $subPage );
// dependencies (css, js)
$out->addModuleStyles( 'ext.uploadWizard' );
@@ -234,7 +234,7 @@
*
* @return string|false
*/
- protected function getPageContent( $pageName, $parse = false, $langCode
= null ) {
+ public function getPageContent( $pageName, $parse = false, $langCode =
null ) {
$content = false;
if ( trim( $pageName ) !== '' ) {
--
To view, visit https://gerrit.wikimedia.org/r/64520
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e96e29796054fe758fc33bee6bf3501f3893448
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Nischayn22 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits