[MediaWiki-commits] [Gerrit] mediawiki...AdvancedSearch[master]: Track usage of features

2017-11-02 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/388131 )

Change subject: Track usage of features
..

Track usage of features

This change adds tracking capabilities to the extension.

Bug: T173572
Change-Id: Ia2bdcf783da76273819dddab611f57cfda7aae63
---
M AdvancedSearch.hooks.php
M extension.json
A modules/dm/trackingEvents/ext.advancedSearch.SearchRequest.js
M modules/ext.advancedSearch.init.js
A tests/qunit/dm/trackingEvents/SearchRequest.test.js
5 files changed, 122 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/31/388131/1

diff --git a/AdvancedSearch.hooks.php b/AdvancedSearch.hooks.php
index 016893c..24837e3 100644
--- a/AdvancedSearch.hooks.php
+++ b/AdvancedSearch.hooks.php
@@ -89,7 +89,8 @@
'tests/qunit/ui/SearchPreview.test.js',
'tests/qunit/ui/TemplateSearch.test.js',
'tests/qunit/dm/SearchModel.test.js',
-   'tests/qunit/dm/FileTypeOptionProvider.test.js'
+   'tests/qunit/dm/FileTypeOptionProvider.test.js',
+   
'tests/qunit/dm/trackingEvents/SearchRequest.test.js'
],
'dependencies' => [
'ext.advancedSearch.ui.ArbitraryWordInput',
@@ -99,6 +100,7 @@
'ext.advancedSearch.ui.TemplateSearch',
'ext.advancedSearch.dm.SearchModel',
'ext.advancedSearch.dm.FileTypeOptionProvider',
+   
'ext.advancedSearch.dm.trackingEvents.SearchRequest',
'oojs-ui'
],
'localBasePath' => __DIR__,
diff --git a/extension.json b/extension.json
index 491cfb9..8f5fb6b 100644
--- a/extension.json
+++ b/extension.json
@@ -85,6 +85,7 @@
"ext.advancedSearch.util",
"ext.advancedSearch.dm.SearchModel",
"ext.advancedSearch.dm.FileTypeOptionProvider",
+   
"ext.advancedSearch.dm.trackingEvents.SearchRequest",
"ext.advancedSearch.ui.ArbitraryWordInput",
"ext.advancedSearch.ui.FileTypeSelection",
"ext.advancedSearch.ui.FormState",
@@ -230,12 +231,24 @@
"ext.advancedSearch.util"
]
},
+   "ext.advancedSearch.dm.trackingEvents.SearchRequest": {
+   "scripts": [
+   
"modules/dm/trackingEvents/ext.advancedSearch.SearchRequest.js"
+   ],
+   "dependencies": [
+   "oojs-ui",
+   "schema.AdvancedSearchRequest"
+   ]
+   },
"ext.advancedSearch.util": {
"scripts": [
"modules/ext.advancedSearch.util.js"
]
}
},
+   "EventLoggingSchemas": {
+   "AdvancedSearchRequest": 17379859
+   },
"ResourceFileModulePaths": {
"localBasePath": "",
"remoteExtPath": "AdvancedSearch"
diff --git a/modules/dm/trackingEvents/ext.advancedSearch.SearchRequest.js 
b/modules/dm/trackingEvents/ext.advancedSearch.SearchRequest.js
new file mode 100644
index 000..2ea946b
--- /dev/null
+++ b/modules/dm/trackingEvents/ext.advancedSearch.SearchRequest.js
@@ -0,0 +1,75 @@
+( function ( mw ) {
+   'use strict';
+
+   mw.libs = mw.libs || {};
+   mw.libs.advancedSearch = mw.libs.advancedSearch || {};
+   mw.libs.advancedSearch.dm = mw.libs.advancedSearch.dm || {};
+   mw.libs.advancedSearch.dm.trackingEvents = 
mw.libs.advancedSearch.dm.trackingEvents || {};
+
+   /**
+* Sets an event data property
+* @param {Object} eventData
+* @param {string} key
+* @param {*} value
+* @return {boolean}
+*/
+   function setEventDataProperty( eventData, key, value ) {
+   if ( eventData.hasOwnProperty( key ) ) {
+   eventData[ key ] = value;
+   }
+
+   return false;
+   }
+
+   /**
+* @class
+* @constructor
+*/
+   mw.libs.advancedSearch.dm.trackingEvents.SearchRequest = function () {
+   this.eventName = 'AdvancedSearchRequest';
+   this.eventData = {
+   plain: false,
+   phrase: false,
+   not: false,
+   or: false,
+

[MediaWiki-commits] [Gerrit] mediawiki...AdvancedSearch[master]: Clear input field when choosing a namespace from the menu

2017-10-06 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382751 )

Change subject: Clear input field when choosing a namespace from the menu
..

Clear input field when choosing a namespace from the menu

When typing into the namespace filter widget and clicking a menu item to
add it afterwards, the input field is cleared.

Bug: T172863
Change-Id: I47e5a80a0a21a927716ae131d9e2eb61aa240799
---
M modules/ui/ext.advancedSearch.NamespaceFilters.js
M tests/qunit/ui/NamespaceFilters.test.js
2 files changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/51/382751/1

diff --git a/modules/ui/ext.advancedSearch.NamespaceFilters.js 
b/modules/ui/ext.advancedSearch.NamespaceFilters.js
index ca779c1..fb04c63 100644
--- a/modules/ui/ext.advancedSearch.NamespaceFilters.js
+++ b/modules/ui/ext.advancedSearch.NamespaceFilters.js
@@ -178,4 +178,14 @@
}
};
 
+   /**
+* Respond to menu choose event by clearing the input field
+*
+* @param {OO.ui.OptionWidget} menuItem Chosen menu item
+*/
+   mw.libs.advancedSearch.ui.NamespaceFilters.prototype.onMenuChoose = 
function ( menuItem ) {
+   
mw.libs.advancedSearch.ui.NamespaceFilters.parent.prototype.onMenuChoose.call( 
this, menuItem );
+   this.clearInput();
+   };
+
 }( mediaWiki, jQuery ) );
diff --git a/tests/qunit/ui/NamespaceFilters.test.js 
b/tests/qunit/ui/NamespaceFilters.test.js
index 7cd62f0..4d75f64 100644
--- a/tests/qunit/ui/NamespaceFilters.test.js
+++ b/tests/qunit/ui/NamespaceFilters.test.js
@@ -150,4 +150,23 @@
filter.onValueUpdate();
} );
 
+   QUnit.test( 'Choosing a namespace from the menu clears the input 
field', function ( assert ) {
+   assert.expect( 1 );
+
+   var model = new Model(),
+   filter = new NamespaceFilters( model, {
+   namespaces: {
+   0: 'Article',
+   1: 'Talk',
+   2: 'User',
+   3: 'UserTalk'
+   }
+   } );
+
+   model.setNamespaces( [ '0' ] );
+   filter.input.setValue( 'Use' );
+   filter.getMenu().chooseItem( filter.getMenu().getItems()[ 0 ] );
+   assert.equal( filter.input.getValue(), '' );
+   } );
+
 }( mediaWiki ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/382751
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47e5a80a0a21a927716ae131d9e2eb61aa240799
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AdvancedSearch
Gerrit-Branch: master
Gerrit-Owner: Kai Nissen (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...AdvancedSearch[master]: Disable menu items when adding tags

2017-10-06 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382703 )

Change subject: Disable menu items when adding tags
..

Disable menu items when adding tags

Adding tags to the namespace filter widget is now reflected by their
corresponding menu option item's disabled state.

Bug: T172866
Change-Id: I28bdaac8098a19fe76d0df7fd3d35a10ec49e623
---
M modules/ui/ext.advancedSearch.NamespaceFilters.js
M tests/qunit/ui/NamespaceFilters.test.js
2 files changed, 45 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/03/382703/1

diff --git a/modules/ui/ext.advancedSearch.NamespaceFilters.js 
b/modules/ui/ext.advancedSearch.NamespaceFilters.js
index ca779c1..01066b2 100644
--- a/modules/ui/ext.advancedSearch.NamespaceFilters.js
+++ b/modules/ui/ext.advancedSearch.NamespaceFilters.js
@@ -58,7 +58,8 @@
return new OO.ui.MenuOptionWidget( {
data: data,
label: label || data,
-   icon: this.getNamespaceIcon( data )
+   icon: this.getNamespaceIcon( data )/* ,
+   disabled: !this.getItemFromData( data ) */
} );
};
 
@@ -169,12 +170,18 @@
 * Overrides OO.ui.TagMultiselectWidget.prototype.onChangeTags default 
behaviour to add GUI effect
 */
mw.libs.advancedSearch.ui.NamespaceFilters.prototype.onChangeTags = 
function () {
-   var items = this.getItems();
+   var self = this,
+   tagItems = this.getItems(),
+   menuItems = this.getMenu().getItems();
 

mw.libs.advancedSearch.ui.NamespaceFilters.parent.prototype.onChangeTags.call( 
this );
 
-   if ( items.length > 0 ) {
-   items[ 0 ].setDisabled( items.length === 1 );
+   $.each( menuItems, function ( index, menuItem ) {
+   menuItem.setDisabled( !!self.getItemFromData( 
menuItem.getData() ) );
+   } );
+
+   if ( tagItems.length > 0 ) {
+   tagItems[ 0 ].setDisabled( tagItems.length === 1 );
}
};
 
diff --git a/tests/qunit/ui/NamespaceFilters.test.js 
b/tests/qunit/ui/NamespaceFilters.test.js
index 7cd62f0..f079649 100644
--- a/tests/qunit/ui/NamespaceFilters.test.js
+++ b/tests/qunit/ui/NamespaceFilters.test.js
@@ -150,4 +150,38 @@
filter.onValueUpdate();
} );
 
+   QUnit.test( 'Selected namespaces are disabled in menu', function ( 
assert ) {
+   assert.expect( 1 );
+
+   var model = new Model(),
+   filter = new NamespaceFilters( model, {
+   namespaces: {
+   0: 'Article',
+   1: 'Talk',
+   2: 'User',
+   3: 'UserTalk'
+   }
+   } );
+
+   model.setNamespaces( [ '1' ] );
+   assert.equal( filter.getMenu().getItems()[ 1 ].isDisabled(), 
true );
+   } );
+
+   QUnit.test( 'Unselected namespaces are not disabled in menu', function 
( assert ) {
+   assert.expect( 1 );
+
+   var model = new Model(),
+   filter = new NamespaceFilters( model, {
+   namespaces: {
+   0: 'Article',
+   1: 'Talk',
+   2: 'User',
+   3: 'UserTalk'
+   }
+   } );
+
+   model.setNamespaces( [ '1', '2', '3' ] );
+   assert.equal( filter.getMenu().getItems()[ 0 ].isDisabled(), 
false );
+   } );
+
 }( mediaWiki ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/382703
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I28bdaac8098a19fe76d0df7fd3d35a10ec49e623
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AdvancedSearch
Gerrit-Branch: master
Gerrit-Owner: Kai Nissen (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...AdvancedSearch[master]: Fix coding style issue

2017-09-15 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378230 )

Change subject: Fix coding style issue
..

Fix coding style issue

This is just a minor change removing indentations on empty lines
introduced in 2a5f20c.

Bug: T168405
Change-Id: Ic1fca2aa8216e4404229742764ccaebbe2d1e733
---
M includes/TooltipGenerator.php
1 file changed, 4 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/30/378230/1

diff --git a/includes/TooltipGenerator.php b/includes/TooltipGenerator.php
index cacbc72..871d098 100644
--- a/includes/TooltipGenerator.php
+++ b/includes/TooltipGenerator.php
@@ -15,7 +15,7 @@
 class TooltipGenerator {
 
public static function generateToolTips( ) {
-   
+
$messageKeys = [
'advancedsearch-help-plain',
'advancedsearch-help-phrase',
@@ -28,7 +28,7 @@
'advancedsearch-help-filew',
'advancedsearch-help-fileh'
];
-   
+
return array_combine(
$messageKeys,
array_map( function( $messageKey ) {
@@ -37,4 +37,5 @@
);
}
 
-}
\ No newline at end of file
+}
+

-- 
To view, visit https://gerrit.wikimedia.org/r/378230
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1fca2aa8216e4404229742764ccaebbe2d1e733
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AdvancedSearch
Gerrit-Branch: master
Gerrit-Owner: Kai Nissen (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...AdvancedSearch[master]: Create file type options dynamically

2017-09-08 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376706 )

Change subject: Create file type options dynamically
..

Create file type options dynamically

File type options that allow users to search by CirrusSearch's filemime keyword
are now provided based on the allowed file type configuration of Special:Upload.
Options for the filetype keyword are still based on a hard-coded list of 
options.

Bug: T170402
Change-Id: I43b362fb55e4dfa94a5c4fa0435729f673747fd6
---
M AdvancedSearch.hooks.php
M extension.json
M i18n/en.json
M i18n/qqq.json
A modules/dm/ext.advancedSearch.FileTypeConfigurator.js
M modules/ext.advancedSearch.init.js
M modules/ui/ext.advancedSearch.FileTypeSelection.js
A tests/qunit/dm/FileTypeConfigurator.test.js
8 files changed, 247 insertions(+), 128 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/06/376706/1

diff --git a/AdvancedSearch.hooks.php b/AdvancedSearch.hooks.php
index 2ffab78..4dc734d 100644
--- a/AdvancedSearch.hooks.php
+++ b/AdvancedSearch.hooks.php
@@ -30,7 +30,52 @@
if ( $special->getName() === 'Search' ) {
$special->getOutput()->addModules( 
'ext.advancedSearch.init' );
$special->getOutput()->addModuleStyles( 
'ext.advancedSearch.initialstyles' );
+
+   $special->getOutput()->addJsConfigVars(
+   'advancedSearch.mimeTypes',
+   self::newMimeTypesConfigVar( 
$special->getConfig()->get( 'FileExtensions' ) )
+   );
}
+   }
+
+   private static function newMimeTypesConfigVar( $fileExtensions ) {
+   $mimeTypes = [];
+
+   foreach ( $fileExtensions as $ext ) {
+   $mimeTypesForExtension = 
self::getMimeTypesByFileExtension( $ext );
+   if ( !in_array( $mimeTypesForExtension, $mimeTypes ) ) {
+   $mimeTypes[$ext] = $mimeTypesForExtension;
+   }
+   }
+
+   return self::makeUniqueArrayOfArrays( $mimeTypes );
+   }
+
+   /**
+* Uses MimeAnalyzer to determine mimetypes of a given file extension
+*
+* @param $fileExtension
+* @return array 
+*/
+   private static function getMimeTypesByFileExtension( $fileExtension ) {
+   return array_unique(
+   explode(
+   ' ',
+   
MediaWikiServices::getInstance()->getMimeAnalyzer()->getTypesForExtension( 
$fileExtension )
+   )
+   );
+   }
+
+   private static function makeUniqueArrayOfArrays( $array ) {
+   $result = array_map( 'unserialize', array_unique( array_map( 
'serialize', $array ) ) );
+
+   foreach ( $result as $key => $value ) {
+   if ( is_array( $value ) ) {
+   $result[$key] = self::makeUniqueArrayOfArrays( 
$value );
+   }
+   }
+
+   return $result;
}
 
/**
@@ -80,7 +125,8 @@
'tests/qunit/ui/NamespacePresets.test.js',
'tests/qunit/ui/SearchPreview.test.js',
'tests/qunit/ui/TemplateSearch.test.js',
-   'tests/qunit/dm/SearchModel.test.js'
+   'tests/qunit/dm/SearchModel.test.js',
+   'tests/qunit/dm/FileTypeOptionProvider.test.js'
],
'dependencies' => [
'ext.advancedSearch.ui.NamespaceFilters',
@@ -88,6 +134,7 @@
'ext.advancedSearch.ui.SearchPreview',
'ext.advancedSearch.ui.TemplateSearch',
'ext.advancedSearch.dm.SearchModel',
+   'ext.advancedSearch.dm.FileTypeOptionProvider',
'oojs-ui'
],
'localBasePath' => __DIR__,
diff --git a/extension.json b/extension.json
index 4247c6c..d012717 100644
--- a/extension.json
+++ b/extension.json
@@ -89,6 +89,7 @@
"oojs-ui.styles.icons-wikimedia",
"ext.advancedSearch.util",
"ext.advancedSearch.dm.SearchModel",
+   "ext.advancedSearch.dm.FileTypeOptionProvider",
"ext.advancedSearch.ui.ArbitraryWordInput",
"ext.advancedSearch.ui.FileTypeSelection",
"ext.advancedSearch.ui.FormState",
@@ -130,22 +131,14 @@

[MediaWiki-commits] [Gerrit] Consider the object reference not being passed in the expect... - change (mediawiki...UploadWizard)

2015-09-04 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/236026

Change subject: Consider the object reference not being passed in the expected 
format
..

Consider the object reference not being passed in the expected format

This fix cares for the parameter objref not containing the expected pipe
character as the delimiter. The href of the button that is configured to
'useObjref' will only be applied if the objref parameter consists of at
least two values delimited by the pipe character.

Bug: T111381
Change-Id: I1e422f135aad29d569b81a867da9a393c974f31e
---
M includes/UploadWizardCampaign.php
M tests/phpunit/UploadWizardConfigTest.php
2 files changed, 46 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/26/236026/1

diff --git a/includes/UploadWizardCampaign.php 
b/includes/UploadWizardCampaign.php
index cdd7938..872401a 100755
--- a/includes/UploadWizardCampaign.php
+++ b/includes/UploadWizardCampaign.php
@@ -444,9 +444,12 @@
 * @return bool|string
 */
private function getButtonHrefByObjectReference( $objRef ) {
-   list( $wiki, $title ) = explode( '|', $objRef );
-   if ( Interwiki::isValidInterwiki( $wiki ) ) {
-   return str_replace( '$1', $title, Interwiki::fetch( 
$wiki )->getURL() );
+   $arrObjRef = explode( '|', $objRef );
+   if ( count( $arrObjRef ) > 1 ) {
+   list( $wiki, $title ) = $arrObjRef;
+   if ( Interwiki::isValidInterwiki( $wiki ) ) {
+   return str_replace( '$1', $title, 
Interwiki::fetch( $wiki )->getURL() );
+   }
}
return false;
}
diff --git a/tests/phpunit/UploadWizardConfigTest.php 
b/tests/phpunit/UploadWizardConfigTest.php
index c511606..e59ddc5 100644
--- a/tests/phpunit/UploadWizardConfigTest.php
+++ b/tests/phpunit/UploadWizardConfigTest.php
@@ -7,18 +7,52 @@
 
 class UploadWizardConfigTest extends MediaWikiTestCase {
 
-   public function 
testButtonTargetIsSetToUseObjRef_buttonHrefMatchesRefPage() {
+   public function objRefProvider() {
+   return array(
+   array(
+   '',
+   false
+   ),
+   array(
+   'JustSomeString',
+   false
+   ),
+   array(
+   'notawiki|Page Title',
+   false
+   ),
+   array(
+   'es|Page Title',
+   'http://es.wikipedia.org/wiki/Page Title'
+   ),
+   array(
+   'es|Page Title|id12345',
+   'http://es.wikipedia.org/wiki/Page Title'
+   ),
+   );
+   }
+
+   /**
+* @dataProvider objRefProvider
+*/
+   public function 
testButtonTargetIsSetToUseObjRef_buttonHrefMatchesRefPage( $objRef, 
$expectedResult ) {
global $wgUploadWizardConfig;
ParserTest::setupInterwikis();
 
$this->setMwGlobals( array(
'wgUploadWizardConfig' => array_merge( 
$wgUploadWizardConfig, array(
-   'defaults' => array( 'objref' => 'es|My 
Monuments|12345' ),
+   'defaults' => array( 'objref' => $objRef ),
) ),
) );
 
-   $campaign = new UploadWizardCampaign(
-   Title::newFromText( 'uw-test-campaign', NS_CAMPAIGN ),
+   $this->assertEquals(
+   $expectedResult,
+   $this->getHomeButtonHref()
+   );
+   }
+
+   private function getHomeButtonHref() {
+   $campaign = new UploadWizardCampaign( Title::newFromText( 
'uw-test-campaign', NS_CAMPAIGN ),
array(
'enabled' => true,
'display' => array(
@@ -29,12 +63,8 @@
)
)
);
+
$config = $campaign->getParsedConfig();
-
-   $this->assertEquals(
-   'http://es.wikipedia.org/wiki/My Monuments',
-   $config['display']['homeButton']['target']
-   );
+   return isset( $config['display']['homeButton']['target'] ) ? 
$config['display']['homeButton']['target'] : false;
}
-
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/236026
To unsubscribe, visit 

[MediaWiki-commits] [Gerrit] Fix button config for campaigns to check for a given object ... - change (mediawiki...UploadWizard)

2015-08-28 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/234567

Change subject: Fix button config for campaigns to check for a given object 
reference
..

Fix button config for campaigns to check for a given object reference

This fixes the issue that occurs, when the campaign definition sets a
custom target for one of the buttons on the Thanks page and no actual
objref is given in the query string.

Bug: T110697
Change-Id: I107def03c501eb81f0e671bf41c3e972e78e0e9f
---
M includes/UploadWizardCampaign.php
M resources/ui/uw.ui.Thanks.js
2 files changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/67/234567/1

diff --git a/includes/UploadWizardCampaign.php 
b/includes/UploadWizardCampaign.php
index feff16b..cdd7938 100755
--- a/includes/UploadWizardCampaign.php
+++ b/includes/UploadWizardCampaign.php
@@ -466,6 +466,8 @@
$validUrl = 
$this-getButtonHrefByObjectReference( $objRef );
if ( $validUrl ) {

$this-parsedConfig['display'][$button]['target'] = $validUrl;
+   } else {
+   unset( 
$this-parsedConfig['display'][$button] );
}
}
}
diff --git a/resources/ui/uw.ui.Thanks.js b/resources/ui/uw.ui.Thanks.js
index 6e82225..956857c 100644
--- a/resources/ui/uw.ui.Thanks.js
+++ b/resources/ui/uw.ui.Thanks.js
@@ -37,7 +37,7 @@
$( '#mwe-upwiz-step-thanks' )
);
 
-   if ( mw.UploadWizard.config.defaults  
mw.UploadWizard.config.defaults.objref !== '' ) {
+   if ( this.isObjectReferenceGiven() ) {
this.getDelayNotice().prependTo( this.$div );
}
 
@@ -70,7 +70,7 @@
 
// TODO: make the step order configurable by campaign 
definitions instead of using these hacks
beginButtonTarget = this.getButtonConfig( 'beginButton', 
'target' );
-   if ( !beginButtonTarget ) {
+   if ( !beginButtonTarget || ( beginButtonTarget === 'dropObjref' 
 !this.isObjectReferenceGiven() ) ) {
this.beginButton.on( 'click', function () {
thanks.emit( 'next-step' );
} );
@@ -219,5 +219,9 @@
return $delayNotice;
};
 
+   TP.isObjectReferenceGiven = function () {
+   return mw.UploadWizard.config.defaults  
mw.UploadWizard.config.defaults.objref !== '';
+   };
+
ui.Thanks = Thanks;
 }( mediaWiki, jQuery, mediaWiki.uploadWizard.ui, OO ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/234567
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I107def03c501eb81f0e671bf41c3e972e78e0e9f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Kai Nissen (WMDE) kai.nis...@wikimedia.de

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] [UploadWizard] Introducing the usage of an object reference - change (mediawiki...UploadWizard)

2015-08-05 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/229456

Change subject: [UploadWizard] Introducing the usage of an object reference
..

[UploadWizard] Introducing the usage of an object reference

This patch adds checkboxes to the uploads on Upload Wizard's upload page.

Users can then decide, to which image the object reference should be
applied. Whether checkboxes are being displayed depends on the objref
parameter passed to the Upload Wizard. The checkboxes are only enabled
if the parameter updateList contains any value. If the parameter is not
set or not given the checkboxes are disabled and a notice is being
displayed stating that the list entry already contains an image.

Bug: T105283
Change-Id: I6012a7f66267cc361e34ccd30bfcb06961701a83
---
M UploadWizardHooks.php
M i18n/en.json
M i18n/qqq.json
M includes/specials/SpecialUploadWizard.php
M resources/mw.UploadWizardDetails.js
M resources/mw.UploadWizardUploadInterface.js
M resources/uploadWizard.css
7 files changed, 79 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/56/229456/1

diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 1ac24b0..4611ec4 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -285,6 +285,8 @@
'mwe-upwiz-location-alt',
'mwe-upwiz-location-heading',
'mwe-upwiz-copyright-info',
+   'mwe-upwiz-objref-pick-image',
+   'mwe-upwiz-objref-notice-existing-image',
'mwe-upwiz-author',
'mwe-upwiz-autoconverted',
'mwe-upwiz-other',
diff --git a/i18n/en.json b/i18n/en.json
index d1e3171..222b39b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -145,6 +145,8 @@
mwe-upwiz-location-alt: Altitude,
mwe-upwiz-location-heading: Heading,
mwe-upwiz-copyright-info: Release rights,
+   mwe-upwiz-objref-pick-image: Insert this image into the monument 
list page.,
+   mwe-upwiz-objref-notice-existing-image: Monument list already 
contains an image,
mwe-upwiz-author: Author(s),
mwe-upwiz-autoconverted: This file was automatically converted to 
the $1 format,
mwe-upwiz-other: Other information,
diff --git a/i18n/qqq.json b/i18n/qqq.json
index ef38038..e4197e2 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -168,6 +168,8 @@
mwe-upwiz-location-alt: Altitude - the GPS coordinate, expressed in 
metres.\n{{Identical|Altitude}},
mwe-upwiz-location-heading: '''This is not \Heading\ in the sense 
of \Title\.''' This is the direction the camera or other device was pointing 
based on GPS data.,
mwe-upwiz-copyright-info: Used as fieldset label.,
+   mwe-upwiz-objref-pick-image: Used as label for the object reference 
checkbox, which selects the image that will be inserted into the referring 
page.,
+   mwe-upwiz-objref-notice-existing-image: Notice that is being 
displayed when there already is an image on the list page,
mwe-upwiz-author: Used as label for the Author(s) input 
box.\n{{Identical|Author}},
mwe-upwiz-autoconverted: Unused at this time.\n\nParameters:\n* $1 - 
...,
mwe-upwiz-other: [[File:Commons-uw-L52P.png|right|thumb|Screenshot 
showing a sample of this message]]\n\n{{Identical|Other information}},
diff --git a/includes/specials/SpecialUploadWizard.php 
b/includes/specials/SpecialUploadWizard.php
index 645f14e..ad47972 100644
--- a/includes/specials/SpecialUploadWizard.php
+++ b/includes/specials/SpecialUploadWizard.php
@@ -78,6 +78,7 @@
}
 
$urlDefaults['objref'] = $req-getText( 'objref' ) ?: '';
+   $urlDefaults['updateList'] = $req-getText( 'updateList' ) ?: 
'';
 
UploadWizardConfig::setUrlSetting( 'defaults', $urlDefaults );
 
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index d439798..9537ad8 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -1468,7 +1468,7 @@
}
 
// add parameters for list callback bot
-   if ( mw.UploadWizard.config.defaults.objref !== 
undefined ) {
+   if ( $( '#imgPicker' + this.upload.index 
).attr( 'checked' ) ) {
wikiText += '\n!-- 
LIST_CALLBACK_PARAMS ' +

mw.UploadWizard.config.defaults.objref +
' --\n\n';
diff --git a/resources/mw.UploadWizardUploadInterface.js 
b/resources/mw.UploadWizardUploadInterface.js
index c150cf3..0aec133 100644
--- 

[MediaWiki-commits] [Gerrit] [UploadWizard] Introducing the usage of an object reference - change (mediawiki...UploadWizard)

2015-07-30 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227984

Change subject: [UploadWizard] Introducing the usage of an object reference
..

[UploadWizard] Introducing the usage of an object reference

The parameter objref will be used to have a bot updating the
lists of monuments with a thumbnail image of one of the uploaded
images.

This patch also adds the keyword 'useObjref' to the home button
and the keyword 'dropObjref' to the begin button configuration.

If it is set and there is an objref parameter passed with the request,
clicking the home button leads to the page passed as the reference (this
may be any page in any wiki defined for interwiki links; it is intended
to be the referer, though). If the begin button is configured to drop the
object reference, it will reload the Upload Wizard page, but will drop
the reference parameter from the URL.

Independently from the button configuration, if the objref parameter is
set, the Upload Wizard adds the reference parameter to the description
page inside a comment tag. This will later be used by a bot that
supplements an image thumbnail to monument lists.

Bug: T105281
Change-Id: Ia974a148a6326dbca17a70c54a0cffcd2e4a39ac
---
M includes/UploadWizardCampaign.php
M includes/specials/SpecialUploadWizard.php
M resources/mw.UploadWizardDetails.js
M resources/ui/uw.ui.Thanks.js
A tests/phpunit/UploadWizardConfigTest.php
M tests/qunit/controller/uw.controller.Thanks.test.js
6 files changed, 144 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/84/227984/1

diff --git a/includes/UploadWizardCampaign.php 
b/includes/UploadWizardCampaign.php
index b58ebd9..feff16b 100755
--- a/includes/UploadWizardCampaign.php
+++ b/includes/UploadWizardCampaign.php
@@ -337,9 +337,14 @@
}
 
$this-parsedConfig = $parsedConfig;
+
$cache-set( $memKey, array( 'timestamp' = time(), 
'config' = $parsedConfig ) );
}
 
+   $uwDefaults = UploadWizardConfig::getSetting( 'defaults' );
+   if ( array_key_exists( 'objref', $uwDefaults ) ) {
+   $this-applyObjectReferenceToButtons( 
$uwDefaults['objref'] );
+   }
$this-modifyIfNecessary();
 
return $this-parsedConfig;
@@ -431,4 +436,38 @@
 
return $start === null || $start = $today;
}
+
+   /**
+* Generate the URL out of the object reference
+*
+* @param string $objRef
+* @return bool|string
+*/
+   private function getButtonHrefByObjectReference( $objRef ) {
+   list( $wiki, $title ) = explode( '|', $objRef );
+   if ( Interwiki::isValidInterwiki( $wiki ) ) {
+   return str_replace( '$1', $title, Interwiki::fetch( 
$wiki )-getURL() );
+   }
+   return false;
+   }
+
+   /**
+* Apply given object reference to buttons configured to use it as href
+*
+* @param string $objRef
+*/
+   private function applyObjectReferenceToButtons( $objRef ) {
+   $customizableButtons = array( 'homeButton', 'beginButton' );
+
+   foreach( $customizableButtons as $button ) {
+   if ( array_key_exists( $button, 
$this-parsedConfig['display'] ) 
+
$this-parsedConfig['display'][$button]['target'] === 'useObjref'
+   ) {
+   $validUrl = 
$this-getButtonHrefByObjectReference( $objRef );
+   if ( $validUrl ) {
+   
$this-parsedConfig['display'][$button]['target'] = $validUrl;
+   }
+   }
+   }
+   }
 }
diff --git a/includes/specials/SpecialUploadWizard.php 
b/includes/specials/SpecialUploadWizard.php
index 3015f36..645f14e 100644
--- a/includes/specials/SpecialUploadWizard.php
+++ b/includes/specials/SpecialUploadWizard.php
@@ -77,6 +77,8 @@
$urlDefaults['categories'] = explode( '|', $categories 
);
}
 
+   $urlDefaults['objref'] = $req-getText( 'objref' ) ?: '';
+
UploadWizardConfig::setUrlSetting( 'defaults', $urlDefaults );
 
$fields = $req-getArray( 'fields' );
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index 5a50321..d439798 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -1467,6 +1467,13 @@
wikiText += 
mw.UploadWizard.config.autoAdd.wikitext;
}
 
+   // add parameters for list callback bot
+   

[MediaWiki-commits] [Gerrit] [UploadWizard] Make button labels and targets configurable - change (mediawiki...UploadWizard)

2015-07-23 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/226522

Change subject: [UploadWizard] Make button labels and targets configurable
..

[UploadWizard] Make button labels and targets configurable

This patch adds configurability of button labels and targets on the
Thanks page. To set a label and/or target, the 'display' section of
the campaign configuration is used. An example can be found in the
unit test.

Bug: T105285
Change-Id: Ieb6ee3660f7021d18a63c1fff3c6b088b54b6b23
---
M resources/ui/uw.ui.Thanks.js
M tests/qunit/controller/uw.controller.Thanks.test.js
2 files changed, 68 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/22/226522/1

diff --git a/resources/ui/uw.ui.Thanks.js b/resources/ui/uw.ui.Thanks.js
index e2b4304..48ac7c6 100644
--- a/resources/ui/uw.ui.Thanks.js
+++ b/resources/ui/uw.ui.Thanks.js
@@ -28,6 +28,20 @@
var $header,
thanks = this;
 
+   this.getButtonConfig = function( buttonName, configField ) {
+   if (
+   !mw.UploadWizard.config ||
+   !mw.UploadWizard.config.display ||
+   !mw.UploadWizard.config.display[buttonName]
+   ) {
+   return false;
+   }
+
+   return typeof 
mw.UploadWizard.config.display[buttonName][configField] !== 'undefined' ?
+   
mw.UploadWizard.config.display[buttonName][configField] :
+   false;
+   };
+
ui.Step.call(
this,
$( '#mwe-upwiz-stepdiv-thanks' ),
@@ -52,18 +66,25 @@
this.$buttons = this.$div.find( '.mwe-upwiz-buttons' );
 
this.homeButton = new oo.ui.ButtonWidget( {
-   label: mw.message( 'mwe-upwiz-home' ).text(),
-   href: mw.config.get( 'wgArticlePath' ).replace( '$1', 
'' )
+   label: this.getButtonConfig( 'homeButton', 'label' ) || 
mw.message( 'mwe-upwiz-home' ).text(),
+   href: this.getButtonConfig( 'homeButton', 'target' ) || 
mw.config.get( 'wgArticlePath' ).replace( '$1', '' )
} );
 
-   this.homeButtonField = new oo.ui.FieldLayout( this.homeButton, 
{ align: 'inline' } );
+   this.homeButtonField = new oo.ui.FieldLayout( this.homeButton, 
{ align: 'inline' });
 
this.beginButton = new oo.ui.ButtonWidget( {
-   label: mw.message( 'mwe-upwiz-upload-another' ).text(),
+   label: this.getButtonConfig( 'beginButton', 'label' ) 
||  mw.message( 'mwe-upwiz-upload-another' ).text(),
flags: [ 'progressive', 'primary' ]
-   } ).on( 'click', function () {
-   thanks.emit( 'next-step' );
} );
+   
+   var beginButtonTarget = this.getButtonConfig( 'beginButton', 
'target' );
+   if ( !beginButtonTarget ) {
+   this.beginButton.on( 'click', function () {
+   thanks.emit( 'next-step' );
+   } );
+   } else {
+   this.beginButton.setHref( beginButtonTarget );
+   }
 
this.beginButtonField = new oo.ui.FieldLayout( 
this.beginButton, { align: 'inline' } );
 
diff --git a/tests/qunit/controller/uw.controller.Thanks.test.js 
b/tests/qunit/controller/uw.controller.Thanks.test.js
index 6c2acc5..62e9fda 100644
--- a/tests/qunit/controller/uw.controller.Thanks.test.js
+++ b/tests/qunit/controller/uw.controller.Thanks.test.js
@@ -38,4 +38,45 @@
 
assert.strictEqual( auStub.callCount, 3 );
} );
+
+   QUnit.test( 'Custom button configuration', 4, function( assert ) {
+   mw.UploadWizard.config = {
+   display: {
+   homeButton: {
+   label: 'This is just a test',
+   target: 
'https://wiki.example.com/wiki/Main_Page'
+   },
+   beginButton: {
+   label: 'Let me start again',
+   target: 
'https://commons.wikimedia.org/wiki/Special:UploadWizard'
+   }
+   }
+   };
+   var uiThanks = new uw.ui.Thanks();
+
+   assert.equal(
+   uiThanks.homeButton.getLabel(),
+   'This is just a test',
+   'The label of the home button matches the configured 
text.'
+   

[MediaWiki-commits] [Gerrit] (bug 47653) Processing foreign API files protocol-relative - change (mediawiki/core)

2013-04-29 Thread Kai Nissen (WMDE) (Code Review)
Kai Nissen (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/61390


Change subject: (bug 47653) Processing foreign API files protocol-relative
..

(bug 47653) Processing foreign API files protocol-relative

Bug: 47653

When a page contains resources being loaded by a foreign wiki's API, the
protocol type is being cached by the parser. When a user calls the
cached page afterwards, resources that have been originally loaded using
an unsecure protocol will always be loaded using an unsecure connection,
even if the user requests the page using a secure connection. Some
browsers warn the user about that.

The patch removes the protocol type from the retrieved 'thumburl',
leaving it protocol-relative.

Change-Id: Id40186d10019a77f8b827a6a67982d40f3e97f11
---
M includes/filerepo/ForeignAPIRepo.php
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/90/61390/1

diff --git a/includes/filerepo/ForeignAPIRepo.php 
b/includes/filerepo/ForeignAPIRepo.php
index 5cd6fc2..71129fa 100644
--- a/includes/filerepo/ForeignAPIRepo.php
+++ b/includes/filerepo/ForeignAPIRepo.php
@@ -236,7 +236,9 @@
if ( $data  $info  isset( $info['thumburl'] ) ) {
wfDebug( __METHOD__ .  got remote thumb  . 
$info['thumburl'] . \n );
$result = $info;
-   return $info['thumburl'];
+   // replacing protocol type by protocol-relative '//'
+   $thumbUrl = preg_replace( /^(http\:|https\:)/i, , 
$info['thumburl'] );
+   return $thumbUrl;
} else {
return false;
}

-- 
To view, visit https://gerrit.wikimedia.org/r/61390
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id40186d10019a77f8b827a6a67982d40f3e97f11
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Kai Nissen (WMDE) kai.nis...@wikimedia.de

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits