Harjotsingh has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/342076 )
Change subject: Add filter by project on Special:GlobalUsage [WIP] ...................................................................... Add filter by project on Special:GlobalUsage [WIP] Bug:T38859 Change-Id: I59cd0303492821d4734e2b6c2e2704f45e9609d2 --- M SpecialGlobalUsage.php M i18n/en.json 2 files changed, 33 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUsage refs/changes/76/342076/1 diff --git a/SpecialGlobalUsage.php b/SpecialGlobalUsage.php index 8c23783..cd15bab 100644 --- a/SpecialGlobalUsage.php +++ b/SpecialGlobalUsage.php @@ -73,6 +73,19 @@ 'align' => 'top', ] ); + // T38859 + $fields[] = new OOUI\FieldLayout( + new OOUI\TextInputWidget( [ + 'name' => 'filter', + 'id' => 'filter', + 'autosize' => true, + ] ), + [ + 'label' => $this->msg( 'globalusage-filter' )->text(), + 'align' => 'top', + ] + ); + // Filter local checkbox $fields[] = new OOUI\FieldLayout( @@ -153,6 +166,7 @@ } $query->setLimit( $request->getInt( 'limit', 50 ) ); $query->filterLocal( $this->filterLocal ); + $filter = $request->getVal('filter'); // Perform query $query->execute(); @@ -163,6 +177,7 @@ return; } + $found = 0; $navbar = $this->getNavBar( $query ); $targetName = $this->target->getText(); $out = $this->getOutput(); @@ -172,15 +187,24 @@ $out->addHtml( '<div id="mw-globalusage-result">' ); foreach ( $query->getSingleImageResult() as $wiki => $result ) { - $out->addHtml( - '<h2>' . $this->msg( - 'globalusage-on-wiki', - $targetName, WikiMap::getWikiName( $wiki ) )->parse() - . "</h2><ul>\n" ); - foreach ( $result as $item ) { - $out->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); + $project = WikiMap::getWikiName( $wiki ) ; + if($project == $filter || $filter=='' ) { + $found++; + $out->addHtml( + '<h2>' . $this->msg( + 'globalusage-on-wiki', + $targetName, WikiMap::getWikiName( $wiki ) )->parse() + . "</h2><ul>\n" ); + foreach ( $result as $item ) { + $out->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); + } + $out->addHtml( "</ul>\n" ); + }else { + continue; } - $out->addHtml( "</ul>\n" ); + } + if($found ==0 ) { + $out->addHtml( "<p>".$found." Results </p>" ); } $out->addHtml( '</div>' ); diff --git a/i18n/en.json b/i18n/en.json index d4db06c..2ccbef8 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -7,6 +7,7 @@ "globalusage": "Global file usage", "globalusage-for": "Global usage for \"$1\"", "globalusage-filename": "Filename:", + "globalusage-filter": "Project Filter:", "globalusage-desc": "[[Special:GlobalUsage|Special page]] to view global file usage", "globalusage-ok": "Search", "globalusage-text": "Search global file usage", -- To view, visit https://gerrit.wikimedia.org/r/342076 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I59cd0303492821d4734e2b6c2e2704f45e9609d2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GlobalUsage Gerrit-Branch: master Gerrit-Owner: Harjotsingh <harjo...@ymail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits