/**
  * Adds the preferences of UploadWizard to the list of available ones.
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
  *
  * @since 1.2
  *
  * @param User $user
  * @param array $preferences
  *
  * @return true
  */
 public static function onGetPreferences(User $user, array &$preferences)
 {
     // User preference to skip the licensing tutorial, provided it's not globally disabled
     if (UploadWizardConfig::getSetting('skipTutorial') == false) {
         $preferences['upwiz_skiptutorial'] = array('type' => 'check', 'label-message' => 'mwe-upwiz-prefs-skiptutorial', 'section' => 'uploads/upwiz-interface');
     }
     if (UploadWizardConfig::getSetting('enableLicensePreference')) {
         $licenseConfig = UploadWizardConfig::getSetting('licenses');
         $licenses = array();
         $ownWork = UploadWizardConfig::getSetting('licensesOwnWork');
         foreach ($ownWork['licenses'] as $license) {
             $licenseMessage = self::getLicenseMessage($license, $licenseConfig);
             $licenses[wfMessage('mwe-upwiz-prefs-license-own', $licenseMessage)->text()] = 'ownwork-' . $license;
         }
         foreach (UploadWizardConfig::getThirdPartyLicenses() as $license) {
             if ($license !== 'custom') {
                 $licenseMessage = self::getLicenseMessage($license, $licenseConfig);
                 $licenses[wfMessage('mwe-upwiz-prefs-license-thirdparty', $licenseMessage)->text()] = 'thirdparty-' . $license;
             }
         }
         $licenses = array_merge(array(wfMessage('mwe-upwiz-prefs-def-license-def')->text() => 'default'), $licenses);
         $preferences['upwiz_deflicense'] = array('type' => 'radio', 'label-message' => 'mwe-upwiz-prefs-def-license', 'section' => 'uploads/upwiz-licensing', 'options' => $licenses);
         if (UploadWizardConfig::getSetting('enableChunked') === 'opt-in') {
             $preferences['upwiz-chunked'] = array('type' => 'check', 'label-message' => 'mwe-upwiz-prefs-chunked', 'section' => 'uploads/upwiz-experimental');
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Adds the preferences of UploadWizard to the list of available ones.
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
  *
  * @since 1.2
  *
  * @param User $user
  * @param array $preferences
  *
  * @return true
  */
 public static function onGetPreferences(User $user, array &$preferences)
 {
     if (UploadWizardConfig::getSetting('enableLicensePreference')) {
         $licenseConfig = UploadWizardConfig::getSetting('licenses');
         $licenses = array();
         $ownWork = UploadWizardConfig::getSetting('licensesOwnWork');
         foreach ($ownWork['licenses'] as $license) {
             $licenseMessage = self::getLicenseMessage($license, $licenseConfig);
             $licenses[wfMsgExt('mwe-upwiz-prefs-license-own', 'parsemag', $licenseMessage)] = 'ownwork-' . $license;
         }
         foreach (UploadWizardConfig::getThirdPartyLicenses() as $license) {
             if ($license !== 'custom') {
                 $licenseMessage = self::getLicenseMessage($license, $licenseConfig);
                 $licenses[wfMsgExt('mwe-upwiz-prefs-license-thirdparty', 'parsemag', $licenseMessage)] = 'thirdparty-' . $license;
             }
         }
         $licenses = array_merge(array(wfMsg('mwe-upwiz-prefs-def-license-def') => 'default'), $licenses);
         $preferences['upwiz_deflicense'] = array('type' => 'radio', 'label-message' => 'mwe-upwiz-prefs-def-license', 'section' => 'under-the-hood', 'options' => $licenses);
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Adds the preferences of UploadWizard to the list of available ones.
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
  *
  * @since 1.2
  *
  * @param User $user
  * @param array $preferences
  *
  * @return true
  */
 public static function onGetPreferences(User $user, array &$preferences)
 {
     global $wgLang;
     $config = UploadWizardConfig::getConfig();
     // User preference to skip the licensing tutorial, provided it's not globally disabled
     if (UploadWizardConfig::getSetting('tutorial') != array()) {
         $preferences['upwiz_skiptutorial'] = array('type' => 'check', 'label-message' => 'mwe-upwiz-prefs-skiptutorial', 'section' => 'uploads/upwiz-interface');
     }
     if (UploadWizardConfig::getSetting('enableLicensePreference')) {
         $licenseConfig = UploadWizardConfig::getSetting('licenses');
         $licenses = array();
         $licensingOptions = UploadWizardConfig::getSetting('licensing');
         $ownWork = $licensingOptions['ownWork'];
         foreach ($ownWork['licenses'] as $license) {
             $licenseMessage = self::getLicenseMessage($license, $licenseConfig);
             $licenseKey = wfMessage('mwe-upwiz-prefs-license-own', $licenseMessage)->text();
             $licenses[$licenseKey] = 'ownwork-' . $license;
         }
         foreach (UploadWizardConfig::getThirdPartyLicenses() as $license) {
             if ($license !== 'custom') {
                 $licenseMessage = self::getLicenseMessage($license, $licenseConfig);
                 $licenseKey = wfMessage('mwe-upwiz-prefs-license-thirdparty', $licenseMessage)->text();
                 $licenses[$licenseKey] = 'thirdparty-' . $license;
             }
         }
         $licenses = array_merge(array(wfMessage('mwe-upwiz-prefs-def-license-def')->text() => 'default'), $licenses);
         $preferences['upwiz_deflicense'] = array('type' => 'radio', 'label-message' => 'mwe-upwiz-prefs-def-license', 'section' => 'uploads/upwiz-licensing', 'options' => $licenses);
         if (UploadWizardConfig::getSetting('enableChunked') === 'opt-in') {
             $preferences['upwiz-chunked'] = array('type' => 'check', 'label-message' => array('mwe-upwiz-prefs-chunked', $wgLang->formatSize(UploadWizardConfig::getSetting('chunkSize'))), 'section' => 'uploads/upwiz-experimental');
         }
     }
     // Setting for maximum number of simultaneous uploads (always lower than the server-side config)
     if ($config['maxSimultaneousConnections'] > 1) {
         // Hack to make the key and value the same otherwise options are added wrongly.
         $range = range(0, $config['maxSimultaneousConnections']);
         $range[0] = 'default';
         $preferences['upwiz_maxsimultaneous'] = array('type' => 'select', 'label-message' => 'mwe-upwiz-prefs-maxsimultaneous-upload', 'section' => 'uploads/upwiz-experimental', 'options' => $range);
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Adds some global variables for our use, as well as initializes the UploadWizard
  * 
  * TODO once bug https://bugzilla.wikimedia.org/show_bug.cgi?id=26901
  * is fixed we should package configuration with the upload wizard instead of
  * in uploadWizard output page. 
  * 
  * @param subpage, e.g. the "foo" in Special:UploadWizard/foo
  */
 public function addJsVars($subPage)
 {
     global $wgSitename;
     $config = UploadWizardConfig::getConfig($this->campaign);
     $labelPageContent = $this->getPageContent($config['idFieldLabelPage']);
     if ($labelPageContent !== false) {
         $config['idFieldLabel'] = $labelPageContent;
     }
     $config['thanksLabel'] = $this->getPageContent($config['thanksLabelPage'], true);
     $defaultLicense = $this->getUser()->getGlobalPreference('upwiz_deflicense');
     if ($defaultLicense !== 'default') {
         $defaultLicense = explode('-', $defaultLicense, 2);
         $licenseType = $defaultLicense[0];
         $defaultLicense = $defaultLicense[1];
         if (in_array($defaultLicense, $config['licensesOwnWork']['licenses']) || in_array($defaultLicense, UploadWizardConfig::getThirdPartyLicenses())) {
             $licenseGroup = $licenseType === 'ownwork' ? 'licensesOwnWork' : 'licensesThirdParty';
             $config[$licenseGroup]['defaults'] = array($defaultLicense);
             $config['defaultLicenseType'] = $licenseType;
         }
     }
     $this->getOutput()->addScript(Skin::makeVariablesScript(array('UploadWizardConfig' => $config) + array('wgSiteName' => $wgSitename)));
 }