Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php |
— | — | @@ -34,24 +34,26 @@ |
35 | 35 | SpecialPage::addPage( new SpecialPage('CreateFilter','',true,'doSpecialCreateFilter',false) ); |
36 | 36 | } |
37 | 37 | |
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; |
40 | 40 | |
41 | 41 | 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(); |
45 | 43 | $smw_version = SMW_VERSION; |
46 | | - $property_tag = "[[" . $specprops[SD_SP_COVERS_PROPERTY] . |
| 44 | + $property_tag = "[[" . $sd_props[SD_SP_COVERS_PROPERTY] . |
47 | 45 | "::$namespace:$property_name|$property_name]]"; |
48 | 46 | $text = wfMsg('sd_filter_coversproperty', $property_tag); |
49 | 47 | if ($values_source == 'category') { |
50 | 48 | global $wgContLang; |
51 | 49 | $namespace_labels = $wgContLang->getNamespaces(); |
52 | 50 | $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]]"; |
54 | 52 | $text .= " " . wfMsg('sd_filter_getsvaluesfromcategory', $category_tag); |
55 | 53 | } 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); |
56 | 58 | } elseif ($values_source == 'manual') { |
57 | 59 | // replace the comma substitution character that has no |
58 | 60 | // chance of being included in the values list - namely, |
— | — | @@ -66,13 +68,19 @@ |
67 | 69 | } |
68 | 70 | // replace beep with comma, trim |
69 | 71 | $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]]"; |
71 | 73 | } |
72 | 74 | $text .= " " . wfMsg('sd_filter_hasvalues', $filter_values_tag); |
73 | 75 | } |
| 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 | + } |
74 | 82 | 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); |
77 | 85 | } |
78 | 86 | return $text; |
79 | 87 | } |
— | — | @@ -85,7 +93,9 @@ |
86 | 94 | $values_source = $wgRequest->getVal('values_source'); |
87 | 95 | $property_name = $wgRequest->getVal('property_name'); |
88 | 96 | $category_name = $wgRequest->getVal('category_name'); |
| 97 | + $time_period = $wgRequest->getVal('time_period'); |
89 | 98 | $filter_values = $wgRequest->getVal('filter_values'); |
| 99 | + $required_filter = $wgRequest->getVal('required_filter'); |
90 | 100 | $filter_label = $wgRequest->getVal('filter_label'); |
91 | 101 | |
92 | 102 | $save_button_text = wfMsg('savearticle'); |
— | — | @@ -101,7 +111,7 @@ |
102 | 112 | # redirect to wiki interface |
103 | 113 | $namespace = SD_NS_FILTER; |
104 | 114 | $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); |
106 | 116 | // HTML-encode |
107 | 117 | $full_text = str_replace('"', '"', $full_text); |
108 | 118 | $text .= sdfPrintRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false); |
— | — | @@ -134,18 +144,23 @@ |
135 | 145 | |
136 | 146 | $values_from_property_label = wfMsg('sd_createfilter_usepropertyvalues'); |
137 | 147 | $values_from_category_label = wfMsg('sd_createfilter_usecategoryvalues'); |
| 148 | + $date_values_label = wfMsg('sd_createfilter_usedatevalues'); |
138 | 149 | $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'); |
140 | 153 | $text .=<<<END |
141 | 154 | </select> |
142 | 155 | </p> |
143 | | - <p><input type="radio" name="values_source" value="propertyy"> |
| 156 | + <p><input type="radio" name="values_source" value="property"> |
144 | 157 | $values_from_property_label |
| 158 | + </p> |
145 | 159 | <p><input type="radio" name="values_source" checked value="category"> |
146 | 160 | $values_from_category_label |
147 | 161 | <select id="category_dropdown" name="category_name"> |
148 | 162 | |
149 | 163 | END; |
| 164 | + $categories = sdfGetTopLevelCategories(); |
150 | 165 | foreach ($categories as $category) { |
151 | 166 | $category = str_replace('_', ' ', $category); |
152 | 167 | $text .= " <option>$category</option>\n"; |
— | — | @@ -153,10 +168,30 @@ |
154 | 169 | $text .=<<<END |
155 | 170 | </select> |
156 | 171 | </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> |
157 | 179 | <p><input type="radio" name="values_source" value="manual"> |
158 | 180 | $enter_values_label <input size="40" name="filter_values" value=""> |
159 | 181 | </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> |
161 | 196 | <div class="editButtons"> |
162 | 197 | <input type="submit" id="wpSave" name="wpSave" value="$save_button_text"></p> |
163 | 198 | <input type="submit" id="wpPreview" name="wpPreview" value="$preview_button_text"></p> |