r28729 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28728‎ | r28729 | r28730 >
Date:20:59, 20 December 2007
Author:yaron
Status:old
Tags:
Comment:
Handling for new 'Uses time period' and 'Requires filter' special properties
Modified paths:
  • /trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php
@@ -34,24 +34,26 @@
3535 SpecialPage::addPage( new SpecialPage('CreateFilter','',true,'doSpecialCreateFilter',false) );
3636 }
3737
38 -function createFilterText($property_string, $values_source, $category_used, $filter_values, $filter_label) {
39 - global $smwgContLang, $sdgContLang;
 38+function createFilterText($property_string, $values_source, $category_used, $time_period, $filter_values, $required_filter, $filter_label) {
 39+ global $sdgContLang;
4040
4141 list($namespace, $property_name) = explode(",", $property_string, 2);
42 - //$namespace_labels = $smwgContLang->getNamespaceArray();
43 - //$property_label = $namespace_labels[$namespace];
44 - $specprops = $sdgContLang->getSpecialPropertiesArray();
 42+ $sd_props = $sdgContLang->getSpecialPropertiesArray();
4543 $smw_version = SMW_VERSION;
46 - $property_tag = "[[" . $specprops[SD_SP_COVERS_PROPERTY] .
 44+ $property_tag = "[[" . $sd_props[SD_SP_COVERS_PROPERTY] .
4745 "::$namespace:$property_name|$property_name]]";
4846 $text = wfMsg('sd_filter_coversproperty', $property_tag);
4947 if ($values_source == 'category') {
5048 global $wgContLang;
5149 $namespace_labels = $wgContLang->getNamespaces();
5250 $category_namespace = $namespace_labels[NS_CATEGORY];
53 - $category_tag = "[[" . $specprops[SD_SP_GETS_VALUES_FROM_CATEGORY] . "::$category_namespace:$category_used|$category_used]]";
 51+ $category_tag = "[[" . $sd_props[SD_SP_GETS_VALUES_FROM_CATEGORY] . "::$category_namespace:$category_used|$category_used]]";
5452 $text .= " " . wfMsg('sd_filter_getsvaluesfromcategory', $category_tag);
5553 } elseif ($values_source == 'property') {
 54+ // do nothing
 55+ } elseif ($values_source == 'dates') {
 56+ $time_period_tag = "[[" . $sd_props[SD_SP_USES_TIME_PERIOD] . ":=$time_period]]";
 57+ $text .= " " . wfMsg('sd_filter_usestimeperiod', $time_period_tag);
5658 } elseif ($values_source == 'manual') {
5759 // replace the comma substitution character that has no
5860 // chance of being included in the values list - namely,
@@ -66,13 +68,19 @@
6769 }
6870 // replace beep with comma, trim
6971 $filter_value = str_replace("\a", $sdgListSeparator, trim($filter_value));
70 - $filter_values_tag .= "[[" . $specprops[SD_SP_HAS_VALUE] . ":=$filter_value]]";
 72+ $filter_values_tag .= "[[" . $sd_props[SD_SP_HAS_VALUE] . ":=$filter_value]]";
7173 }
7274 $text .= " " . wfMsg('sd_filter_hasvalues', $filter_values_tag);
7375 }
 76+ if ($required_filter != '') {
 77+ $sd_namespace_labels = $sdgContLang->getNamespaces();
 78+ $filter_namespace = $sd_namespace_labels[SD_NS_FILTER];
 79+ $filter_tag = "[[" . $sd_props[SD_SP_REQUIRES_FILTER] . "::$filter_namespace:$required_filter|$required_filter]]";
 80+ $text .= " " . wfMsg('sd_filter_requiresfilter', $filter_tag);
 81+ }
7482 if ($filter_label != '') {
75 - $filter_tag = "[[" . $specprops[SD_SP_HAS_LABEL] . ":=$filter_label]]";
76 - $text .= " " . wfMsg('sd_filter_haslabel', $filter_tag);
 83+ $filter_label_tag = "[[" . $sd_props[SD_SP_HAS_LABEL] . ":=$filter_label]]";
 84+ $text .= " " . wfMsg('sd_filter_haslabel', $filter_label_tag);
7785 }
7886 return $text;
7987 }
@@ -85,7 +93,9 @@
8694 $values_source = $wgRequest->getVal('values_source');
8795 $property_name = $wgRequest->getVal('property_name');
8896 $category_name = $wgRequest->getVal('category_name');
 97+ $time_period = $wgRequest->getVal('time_period');
8998 $filter_values = $wgRequest->getVal('filter_values');
 99+ $required_filter = $wgRequest->getVal('required_filter');
90100 $filter_label = $wgRequest->getVal('filter_label');
91101
92102 $save_button_text = wfMsg('savearticle');
@@ -101,7 +111,7 @@
102112 # redirect to wiki interface
103113 $namespace = SD_NS_FILTER;
104114 $title = Title::newFromText($filter_name, $namespace);
105 - $full_text = createFilterText($property_name, $values_source, $category_name, $filter_values, $filter_label);
 115+ $full_text = createFilterText($property_name, $values_source, $category_name, $time_period, $filter_values, $required_filter, $filter_label);
106116 // HTML-encode
107117 $full_text = str_replace('"', '"', $full_text);
108118 $text .= sdfPrintRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false);
@@ -134,18 +144,23 @@
135145
136146 $values_from_property_label = wfMsg('sd_createfilter_usepropertyvalues');
137147 $values_from_category_label = wfMsg('sd_createfilter_usecategoryvalues');
 148+ $date_values_label = wfMsg('sd_createfilter_usedatevalues');
138149 $enter_values_label = wfMsg('sd_createfilter_entervalues');
139 - $categories = sdfGetTopLevelCategories();
 150+ $year_label = wfMsg('sd_filter_year');
 151+ $month_label = wfMsg('sd_filter_month');
 152+ $require_filter_label = wfMsg('sd_createfilter_requirefilter');
140153 $text .=<<<END
141154 </select>
142155 </p>
143 - <p><input type="radio" name="values_source" value="propertyy">
 156+ <p><input type="radio" name="values_source" value="property">
144157 $values_from_property_label
 158+ </p>
145159 <p><input type="radio" name="values_source" checked value="category">
146160 $values_from_category_label
147161 <select id="category_dropdown" name="category_name">
148162
149163 END;
 164+ $categories = sdfGetTopLevelCategories();
150165 foreach ($categories as $category) {
151166 $category = str_replace('_', ' ', $category);
152167 $text .= " <option>$category</option>\n";
@@ -153,10 +168,30 @@
154169 $text .=<<<END
155170 </select>
156171 </p>
 172+ <p><input type="radio" name="values_source" checked value="dates">
 173+ $date_values_label
 174+ <select id="time_period_dropdown" name="time_period">
 175+ <option>$year_label</option>
 176+ <option>$month_label</option>
 177+ </select>
 178+ </p>
157179 <p><input type="radio" name="values_source" value="manual">
158180 $enter_values_label <input size="40" name="filter_values" value="">
159181 </p>
160 - <p>$label_label <input size="25" name="filter_label" value="">
 182+ <p>$require_filter_label
 183+ <select id="required_filter_dropdown" name="required_filter">
 184+ <option />
 185+
 186+END;
 187+ $filters = sdfGetFilters();
 188+ foreach ($filters as $filter) {
 189+ $filter = str_replace('_', ' ', $filter);
 190+ $text .= " <option>$filter</option>\n";
 191+ }
 192+ $text .=<<<END
 193+ </select>
 194+ </p>
 195+ <p>$label_label <input size="25" name="filter_label" value=""></p>
161196 <div class="editButtons">
162197 <input type="submit" id="wpSave" name="wpSave" value="$save_button_text"></p>
163198 <input type="submit" id="wpPreview" name="wpPreview" value="$preview_button_text"></p>

Status & tagging log