Yaron Koren has uploaded a new change for review.
https://gerrit.wikimedia.org/r/205623
Change subject: Special:Drilldown now shows simple text input if many values
......................................................................
Special:Drilldown now shows simple text input if many values
Change-Id: I87ae7a626a1ef7b8a7a800099bf284b1c34c2a50
---
M drilldown/CargoSpecialDrilldown.php
M i18n/ca.json
M i18n/de.json
M i18n/en.json
M i18n/es.json
M i18n/fr.json
M i18n/gl.json
M i18n/mk.json
M i18n/nb.json
M i18n/qqq.json
M i18n/zh-hans.json
11 files changed, 60 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cargo
refs/changes/23/205623/1
diff --git a/drilldown/CargoSpecialDrilldown.php
b/drilldown/CargoSpecialDrilldown.php
index cf564a1..40953dc 100644
--- a/drilldown/CargoSpecialDrilldown.php
+++ b/drilldown/CargoSpecialDrilldown.php
@@ -369,15 +369,19 @@
$or_values = $af->getAllOrValues();
}
if ( $af->search_terms != null ) {
- // HACK - printComboBoxInput() needs values as the
- // *keys* of the array
- $filter_values = array();
- foreach ( $or_values as $or_value ) {
- $filter_values[$or_value] = '';
- }
$curSearchTermNum = count( $af->search_terms );
- $results_line = $this->printComboBoxInput(
- $af->filter->name, $curSearchTermNum,
$filter_values );
+ if ( count( $or_values ) >= 300 ) {
+ $results_line = $this->printTextInput(
$af->filter->name, $curSearchTermNum );
+ } else {
+ // HACK - printComboBoxInput() needs values as
+ // the *keys* of the array
+ $filter_values = array();
+ foreach ( $or_values as $or_value ) {
+ $filter_values[$or_value] = '';
+ }
+ $results_line = $this->printComboBoxInput(
+ $af->filter->name, $curSearchTermNum,
$filter_values );
+ }
return $this->printFilterLine( $af->filter->name, true,
true, $results_line );
}
// add 'Other' and 'None', regardless of whether either has
@@ -695,6 +699,50 @@
return $text;
}
+ function printTextInput( $filter_name, $instance_num, $cur_value = null
) {
+ global $wgRequest;
+
+ $filter_name = str_replace( ' ', '_', $filter_name );
+ // URL-decode the filter name - necessary if it contains
+ // any non-Latin characters.
+ $filter_name = urldecode( $filter_name );
+
+ // Add on the instance number, since it can be one of a string
+ // of values.
+ $filter_name .= '[' . $instance_num . ']';
+
+ $inputName = "_search_$filter_name";
+
+ $text = <<< END
+<form method="get">
+
+END;
+
+ foreach ( $wgRequest->getValues() as $key => $val ) {
+ if ( $key != $inputName ) {
+ if ( is_array( $val ) ) {
+ foreach ( $val as $i => $realVal ) {
+ $keyString = $key . '[' . $i .
']';
+ $text .= Html::hidden(
$keyString, $realVal ) . "\n";
+ }
+ } else {
+ $text .= Html::hidden( $key, $val ) .
"\n";
+ }
+ }
+ }
+
+ $text .=<<< END
+ <input type="text" name="$inputName" value="$cur_value" />
+ <br />
+
+END;
+
+ $text .= Html::input( null, $this->msg( 'searchresultshead'
)->text(), 'submit',
+ array( 'style' => 'margin: 4px 0 8px 0;' ) ) .
"\n";
+ $text .= "</form>\n";
+ return $text;
+ }
+
function printComboBoxInput( $filter_name, $instance_num,
$filter_values, $cur_value = null ) {
global $wgRequest;
@@ -813,8 +861,10 @@
} elseif ( $fieldType == 'Integer' || $fieldType == 'Float' ) {
$results_line = $this->printNumberRanges( $filter_name,
$filter_values );
} elseif ( count( $filter_values ) >= 300 ) {
- // If it's really big, don't show anything.
- $results_line = $this->msg(
'cargo-drilldown-toomanyvalues' )->text();
+ // If it's really big, just show a text input.
+ // @TODO - this should ideally use remote
+ // autocompletion instead.
+ $results_line = $this->printTextInput( $filter_name, 0
);
$normal_filter = false;
} elseif ( count( $filter_values ) >=
$wgCargoDrilldownMinValuesForComboBox ) {
$results_line = $this->printComboBoxInput(
$filter_name, 0, $filter_values );
diff --git a/i18n/ca.json b/i18n/ca.json
index ed50a8d..82a0546 100644
--- a/i18n/ca.json
+++ b/i18n/ca.json
@@ -38,7 +38,6 @@
"cargo-drilldown-resetfilters": "Reinicia els filtres",
"cargo-drilldown-addanothervalue": "Feu clic a la fletxa per afegir un
altre valor",
"cargo-drilldown-novalues": "No hi ha cap valor per a aquest filtre",
- "cargo-drilldown-toomanyvalues": "Hi ha massa valors; no es mostraran.",
"cargo-viewcsv": "Mostra el CSV",
"cargo-viewjson": "Mostra el JSON",
"cargo-purgecache": "Purga la memòria cau",
diff --git a/i18n/de.json b/i18n/de.json
index 1592d0b..4640eae 100644
--- a/i18n/de.json
+++ b/i18n/de.json
@@ -39,7 +39,6 @@
"cargo-drilldown-resetfilters": "Filter zurücksetzen",
"cargo-drilldown-addanothervalue": "Auf den Pfeil klicken, um einen
weiteren Wert hinzuzufügen",
"cargo-drilldown-novalues": "Es gibt keine Werte für diesen Filter",
- "cargo-drilldown-toomanyvalues": "Zu viele Werte. Es wird nichts
angezeigt.",
"cargo-viewcsv": "CSV ansehen",
"cargo-viewxls": "XLS ansehen",
"cargo-viewjson": "JSON ansehen",
diff --git a/i18n/en.json b/i18n/en.json
index d7b5c29..d933e1c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -37,7 +37,6 @@
"cargo-drilldown-resetfilters": "Reset filters",
"cargo-drilldown-addanothervalue": "Click arrow to add another value",
"cargo-drilldown-novalues": "There are no values for this filter",
- "cargo-drilldown-toomanyvalues": "Too many values; not displaying.",
"cargo-viewcsv": "View CSV",
"cargo-viewxls": "View XLS",
"cargo-viewjson": "View JSON",
diff --git a/i18n/es.json b/i18n/es.json
index 735ecb3..99060ca 100644
--- a/i18n/es.json
+++ b/i18n/es.json
@@ -39,7 +39,6 @@
"cargo-drilldown-resetfilters": "Restablecer filtros",
"cargo-drilldown-addanothervalue": "Haz clic en la flecha para agregar
otro valor",
"cargo-drilldown-novalues": "No hay valores para este filtro",
- "cargo-drilldown-toomanyvalues": "Demasiados valores; no se muestra.",
"cargo-viewcsv": "Ver CSV",
"cargo-viewxls": "Ver XLS",
"cargo-viewjson": "Ver JSON",
diff --git a/i18n/fr.json b/i18n/fr.json
index 29318bc..a0d0130 100644
--- a/i18n/fr.json
+++ b/i18n/fr.json
@@ -43,7 +43,6 @@
"cargo-drilldown-resetfilters": "Remise à zéro des filtres",
"cargo-drilldown-addanothervalue": "Cliquez sur la flèche pour ajouter
une autre valeur",
"cargo-drilldown-novalues": "Il n’y a pas de valeur pour ce filtre",
- "cargo-drilldown-toomanyvalues": "Trop de valeurs ; non affiché.",
"cargo-viewcsv": "Afficher le CSV",
"cargo-viewxls": "Afficher l'XLS",
"cargo-viewjson": "Afficher le JSON",
diff --git a/i18n/gl.json b/i18n/gl.json
index 71734aa..b6da186 100644
--- a/i18n/gl.json
+++ b/i18n/gl.json
@@ -39,7 +39,6 @@
"cargo-drilldown-resetfilters": "Restablecer filtros",
"cargo-drilldown-addanothervalue": "Prema na frecha para engadir outro
valor",
"cargo-drilldown-novalues": "Non hai valores para este filtro",
- "cargo-drilldown-toomanyvalues": "Demasiados valores; non se mostra.",
"cargo-viewcsv": "Ver CSV",
"cargo-viewxls": "Ver XLS",
"cargo-viewjson": "Ver JSON",
diff --git a/i18n/mk.json b/i18n/mk.json
index 708db47..a866713 100644
--- a/i18n/mk.json
+++ b/i18n/mk.json
@@ -39,7 +39,6 @@
"cargo-drilldown-resetfilters": "Врати ги филтрите по основно",
"cargo-drilldown-addanothervalue": "Стиснете на стрелката за да
додадете друга вредност",
"cargo-drilldown-novalues": "Нема зададено вредности за овој филтер",
- "cargo-drilldown-toomanyvalues": "Премногу вредности. Не можам да ги
прикажам.",
"cargo-viewcsv": "Погл. CSV",
"cargo-viewxls": "Преглед на XLS",
"cargo-viewjson": "Погл. JSON",
diff --git a/i18n/nb.json b/i18n/nb.json
index 556696d..160143b 100644
--- a/i18n/nb.json
+++ b/i18n/nb.json
@@ -39,7 +39,6 @@
"cargo-drilldown-resetfilters": "Nullstill filtre",
"cargo-drilldown-addanothervalue": "Klikk på pilen for å legge til
flere verdier",
"cargo-drilldown-novalues": "Det finnes ingen verdier for dette
filteret",
- "cargo-drilldown-toomanyvalues": "For mange verdier til at de kan
vises.",
"cargo-viewcsv": "Vis CSV",
"cargo-viewxls": "Se XLS",
"cargo-viewjson": "Vis JSON",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d6a5c42..220eab3 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -38,7 +38,6 @@
"cargo-drilldown-resetfilters": "This is the content of a tooltip on
[[Special:Drilldown]] when you hover your mouse over the name of a table.",
"cargo-drilldown-addanothervalue": "This is an informational message
providing help for the usage of [[Special:Drilldown]].",
"cargo-drilldown-novalues": "This is an informational message on
[[Special:Drildown]].",
- "cargo-drilldown-toomanyvalues": "This is an informational message on
[[Special:Drildown]].",
"cargo-viewcsv": "The text of a link.",
"cargo-viewxls": "The text of a link.",
"cargo-viewjson": "The text of a link.",
diff --git a/i18n/zh-hans.json b/i18n/zh-hans.json
index d501746..82b7594 100644
--- a/i18n/zh-hans.json
+++ b/i18n/zh-hans.json
@@ -39,7 +39,6 @@
"cargo-drilldown-resetfilters": "重置过滤器",
"cargo-drilldown-addanothervalue": "点击箭头以添加其他值",
"cargo-drilldown-novalues": "此过滤器没有值",
- "cargo-drilldown-toomanyvalues": "太多的值;没有显示。",
"cargo-viewcsv": "查看CSV",
"cargo-viewxls": "查看XLS",
"cargo-viewjson": "查看JSON",
--
To view, visit https://gerrit.wikimedia.org/r/205623
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I87ae7a626a1ef7b8a7a800099bf284b1c34c2a50
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits