r45317 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45316‎ | r45317 | r45318 >
Date:15:39, 2 January 2009
Author:yaron
Status:deferred
Tags:
Comment:
Helper functions moved into SDUtils class
Modified paths:
  • /trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php
@@ -117,13 +117,13 @@
118118 $full_text = createFilterText($property_name, $values_source, $category_name, $time_period, $filter_values, $input_type, $required_filter, $filter_label);
119119 // HTML-encode
120120 $full_text = str_replace('"', '"', $full_text);
121 - $text = sdfPrintRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false);
 121+ $text = SDUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false);
122122 $wgOut->addHTML($text);
123123 return;
124124 }
125125 }
126126
127 - $all_properties = sdfGetSemanticProperties();
 127+ $all_properties = SDUtils::getSemanticProperties();
128128
129129 // set 'title' as hidden field, in case there's no URL niceness
130130 global $wgContLang;
@@ -174,7 +174,7 @@
175175 <select id="category_dropdown" name="category_name">
176176
177177 END;
178 - $categories = sdfGetTopLevelCategories();
 178+ $categories = SDUtils::getTopLevelCategories();
179179 foreach ($categories as $category) {
180180 $category = str_replace('_', ' ', $category);
181181 $text .= " <option>$category</option>\n";
@@ -204,7 +204,7 @@
205205 <option />
206206
207207 END;
208 - $filters = sdfGetFilters();
 208+ $filters = SDUtils::getFilters();
209209 foreach ($filters as $filter) {
210210 $filter = str_replace('_', ' ', $filter);
211211 $text .= " <option>$filter</option>\n";
Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php
@@ -56,8 +56,8 @@
5757 // get the two arrays for subcategories - one for only the
5858 // immediate subcategories, for display, and the other for
5959 // all subcategories, sub-subcategories, etc., for querying
60 - $this->next_level_subcategories = sdfGetCategoryChildren($actual_cat, true, 1);
61 - $this->all_subcategories = sdfGetCategoryChildren($actual_cat, true, 10);
 60+ $this->next_level_subcategories = SDUtils::getCategoryChildren($actual_cat, true, 1);
 61+ $this->all_subcategories = SDUtils::getCategoryChildren($actual_cat, true, 10);
6262 }
6363
6464 function makeBrowseURL($category, $applied_filters = array(), $subcategory = null) {
@@ -398,7 +398,7 @@
399399
400400 END;
401401 foreach ($categories as $i => $category) {
402 - $category_children = sdfGetCategoryChildren($category, false, 5);
 402+ $category_children = SDUtils::getCategoryChildren($category, false, 5);
403403 $category_str = $category . " (" . count($category_children) . ")";
404404 if (str_replace('_', ' ', $this->category) == $category) {
405405 $text .= ' <div class="drilldown-category selected-category">';
@@ -419,7 +419,7 @@
420420 }
421421
422422 function printFilterLabel($filter_name) {
423 - $labels_for_filter = sdfGetValuesForProperty($filter_name, SD_NS_FILTER, '_SD_L', SD_SP_HAS_LABEL, NS_MAIN);
 423+ $labels_for_filter = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_L', SD_SP_HAS_LABEL, NS_MAIN);
424424 if (count($labels_for_filter) > 0) {
425425 $filter_label = $labels_for_filter[0];
426426 } else {
@@ -472,7 +472,7 @@
473473 elseif ($value === ' none')
474474 $filter_text = wfMsg('sd_browsedata_none');
475475 elseif ($af->filter->is_boolean)
476 - $filter_text = sdfBooleanToString($value);
 476+ $filter_text = SDUtils::booleanToString($value);
477477 else
478478 $filter_text = $value;
479479 $applied_filters = $this->applied_filters;
@@ -540,7 +540,7 @@
541541 elseif ($value_str === '_none')
542542 $filter_text = wfMsg('sd_browsedata_none');
543543 elseif ($f->is_boolean)
544 - $filter_text = sdfBooleanToString($value_str);
 544+ $filter_text = SDUtils::booleanToString($value_str);
545545 else
546546 $filter_text = str_replace('_', ' ', $value_str);
547547 $filter_text .= " ($num_results)";
@@ -759,7 +759,7 @@
760760
761761 $skin = $wgUser->getSkin();
762762 $browse_data_title = Title::newFromText('BrowseData', NS_SPECIAL);
763 - $categories = sdfGetTopLevelCategories();
 763+ $categories = SDUtils::getTopLevelCategories();
764764 // if there are no categories, escape quickly
765765 if (count($categories) == 0) {
766766 return "";
@@ -805,7 +805,7 @@
806806 elseif ($fv->text == ' none')
807807 $filter_text = wfMsg('sd_browsedata_none');
808808 elseif ($af->filter->is_boolean)
809 - $filter_text = sdfBooleanToString($fv->text);
 809+ $filter_text = SDUtils::booleanToString($fv->text);
810810 else
811811 $filter_text = $fv->text;
812812 $temp_filters_array = $this->applied_filters;
@@ -840,7 +840,7 @@
841841 if (count($this->next_level_subcategories) > 0) {
842842 $results_line = "";
843843 foreach ($this->next_level_subcategories as $i => $subcat) {
844 - $further_subcats = sdfGetCategoryChildren($subcat, true, 10);
 844+ $further_subcats = SDUtils::getCategoryChildren($subcat, true, 10);
845845 $num_results = $this->getNumResults($subcat, $further_subcats);
846846 if ($num_results > 0) {
847847 if ($num_printed_values++ > 0) { $results_line .= " &middot; "; }
@@ -853,7 +853,7 @@
854854 $header .= " <p><strong>$subcategory_text:</strong> $results_line</p>\n";
855855 }
856856 }
857 - $filters = sdfLoadFiltersForCategory($this->category);
 857+ $filters = SDUtils::loadFiltersForCategory($this->category);
858858 foreach ($filters as $f) {
859859 foreach ($this->applied_filters as $af) {
860860 if ($af->filter->name == $f->name)
@@ -1078,7 +1078,7 @@
10791079 if (! $category) {
10801080 $category_title = wfMsg('browsedata');
10811081 } else {
1082 - $titles_for_category = sdfGetValuesForProperty($category, NS_CATEGORY, '_SD_DT', SD_SP_HAS_DRILLDOWN_TITLE, NS_MAIN);
 1082+ $titles_for_category = SDUtils::getValuesForProperty($category, NS_CATEGORY, '_SD_DT', SD_SP_HAS_DRILLDOWN_TITLE, NS_MAIN);
10831083 if (count($titles_for_category) > 0) {
10841084 $category_title = str_replace('_', ' ', $titles_for_category[0]);
10851085 } else {
@@ -1088,7 +1088,7 @@
10891089 // if no category was specified, go with the first
10901090 // category on the site, alphabetically
10911091 if (! $category) {
1092 - $categories = sdfGetTopLevelCategories();
 1092+ $categories = SDUtils::getTopLevelCategories();
10931093 if (count($categories) > 0) {
10941094 $category = $categories[0];
10951095 }
@@ -1097,7 +1097,7 @@
10981098 $wgOut->setPageTitle($category_title);
10991099 $subcategory = $wgRequest->getVal('_subcat');
11001100
1101 - $filters = sdfLoadFiltersForCategory($category);
 1101+ $filters = SDUtils::loadFiltersForCategory($category);
11021102
11031103 $filters_used = array();
11041104 foreach ($filters as $i => $filter)
@@ -1126,7 +1126,7 @@
11271127 // add every unused filter to the $remaining_filters array, unless
11281128 // it requires some other filter that hasn't been applied
11291129 foreach ($filters as $i => $filter) {
1130 - $required_filters = sdfGetValuesForProperty($filter->name, SD_NS_FILTER, '_SD_RF', SD_SP_REQUIRES_FILTER, SD_NS_FILTER);
 1130+ $required_filters = SDUtils::getValuesForProperty($filter->name, SD_NS_FILTER, '_SD_RF', SD_SP_REQUIRES_FILTER, SD_NS_FILTER);
11311131 $matched_all_required_filters = true;
11321132 foreach ($required_filters as $required_filter) {
11331133 $found_match = false;

Status & tagging log