r49520 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49519‎ | r49520 | r49521 >
Date:20:01, 15 April 2009
Author:yaron
Status:deferred
Tags:
Comment:
Check changed from 'SMWSQLStore2' to 'SMWSQLStore' to accomodate Halo 1.4; printFreeTextInput() renamed to printComboBoxInput(); 'none' value removed for number-range filters; filters with no values displayed with a "no values" message, instead of being hidden
Modified paths:
  • /trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php
@@ -106,12 +106,12 @@
107107 INDEX id_index (id)
108108 ) AS SELECT
109109 END;
110 - if ($smwgDefaultStore == 'SMWSQLStore2') {
 110+ if ($smwgDefaultStore == 'SMWSQLStore') {
 111+ $sql .= " p.page_id AS id ";
 112+ $sql .= $this->getSQLFromClause_orig($category, $subcategory, $subcategories, $applied_filters);
 113+ } else {
111114 $sql .= " ids.smw_id AS id ";
112115 $sql .= $this->getSQLFromClause_2($category, $subcategory, $subcategories, $applied_filters);
113 - } else {
114 - $sql .= " p.page_id AS id ";
115 - $sql .= $this->getSQLFromClause_orig($category, $subcategory, $subcategories, $applied_filters);
116116 }
117117 $dbr->query($sql);
118118 }
@@ -138,10 +138,10 @@
139139 */
140140 function getSQLFromClauseForCategory($subcategory, $child_subcategories) {
141141 global $smwgDefaultStore;
142 - if ($smwgDefaultStore == 'SMWSQLStore2') {
 142+ if ($smwgDefaultStore == 'SMWSQLStore') {
 143+ return $this->getSQLFromClauseForCategory_orig($subcategory, $child_subcategories);
 144+ } else {
143145 return $this->getSQLFromClauseForCategory_2($subcategory, $child_subcategories);
144 - } else {
145 - return $this->getSQLFromClauseForCategory_orig($subcategory, $child_subcategories);
146146 }
147147 }
148148
@@ -188,10 +188,10 @@
189189 */
190190 function getSQLFromClause($category, $subcategory, $subcategories, $applied_filters) {
191191 global $smwgDefaultStore;
192 - if ($smwgDefaultStore == 'SMWSQLStore2') {
 192+ if ($smwgDefaultStore == 'SMWSQLStore') {
 193+ return $this->getSQLFromClause_orig($category, $subcategory, $subcategories, $applied_filters);
 194+ } else {
193195 return $this->getSQLFromClause_2($category, $subcategory, $subcategories, $applied_filters);
194 - } else {
195 - return $this->getSQLFromClause_orig($category, $subcategory, $subcategories, $applied_filters);
196196 }
197197 }
198198
@@ -446,13 +446,13 @@
447447 else
448448 $or_values = $af->getAllOrValues($this->category);
449449 if ($af->search_term != null) {
450 - // HACK - printFreeTextInput() needs values as the
 450+ // HACK - printComboBoxInput() needs values as the
451451 // *keys* of the array
452452 $filter_values = array();
453453 foreach ($or_values as $or_value) {
454454 $filter_values[$or_value] = '';
455455 }
456 - $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printFreeTextInput($af->filter->name, $filter_values, $af->search_term);
 456+ $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printComboBoxInput($af->filter->name, $filter_values, $af->search_term);
457457 return $results_line;
458458 } elseif ($af->lower_date != null || $af->upper_date != null) {
459459 $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printDateRangeInput($af->filter->name, $af->lower_date, $af->upper_date);
@@ -555,7 +555,7 @@
556556 return $results_line;
557557 }
558558
559 - function printFreeTextInput($filter_name, $filter_values, $cur_value = null) {
 559+ function printComboBoxInput($filter_name, $filter_values, $cur_value = null) {
560560 global $wgRequest;
561561
562562 $input_id = "_search_$filter_name";
@@ -605,8 +605,6 @@
606606 }
607607
608608 function printDateInput($input_name, $cur_value = null) {
609 - global $wgAmericanDates;
610 -
611609 $month_names = array(
612610 wfMsgForContent('january'),
613611 wfMsgForContent('february'),
@@ -701,24 +699,29 @@
702700 $filter_values['_other'] = $num_results;
703701 }
704702 }
705 - // show 'None' only if any other results have been found
 703+ // show 'None' only if any other results have been found, and
 704+ // if it's not a numeric filter
706705 if (count($f->allowed_values) > 0) {
707 - $none_filter = SDAppliedFilter::create($f, ' none');
708 - $num_results = $this->getNumResults($this->subcategory, $this->all_subcategories, $none_filter);
709 - if ($num_results > 0) {
710 - $filter_values['_none'] = $num_results;
 706+ $fv = SDFilterValue::create($f->allowed_values[0]);
 707+ if (! $fv->is_numeric) {
 708+ $none_filter = SDAppliedFilter::create($f, ' none');
 709+ $num_results = $this->getNumResults($this->subcategory, $this->all_subcategories, $none_filter);
 710+ if ($num_results > 0) {
 711+ $filter_values['_none'] = $num_results;
 712+ }
711713 }
712714 }
713 - // escape here if there are no values
714 - if (count($filter_values) == 0) {
715 - $f->dropTempTable();
716 - return "";
717 - }
718715
719716 $filter_name = urlencode(str_replace(' ', '_', $f->name));
720717 $normal_filter = true;
721 - if ($f->input_type == wfMsgForContent('sd_filter_freetext')) {
722 - $results_line = $this->printFreeTextInput($filter_name, $filter_values);
 718+ if (count($filter_values) == 0) {
 719+ $results_line = '(' . wfMsg('sd_browsedata_novalues') . ')';
 720+ // for backward compatibility, also check against
 721+ // 'sd_filter_freetext' (i.e. 'text' in English), which was
 722+ // the old name of the input
 723+ } elseif ($f->input_type == wfMsgForContent('sd_filter_combobox') ||
 724+ $f->input_type == wfMsgForContent('sd_filter_freetext')) {
 725+ $results_line = $this->printComboBoxInput($filter_name, $filter_values);
723726 $normal_filter = false;
724727 } elseif ($f->input_type == wfMsgForContent('sd_filter_daterange')) {
725728 $results_line = $this->printDateRangeInput($filter_name);
@@ -727,30 +730,27 @@
728731 $results_line = $this->printUnappliedFilterValues($cur_url, $f, $filter_values);
729732
730733 $text = "";
731 - // TODO - this check might no longer be necessary
732 - if ($results_line != "") {
733 - $filter_label = $this->printFilterLabel($f->name);
734 - $results_div_id = strtolower(str_replace(' ', '_', $filter_label)) . "_values";
735 - $text .=<<<END
 734+ $filter_label = $this->printFilterLabel($f->name);
 735+ $results_div_id = strtolower(str_replace(' ', '_', $filter_label)) . "_values";
 736+ $text .=<<<END
736737 <div class="drilldown-filter-label">
737738
738739 END;
739 - // no point showing "minimize" arrow if it's just a
740 - // single text or date input
741 - if ($normal_filter) {
742 - $text .=<<<END
 740+ // no point showing "minimize" arrow if it's just a
 741+ // single text or date input
 742+ if ($normal_filter) {
 743+ $text .=<<<END
743744 <a onclick="toggleFilterDiv('$results_div_id', this)" style="cursor: default;"><img src="$sdgScriptPath/skins/down-arrow.png"></a>
744745
745746 END;
746 - }
747 - $text .=<<<END
 747+ }
 748+ $text .=<<<END
748749 $filter_label:
749750 </div>
750751 <div class="drilldown-filter-values" id="$results_div_id">$results_line
751752 </div>
752753
753754 END;
754 - }
755755 $f->dropTempTable();
756756 return $text;
757757 }
@@ -938,16 +938,16 @@
939939 // QueryPage uses the value from this SQL in an ORDER clause,
940940 // so return page_title as title.
941941 global $smwgDefaultStore;
942 - if ($smwgDefaultStore == 'SMWSQLStore2') {
 942+ if ($smwgDefaultStore == 'SMWSQLStore') {
 943+ $sql = "SELECT DISTINCT p.page_title AS title,
 944+ p.page_title AS value,
 945+ p.page_namespace AS namespace,
 946+ c.cl_sortkey AS sortkey\n";
 947+ } else {
943948 $sql = "SELECT DISTINCT ids.smw_title AS title,
944949 ids.smw_title AS value,
945950 ids.smw_namespace AS namespace,
946951 ids.smw_sortkey AS sortkey\n";
947 - } else {
948 - $sql = "SELECT DISTINCT p.page_title AS title,
949 - p.page_title AS value,
950 - p.page_namespace AS namespace,
951 - c.cl_sortkey AS sortkey\n";
952952 }
953953 $sql .= $this->getSQLFromClause($this->category, $this->subcategory, $this->all_subcategories, $this->applied_filters);
954954 return $sql;

Status & tagging log