r36912 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36911‎ | r36912 | r36913 >
Date:14:13, 2 July 2008
Author:yaron
Status:old
Tags:
Comment:
Changed to use correct initialization of special pages, set created filter
text to be written in content language instead of user's language
Modified paths:
  • /trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php
@@ -8,30 +8,20 @@
99
1010 if (!defined('MEDIAWIKI')) die();
1111
12 -global $IP;
13 -require_once( "$IP/includes/SpecialPage.php" );
 12+class SDCreateFilter extends SpecialPage {
1413
15 -global $sdgSpecialPagesSpecialInit;
16 -if ($sdgSpecialPagesSpecialInit) {
17 - global $wgSpecialPages;
18 - $wgSpecialPages['CreateFilter'] = 'SDCreateFilter';
 14+ /**
 15+ * Constructor
 16+ */
 17+ public function SDCreateFilter() {
 18+ SpecialPage::SpecialPage('CreateFilter');
 19+ wfLoadExtensionMessages('SemanticDrilldown');
 20+ }
1921
20 - class SDCreateFilter extends SpecialPage {
21 -
22 - /**
23 - * Constructor
24 - */
25 - public function __construct() {
26 - smwfInitUserMessages();
27 - parent::__construct('CreateFilter', '', true);
28 - }
29 -
30 - function execute() {
31 - doSpecialCreateFilter();
32 - }
 22+ function execute() {
 23+ $this->setHeaders();
 24+ doSpecialCreateFilter();
3325 }
34 -} else {
35 - SpecialPage::addPage( new SpecialPage('CreateFilter','',true,'doSpecialCreateFilter',false) );
3626 }
3727
3828 function createFilterText($property_string, $values_source, $category_used, $time_period, $filter_values, $required_filter, $filter_label) {
@@ -42,18 +32,18 @@
4333 $smw_version = SMW_VERSION;
4434 $property_tag = "[[" . $sd_props[SD_SP_COVERS_PROPERTY] .
4535 "::$namespace:$property_name|$property_name]]";
46 - $text = wfMsg('sd_filter_coversproperty', $property_tag);
 36+ $text = wfMsgForContent('sd_filter_coversproperty', $property_tag);
4737 if ($values_source == 'category') {
4838 global $wgContLang;
4939 $namespace_labels = $wgContLang->getNamespaces();
5040 $category_namespace = $namespace_labels[NS_CATEGORY];
5141 $category_tag = "[[" . $sd_props[SD_SP_GETS_VALUES_FROM_CATEGORY] . "::$category_namespace:$category_used|$category_used]]";
52 - $text .= " " . wfMsg('sd_filter_getsvaluesfromcategory', $category_tag);
 42+ $text .= " " . wfMsgForContent('sd_filter_getsvaluesfromcategory', $category_tag);
5343 } elseif ($values_source == 'property') {
5444 // do nothing
5545 } elseif ($values_source == 'dates') {
5646 $time_period_tag = "[[" . $sd_props[SD_SP_USES_TIME_PERIOD] . ":=$time_period]]";
57 - $text .= " " . wfMsg('sd_filter_usestimeperiod', $time_period_tag);
 47+ $text .= " " . wfMsgForContent('sd_filter_usestimeperiod', $time_period_tag);
5848 } elseif ($values_source == 'manual') {
5949 // replace the comma substitution character that has no
6050 // chance of being included in the values list - namely,
@@ -70,17 +60,17 @@
7161 $filter_value = str_replace("\a", $sdgListSeparator, trim($filter_value));
7262 $filter_values_tag .= "[[" . $sd_props[SD_SP_HAS_VALUE] . ":=$filter_value]]";
7363 }
74 - $text .= " " . wfMsg('sd_filter_hasvalues', $filter_values_tag);
 64+ $text .= " " . wfMsgForContent('sd_filter_hasvalues', $filter_values_tag);
7565 }
7666 if ($required_filter != '') {
7767 $sd_namespace_labels = $sdgContLang->getNamespaces();
7868 $filter_namespace = $sd_namespace_labels[SD_NS_FILTER];
7969 $filter_tag = "[[" . $sd_props[SD_SP_REQUIRES_FILTER] . "::$filter_namespace:$required_filter|$required_filter]]";
80 - $text .= " " . wfMsg('sd_filter_requiresfilter', $filter_tag);
 70+ $text .= " " . wfMsgForContent('sd_filter_requiresfilter', $filter_tag);
8171 }
8272 if ($filter_label != '') {
8373 $filter_label_tag = "[[" . $sd_props[SD_SP_HAS_LABEL] . ":=$filter_label]]";
84 - $text .= " " . wfMsg('sd_filter_haslabel', $filter_label_tag);
 74+ $text .= " " . wfMsgForContent('sd_filter_haslabel', $filter_label_tag);
8575 }
8676 return $text;
8777 }
@@ -146,8 +136,12 @@
147137 $values_from_category_label = wfMsg('sd_createfilter_usecategoryvalues');
148138 $date_values_label = wfMsg('sd_createfilter_usedatevalues');
149139 $enter_values_label = wfMsg('sd_createfilter_entervalues');
 140+ // need both label and value, in case user's language is different
 141+ // from wiki's
150142 $year_label = wfMsg('sd_filter_year');
 143+ $year_value = wfMsgForContent('sd_filter_year');
151144 $month_label = wfMsg('sd_filter_month');
 145+ $month_value = wfMsgForContent('sd_filter_month');
152146 $require_filter_label = wfMsg('sd_createfilter_requirefilter');
153147 $text .=<<<END
154148 </select>
@@ -171,8 +165,8 @@
172166 <p><input type="radio" name="values_source" value="dates">
173167 $date_values_label
174168 <select id="time_period_dropdown" name="time_period">
175 - <option>$year_label</option>
176 - <option>$month_label</option>
 169+ <option value="$year_value">$year_label</option>
 170+ <option value="$month_value">$month_label</option>
177171 </select>
178172 </p>
179173 <p><input type="radio" name="values_source" value="manual">

Status & tagging log