Index: trunk/extensions/JS2Support/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/JS2Support/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<? |
| 3 | +/** |
| 4 | + * Internationalisation for Add Media 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 | +); |
\ No newline at end of file |
Index: trunk/extensions/JS2Support/UploadWizard/UploadWizard.php |
— | — | @@ -0,0 +1,46 @@ |
| 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['other'][] = 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 | +// Includes parent JS2Support |
| 35 | +require_once( dirname( dirname( __FILE__ ) ) . "/JS2Support.php" ); |
| 36 | + |
| 37 | +$dir = dirname(__FILE__) . '/'; |
| 38 | + |
| 39 | +$wgExtensionMessagesFiles['UploadWizard'] = $dir . 'UploadWizard.i18n.php'; |
| 40 | +$wgExtensionAliasesFiles['UploadWizard'] = $dir . 'UploadWizard.alias.php'; |
| 41 | + |
| 42 | +# Add the special page |
| 43 | +$wgAutoloadLocalClasses[ 'SpecialUploadWizard' ] = $dir . 'SpecialUploadWizard.php'; |
| 44 | +$wgSpecialPages['UploadWizard'] = 'SpecialUploadWizard'; |
| 45 | + |
| 46 | +$wgScriptLoaderNamedPaths[ 'UploadWizardPage' ] = 'extensions/JS2Support/UploadWizard/UploadWizardPage.js'; |
| 47 | + |
Index: trunk/extensions/JS2Support/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/JS2Support/UploadWizard/README |
— | — | @@ -0,0 +1,3 @@ |
| 2 | + |
| 3 | +To enable add the following to localsettings.php |
| 4 | +require_once( "$IP/extensions/JS2Support/UploadWizard/UploadWizard.php" ); |
\ No newline at end of file |
Index: trunk/extensions/JS2Support/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 | + |
Index: trunk/extensions/JS2Support/AddMediaWizard/AddMediaWizard.php |
— | — | @@ -0,0 +1,49 @@ |
| 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 Michael Dale <mdale@wikimedia.org> and others |
| 17 | + * @license GPL v2 or later |
| 18 | + * @version 0.1.1 |
| 19 | + */ |
| 20 | + |
| 21 | +/* Configuration */ |
| 22 | + |
| 23 | + |
| 24 | +// Credits |
| 25 | +$wgExtensionCredits['other'][] = array( |
| 26 | + 'path' => __FILE__, |
| 27 | + 'name' => 'Add Media Wizard', |
| 28 | + 'author' => 'Michael Dale and others', |
| 29 | + 'version' => '0.1.1', |
| 30 | + 'descriptionmsg' => 'addmediawizard-desc', |
| 31 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:AddMediaWizard' |
| 32 | +); |
| 33 | + |
| 34 | +// Includes parent JS2Support |
| 35 | +require_once( dirname( dirname( __FILE__ ) ) . "/JS2Support.php" ); |
| 36 | + |
| 37 | +// Add the addMediaWizard binding on pages that include the Edit Toolbar: |
| 38 | +$wgHooks['EditPageBeforeEditToolbar'][] = 'AddMediaWizard::addJS'; |
| 39 | + |
| 40 | +// Add the Named path for js2 AddMediaWizardEditPage |
| 41 | +$wgScriptLoaderNamedPaths[ 'AMWEditPage' ] = 'extensions/JS2Support/AddMediaWizard/AddMediaWizardEditPage.js'; |
| 42 | + |
| 43 | +class AddMediaWizard { |
| 44 | + public static function addJS( $toolbar) { |
| 45 | + global $wgOut; |
| 46 | + // Add the amwEditPage script to the "page" script bucket |
| 47 | + $wgOut->addScriptClass( 'AMWEditPage', 'page' ); |
| 48 | + return true; |
| 49 | + } |
| 50 | +} |
Index: trunk/extensions/JS2Support/AddMediaWizard/AddMediaWizardEditPage.js |
— | — | @@ -0,0 +1,90 @@ |
| 2 | +// Setup configuration vars (if not set already) |
| 3 | +if ( !mwAddMediaConfig ) { |
| 4 | + var mwAddMediaConfig = { }; |
| 5 | +} |
| 6 | + |
| 7 | +// The default editPage AMW config ( should move to mw.setConfig mw.getConfig ) |
| 8 | +var defaultAddMediaConfig = { |
| 9 | + 'profile': 'mediawiki_edit', |
| 10 | + 'target_textbox': '#wpTextbox1', |
| 11 | + // Note: selections in the textbox will take over the default query |
| 12 | + 'default_query': wgTitle, |
| 13 | + 'target_title': wgPageName, |
| 14 | + |
| 15 | + // If the info overlay per asset should be displayed |
| 16 | + 'displayResourceInfoIcons' : true, |
| 17 | + |
| 18 | + // If we should display buttons to switch between "box" and "detailed" view |
| 19 | + 'displayResultFormatButton' : false, |
| 20 | + |
| 21 | + // Here we can setup the content provider overrides |
| 22 | + 'enabled_providers': ['wiki_commons'], |
| 23 | + // The local wiki API URL: |
| 24 | + 'local_wiki_apiUrl': wgServer + wgScriptPath + '/api.php' |
| 25 | +}; |
| 26 | + |
| 27 | +mw.ready( function() { |
| 28 | + var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); |
| 29 | + // Kind of tricky, it would be nice to use run on ready "loader" call here |
| 30 | + var didWikiEditorBind = false; |
| 31 | + |
| 32 | + // Set-up the drag drop binding (will only work for html5 upload browsers) |
| 33 | + // $j('textarea#wpTextbox1').dragFileUpload(); |
| 34 | + |
| 35 | + // set up the add-media-wizard binding: |
| 36 | + if ( typeof $j.wikiEditor != 'undefined' ) { |
| 37 | + // the below seems to be broken :( |
| 38 | + $j( 'textarea#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main', |
| 39 | + function( e, section ) { |
| 40 | + didWikiEditorBind = true; |
| 41 | + if ( typeof section.groups.insert.tools.file !== 'undefined' ) { |
| 42 | + section.groups.insert.tools.file.action = { |
| 43 | + 'type': 'callback', |
| 44 | + 'execute': function() { |
| 45 | + mw.log( 'Added via wikiEditor bind' ); |
| 46 | + // Display a loader ( since its triggered onClick ) |
| 47 | + mw.addLoaderDialog( gM( 'mwe-loading-add-media-wiz' ) ); |
| 48 | + mw.load( 'AddMedia.addMediaWizard', function() { |
| 49 | + mw.closeLoaderDialog(); |
| 50 | + $j.addMediaWizard( amwConf ); |
| 51 | + }); |
| 52 | + } |
| 53 | + }; |
| 54 | + } |
| 55 | + } |
| 56 | + ); |
| 57 | + } |
| 58 | + // Add to old toolbar if wikiEditor did not remove '#toolbar' from the page: |
| 59 | + setTimeout( function() { |
| 60 | + if ( $j( '#btn-add-media-wiz' ).length == 0 && $j( '#toolbar' ).length != 0 ) { |
| 61 | + mw.log( 'Do old toolbar bind:' ); |
| 62 | + didWikiEditorBind = true; |
| 63 | + $j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' + |
| 64 | + mw.getConfig( 'images_path' ) + 'Button_add_media.png">' ); |
| 65 | + |
| 66 | + $j( '#btn-add-media-wiz' ).attr( 'title', gM( 'mwe-loading-add-media-wiz' ) ); |
| 67 | + mw.load( 'AddMedia.addMediaWizard', function() { |
| 68 | + $j( '#btn-add-media-wiz' ).addMediaWizard( |
| 69 | + amwConf |
| 70 | + ); |
| 71 | + }); |
| 72 | + |
| 73 | + } else { |
| 74 | + // Make sure the wikieditor got binded: |
| 75 | + if ( !didWikiEditorBind ) { |
| 76 | + mw.log( 'Failed to bind via build section bind via target:' ); |
| 77 | + var $targetFileButton = $j( ".toolbar [rel='file']" ); |
| 78 | + |
| 79 | + $targetFileButton |
| 80 | + .attr( 'title', gM( 'mwe-loading-add-media-wiz' ) ); |
| 81 | + |
| 82 | + mw.load( 'AddMedia.addMediaWizard', function() { |
| 83 | + if( $targetFileButton.length != 0 ) { |
| 84 | + $targetFileButton.unbind().addMediaWizard( amwConf ); |
| 85 | + } |
| 86 | + } ); |
| 87 | + } |
| 88 | + } |
| 89 | + }, 120 ) |
| 90 | + |
| 91 | +} ); |
Property changes on: trunk/extensions/JS2Support/AddMediaWizard/AddMediaWizardEditPage.js |
___________________________________________________________________ |
Name: svn:executable |
1 | 92 | + * |
Index: trunk/extensions/JS2Support/AddMediaWizard/AddMediaWizard.i18n.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<? |
| 3 | +/** |
| 4 | + * Internationalisation for Add Media Wizard extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Michael Dale |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'addmediawizard-desc' => 'Add Media Wizard, Developed in partnership by kaltura and wikimedia foundation' |
| 17 | +); |
\ No newline at end of file |