r66228 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66227‎ | r66228 | r66229 >
Date:22:01, 11 May 2010
Author:dale
Status:deferred
Tags:
Comment:
Extension part of UploadWizard
Modified paths:
  • /trunk/extensions/UploadWizard/README (added) (history)
  • /trunk/extensions/UploadWizard/SpecialUploadWizard.php (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.alias.php (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.i18n.php (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizard.php (added) (history)
  • /trunk/extensions/UploadWizard/UploadWizardPage.js (added) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/UploadWizard.alias.php
@@ -0,0 +1,13 @@
 2+<?
 3+/*
 4+ * Allows the special page title to be translated to another language.
 5+ * The page title can be customized into another language
 6+*/
 7+
 8+$aliases = array();
 9+
 10+/** English */
 11+$aliases['en'] = array(
 12+ 'UploadWizard' => array( 'UploadWizard' ),
 13+);
 14+
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php
@@ -0,0 +1,171 @@
 2+<?
 3+/**
 4+ * Internationalisation for Upload Wizard extension
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Neil Kandalgaonkar
 14+ */
 15+$messages['en'] = array(
 16+ 'uploadwizard' => 'Upload wizard',
 17+ 'uploadwizard-desc' => 'Upload wizard, developed for the Multimedia Usability grant'
 18+);
 19+
 20+/** Belarusian (TaraÅ¡kievica orthography) (Беларуская (тарашкевіца))
 21+ * @author Jim-by
 22+ */
 23+$messages['be-tarask'] = array(
 24+ 'uploadwizard' => 'Майстар загрузкі',
 25+ 'uploadwizard-desc' => 'Майстар загрузкі, распрацавацы па гранту Multimedia Usability',
 26+);
 27+
 28+/** Breton (Brezhoneg)
 29+ * @author Fulup
 30+ */
 31+$messages['br'] = array(
 32+ 'uploadwizard' => 'Ameiler enporzhiañ',
 33+ 'uploadwizard-desc' => "Ameiler enporzhiañ, diorroet evit ar yalc'had Implijadusted Liesmedia",
 34+);
 35+
 36+/** Catalan (Català )
 37+ * @author Paucabot
 38+ */
 39+$messages['ca'] = array(
 40+ 'uploadwizard' => 'Assistent de cà rrega',
 41+);
 42+
 43+/** German (Deutsch)
 44+ * @author Kghbln
 45+ */
 46+$messages['de'] = array(
 47+ 'uploadwizard' => 'Assistent zum Hochladen von Dateien',
 48+ 'uploadwizard-desc' => 'Assistent zum Hochladen von Dateien. Entwicklung wurde durch Fördergelder zur Verbesserung der Benutzerfreundlichkeit ermöglicht (Multimedia Usability Project).',
 49+);
 50+
 51+/** Lower Sorbian (Dolnoserbski)
 52+ * @author Michawiki
 53+ */
 54+$messages['dsb'] = array(
 55+ 'uploadwizard' => 'Asistent za nagraÅ›a',
 56+ 'uploadwizard-desc' => 'Aistent za nagraÅ›a, uwity za spÄ›chowanje wužywajobnosći multimedijow',
 57+);
 58+
 59+/** Spanish (Español)
 60+ * @author Locos epraix
 61+ */
 62+$messages['es'] = array(
 63+ 'uploadwizard' => 'Asistente de subida',
 64+ 'uploadwizard-desc' => 'Asistente de subida, desarrollado por el equipo de de Usabilidad Multimedia',
 65+);
 66+
 67+/** French (Français)
 68+ * @author Peter17
 69+ */
 70+$messages['fr'] = array(
 71+ 'uploadwizard' => "Assistant d'import",
 72+ 'uploadwizard-desc' => "Assistant d'import, développé pour la subvention Multimedia Usability",
 73+);
 74+
 75+/** Galician (Galego)
 76+ * @author Toliño
 77+ */
 78+$messages['gl'] = array(
 79+ 'uploadwizard' => 'Asistente de cargas',
 80+ 'uploadwizard-desc' => 'Asistente de cargas, desenvolvido para o equipo da Usabilidade multimedia',
 81+);
 82+
 83+/** Upper Sorbian (Hornjoserbsce)
 84+ * @author Michawiki
 85+ */
 86+$messages['hsb'] = array(
 87+ 'uploadwizard' => 'Asistent za nahraća',
 88+ 'uploadwizard-desc' => 'Asistent za nahraćow, wuwity za spÄ›chowanje wužiwajomnosće multimedijow',
 89+);
 90+
 91+/** Interlingua (Interlingua)
 92+ * @author McDutchie
 93+ */
 94+$messages['ia'] = array(
 95+ 'uploadwizard' => 'Assistente de incargamento',
 96+ 'uploadwizard-desc' => 'Assistente de incargamento, disveloppate pro le bursa Initiativa de Usabilitate',
 97+);
 98+
 99+/** Japanese (日本語)
 100+ * @author 青子守歌
 101+ */
 102+$messages['ja'] = array(
 103+ 'uploadwizard' => 'アップロード・ウィザード',
 104+ 'uploadwizard-desc' => 'アップロード・ウィザード(マルチメディア・ユーザビリティで開発された機能)',
 105+);
 106+
 107+/** Luxembourgish (Lëtzebuergesch)
 108+ * @author Robby
 109+ */
 110+$messages['lb'] = array(
 111+ 'uploadwizard' => 'Assistent fir eropzelueden',
 112+ 'uploadwizard-desc' => "Assistent fir eropzelueden, entwéckelt fir d'Subventioun vun der Multimedia Benotzerfrëndlechkeet",
 113+);
 114+
 115+/** Macedonian (Македонски)
 116+ * @author Bjankuloski06
 117+ */
 118+$messages['mk'] = array(
 119+ 'uploadwizard' => 'Помошник за подигање',
 120+ 'uploadwizard-desc' => 'Помошник за подигање, создаден со средства доделени за Употребливост на мултимедија',
 121+);
 122+
 123+/** Dutch (Nederlands)
 124+ * @author Siebrand
 125+ */
 126+$messages['nl'] = array(
 127+ 'uploadwizard' => 'Wizard uploaden',
 128+ 'uploadwizard-desc' => 'Wizard uploaden, ontwikkeld voor de schenking voor Multimediabruikbaarheid',
 129+);
 130+
 131+/** Occitan (Occitan)
 132+ * @author Cedric31
 133+ */
 134+$messages['oc'] = array(
 135+ 'uploadwizard' => "Assistent d'impòrt",
 136+ 'uploadwizard-desc' => "Assistent d'impòrt, desvolopat per la subvencion Multimedia Usability",
 137+);
 138+
 139+/** Polish (Polski)
 140+ * @author Marcin Łukasz Kiejzik
 141+ */
 142+$messages['pl'] = array(
 143+ 'uploadwizard' => 'Kreator przesyÅ‚ania',
 144+ 'uploadwizard-desc' => 'Kreator dodawania, opracowany dla nagrody użytecznoÅ›ci multimediów',
 145+);
 146+
 147+/** Piedmontese (Piemontèis)
 148+ * @author Borichèt
 149+ * @author Dragonòt
 150+ */
 151+$messages['pms'] = array(
 152+ 'uploadwizard' => "Assistent d'amportassion",
 153+ 'uploadwizard-desc' => "Assistent d'amportassion, dësvlupà për ël programa d'Usabilità Multimojen",
 154+);
 155+
 156+/** Portuguese (Português)
 157+ * @author Hamilton Abreu
 158+ */
 159+$messages['pt'] = array(
 160+ 'uploadwizard' => 'Assistente de uploads',
 161+ 'uploadwizard-desc' => 'Assistente de uploads, desenvolvido para a bolsa Iniciativa de Usabilidade',
 162+);
 163+
 164+/** Russian (Русский)
 165+ * @author Александр Сигачёв
 166+ */
 167+$messages['ru'] = array(
 168+ 'uploadwizard' => 'Мастер загрузки',
 169+ 'uploadwizard-desc' => 'Мастер загрузки, разработанный по гранту Юзабилити мультимедиа',
 170+);
 171+
 172+
Index: trunk/extensions/UploadWizard/UploadWizard.php
@@ -0,0 +1,53 @@
 2+<?php
 3+/**
 4+ * Add Media Wizard extension
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ *
 9+ * This file contains the include file for the Add Media Wizard support
 10+ * The addMediaWizard is dependent on JS2Support and
 11+ * the core "AddMedia" module
 12+ *
 13+ * Usage: Include the following line in your LocalSettings.php
 14+ * require_once( "$IP/extensions/JS2Support/AddMediaWizard/AddMediaWizard.php" );
 15+ *
 16+ * @author Neil Kandalgaonkar <neil@wikimedia.org>
 17+ * @license GPL v2 or later
 18+ * @version 0.1.1
 19+ */
 20+
 21+/* Configuration */
 22+
 23+
 24+// Credits
 25+$wgExtensionCredits['jsModule'][] = array(
 26+ 'path' => __FILE__,
 27+ 'name' => 'Upload Wizard',
 28+ 'author' => 'Neil Kandalgaonkar',
 29+ 'version' => '0.1.1',
 30+ 'descriptionmsg' => 'uploadwizard-desc',
 31+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UploadWizard'
 32+);
 33+
 34+// Check for JS2 support
 35+if( ! isset( $wgEnableJS2system ) ){
 36+ throw new MWException( 'UploadWizard requires JS2 Support. Please include the JS2Support extension.');
 37+}
 38+
 39+
 40+$dir = dirname(__FILE__) . '/';
 41+
 42+$wgExtensionMessagesFiles['UploadWizard'] = $dir . 'UploadWizard.i18n.php';
 43+$wgExtensionAliasesFiles['UploadWizard'] = $dir . 'UploadWizard.alias.php';
 44+
 45+# Add the special page
 46+$wgAutoloadLocalClasses[ 'SpecialUploadWizard' ] = $dir . 'SpecialUploadWizard.php';
 47+$wgSpecialPages['UploadWizard'] = 'SpecialUploadWizard';
 48+$wgSpecialPageGroups['UploadWizard'] = 'media';
 49+
 50+$wgScriptLoaderNamedPaths[ 'UploadWizardPage' ] = 'extensions/UploadWizard/UploadWizardPage.js';
 51+
 52+// Set up the javascript loader for the jsModule
 53+$wgExtensionJavascriptLoader[] = 'extensions/UploadWizard/UploadWizardJsModule/loader.js';
 54+
Index: trunk/extensions/UploadWizard/SpecialUploadWizard.php
@@ -0,0 +1,163 @@
 2+<?php
 3+/**
 4+ * Special:UploadWizard
 5+ *
 6+ * Usability Initiative multi-file upload page.
 7+ *
 8+ * @file
 9+ * @ingroup SpecialPage
 10+ * @ingroup Upload
 11+ */
 12+
 13+class SpecialUploadWizard extends SpecialPage {
 14+
 15+ // $request is the request (usually wgRequest)
 16+ // $par is everything in the URL after Special:UploadWizard. Not sure what we can use it for
 17+ public function __construct( $request=null ) {
 18+ global $wgEnableJS2, $wgEnableAPI, $wgRequest;
 19+
 20+ if (! $wgEnableJS2) {
 21+ // XXX complain
 22+ }
 23+
 24+ if (! $wgEnableAPI) {
 25+ // XXX complain
 26+ }
 27+
 28+ // here we would configure ourselves based on stuff in $request and $wgRequest, but so far, we
 29+ // don't have such things
 30+
 31+ parent::__construct( 'UploadWizard', 'upload' );
 32+
 33+ $this->simpleForm = new UploadWizardSimpleForm();
 34+ $this->simpleForm->setTitle( $this->getTitle() );
 35+ }
 36+
 37+ public function execute() {
 38+ global $wgUser, $wgOut, $wgMessageCache;
 39+
 40+ # Check uploading enabled
 41+ if( !UploadBase::isEnabled() ) {
 42+ $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' );
 43+ return;
 44+ }
 45+
 46+ # Check permissions
 47+ global $wgGroupPermissions;
 48+ if( !$wgUser->isAllowed( 'upload' ) ) {
 49+ if( !$wgUser->isLoggedIn() && ( $wgGroupPermissions['user']['upload']
 50+ || $wgGroupPermissions['autoconfirmed']['upload'] ) ) {
 51+ // Custom message if logged-in users without any special rights can upload
 52+ $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
 53+ } else {
 54+ $wgOut->permissionRequired( 'upload' );
 55+ }
 56+ return;
 57+ }
 58+
 59+ # Check blocks
 60+ if( $wgUser->isBlocked() ) {
 61+ $wgOut->blockedPage();
 62+ return;
 63+ }
 64+
 65+ # Check whether we actually want to allow changing stuff
 66+ if( wfReadOnly() ) {
 67+ $wgOut->readOnlyPage();
 68+ return;
 69+ }
 70+
 71+
 72+ $wgMessageCache->loadAllMessages();
 73+
 74+ $this->setHeaders();
 75+ $this->outputHeader();
 76+
 77+ $wgOut->addHTML(
 78+ '<div id="upload-licensing" class="upload-section" style="display: none;">Licensing tutorial</div>'
 79+ . '<div id="upload-wizard" class="upload-section"></div>'
 80+ );
 81+
 82+ $wgOut->addHTML('<noscript>');
 83+ $this->simpleForm->show();
 84+ $wgOut->addHTML('</noscript>');
 85+
 86+
 87+ //$j('#firstHeading').html("Upload wizard");
 88+
 89+ $this->addJS();
 90+ }
 91+
 92+ /**
 93+ * Adds some global variables for our use, as well as initializes the UploadWizard
 94+ */
 95+ public function addJS() {
 96+ global $wgUser, $wgOut;
 97+ global $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI;
 98+ global $wgEnableFirefogg, $wgFileExtensions;
 99+
 100+ $wgOut->addScript( Skin::makeVariablesScript( array(
 101+ // uncertain if this is relevant. Can we do license preview with API?
 102+ 'wgAjaxLicensePreview' => $wgUseAjax && $wgAjaxLicensePreview,
 103+
 104+ 'wgEnableFirefogg' => (bool)$wgEnableFirefogg,
 105+
 106+ // what is acceptable in this wiki
 107+ 'wgFileExtensions' => $wgFileExtensions,
 108+
 109+ // our edit token
 110+ 'wgEditToken' => $wgUser->editToken()
 111+
 112+ // in the future, we ought to be telling JS land other things,
 113+ // like: requirements for publication, acceptable licenses, etc.
 114+
 115+ ) )
 116+ );
 117+
 118+
 119+//
 120+// $initScript = <<<EOD
 121+//EOD;
 122+// $wgOut->addScript( Html::inlineScript( $initScript ) );
 123+ // not sure why -- can we even load libraries with an included script, or does that cause things to be out of order?
 124+ global $wgScriptPath;
 125+ $wgOut->addScriptClass( 'UploadWizardPage', 'page');
 126+
 127+
 128+ // XXX unlike other vars this is specific to the file being uploaded -- re-upload context, for instance
 129+ // Recorded here because we may probably need to
 130+ // bring it back in some form later. Reupload forms may be special, only one file allowed
 131+ /*
 132+ $scriptVars = array(
 133+ 'wgUploadAutoFill' => !$this->mForReUpload,
 134+ 'wgUploadSourceIds' => $this->mSourceIds,
 135+ );
 136+ */
 137+
 138+
 139+ }
 140+
 141+}
 142+
 143+
 144+/**
 145+ * This is a hack on UploadForm.
 146+ * Normally, UploadForm adds its own Javascript.
 147+ * We wish to prevent this, because we want to control the case where we have Javascript.
 148+ * So, we subclass UploadForm, and make the addUploadJS a no-op.
 149+ */
 150+class UploadWizardSimpleForm extends UploadForm {
 151+ protected function addUploadJS( ) { }
 152+
 153+}
 154+
 155+/*
 156+// XXX UploadWizard extension, do this in the normal SpecialPage way once JS2 issue resolved
 157+function wfSpecialUploadWizard( $par ) {
 158+ global $wgRequest;
 159+ // can we obtain $request from here?
 160+ // $this->loadRequest( is_null( $request ) ? $wgRequest : $request );
 161+ $o = new SpecialUploadWizard( $wgRequest, $par );
 162+ $o->execute();
 163+}
 164+*/
Index: trunk/extensions/UploadWizard/README
@@ -0,0 +1,10 @@
 2+UploadWizard is dependent on js2 / mwEmbed, you must include JS2Support extension prior to UploadWizard.php
 3+
 4+# To enable add the following to localSettings.php
 5+
 6+# JS2 / mwEmbed Support
 7+require_once( "$IP/extensions/JS2Support/JS2Support.php" );
 8+
 9+# Upload Wizard
 10+require_once( "$IP/extensions/UploadWizard/UploadWizard.php" );
 11+
Index: trunk/extensions/UploadWizard/UploadWizardPage.js
@@ -0,0 +1,31 @@
 2+/*
 3+ * This script is run on [[Special:UploadWizard]].
 4+ * Creates an interface for uploading files in multiple steps, hence "wizard"
 5+ */
 6+
 7+mw.ready( function() {
 8+ mw.load( 'UploadWizard.UploadWizard', function () {
 9+
 10+ mw.setConfig( 'debug', true );
 11+
 12+ mw.setDefaultConfig( 'uploadHandlerClass', null );
 13+ mw.setConfig( 'userName', wgUserName );
 14+ mw.setConfig( 'userLanguage', wgUserLanguage );
 15+ mw.setConfig( 'fileExtensions', wgFileExtensions );
 16+ mw.setConfig( 'token', wgEditToken );
 17+ mw.setConfig( 'thumbnailWidth', 120 );
 18+
 19+ // not for use with all wikis.
 20+ // The ISO 639 code for the language tagalog is "tl".
 21+ // Normally we name templates for languages by the ISO 639 code.
 22+ // Commons already had a template called 'tl', though.
 23+ // so, this workaround will cause tagalog descriptions to be saved with this template instead.
 24+ mw.setConfig( 'languageTemplateFixups', { tl: 'tgl' } );
 25+ mw.setConfig( 'defaultLicenses', [ 'cc_by_sa_30', 'gfdl' ] );
 26+
 27+ var uploadWizard = new mw.UploadWizard();
 28+ uploadWizard.createInterface( '#upload-wizard' );
 29+
 30+ } );
 31+} );
 32+

Follow-up revisions

RevisionCommit summaryAuthorDate
r66261Follow-up r66228/r66245: UTF-8 characters are completly broken. Delete all tr...raymond10:57, 12 May 2010
r66262Follow-up r66228: Add defintion for alias file to translatewikiraymond11:02, 12 May 2010

Status & tagging log