Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php |
— | — | @@ -106,12 +106,12 @@ |
107 | 107 | INDEX id_index (id) |
108 | 108 | ) AS SELECT |
109 | 109 | 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 { |
111 | 114 | $sql .= " ids.smw_id AS id "; |
112 | 115 | $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); |
116 | 116 | } |
117 | 117 | $dbr->query($sql); |
118 | 118 | } |
— | — | @@ -138,10 +138,10 @@ |
139 | 139 | */ |
140 | 140 | function getSQLFromClauseForCategory($subcategory, $child_subcategories) { |
141 | 141 | global $smwgDefaultStore; |
142 | | - if ($smwgDefaultStore == 'SMWSQLStore2') { |
| 142 | + if ($smwgDefaultStore == 'SMWSQLStore') { |
| 143 | + return $this->getSQLFromClauseForCategory_orig($subcategory, $child_subcategories); |
| 144 | + } else { |
143 | 145 | return $this->getSQLFromClauseForCategory_2($subcategory, $child_subcategories); |
144 | | - } else { |
145 | | - return $this->getSQLFromClauseForCategory_orig($subcategory, $child_subcategories); |
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
— | — | @@ -188,10 +188,10 @@ |
189 | 189 | */ |
190 | 190 | function getSQLFromClause($category, $subcategory, $subcategories, $applied_filters) { |
191 | 191 | global $smwgDefaultStore; |
192 | | - if ($smwgDefaultStore == 'SMWSQLStore2') { |
| 192 | + if ($smwgDefaultStore == 'SMWSQLStore') { |
| 193 | + return $this->getSQLFromClause_orig($category, $subcategory, $subcategories, $applied_filters); |
| 194 | + } else { |
193 | 195 | return $this->getSQLFromClause_2($category, $subcategory, $subcategories, $applied_filters); |
194 | | - } else { |
195 | | - return $this->getSQLFromClause_orig($category, $subcategory, $subcategories, $applied_filters); |
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
— | — | @@ -446,13 +446,13 @@ |
447 | 447 | else |
448 | 448 | $or_values = $af->getAllOrValues($this->category); |
449 | 449 | if ($af->search_term != null) { |
450 | | - // HACK - printFreeTextInput() needs values as the |
| 450 | + // HACK - printComboBoxInput() needs values as the |
451 | 451 | // *keys* of the array |
452 | 452 | $filter_values = array(); |
453 | 453 | foreach ($or_values as $or_value) { |
454 | 454 | $filter_values[$or_value] = ''; |
455 | 455 | } |
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); |
457 | 457 | return $results_line; |
458 | 458 | } elseif ($af->lower_date != null || $af->upper_date != null) { |
459 | 459 | $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 @@ |
556 | 556 | return $results_line; |
557 | 557 | } |
558 | 558 | |
559 | | - function printFreeTextInput($filter_name, $filter_values, $cur_value = null) { |
| 559 | + function printComboBoxInput($filter_name, $filter_values, $cur_value = null) { |
560 | 560 | global $wgRequest; |
561 | 561 | |
562 | 562 | $input_id = "_search_$filter_name"; |
— | — | @@ -605,8 +605,6 @@ |
606 | 606 | } |
607 | 607 | |
608 | 608 | function printDateInput($input_name, $cur_value = null) { |
609 | | - global $wgAmericanDates; |
610 | | - |
611 | 609 | $month_names = array( |
612 | 610 | wfMsgForContent('january'), |
613 | 611 | wfMsgForContent('february'), |
— | — | @@ -701,24 +699,29 @@ |
702 | 700 | $filter_values['_other'] = $num_results; |
703 | 701 | } |
704 | 702 | } |
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 |
706 | 705 | 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 | + } |
711 | 713 | } |
712 | 714 | } |
713 | | - // escape here if there are no values |
714 | | - if (count($filter_values) == 0) { |
715 | | - $f->dropTempTable(); |
716 | | - return ""; |
717 | | - } |
718 | 715 | |
719 | 716 | $filter_name = urlencode(str_replace(' ', '_', $f->name)); |
720 | 717 | $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); |
723 | 726 | $normal_filter = false; |
724 | 727 | } elseif ($f->input_type == wfMsgForContent('sd_filter_daterange')) { |
725 | 728 | $results_line = $this->printDateRangeInput($filter_name); |
— | — | @@ -727,30 +730,27 @@ |
728 | 731 | $results_line = $this->printUnappliedFilterValues($cur_url, $f, $filter_values); |
729 | 732 | |
730 | 733 | $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 |
736 | 737 | <div class="drilldown-filter-label"> |
737 | 738 | |
738 | 739 | 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 |
743 | 744 | <a onclick="toggleFilterDiv('$results_div_id', this)" style="cursor: default;"><img src="$sdgScriptPath/skins/down-arrow.png"></a> |
744 | 745 | |
745 | 746 | END; |
746 | | - } |
747 | | - $text .=<<<END |
| 747 | + } |
| 748 | + $text .=<<<END |
748 | 749 | $filter_label: |
749 | 750 | </div> |
750 | 751 | <div class="drilldown-filter-values" id="$results_div_id">$results_line |
751 | 752 | </div> |
752 | 753 | |
753 | 754 | END; |
754 | | - } |
755 | 755 | $f->dropTempTable(); |
756 | 756 | return $text; |
757 | 757 | } |
— | — | @@ -938,16 +938,16 @@ |
939 | 939 | // QueryPage uses the value from this SQL in an ORDER clause, |
940 | 940 | // so return page_title as title. |
941 | 941 | 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 { |
943 | 948 | $sql = "SELECT DISTINCT ids.smw_title AS title, |
944 | 949 | ids.smw_title AS value, |
945 | 950 | ids.smw_namespace AS namespace, |
946 | 951 | 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"; |
952 | 952 | } |
953 | 953 | $sql .= $this->getSQLFromClause($this->category, $this->subcategory, $this->all_subcategories, $this->applied_filters); |
954 | 954 | return $sql; |