https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103523
Revision: 103523
Author: raindrift
Date: 2011-11-17 23:28:16 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Category autocomplete now only suggests categories that have corresponding
description pages. Fixes bug 30718
Modified Paths:
--------------
trunk/extensions/UploadWizard/resources/mw.Api.category.js
Modified: trunk/extensions/UploadWizard/resources/mw.Api.category.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.Api.category.js 2011-11-17
23:12:58 UTC (rev 103522)
+++ trunk/extensions/UploadWizard/resources/mw.Api.category.js 2011-11-17
23:28:16 UTC (rev 103523)
@@ -42,18 +42,20 @@
*/
getCategoriesByPrefix: function( prefix, callback, err ) {
+ // fetch with allpages to only get categories that have
a corresponding description page.
var params = {
- 'list': 'allcategories',
- 'acprefix': prefix
+ 'list': 'allpages',
+ 'apprefix': prefix,
+ 'apnamespace':
mw.config.get('wgNamespaceIds').category
};
var ok = function( data ) {
var texts = [];
- if ( data.query && data.query.allcategories ) {
+ if ( data.query && data.query.allpages ) {
// API returns an array of objects like
- // allcategories: [ {'*':'foo'},
{'*':'bar'} ]
- $.each( data.query.allcategories,
function( i, category ) {
- texts.push( category['*'] );
+ // allpages: [ {'*':'foo'}, {'*':'bar'}
]
+ $.each( data.query.allpages, function(
i, category ) {
+ texts.push(
category.title.substr(9) ); // the substr removes Category: from the title.
} );
}
callback( texts );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs