r65107 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65106‎ | r65107 | r65108 >
Date:04:16, 16 April 2010
Author:yaron
Status:deferred
Tags:
Comment:
Modified with stylize.php to fit MediaWiki spacing conventions
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_AppliedFilter.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/includes/SD_Filter.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/includes/SD_FilterValue.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/includes/SD_Settings.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php (modified) (history)
  • /trunk/extensions/SemanticDrilldown/specials/SD_Filters.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/specials/SD_Filters.php
@@ -5,7 +5,7 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
1111 class SDFilters extends SpecialPage {
1212
@@ -13,8 +13,8 @@
1414 * Constructor
1515 */
1616 function SDFilters() {
17 - SpecialPage::SpecialPage('Filters');
18 - wfLoadExtensionMessages('SemanticDrilldown');
 17+ SpecialPage::SpecialPage( 'Filters' );
 18+ wfLoadExtensionMessages( 'SemanticDrilldown' );
1919 }
2020
2121 function execute( $par ) {
@@ -35,7 +35,7 @@
3636 function isSyndicated() { return false; }
3737
3838 function getPageHeader() {
39 - $header = '<p>' . wfMsg('sd_filters_docu') . "</p><br />\n";
 39+ $header = '<p>' . wfMsg( 'sd_filters_docu' ) . "</p><br />\n";
4040 return $header;
4141 }
4242
@@ -59,7 +59,7 @@
6060 return false;
6161 }
6262
63 - function formatResult($skin, $result) {
 63+ function formatResult( $skin, $result ) {
6464 $title = Title::makeTitle( SD_NS_FILTER, $result->value );
6565 $text = $skin->makeLinkObj( $title, $title->getText() );
6666 return $text;
Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php
@@ -6,7 +6,7 @@
77 * @author Yaron Koren
88 */
99
10 -if (!defined('MEDIAWIKI')) die();
 10+if ( !defined( 'MEDIAWIKI' ) ) die();
1111
1212 class SDCreateFilter extends SpecialPage {
1313
@@ -14,8 +14,8 @@
1515 * Constructor
1616 */
1717 public function SDCreateFilter() {
18 - SpecialPage::SpecialPage('CreateFilter');
19 - wfLoadExtensionMessages('SemanticDrilldown');
 18+ SpecialPage::SpecialPage( 'CreateFilter' );
 19+ wfLoadExtensionMessages( 'SemanticDrilldown' );
2020 }
2121
2222 function execute( $par ) {
@@ -24,51 +24,51 @@
2525 }
2626 }
2727
28 -function createFilterText($property_name, $values_source, $category_used, $time_period, $filter_values, $input_type, $required_filter, $filter_label) {
 28+function createFilterText( $property_name, $values_source, $category_used, $time_period, $filter_values, $input_type, $required_filter, $filter_label ) {
2929 global $sdgContLang;
3030
3131 $sd_props = $sdgContLang->getPropertyLabels();
3232 $property_tag = "[[" . $sd_props[SD_SP_COVERS_PROPERTY] . "::$property_name]]";
33 - $text = wfMsgForContent('sd_filter_coversproperty', $property_tag);
34 - if ($values_source == 'category') {
 33+ $text = wfMsgForContent( 'sd_filter_coversproperty', $property_tag );
 34+ if ( $values_source == 'category' ) {
3535 $category_tag = "[[" . $sd_props[SD_SP_GETS_VALUES_FROM_CATEGORY] . "::$category_used]]";
36 - $text .= " " . wfMsgForContent('sd_filter_getsvaluesfromcategory', $category_tag);
37 - } elseif ($values_source == 'property') {
 36+ $text .= " " . wfMsgForContent( 'sd_filter_getsvaluesfromcategory', $category_tag );
 37+ } elseif ( $values_source == 'property' ) {
3838 // do nothing
39 - } elseif ($values_source == 'dates') {
 39+ } elseif ( $values_source == 'dates' ) {
4040 $time_period_tag = "[[" . $sd_props[SD_SP_USES_TIME_PERIOD] . "::$time_period]]";
41 - $text .= " " . wfMsgForContent('sd_filter_usestimeperiod', $time_period_tag);
42 - } elseif ($values_source == 'manual') {
 41+ $text .= " " . wfMsgForContent( 'sd_filter_usestimeperiod', $time_period_tag );
 42+ } elseif ( $values_source == 'manual' ) {
4343 // replace the comma substitution character that has no
4444 // chance of being included in the values list - namely,
4545 // the ASCII beep
4646 global $sdgListSeparator;
47 - $filter_values = str_replace("\\$sdgListSeparator", "\a", $filter_values);
48 - $filter_values_array = explode($sdgListSeparator, $filter_values);
 47+ $filter_values = str_replace( "\\$sdgListSeparator", "\a", $filter_values );
 48+ $filter_values_array = explode( $sdgListSeparator, $filter_values );
4949 $filter_values_tag = "";
50 - foreach ($filter_values_array as $i => $filter_value) {
51 - if ($i > 0) {
 50+ foreach ( $filter_values_array as $i => $filter_value ) {
 51+ if ( $i > 0 ) {
5252 $filter_values_tag .= ", ";
5353 }
5454 // replace beep with comma, trim
55 - $filter_value = str_replace("\a", $sdgListSeparator, trim($filter_value));
 55+ $filter_value = str_replace( "\a", $sdgListSeparator, trim( $filter_value ) );
5656 $filter_values_tag .= "[[" . $sd_props[SD_SP_HAS_VALUE] . "::$filter_value]]";
5757 }
58 - $text .= " " . wfMsgForContent('sd_filter_hasvalues', $filter_values_tag);
 58+ $text .= " " . wfMsgForContent( 'sd_filter_hasvalues', $filter_values_tag );
5959 }
60 - if ($input_type != '') {
 60+ if ( $input_type != '' ) {
6161 $input_type_tag = "[[" . $sd_props[SD_SP_HAS_INPUT_TYPE] . "::$input_type]]";
62 - $text .= " " . wfMsgForContent('sd_filter_hasinputtype', "\"$input_type_tag\"");
 62+ $text .= " " . wfMsgForContent( 'sd_filter_hasinputtype', "\"$input_type_tag\"" );
6363 }
64 - if ($required_filter != '') {
 64+ if ( $required_filter != '' ) {
6565 $sd_namespace_labels = $sdgContLang->getNamespaces();
6666 $filter_namespace = $sd_namespace_labels[SD_NS_FILTER];
6767 $filter_tag = "[[" . $sd_props[SD_SP_REQUIRES_FILTER] . "::$filter_namespace:$required_filter|$required_filter]]";
68 - $text .= " " . wfMsgForContent('sd_filter_requiresfilter', $filter_tag);
 68+ $text .= " " . wfMsgForContent( 'sd_filter_requiresfilter', $filter_tag );
6969 }
70 - if ($filter_label != '') {
 70+ if ( $filter_label != '' ) {
7171 $filter_label_tag = "[[" . $sd_props[SD_SP_HAS_LABEL] . "::$filter_label]]";
72 - $text .= " " . wfMsgForContent('sd_filter_haslabel', $filter_label_tag);
 72+ $text .= " " . wfMsgForContent( 'sd_filter_haslabel', $filter_label_tag );
7373 }
7474 return $text;
7575 }
@@ -77,34 +77,34 @@
7878 global $wgOut, $wgRequest, $wgUser, $sdgScriptPath;
7979
8080 # cycle through the query values, setting the appropriate local variables
81 - $filter_name = $wgRequest->getVal('filter_name');
82 - $values_source = $wgRequest->getVal('values_source');
83 - $property_name = $wgRequest->getVal('property_name');
84 - $category_name = $wgRequest->getVal('category_name');
85 - $time_period = $wgRequest->getVal('time_period');
86 - $filter_values = $wgRequest->getVal('filter_values');
87 - $input_type = $wgRequest->getVal('input_type');
88 - $required_filter = $wgRequest->getVal('required_filter');
89 - $filter_label = $wgRequest->getVal('filter_label');
 81+ $filter_name = $wgRequest->getVal( 'filter_name' );
 82+ $values_source = $wgRequest->getVal( 'values_source' );
 83+ $property_name = $wgRequest->getVal( 'property_name' );
 84+ $category_name = $wgRequest->getVal( 'category_name' );
 85+ $time_period = $wgRequest->getVal( 'time_period' );
 86+ $filter_values = $wgRequest->getVal( 'filter_values' );
 87+ $input_type = $wgRequest->getVal( 'input_type' );
 88+ $required_filter = $wgRequest->getVal( 'required_filter' );
 89+ $filter_label = $wgRequest->getVal( 'filter_label' );
9090
91 - $save_button_text = wfMsg('savearticle');
92 - $preview_button_text = wfMsg('preview');
 91+ $save_button_text = wfMsg( 'savearticle' );
 92+ $preview_button_text = wfMsg( 'preview' );
9393 $filter_name_error_str = '';
94 - $save_page = $wgRequest->getCheck('wpSave');
95 - $preview_page = $wgRequest->getCheck('wpPreview');
96 - if ($save_page || $preview_page) {
 94+ $save_page = $wgRequest->getCheck( 'wpSave' );
 95+ $preview_page = $wgRequest->getCheck( 'wpPreview' );
 96+ if ( $save_page || $preview_page ) {
9797 # validate filter name
98 - if ($filter_name == '') {
99 - $filter_name_error_str = wfMsg('sd_blank_error');
 98+ if ( $filter_name == '' ) {
 99+ $filter_name_error_str = wfMsg( 'sd_blank_error' );
100100 } else {
101101 # redirect to wiki interface
102102 $namespace = SD_NS_FILTER;
103 - $title = Title::newFromText($filter_name, $namespace);
104 - $full_text = createFilterText($property_name, $values_source, $category_name, $time_period, $filter_values, $input_type, $required_filter, $filter_label);
 103+ $title = Title::newFromText( $filter_name, $namespace );
 104+ $full_text = createFilterText( $property_name, $values_source, $category_name, $time_period, $filter_values, $input_type, $required_filter, $filter_label );
105105 // HTML-encode
106 - $full_text = str_replace('"', '&quot;', $full_text);
107 - $text = SDUtils::printRedirectForm($title, $full_text, "", $save_page, $preview_page, false, false, false);
108 - $wgOut->addHTML($text);
 106+ $full_text = str_replace( '"', '&quot;', $full_text );
 107+ $text = SDUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false );
 108+ $wgOut->addHTML( $text );
109109 return;
110110 }
111111 }
@@ -113,10 +113,10 @@
114114 global $wgContLang;
115115 $mw_namespace_labels = $wgContLang->getNamespaces();
116116 $special_namespace = $mw_namespace_labels[NS_SPECIAL];
117 - $name_label = wfMsg('sd_createfilter_name');
118 - $property_label = wfMsg('sd_createfilter_property');
119 - $label_label = wfMsg('sd_createfilter_label');
120 - $text =<<<END
 117+ $name_label = wfMsg( 'sd_createfilter_name' );
 118+ $property_label = wfMsg( 'sd_createfilter_property' );
 119+ $label_label = wfMsg( 'sd_createfilter_label' );
 120+ $text = <<<END
121121 <form action="" method="post">
122122 <input type="hidden" name="title" value="$special_namespace:CreateFilter">
123123 <p>$name_label <input size="25" name="filter_name" value="">
@@ -126,29 +126,29 @@
127127
128128 END;
129129 $all_properties = SDUtils::getSemanticProperties();
130 - foreach ($all_properties as $property_name) {
 130+ foreach ( $all_properties as $property_name ) {
131131 $text .= " <option>$property_name</option>\n";
132132 }
133133
134 - $values_from_property_label = wfMsg('sd_createfilter_usepropertyvalues');
135 - $values_from_category_label = wfMsg('sd_createfilter_usecategoryvalues');
136 - $date_values_label = wfMsg('sd_createfilter_usedatevalues');
137 - $enter_values_label = wfMsg('sd_createfilter_entervalues');
 134+ $values_from_property_label = wfMsg( 'sd_createfilter_usepropertyvalues' );
 135+ $values_from_category_label = wfMsg( 'sd_createfilter_usecategoryvalues' );
 136+ $date_values_label = wfMsg( 'sd_createfilter_usedatevalues' );
 137+ $enter_values_label = wfMsg( 'sd_createfilter_entervalues' );
138138 // need both label and value, in case user's language is different
139139 // from wiki's
140 - $year_label = wfMsg('sd_filter_year');
141 - $year_value = wfMsgForContent('sd_filter_year');
142 - $month_label = wfMsg('sd_filter_month');
143 - $month_value = wfMsgForContent('sd_filter_month');
144 - $input_type_label = wfMsg('sd_createfilter_inputtype');
145 - $values_list_label = wfMsg('sd_createfilter_listofvalues');
 140+ $year_label = wfMsg( 'sd_filter_year' );
 141+ $year_value = wfMsgForContent( 'sd_filter_year' );
 142+ $month_label = wfMsg( 'sd_filter_month' );
 143+ $month_value = wfMsgForContent( 'sd_filter_month' );
 144+ $input_type_label = wfMsg( 'sd_createfilter_inputtype' );
 145+ $values_list_label = wfMsg( 'sd_createfilter_listofvalues' );
146146 // same as for time values
147 - $combo_box_label = wfMsg('sd_filter_combobox');
148 - $combo_box_value = wfMsgForContent('sd_filter_combobox');
149 - $date_range_label = wfMsg('sd_filter_daterange');
150 - $date_range_value = wfMsgForContent('sd_filter_daterange');
151 - $require_filter_label = wfMsg('sd_createfilter_requirefilter');
152 - $text .=<<<END
 147+ $combo_box_label = wfMsg( 'sd_filter_combobox' );
 148+ $combo_box_value = wfMsgForContent( 'sd_filter_combobox' );
 149+ $date_range_label = wfMsg( 'sd_filter_daterange' );
 150+ $date_range_value = wfMsgForContent( 'sd_filter_daterange' );
 151+ $require_filter_label = wfMsg( 'sd_createfilter_requirefilter' );
 152+ $text .= <<<END
153153 </select>
154154 </p>
155155 <p><input type="radio" name="values_source" checked value="property">
@@ -160,11 +160,11 @@
161161
162162 END;
163163 $categories = SDUtils::getTopLevelCategories();
164 - foreach ($categories as $category) {
165 - $category = str_replace('_', ' ', $category);
 164+ foreach ( $categories as $category ) {
 165+ $category = str_replace( '_', ' ', $category );
166166 $text .= " <option>$category</option>\n";
167167 }
168 - $text .=<<<END
 168+ $text .= <<<END
169169 </select>
170170 </p>
171171 <p><input type="radio" name="values_source" value="dates">
@@ -190,11 +190,11 @@
191191
192192 END;
193193 $filters = SDUtils::getFilters();
194 - foreach ($filters as $filter) {
195 - $filter = str_replace('_', ' ', $filter);
 194+ foreach ( $filters as $filter ) {
 195+ $filter = str_replace( '_', ' ', $filter );
196196 $text .= " <option>$filter</option>\n";
197197 }
198 - $text .=<<<END
 198+ $text .= <<<END
199199 </select>
200200 </p>
201201 <p>$label_label <input size="25" name="filter_label" value=""></p>
@@ -212,6 +212,6 @@
213213 'type' => 'text/css',
214214 'media' => "screen",
215215 'href' => $sdgScriptPath . "/skins/SD_main.css"
216 - ));
217 - $wgOut->addHTML($text);
 216+ ) );
 217+ $wgOut->addHTML( $text );
218218 }
Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php
@@ -7,7 +7,7 @@
88 * @author Yaron Koren
99 */
1010
11 -if (!defined('MEDIAWIKI')) die();
 11+if ( !defined( 'MEDIAWIKI' ) ) die();
1212
1313 class SDBrowseData extends IncludableSpecialPage {
1414
@@ -15,15 +15,15 @@
1616 * Constructor
1717 */
1818 public function __construct() {
19 - parent::__construct('BrowseData');
20 - wfLoadExtensionMessages('SemanticDrilldown');
 19+ parent::__construct( 'BrowseData' );
 20+ wfLoadExtensionMessages( 'SemanticDrilldown' );
2121 }
2222
2323 function execute( $query ) {
2424 global $wgRequest, $wgOut, $wgTitle;
2525 global $sdgScriptPath, $sdgContLang, $sdgNumResultsPerPage;
2626
27 - if ($wgTitle->getNamespace() != NS_SPECIAL) {
 27+ if ( $wgTitle->getNamespace() != NS_SPECIAL ) {
2828 global $wgParser;
2929 $wgParser->disableCache();
3030 }
@@ -34,20 +34,20 @@
3535 'type' => 'text/css',
3636 'media' => "screen",
3737 'href' => $mainCssDir . 'SD_main.css'
38 - ));
 38+ ) );
3939 $wgOut->addLink( array(
4040 'rel' => 'stylesheet',
4141 'type' => 'text/css',
4242 'media' => "screen",
4343 'href' => $mainCssDir . 'xtheme-gray.css'
44 - ));
 44+ ) );
4545 $wgOut->addLink( array(
4646 'rel' => 'stylesheet',
4747 'type' => 'text/css',
4848 'media' => "screen",
4949 'href' => $mainCssDir . 'combos.css'
50 - ));
51 - $javascript_text =<<<END
 50+ ) );
 51+ $javascript_text = <<<END
5252 function toggleFilterDiv(element_id, label_element) {
5353 element = document.getElementById(element_id);
5454 if (element.style.display == "none") {
@@ -67,97 +67,97 @@
6868 }
6969
7070 END;
71 - $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n");
 71+ $wgOut->addScript( ' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n" );
7272
7373 // set default
74 - if ($sdgNumResultsPerPage == null)
 74+ if ( $sdgNumResultsPerPage == null )
7575 $sdgNumResultsPerPage = 250;
76 - list( $limit, $offset ) = wfCheckLimits($sdgNumResultsPerPage, 'sdlimit');
 76+ list( $limit, $offset ) = wfCheckLimits( $sdgNumResultsPerPage, 'sdlimit' );
7777 $filters = array();
7878
7979 // get information on current category, subcategory and filters
8080 // that have already been applied from the query string
81 - $category = str_replace('_', ' ', $wgRequest->getVal('_cat'));
 81+ $category = str_replace( '_', ' ', $wgRequest->getVal( '_cat' ) );
8282 // if query string did not contain this variables, try the URL
83 - if (! $category) {
84 - $queryparts = explode('/', $query, 1);
85 - $category = isset($queryparts[0]) ? $queryparts[0] : '';
 83+ if ( ! $category ) {
 84+ $queryparts = explode( '/', $query, 1 );
 85+ $category = isset( $queryparts[0] ) ? $queryparts[0] : '';
8686 }
87 - if (! $category) {
88 - $category_title = wfMsg('browsedata');
 87+ if ( ! $category ) {
 88+ $category_title = wfMsg( 'browsedata' );
8989 } else {
90 - $titles_for_category = SDUtils::getValuesForProperty($category, NS_CATEGORY, '_SD_DT', SD_SP_HAS_DRILLDOWN_TITLE, NS_MAIN);
91 - if (count($titles_for_category) > 0) {
92 - $category_title = str_replace('_', ' ', $titles_for_category[0]);
 90+ $titles_for_category = SDUtils::getValuesForProperty( $category, NS_CATEGORY, '_SD_DT', SD_SP_HAS_DRILLDOWN_TITLE, NS_MAIN );
 91+ if ( count( $titles_for_category ) > 0 ) {
 92+ $category_title = str_replace( '_', ' ', $titles_for_category[0] );
9393 } else {
9494 $category_title = wfMsg( 'browsedata' ) . html_entity_decode( wfMsg( 'colon-separator' ) ) . str_replace( '_', ' ', $category );
9595 }
9696 }
9797 // if no category was specified, go with the first
9898 // category on the site, alphabetically
99 - if (! $category) {
 99+ if ( ! $category ) {
100100 $categories = SDUtils::getTopLevelCategories();
101 - if (count($categories) > 0) {
 101+ if ( count( $categories ) > 0 ) {
102102 $category = $categories[0];
103103 }
104104 }
105105
106 - $wgOut->setPageTitle($category_title);
107 - $subcategory = $wgRequest->getVal('_subcat');
 106+ $wgOut->setPageTitle( $category_title );
 107+ $subcategory = $wgRequest->getVal( '_subcat' );
108108
109 - $filters = SDUtils::loadFiltersForCategory($category);
 109+ $filters = SDUtils::loadFiltersForCategory( $category );
110110
111111 $filters_used = array();
112 - foreach ($filters as $i => $filter)
 112+ foreach ( $filters as $i => $filter )
113113 $filter_used[] = false;
114114 $applied_filters = array();
115115 $remaining_filters = array();
116 - foreach ($filters as $i => $filter) {
117 - $filter_name = str_replace(' ', '_', $filter->name);
118 - $search_term = $wgRequest->getVal('_search_' . $filter_name);
119 - $lower_date = $wgRequest->getArray('_lower_' . $filter_name);
120 - $upper_date = $wgRequest->getArray('_upper_' . $filter_name);
121 - if ($vals_array = $wgRequest->getArray($filter_name)) {
122 - foreach ($vals_array as $j => $val) {
123 - $vals_array[$j] = str_replace('_', ' ', $val);
 116+ foreach ( $filters as $i => $filter ) {
 117+ $filter_name = str_replace( ' ', '_', $filter->name );
 118+ $search_term = $wgRequest->getVal( '_search_' . $filter_name );
 119+ $lower_date = $wgRequest->getArray( '_lower_' . $filter_name );
 120+ $upper_date = $wgRequest->getArray( '_upper_' . $filter_name );
 121+ if ( $vals_array = $wgRequest->getArray( $filter_name ) ) {
 122+ foreach ( $vals_array as $j => $val ) {
 123+ $vals_array[$j] = str_replace( '_', ' ', $val );
124124 }
125 - $applied_filters[] = SDAppliedFilter::create($filter, $vals_array);
 125+ $applied_filters[] = SDAppliedFilter::create( $filter, $vals_array );
126126 $filter_used[$i] = true;
127 - } elseif ($search_term != null) {
128 - $applied_filters[] = SDAppliedFilter::create($filter, array(), $search_term);
 127+ } elseif ( $search_term != null ) {
 128+ $applied_filters[] = SDAppliedFilter::create( $filter, array(), $search_term );
129129 $filter_used[$i] = true;
130 - } elseif ($lower_date != null || $upper_date != null) {
131 - $applied_filters[] = SDAppliedFilter::create($filter, array(), null, $lower_date, $upper_date);
 130+ } elseif ( $lower_date != null || $upper_date != null ) {
 131+ $applied_filters[] = SDAppliedFilter::create( $filter, array(), null, $lower_date, $upper_date );
132132 $filter_used[$i] = true;
133133 }
134134 }
135135 // add every unused filter to the $remaining_filters array,
136136 // unless it requires some other filter that hasn't been applied
137 - foreach ($filters as $i => $filter) {
138 - $required_filters = SDUtils::getValuesForProperty($filter->name, SD_NS_FILTER, '_SD_RF', SD_SP_REQUIRES_FILTER, SD_NS_FILTER);
 137+ foreach ( $filters as $i => $filter ) {
 138+ $required_filters = SDUtils::getValuesForProperty( $filter->name, SD_NS_FILTER, '_SD_RF', SD_SP_REQUIRES_FILTER, SD_NS_FILTER );
139139 $matched_all_required_filters = true;
140 - foreach ($required_filters as $required_filter) {
 140+ foreach ( $required_filters as $required_filter ) {
141141 $found_match = false;
142 - foreach ($applied_filters as $af) {
143 - if ($af->filter->name == $required_filter) {
 142+ foreach ( $applied_filters as $af ) {
 143+ if ( $af->filter->name == $required_filter ) {
144144 $found_match = true;
145145 }
146146 }
147 - if (! $found_match) {
 147+ if ( ! $found_match ) {
148148 $matched_all_required_filters = false;
149149 continue;
150150 }
151151 }
152 - if ($matched_all_required_filters) {
153 - if (! $filter_used[$i])
 152+ if ( $matched_all_required_filters ) {
 153+ if ( ! $filter_used[$i] )
154154 $remaining_filters[] = $filter;
155155 }
156156 }
157157
158 - $wgOut->addHTML("\n <div class=\"drilldown-results\">\n");
159 - $rep = new SDBrowseDataPage($category, $subcategory, $applied_filters, $remaining_filters);
 158+ $wgOut->addHTML( "\n <div class=\"drilldown-results\">\n" );
 159+ $rep = new SDBrowseDataPage( $category, $subcategory, $applied_filters, $remaining_filters );
160160 $num = $rep->doQuery( $offset, $limit );
161 - $wgOut->addHTML("\n </div> <!-- drilldown-results -->\n");
 161+ $wgOut->addHTML( "\n </div> <!-- drilldown-results -->\n" );
162162 return $num;
163163 }
164164 }
@@ -174,7 +174,7 @@
175175 /**
176176 * Initialize the variables of this page
177177 */
178 - function __construct($category, $subcategory, $applied_filters, $remaining_filters) {
 178+ function __construct( $category, $subcategory, $applied_filters, $remaining_filters ) {
179179 $this->category = $category;
180180 $this->subcategory = $subcategory;
181181 $this->applied_filters = $applied_filters;
@@ -184,44 +184,44 @@
185185 $categorylinks = $dbr->tableName( 'categorylinks' );
186186 $page = $dbr->tableName( 'page' );
187187 $cat_ns = NS_CATEGORY;
188 - if ($this->subcategory)
189 - $actual_cat = str_replace(' ', '_', $this->subcategory);
 188+ if ( $this->subcategory )
 189+ $actual_cat = str_replace( ' ', '_', $this->subcategory );
190190 else
191 - $actual_cat = str_replace(' ', '_', $this->category);
 191+ $actual_cat = str_replace( ' ', '_', $this->category );
192192 // get the two arrays for subcategories - one for only the
193193 // immediate subcategories, for display, and the other for
194194 // all subcategories, sub-subcategories, etc., for querying
195 - $this->next_level_subcategories = SDUtils::getCategoryChildren($actual_cat, true, 1);
196 - $this->all_subcategories = SDUtils::getCategoryChildren($actual_cat, true, 10);
 195+ $this->next_level_subcategories = SDUtils::getCategoryChildren( $actual_cat, true, 1 );
 196+ $this->all_subcategories = SDUtils::getCategoryChildren( $actual_cat, true, 10 );
197197 }
198198
199 - function makeBrowseURL($category, $applied_filters = array(), $subcategory = null) {
 199+ function makeBrowseURL( $category, $applied_filters = array(), $subcategory = null ) {
200200 global $wgTitle;
201201 $url = $wgTitle->getFullURL() . '/' . $category;
202 - if ($this->show_single_cat) {
203 - $url .= (strpos($url, '?')) ? '&' : '?';
 202+ if ( $this->show_single_cat ) {
 203+ $url .= ( strpos( $url, '?' ) ) ? '&' : '?';
204204 $url .= "_single";
205205 }
206 - if ($subcategory) {
207 - $url .= (strpos($url, '?')) ? '&' : '?';
 206+ if ( $subcategory ) {
 207+ $url .= ( strpos( $url, '?' ) ) ? '&' : '?';
208208 $url .= "_subcat=" . $subcategory;
209209 }
210 - foreach ($applied_filters as $i => $af) {
211 - if (count($af->values) == 0) {
 210+ foreach ( $applied_filters as $i => $af ) {
 211+ if ( count( $af->values ) == 0 ) {
212212 // do nothing
213 - } elseif (count($af->values) == 1) {
214 - $url .= (strpos($url, '?')) ? '&' : '?';
215 - $url .= urlencode(str_replace(' ', '_', $af->filter->name)) . "=" . urlencode(str_replace(' ', '_', $af->values[0]->text));
 213+ } elseif ( count( $af->values ) == 1 ) {
 214+ $url .= ( strpos( $url, '?' ) ) ? '&' : '?';
 215+ $url .= urlencode( str_replace( ' ', '_', $af->filter->name ) ) . "=" . urlencode( str_replace( ' ', '_', $af->values[0]->text ) );
216216 } else {
217 - usort($af->values, array("SDFilterValue", "compare"));
218 - foreach ($af->values as $j => $fv) {
219 - $url .= (strpos($url, '?')) ? '&' : '?';
220 - $url .= urlencode(str_replace(' ', '_', $af->filter->name)) . "[$j]=" . urlencode(str_replace(' ', '_', $fv->text));
 217+ usort( $af->values, array( "SDFilterValue", "compare" ) );
 218+ foreach ( $af->values as $j => $fv ) {
 219+ $url .= ( strpos( $url, '?' ) ) ? '&' : '?';
 220+ $url .= urlencode( str_replace( ' ', '_', $af->filter->name ) ) . "[$j]=" . urlencode( str_replace( ' ', '_', $fv->text ) );
221221 }
222222 }
223 - if ($af->search_term != null) {
224 - $url .= (strpos($url, '?')) ? '&' : '?';
225 - $url .= '_search_' . urlencode(str_replace(' ', '_', $af->filter->name)) . "=" . urlencode(str_replace(' ', '_', $af->search_term));
 223+ if ( $af->search_term != null ) {
 224+ $url .= ( strpos( $url, '?' ) ) ? '&' : '?';
 225+ $url .= '_search_' . urlencode( str_replace( ' ', '_', $af->filter->name ) ) . "=" . urlencode( str_replace( ' ', '_', $af->search_term ) );
226226 }
227227 }
228228 return $url;
@@ -232,17 +232,17 @@
233233 * set of filters selected by the user - used for displaying
234234 * all remaining filters
235235 */
236 - function createTempTable($category, $subcategory, $subcategories, $applied_filters) {
 236+ function createTempTable( $category, $subcategory, $subcategories, $applied_filters ) {
237237 $dbr = wfGetDB( DB_SLAVE );
238 - $sql =<<<END
 238+ $sql = <<<END
239239 CREATE TEMPORARY TABLE semantic_drilldown_values (
240240 id INT NOT NULL,
241241 INDEX id_index (id)
242242 ) AS SELECT ids.smw_id AS id
243243
244244 END;
245 - $sql .= $this->getSQLFromClause($category, $subcategory, $subcategories, $applied_filters);
246 - $dbr->query($sql);
 245+ $sql .= $this->getSQLFromClause( $category, $subcategory, $subcategories, $applied_filters );
 246+ $dbr->query( $sql );
247247 }
248248
249249 /**
@@ -251,12 +251,12 @@
252252 * selected filters, plus the one new filter (with value) that
253253 * was passed in to this function.
254254 */
255 - function getSQLFromClauseForField($new_filter) {
 255+ function getSQLFromClauseForField( $new_filter ) {
256256 $sql = "FROM semantic_drilldown_values sdv
257257 LEFT OUTER JOIN semantic_drilldown_filter_values sdfv
258258 ON sdv.id = sdfv.id
259259 WHERE ";
260 - $sql .= $new_filter->checkSQL("sdfv.value");
 260+ $sql .= $new_filter->checkSQL( "sdfv.value" );
261261 return $sql;
262262 }
263263
@@ -265,20 +265,20 @@
266266 * of a new filter passed in, it's a subcategory, plus all that
267267 * subcategory's child subcategories, to ensure completeness.
268268 */
269 - function getSQLFromClauseForCategory($subcategory, $child_subcategories) {
 269+ function getSQLFromClauseForCategory( $subcategory, $child_subcategories ) {
270270 $dbr = wfGetDB( DB_SLAVE );
271271 $smw_insts = $dbr->tableName( 'smw_inst2' );
272272 $smw_ids = $dbr->tableName( 'smw_ids' );
273273 $ns_cat = NS_CATEGORY;
274 - $subcategory = str_replace("'", "\'", $subcategory);
 274+ $subcategory = str_replace( "'", "\'", $subcategory );
275275 $sql = "FROM semantic_drilldown_values sdv
276276 JOIN $smw_insts inst
277277 ON sdv.id = inst.s_id
278278 WHERE inst.o_id IN
279279 (SELECT smw_id FROM $smw_ids
280280 WHERE smw_namespace = $ns_cat AND (smw_title = '$subcategory' ";
281 - foreach ($child_subcategories as $i => $subcat) {
282 - $subcat = str_replace("'", "\'", $subcat);
 281+ foreach ( $child_subcategories as $i => $subcat ) {
 282+ $subcat = str_replace( "'", "\'", $subcat );
283283 $sql .= "OR smw_title = '$subcat' ";
284284 }
285285 $sql .= ")) ";
@@ -290,7 +290,7 @@
291291 * to get all pages that match a certain set of criteria for
292292 * category, subcategory and filters
293293 */
294 - function getSQLFromClause($category, $subcategory, $subcategories, $applied_filters) {
 294+ function getSQLFromClause( $category, $subcategory, $subcategories, $applied_filters ) {
295295 $dbr = wfGetDB( DB_SLAVE );
296296 $smw_ids = $dbr->tableName( 'smw_ids' );
297297 $smw_insts = $dbr->tableName( 'smw_inst2' );
@@ -303,18 +303,18 @@
304304 JOIN $smw_insts insts
305305 ON ids.smw_id = insts.s_id
306306 AND ids.smw_namespace != $cat_ns ";
307 - foreach ($applied_filters as $i => $af) {
 307+ foreach ( $applied_filters as $i => $af ) {
308308 // if any of this filter's values is 'none',
309309 // include another table to get this information
310310 $includes_none = false;
311 - foreach ($af->values as $fv) {
312 - if ($fv->text === '_none' || $fv->text === ' none') {
 311+ foreach ( $af->values as $fv ) {
 312+ if ( $fv->text === '_none' || $fv->text === ' none' ) {
313313 $includes_none = true;
314314 break;
315315 }
316316 }
317 - if ($includes_none) {
318 - if ($af->filter->is_relation) {
 317+ if ( $includes_none ) {
 318+ if ( $af->filter->is_relation ) {
319319 $property_table_name = $smw_rels;
320320 $property_table_nickname = "nr$i";
321321 $property_field = 'p_id';
@@ -323,8 +323,8 @@
324324 $property_table_nickname = "na$i";
325325 $property_field = 'p_id';
326326 }
327 - $property_value = str_replace(' ', '_', $af->filter->property);
328 - $property_value = str_replace("'", "\'", $property_value);
 327+ $property_value = str_replace( ' ', '_', $af->filter->property );
 328+ $property_value = str_replace( "'", "\'", $property_value );
329329 $sql .= "LEFT OUTER JOIN
330330 (SELECT s_id
331331 FROM $property_table_name
@@ -332,14 +332,14 @@
333333 ON ids.smw_id = $property_table_nickname.s_id ";
334334 }
335335 }
336 - foreach ($applied_filters as $i => $af) {
 336+ foreach ( $applied_filters as $i => $af ) {
337337 $sql .= "\n ";
338 - if ($af->filter->is_relation) {
339 - if ($includes_none) {
 338+ if ( $af->filter->is_relation ) {
 339+ if ( $includes_none ) {
340340 $sql .= "LEFT OUTER ";
341341 }
342342 $sql .= "JOIN $smw_rels r$i ON ids.smw_id = r$i.s_id\n ";
343 - if ($includes_none) {
 343+ if ( $includes_none ) {
344344 $sql .= "LEFT OUTER ";
345345 }
346346 $sql .= "JOIN $smw_ids o_ids$i ON r$i.o_id = o_ids$i.smw_id ";
@@ -347,25 +347,25 @@
348348 $sql .= "JOIN $smw_atts a$i ON ids.smw_id = a$i.s_id ";
349349 }
350350 }
351 - if ($subcategory)
352 - $actual_cat = str_replace(' ', '_', $subcategory);
 351+ if ( $subcategory )
 352+ $actual_cat = str_replace( ' ', '_', $subcategory );
353353 else
354 - $actual_cat = str_replace(' ', '_', $category);
355 - $actual_cat = str_replace("'", "\'", $actual_cat);
 354+ $actual_cat = str_replace( ' ', '_', $category );
 355+ $actual_cat = str_replace( "'", "\'", $actual_cat );
356356 $sql .= "WHERE insts.o_id IN
357357 (SELECT smw_id FROM $smw_ids cat_ids
358358 WHERE smw_namespace = $cat_ns AND (smw_title = '$actual_cat'";
359 - foreach ($subcategories as $i => $subcat) {
360 - $subcat = str_replace("'", "\'", $subcat);
 359+ foreach ( $subcategories as $i => $subcat ) {
 360+ $subcat = str_replace( "'", "\'", $subcat );
361361 $sql .= " OR smw_title = '{$subcat}'";
362362 }
363363 $sql .= ")) ";
364 - foreach ($applied_filters as $i => $af) {
365 - $property_value = str_replace(' ', '_', $af->filter->property);
366 - if ($af->filter->is_relation) {
 364+ foreach ( $applied_filters as $i => $af ) {
 365+ $property_value = str_replace( ' ', '_', $af->filter->property );
 366+ if ( $af->filter->is_relation ) {
367367 $property_field = "r$i.p_id";
368368 $sql .= "\n AND ($property_field = (SELECT smw_id FROM $smw_ids WHERE smw_title = '$property_value' AND smw_namespace = $prop_ns)";
369 - if ($includes_none) {
 369+ if ( $includes_none ) {
370370 $sql .= " OR $property_field IS NULL";
371371 }
372372 $sql .= ")\n AND ";
@@ -375,7 +375,7 @@
376376 $sql .= "\n AND $property_field = (SELECT smw_id FROM $smw_ids WHERE smw_title = '$property_value' AND smw_namespace = $prop_ns) AND ";
377377 $value_field = "a$i.value_xsd";
378378 }
379 - $sql .= $af->checkSQL($value_field);
 379+ $sql .= $af->checkSQL( $value_field );
380380 }
381381 return $sql;
382382 }
@@ -384,16 +384,16 @@
385385 * Gets the number of pages matching both the currently-selected
386386 * set of filters and either a new subcategory or a new filter.
387387 */
388 - function getNumResults($subcategory, $subcategories, $new_filter = null) {
 388+ function getNumResults( $subcategory, $subcategories, $new_filter = null ) {
389389 $dbr = wfGetDB( DB_SLAVE );
390390 $sql = "SELECT COUNT(DISTINCT sdv.id) ";
391 - if ($new_filter)
392 - $sql .= $this->getSQLFromClauseForField($new_filter);
 391+ if ( $new_filter )
 392+ $sql .= $this->getSQLFromClauseForField( $new_filter );
393393 else
394 - $sql .= $this->getSQLFromClauseForCategory($subcategory, $subcategories);
395 - $res = $dbr->query($sql);
396 - $row = $dbr->fetchRow($res);
397 - $dbr->freeResult($res);
 394+ $sql .= $this->getSQLFromClauseForCategory( $subcategory, $subcategories );
 395+ $res = $dbr->query( $sql );
 396+ $row = $dbr->fetchRow( $res );
 397+ $dbr->freeResult( $res );
398398 return $row[0];
399399 }
400400
@@ -405,38 +405,38 @@
406406
407407 function isSyndicated() { return false; }
408408
409 - function printCategoriesList($categories) {
 409+ function printCategoriesList( $categories ) {
410410 global $sdgShowCategoriesAsTabs;
411411
412 - $choose_category_text = wfMsg('sd_browsedata_choosecategory');
413 - if ($sdgShowCategoriesAsTabs) {
 412+ $choose_category_text = wfMsg( 'sd_browsedata_choosecategory' );
 413+ if ( $sdgShowCategoriesAsTabs ) {
414414 $cats_wrapper_class = "drilldown-categories-tabs-wrapper";
415415 $cats_list_class = "drilldown-categories-tabs";
416416 } else {
417417 $cats_wrapper_class = "drilldown-categories-wrapper";
418418 $cats_list_class = "drilldown-categories";
419419 }
420 - $text =<<<END
 420+ $text = <<<END
421421
422422 <div id="$cats_wrapper_class">
423423 <p id="categories-header">$choose_category_text:</p>
424424 <ul id="$cats_list_class">
425425
426426 END;
427 - foreach ($categories as $i => $category) {
428 - $category_children = SDUtils::getCategoryChildren($category, false, 5);
429 - $category_str = $category . " (" . count(array_unique($category_children)) . ")";
430 - if (str_replace('_', ' ', $this->category) == $category) {
 427+ foreach ( $categories as $i => $category ) {
 428+ $category_children = SDUtils::getCategoryChildren( $category, false, 5 );
 429+ $category_str = $category . " (" . count( array_unique( $category_children ) ) . ")";
 430+ if ( str_replace( '_', ' ', $this->category ) == $category ) {
431431 $text .= ' <li class="category selected">';
432432 $text .= $category_str;
433433 } else {
434434 $text .= ' <li class="category">';
435 - $category_url = $this->makeBrowseURL($category);
 435+ $category_url = $this->makeBrowseURL( $category );
436436 $text .= "<a href=\"$category_url\" title=\"$choose_category_text\">$category_str</a>";
437437 }
438438 $text .= "</li>\n";
439439 }
440 - $text .=<<<END
 440+ $text .= <<<END
441441 </li>
442442 </ul>
443443 </div>
@@ -445,12 +445,12 @@
446446 return $text;
447447 }
448448
449 - function printFilterLabel($filter_name) {
450 - $labels_for_filter = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_L', SD_SP_HAS_LABEL, NS_MAIN);
451 - if (count($labels_for_filter) > 0) {
 449+ function printFilterLabel( $filter_name ) {
 450+ $labels_for_filter = SDUtils::getValuesForProperty( $filter_name, SD_NS_FILTER, '_SD_L', SD_SP_HAS_LABEL, NS_MAIN );
 451+ if ( count( $labels_for_filter ) > 0 ) {
452452 $filter_label = $labels_for_filter[0];
453453 } else {
454 - $filter_label = str_replace('_', ' ', $filter_name);
 454+ $filter_label = str_replace( '_', ' ', $filter_name );
455455 }
456456 return $filter_label;
457457 }
@@ -459,17 +459,17 @@
460460 * Print a "nice" version of the value for a filter, if it's some
461461 * special case like 'other', 'none', a boolean, etc.
462462 */
463 - function printFilterValue($filter, $value) {
464 - $value = str_replace('_', ' ', $value);
 463+ function printFilterValue( $filter, $value ) {
 464+ $value = str_replace( '_', ' ', $value );
465465 // if it's boolean, display something nicer than "0" or "1"
466 - if ($value === ' other')
467 - return wfMsg('sd_browsedata_other');
468 - elseif ($value === ' none')
469 - return wfMsg('sd_browsedata_none');
470 - elseif ($filter->is_boolean)
471 - return SDUtils::booleanToString($value);
472 - elseif ($filter->is_date && strpos($value, '//T'))
473 - return str_replace('//T', '', $value);
 466+ if ( $value === ' other' )
 467+ return wfMsg( 'sd_browsedata_other' );
 468+ elseif ( $value === ' none' )
 469+ return wfMsg( 'sd_browsedata_none' );
 470+ elseif ( $filter->is_boolean )
 471+ return SDUtils::booleanToString( $value );
 472+ elseif ( $filter->is_date && strpos( $value, '//T' ) )
 473+ return str_replace( '//T', '', $value );
474474 else
475475 return $value;
476476 }
@@ -478,71 +478,71 @@
479479 * Print the line showing 'OR' values for a filter that already has
480480 * at least one value set
481481 */
482 - function printAppliedFilterLine($af) {
 482+ function printAppliedFilterLine( $af ) {
483483 global $sdgScriptPath;
484484
485485 $results_line = "";
486 - $filter_label = $this->printFilterLabel($af->filter->name);
487 - foreach ($this->applied_filters as $af2) {
488 - if ($af->filter->name == $af2->filter->name)
 486+ $filter_label = $this->printFilterLabel( $af->filter->name );
 487+ foreach ( $this->applied_filters as $af2 ) {
 488+ if ( $af->filter->name == $af2->filter->name )
489489 $current_filter_values = $af2->values;
490490 }
491 - if ($af->filter->allowed_values != null)
 491+ if ( $af->filter->allowed_values != null )
492492 $or_values = $af->filter->allowed_values;
493493 else
494 - $or_values = $af->getAllOrValues($this->category);
495 - if ($af->search_term != null) {
 494+ $or_values = $af->getAllOrValues( $this->category );
 495+ if ( $af->search_term != null ) {
496496 // HACK - printComboBoxInput() needs values as the
497497 // *keys* of the array
498498 $filter_values = array();
499 - foreach ($or_values as $or_value) {
 499+ foreach ( $or_values as $or_value ) {
500500 $filter_values[$or_value] = '';
501501 }
502 - $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printComboBoxInput($af->filter->name, $filter_values, $af->search_term);
 502+ $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printComboBoxInput( $af->filter->name, $filter_values, $af->search_term );
503503 return $results_line;
504 - } elseif ($af->lower_date != null || $af->upper_date != null) {
505 - $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printDateRangeInput($af->filter->name, $af->lower_date, $af->upper_date);
 504+ } elseif ( $af->lower_date != null || $af->upper_date != null ) {
 505+ $results_line = "<div class=\"drilldown-filter-label\">$filter_label:</div> " . $this->printDateRangeInput( $af->filter->name, $af->lower_date, $af->upper_date );
506506 return $results_line;
507507 }
508508 // add 'Other' and 'None', regardless of whether either has
509509 // any results - add 'Other' only if it's not a date field
510 - if ($af->filter->time_period == null)
 510+ if ( $af->filter->time_period == null )
511511 $or_values[] = '_other';
512512 $or_values[] = '_none';
513 - foreach ($or_values as $i => $value) {
514 - if ($i > 0) { $results_line .= " &middot; "; }
515 - $filter_text = $this->printFilterValue($af->filter, $value);
 513+ foreach ( $or_values as $i => $value ) {
 514+ if ( $i > 0 ) { $results_line .= " &middot; "; }
 515+ $filter_text = $this->printFilterValue( $af->filter, $value );
516516 $applied_filters = $this->applied_filters;
517 - foreach ($applied_filters as $af2) {
518 - if ($af->filter->name == $af2->filter->name) {
519 - $or_fv = SDFilterValue::create($value, $af->filter->time_period);
520 - $af2->values = array_merge($current_filter_values, array($or_fv));
 517+ foreach ( $applied_filters as $af2 ) {
 518+ if ( $af->filter->name == $af2->filter->name ) {
 519+ $or_fv = SDFilterValue::create( $value, $af->filter->time_period );
 520+ $af2->values = array_merge( $current_filter_values, array( $or_fv ) );
521521 }
522522 }
523523 // show the list of OR values, only linking
524524 // the ones that haven't been used yet
525525 $found_match = false;
526 - foreach ($current_filter_values as $fv) {
527 - if ($value == $fv->text) {
 526+ foreach ( $current_filter_values as $fv ) {
 527+ if ( $value == $fv->text ) {
528528 $found_match = true;
529529 break;
530530 }
531531 }
532 - if ($found_match) {
 532+ if ( $found_match ) {
533533 $results_line .= "\n $filter_text";
534534 } else {
535 - $filter_url = $this->makeBrowseURL($this->category, $applied_filters, $this->subcategory);
536 - $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg('sd_browsedata_filterbyvalue') . '">' . $filter_text . '</a>';
 535+ $filter_url = $this->makeBrowseURL( $this->category, $applied_filters, $this->subcategory );
 536+ $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg( 'sd_browsedata_filterbyvalue' ) . '">' . $filter_text . '</a>';
537537 }
538 - foreach ($applied_filters as $af2) {
539 - if ($af->filter->name == $af2->filter->name) {
 538+ foreach ( $applied_filters as $af2 ) {
 539+ if ( $af->filter->name == $af2->filter->name ) {
540540 $af2->values = $current_filter_values;
541541 }
542542 }
543543 }
544 - $add_another_str = wfMsg('sd_browsedata_addanothervalue');
545 - $results_div_id = strtolower(str_replace(' ', '_', $filter_label)) . "_values";
546 - $text =<<<END
 544+ $add_another_str = wfMsg( 'sd_browsedata_addanothervalue' );
 545+ $results_div_id = strtolower( str_replace( ' ', '_', $filter_label ) ) . "_values";
 546+ $text = <<<END
547547 <div class="drilldown-filter-label">
548548 <a onclick="toggleFilterDiv('$results_div_id', this)" style="cursor: default;"><img src="$sdgScriptPath/skins/right-arrow.png"></a>
549549 $filter_label: <span class="drilldown-filter-notes">($add_another_str)</span>
@@ -554,56 +554,56 @@
555555 return $text;
556556 }
557557
558 - function printUnappliedFilterValues($cur_url, $f, $filter_values) {
 558+ function printUnappliedFilterValues( $cur_url, $f, $filter_values ) {
559559 global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize;
560560
561561 $results_line = "";
562562 // set font-size values for filter "tag cloud", if the
563563 // appropriate global variables are set
564 - if ($sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0) {
565 - $lowest_num_results = min($filter_values);
566 - $highest_num_results = max($filter_values);
567 - $num_results_midpoint = ($lowest_num_results + $highest_num_results) / 2;
568 - $font_size_midpoint = ($sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize) / 2;
569 - $num_results_per_font_pixel = ($highest_num_results + 1 - $lowest_num_results) / ($sdgFiltersLargestFontSize + 1 - $sdgFiltersSmallestFontSize);
 564+ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) {
 565+ $lowest_num_results = min( $filter_values );
 566+ $highest_num_results = max( $filter_values );
 567+ $num_results_midpoint = ( $lowest_num_results + $highest_num_results ) / 2;
 568+ $font_size_midpoint = ( $sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2;
 569+ $num_results_per_font_pixel = ( $highest_num_results + 1 - $lowest_num_results ) / ( $sdgFiltersLargestFontSize + 1 - $sdgFiltersSmallestFontSize );
570570 }
571571 // now print the values
572572 $num_printed_values = 0;
573 - foreach ($filter_values as $value_str => $num_results) {
574 - if ($num_printed_values++ > 0) { $results_line .= " &middot; "; }
575 - $filter_text = $this->printFilterValue($f, $value_str);
 573+ foreach ( $filter_values as $value_str => $num_results ) {
 574+ if ( $num_printed_values++ > 0 ) { $results_line .= " &middot; "; }
 575+ $filter_text = $this->printFilterValue( $f, $value_str );
576576 $filter_text .= " ($num_results)";
577 - $filter_url = $cur_url . urlencode(str_replace(' ', '_', $f->name)) . '=' . urlencode(str_replace(' ', '_', $value_str));
578 - if ($sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0) {
579 - $font_size = round($font_size_midpoint + (($num_results - $num_results_midpoint) / $num_results_per_font_pixel));
580 - $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg('sd_browsedata_filterbyvalue') . '" style="font-size: ' . $font_size . 'px">' . $filter_text . '</a>';
 577+ $filter_url = $cur_url . urlencode( str_replace( ' ', '_', $f->name ) ) . '=' . urlencode( str_replace( ' ', '_', $value_str ) );
 578+ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) {
 579+ $font_size = round( $font_size_midpoint + ( ( $num_results - $num_results_midpoint ) / $num_results_per_font_pixel ) );
 580+ $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg( 'sd_browsedata_filterbyvalue' ) . '" style="font-size: ' . $font_size . 'px">' . $filter_text . '</a>';
581581 } else {
582 - $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg('sd_browsedata_filterbyvalue') . '">' . $filter_text . '</a>';
 582+ $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg( 'sd_browsedata_filterbyvalue' ) . '">' . $filter_text . '</a>';
583583 }
584584 }
585585 return $results_line;
586586 }
587587
588 - function printComboBoxInput($filter_name, $filter_values, $cur_value = null) {
 588+ function printComboBoxInput( $filter_name, $filter_values, $cur_value = null ) {
589589 global $wgRequest;
590590
591 - $filter_name = str_replace(' ', '_', $filter_name);
 591+ $filter_name = str_replace( ' ', '_', $filter_name );
592592 $input_id = "_search_$filter_name";
593 - $text =<<<END
 593+ $text = <<<END
594594
595595 <script>
596596 Ext.onReady(function(){
597597 var {$filter_name}_values = [
598598
599599 END;
600 - foreach ($filter_values as $value => $num_instances) {
601 - if ($value != '_other' && $value != '_none') {
602 - $display_value = str_replace('_', ' ', $value);
603 - $display_value = str_replace('\'', '\\\'', $display_value);
 600+ foreach ( $filter_values as $value => $num_instances ) {
 601+ if ( $value != '_other' && $value != '_none' ) {
 602+ $display_value = str_replace( '_', ' ', $value );
 603+ $display_value = str_replace( '\'', '\\\'', $display_value );
604604 $text .= " ['$display_value', '$display_value'],\n";
605605 }
606606 }
607 - $text .=<<<END
 607+ $text .= <<<END
608608 ]
609609
610610 var comboFromArray = new Ext.form.ComboBox({
@@ -618,15 +618,15 @@
619619
620620 END;
621621
622 - foreach ($wgRequest->getValues() as $key => $val) {
623 - if ($key != $input_id)
624 - $text .=<<<END
 622+ foreach ( $wgRequest->getValues() as $key => $val ) {
 623+ if ( $key != $input_id )
 624+ $text .= <<<END
625625 <input type="hidden" name="$key" value="$val" />
626626
627627 END;
628628 }
629 - $search_label = wfMsg('searchresultshead');
630 - $text .=<<<END
 629+ $search_label = wfMsg( 'searchresultshead' );
 630+ $text .= <<<END
631631 <input type="submit" value="$search_label" />
632632 </form>
633633
@@ -634,31 +634,31 @@
635635 return $text;
636636 }
637637
638 - function printDateInput($input_name, $cur_value = null) {
 638+ function printDateInput( $input_name, $cur_value = null ) {
639639 $month_names = array(
640 - wfMsgForContent('january'),
641 - wfMsgForContent('february'),
642 - wfMsgForContent('march'),
643 - wfMsgForContent('april'),
644 - wfMsgForContent('may'),
645 - wfMsgForContent('june'),
646 - wfMsgForContent('july'),
647 - wfMsgForContent('august'),
648 - wfMsgForContent('september'),
649 - wfMsgForContent('october'),
650 - wfMsgForContent('november'),
651 - wfMsgForContent('december')
 640+ wfMsgForContent( 'january' ),
 641+ wfMsgForContent( 'february' ),
 642+ wfMsgForContent( 'march' ),
 643+ wfMsgForContent( 'april' ),
 644+ wfMsgForContent( 'may' ),
 645+ wfMsgForContent( 'june' ),
 646+ wfMsgForContent( 'july' ),
 647+ wfMsgForContent( 'august' ),
 648+ wfMsgForContent( 'september' ),
 649+ wfMsgForContent( 'october' ),
 650+ wfMsgForContent( 'november' ),
 651+ wfMsgForContent( 'december' )
652652 );
653653
654 - if (is_array($cur_value) && array_key_exists('month', $cur_value))
 654+ if ( is_array( $cur_value ) && array_key_exists( 'month', $cur_value ) )
655655 $selected_month = $cur_value['month'];
656656 else
657657 $selected_month = null;
658658 $text = ' <select name="' . $input_name . "[month]\">\n";
659 - foreach ($month_names as $i => $name) {
 659+ foreach ( $month_names as $i => $name ) {
660660 // pad out month to always be two digits
661 - $month_value = ($wgAmericanDates == true) ? $name : str_pad($i + 1, 2, "0", STR_PAD_LEFT);
662 - $selected_str = ($i + 1 == $selected_month) ? "selected" : "";
 661+ $month_value = ( $wgAmericanDates == true ) ? $name : str_pad( $i + 1, 2, "0", STR_PAD_LEFT );
 662+ $selected_str = ( $i + 1 == $selected_month ) ? "selected" : "";
663663 $text .= " <option value=\"$month_value\" $selected_str>$name</option>\n";
664664 }
665665 $text .= " </select>\n";
@@ -667,27 +667,27 @@
668668 return $text;
669669 }
670670
671 - function printDateRangeInput($filter_name, $lower_date = null, $upper_date = null) {
 671+ function printDateRangeInput( $filter_name, $lower_date = null, $upper_date = null ) {
672672 global $wgRequest;
673673
674 - $start_label = wfMsg('sd_browsedata_daterangestart');
675 - $end_label = wfMsg('sd_browsedata_daterangeend');
676 - $start_month_input = $this->printDateInput("_lower_$filter_name", $lower_date);
677 - $end_month_input = $this->printDateInput("_upper_$filter_name", $upper_date);
678 - $text =<<<END
 674+ $start_label = wfMsg( 'sd_browsedata_daterangestart' );
 675+ $end_label = wfMsg( 'sd_browsedata_daterangeend' );
 676+ $start_month_input = $this->printDateInput( "_lower_$filter_name", $lower_date );
 677+ $end_month_input = $this->printDateInput( "_upper_$filter_name", $upper_date );
 678+ $text = <<<END
679679 <form method="get">
680680 <p>$start_label $start_month_input
681681 $end_label $end_month_input</p>
682682
683683 END;
684 - foreach ($wgRequest->getValues() as $key => $val) {
685 - $text .=<<<END
 684+ foreach ( $wgRequest->getValues() as $key => $val ) {
 685+ $text .= <<<END
686686 <input type="hidden" name="$key" value="$val" />
687687
688688 END;
689689 }
690 - $search_label = wfMsg('searchresultshead');
691 - $text .=<<<END
 690+ $search_label = wfMsg( 'searchresultshead' );
 691+ $text .= <<<END
692692 <p><input type="submit" value="$search_label" /></p>
693693 </form>
694694
@@ -699,22 +699,22 @@
700700 * Print the line showing 'AND' values for a filter that has not
701701 * been applied to the drilldown
702702 */
703 - function printUnappliedFilterLine($f, $cur_url) {
 703+ function printUnappliedFilterLine( $f, $cur_url ) {
704704 global $sdgScriptPath;
705705 global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize;
706706
707707 $f->createTempTable();
708708 $found_results_for_filter = false;
709 - if (count($f->allowed_values) == 0) {
 709+ if ( count( $f->allowed_values ) == 0 ) {
710710 $filter_values = $f->getAllValues();
711 - if (count($filter_values) > 0)
 711+ if ( count( $filter_values ) > 0 )
712712 $found_results_for_filter = true;
713713 } else {
714714 $filter_values = array();
715 - foreach ($f->allowed_values as $value) {
716 - $new_filter = SDAppliedFilter::create($f, $value);
717 - $num_results = $this->getNumResults($this->subcategory, $this->all_subcategories, $new_filter);
718 - if ($num_results > 0) {
 715+ foreach ( $f->allowed_values as $value ) {
 716+ $new_filter = SDAppliedFilter::create( $f, $value );
 717+ $num_results = $this->getNumResults( $this->subcategory, $this->all_subcategories, $new_filter );
 718+ if ( $num_results > 0 ) {
719719 $filter_values[$value] = $num_results;
720720 }
721721 }
@@ -722,59 +722,59 @@
723723 // now get values for 'Other' and 'None', as well
724724 // - don't show 'Other' if filter values were
725725 // obtained dynamically
726 - if (count($f->allowed_values) > 0) {
727 - $other_filter = SDAppliedFilter::create($f, ' other');
728 - $num_results = $this->getNumResults($this->subcategory, $this->all_subcategories, $other_filter);
729 - if ($num_results > 0) {
 726+ if ( count( $f->allowed_values ) > 0 ) {
 727+ $other_filter = SDAppliedFilter::create( $f, ' other' );
 728+ $num_results = $this->getNumResults( $this->subcategory, $this->all_subcategories, $other_filter );
 729+ if ( $num_results > 0 ) {
730730 $filter_values['_other'] = $num_results;
731731 }
732732 }
733733 // show 'None' only if any other results have been found, and
734734 // if it's not a numeric filter
735 - if (count($f->allowed_values) > 0) {
736 - $fv = SDFilterValue::create($f->allowed_values[0]);
737 - if (! $fv->is_numeric) {
738 - $none_filter = SDAppliedFilter::create($f, ' none');
739 - $num_results = $this->getNumResults($this->subcategory, $this->all_subcategories, $none_filter);
740 - if ($num_results > 0) {
 735+ if ( count( $f->allowed_values ) > 0 ) {
 736+ $fv = SDFilterValue::create( $f->allowed_values[0] );
 737+ if ( ! $fv->is_numeric ) {
 738+ $none_filter = SDAppliedFilter::create( $f, ' none' );
 739+ $num_results = $this->getNumResults( $this->subcategory, $this->all_subcategories, $none_filter );
 740+ if ( $num_results > 0 ) {
741741 $filter_values['_none'] = $num_results;
742742 }
743743 }
744744 }
745745
746 - $filter_name = urlencode(str_replace(' ', '_', $f->name));
 746+ $filter_name = urlencode( str_replace( ' ', '_', $f->name ) );
747747 $normal_filter = true;
748 - if (count($filter_values) == 0) {
749 - $results_line = '(' . wfMsg('sd_browsedata_novalues') . ')';
 748+ if ( count( $filter_values ) == 0 ) {
 749+ $results_line = '(' . wfMsg( 'sd_browsedata_novalues' ) . ')';
750750 // for backward compatibility, also check against
751751 // 'sd_filter_freetext' (i.e. 'text' in English), which was
752752 // the old name of the input
753 - } elseif ($f->input_type == wfMsgForContent('sd_filter_combobox') ||
754 - $f->input_type == wfMsgForContent('sd_filter_freetext')) {
755 - $results_line = $this->printComboBoxInput($filter_name, $filter_values);
 753+ } elseif ( $f->input_type == wfMsgForContent( 'sd_filter_combobox' ) ||
 754+ $f->input_type == wfMsgForContent( 'sd_filter_freetext' ) ) {
 755+ $results_line = $this->printComboBoxInput( $filter_name, $filter_values );
756756 $normal_filter = false;
757 - } elseif ($f->input_type == wfMsgForContent('sd_filter_daterange')) {
758 - $results_line = $this->printDateRangeInput($filter_name);
 757+ } elseif ( $f->input_type == wfMsgForContent( 'sd_filter_daterange' ) ) {
 758+ $results_line = $this->printDateRangeInput( $filter_name );
759759 $normal_filter = false;
760760 } else
761 - $results_line = $this->printUnappliedFilterValues($cur_url, $f, $filter_values);
 761+ $results_line = $this->printUnappliedFilterValues( $cur_url, $f, $filter_values );
762762
763763 $text = "";
764 - $filter_label = $this->printFilterLabel($f->name);
765 - $results_div_id = strtolower(str_replace(' ', '_', $filter_label)) . "_values";
766 - $text .=<<<END
 764+ $filter_label = $this->printFilterLabel( $f->name );
 765+ $results_div_id = strtolower( str_replace( ' ', '_', $filter_label ) ) . "_values";
 766+ $text .= <<<END
767767 <div class="drilldown-filter-label">
768768
769769 END;
770770 // no point showing "minimize" arrow if it's just a
771771 // single text or date input
772 - if ($normal_filter) {
773 - $text .=<<<END
 772+ if ( $normal_filter ) {
 773+ $text .= <<<END
774774 <a onclick="toggleFilterDiv('$results_div_id', this)" style="cursor: default;"><img src="$sdgScriptPath/skins/down-arrow.png"></a>
775775
776776 END;
777777 }
778 - $text .=<<<END
 778+ $text .= <<<END
779779 $filter_label:
780780 </div>
781781 <div class="drilldown-filter-values" id="$results_div_id">$results_line
@@ -793,84 +793,84 @@
794794 $skin = $wgUser->getSkin();
795795 $categories = SDUtils::getTopLevelCategories();
796796 // if there are no categories, escape quickly
797 - if (count($categories) == 0) {
 797+ if ( count( $categories ) == 0 ) {
798798 return "";
799799 }
800 - $subcategory_text = wfMsg('sd_browsedata_subcategory');
 800+ $subcategory_text = wfMsg( 'sd_browsedata_subcategory' );
801801
802802 $header = "";
803 - $this->show_single_cat = $wgRequest->getCheck('_single');
804 - if (! $this->show_single_cat) {
805 - $header .= $this->printCategoriesList($categories);
 803+ $this->show_single_cat = $wgRequest->getCheck( '_single' );
 804+ if ( ! $this->show_single_cat ) {
 805+ $header .= $this->printCategoriesList( $categories );
806806 }
807807 // if there are no subcategories or filters for this
808808 // category, escape now that we've (possibly) printed the
809809 // categories list
810 - if ((count($this->next_level_subcategories) == 0) &&
811 - (count($this->applied_filters) == 0) &&
812 - (count($this->remaining_filters) == 0)) {
 810+ if ( ( count( $this->next_level_subcategories ) == 0 ) &&
 811+ ( count( $this->applied_filters ) == 0 ) &&
 812+ ( count( $this->remaining_filters ) == 0 ) ) {
813813 return $header;
814814 }
815815 $header .= ' <div id="drilldown-header">' . "\n";
816 - if (count ($this->applied_filters) > 0 || $this->subcategory) {
817 - $category_url = $this->makeBrowseURL($this->category);
818 - $header .= '<a href="' . $category_url . '" title="' . wfMsg('sd_browsedata_resetfilters') . '">' . str_replace('_', ' ', $this->category) . '</a>';
 816+ if ( count ( $this->applied_filters ) > 0 || $this->subcategory ) {
 817+ $category_url = $this->makeBrowseURL( $this->category );
 818+ $header .= '<a href="' . $category_url . '" title="' . wfMsg( 'sd_browsedata_resetfilters' ) . '">' . str_replace( '_', ' ', $this->category ) . '</a>';
819819 } else
820 - $header .= str_replace('_', ' ', $this->category);
821 - if ($this->subcategory) {
 820+ $header .= str_replace( '_', ' ', $this->category );
 821+ if ( $this->subcategory ) {
822822 $header .= " > ";
823823 $header .= "$subcategory_text: ";
824 - $subcat_string = str_replace('_', ' ', $this->subcategory);
825 - $remove_filter_url = $this->makeBrowseURL($this->category, $this->applied_filters);
826 - $header .= "\n" . ' <span class="drilldown-header-value">' . $subcat_string . '</span> <a href="' . $remove_filter_url . '" title="' . wfMsg('sd_browsedata_removesubcategoryfilter') . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>';
 824+ $subcat_string = str_replace( '_', ' ', $this->subcategory );
 825+ $remove_filter_url = $this->makeBrowseURL( $this->category, $this->applied_filters );
 826+ $header .= "\n" . ' <span class="drilldown-header-value">' . $subcat_string . '</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removesubcategoryfilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>';
827827 }
828 - foreach ($this->applied_filters as $i => $af) {
829 - $header .= (! $this->subcategory && $i == 0) ? " > " : "\n <span class=\"drilldown-header-value\">&</span> ";
830 - $filter_label = $this->printFilterLabel($af->filter->name);
 828+ foreach ( $this->applied_filters as $i => $af ) {
 829+ $header .= ( ! $this->subcategory && $i == 0 ) ? " > " : "\n <span class=\"drilldown-header-value\">&</span> ";
 830+ $filter_label = $this->printFilterLabel( $af->filter->name );
831831 // add an "x" to remove this filter, if it has more
832832 // than one value
833 - if (count($this->applied_filters[$i]->values) > 1) {
 833+ if ( count( $this->applied_filters[$i]->values ) > 1 ) {
834834 $temp_filters_array = $this->applied_filters;
835 - array_splice($temp_filters_array, $i, 1);
836 - $remove_filter_url = $this->makeBrowseURL($this->category, $temp_filters_array, $this->subcategory);
837 - array_splice($temp_filters_array, $i, 0);
838 - $header .= $filter_label . ' <a href="' . $remove_filter_url . '" title="' . wfMsg('sd_browsedata_removefilter') . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a> : ';
 835+ array_splice( $temp_filters_array, $i, 1 );
 836+ $remove_filter_url = $this->makeBrowseURL( $this->category, $temp_filters_array, $this->subcategory );
 837+ array_splice( $temp_filters_array, $i, 0 );
 838+ $header .= $filter_label . ' <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removefilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a> : ';
839839 } else {
840840 $header .= "$filter_label: ";
841841 }
842 - foreach ($af->values as $j => $fv) {
843 - if ($j > 0) {$header .= ' <span class="drilldown-or">' . wfMsg('sd_browsedata_or') . '</span> ';}
844 - $filter_text = $this->printFilterValue($af->filter, $fv->text);
 842+ foreach ( $af->values as $j => $fv ) {
 843+ if ( $j > 0 ) { $header .= ' <span class="drilldown-or">' . wfMsg( 'sd_browsedata_or' ) . '</span> '; }
 844+ $filter_text = $this->printFilterValue( $af->filter, $fv->text );
845845 $temp_filters_array = $this->applied_filters;
846 - $removed_values = array_splice($temp_filters_array[$i]->values, $j, 1);
847 - $remove_filter_url = $this->makeBrowseURL($this->category, $temp_filters_array, $this->subcategory);
848 - array_splice($temp_filters_array[$i]->values, $j, 0, $removed_values);
849 - $header .= "\n " . ' <span class="drilldown-header-value">' . $filter_text . '</span> <a href="' . $remove_filter_url . '" title="' . wfMsg('sd_browsedata_removefilter') . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>';
 846+ $removed_values = array_splice( $temp_filters_array[$i]->values, $j, 1 );
 847+ $remove_filter_url = $this->makeBrowseURL( $this->category, $temp_filters_array, $this->subcategory );
 848+ array_splice( $temp_filters_array[$i]->values, $j, 0, $removed_values );
 849+ $header .= "\n " . ' <span class="drilldown-header-value">' . $filter_text . '</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removefilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>';
850850 }
851 - if ($af->search_term != null) {
 851+ if ( $af->search_term != null ) {
852852 $temp_filters_array = $this->applied_filters;
853853 $removed_search_term = $temp_filters_array[$i]->search_term;
854854 $temp_filters_array[$i]->search_term = null;
855 - $remove_filter_url = $this->makeBrowseURL($this->category, $temp_filters_array, $this->subcategory);
 855+ $remove_filter_url = $this->makeBrowseURL( $this->category, $temp_filters_array, $this->subcategory );
856856 $temp_filters_array[$i]->search_term = $removed_search_term;
857 - $header .= "\n " . ' <span class="drilldown-header-value">~ \'' . $af->search_term . '\'</span> <a href="' . $remove_filter_url . '" title="' . wfMsg('sd_browsedata_removefilter') . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>';
858 - } elseif ($af->lower_date != null || $af->upper_date != null) {
 857+ $header .= "\n " . ' <span class="drilldown-header-value">~ \'' . $af->search_term . '\'</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removefilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>';
 858+ } elseif ( $af->lower_date != null || $af->upper_date != null ) {
859859 $header .= "\n <span class=\"drilldown-header-value\">" . $af->lower_date_string . " - " . $af->upper_date_string . "</span>";
860860 }
861861 }
862862 $header .= "</div>\n";
863 - $drilldown_description = wfMsg('sd_browsedata_docu');
 863+ $drilldown_description = wfMsg( 'sd_browsedata_docu' );
864864 $header .= " <p>$drilldown_description</p>\n";
865865 // display the list of subcategories on one line, and below
866866 // it every filter, each on its own line; each line will
867867 // contain the possible values, and, in parentheses, the
868868 // number of pages that match that value
869869 $header .= " <div class=\"drilldown-filters\">\n";
870 - $cur_url = $this->makeBrowseURL($this->category, $this->applied_filters, $this->subcategory);
871 - $cur_url .= (strpos($cur_url, '?')) ? '&' : '?';
872 - $this->createTempTable($this->category, $this->subcategory, $this->all_subcategories, $this->applied_filters);
 870+ $cur_url = $this->makeBrowseURL( $this->category, $this->applied_filters, $this->subcategory );
 871+ $cur_url .= ( strpos( $cur_url, '?' ) ) ? '&' : '?';
 872+ $this->createTempTable( $this->category, $this->subcategory, $this->all_subcategories, $this->applied_filters );
873873 $num_printed_values = 0;
874 - if (count($this->next_level_subcategories) > 0) {
 874+ if ( count( $this->next_level_subcategories ) > 0 ) {
875875 $results_line = "";
876876 // loop through to create an array of subcategory
877877 // names and their number of values, then loop through
@@ -878,47 +878,47 @@
879879 // instead of once, to be able to print a tag-cloud
880880 // display if necessary
881881 $subcat_values = array();
882 - foreach ($this->next_level_subcategories as $i => $subcat) {
883 - $further_subcats = SDUtils::getCategoryChildren($subcat, true, 10);
884 - $num_results = $this->getNumResults($subcat, $further_subcats);
 882+ foreach ( $this->next_level_subcategories as $i => $subcat ) {
 883+ $further_subcats = SDUtils::getCategoryChildren( $subcat, true, 10 );
 884+ $num_results = $this->getNumResults( $subcat, $further_subcats );
885885 $subcat_values[$subcat] = $num_results;
886886 }
887887 // get necessary values for creating the tag cloud,
888888 // if appropriate
889 - if ($sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0) {
890 - $lowest_num_results = min($subcat_values);
891 - $highest_num_results = max($subcat_values);
892 - $num_results_midpoint = ($lowest_num_results + $highest_num_results) / 2;
893 - $font_size_midpoint = ($sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize) / 2;
894 - $num_results_per_font_pixel = ($highest_num_results + 1 - $lowest_num_results) / ($sdgFiltersLargestFontSize + 1 - $sdgFiltersSmallestFontSize);
 889+ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) {
 890+ $lowest_num_results = min( $subcat_values );
 891+ $highest_num_results = max( $subcat_values );
 892+ $num_results_midpoint = ( $lowest_num_results + $highest_num_results ) / 2;
 893+ $font_size_midpoint = ( $sdgFiltersSmallestFontSize + $sdgFiltersLargestFontSize ) / 2;
 894+ $num_results_per_font_pixel = ( $highest_num_results + 1 - $lowest_num_results ) / ( $sdgFiltersLargestFontSize + 1 - $sdgFiltersSmallestFontSize );
895895 }
896896
897 - foreach ($subcat_values as $subcat => $num_results) {
898 - if ($num_results > 0) {
899 - if ($num_printed_values++ > 0) { $results_line .= " &middot; "; }
900 - $filter_text = str_replace('_', ' ', $subcat) . " ($num_results)";
901 - $filter_url = $cur_url . '_subcat=' . urlencode($subcat);
902 - if ($sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0) {
903 - $font_size = round($font_size_midpoint + (($num_results - $num_results_midpoint) / $num_results_per_font_pixel));
904 - $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg('sd_browsedata_filterbysubcategory') . '" style="font-size: ' . $font_size . 'px">' . $filter_text . '</a>';
 897+ foreach ( $subcat_values as $subcat => $num_results ) {
 898+ if ( $num_results > 0 ) {
 899+ if ( $num_printed_values++ > 0 ) { $results_line .= " &middot; "; }
 900+ $filter_text = str_replace( '_', ' ', $subcat ) . " ($num_results)";
 901+ $filter_url = $cur_url . '_subcat=' . urlencode( $subcat );
 902+ if ( $sdgFiltersSmallestFontSize > 0 && $sdgFiltersLargestFontSize > 0 ) {
 903+ $font_size = round( $font_size_midpoint + ( ( $num_results - $num_results_midpoint ) / $num_results_per_font_pixel ) );
 904+ $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg( 'sd_browsedata_filterbysubcategory' ) . '" style="font-size: ' . $font_size . 'px">' . $filter_text . '</a>';
905905 } else {
906 - $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg('sd_browsedata_filterbysubcategory') . '">' . $filter_text . '</a>';
 906+ $results_line .= "\n " . '<a href="' . $filter_url . '" title="' . wfMsg( 'sd_browsedata_filterbysubcategory' ) . '">' . $filter_text . '</a>';
907907 }
908908 }
909909 }
910 - if ($results_line != "") {
 910+ if ( $results_line != "" ) {
911911 $header .= " <p><strong>$subcategory_text:</strong> $results_line</p>\n";
912912 }
913913 }
914 - $filters = SDUtils::loadFiltersForCategory($this->category);
915 - foreach ($filters as $f) {
916 - foreach ($this->applied_filters as $af) {
917 - if ($af->filter->name == $f->name)
918 - $header .= $this->printAppliedFilterLine($af);
 914+ $filters = SDUtils::loadFiltersForCategory( $this->category );
 915+ foreach ( $filters as $f ) {
 916+ foreach ( $this->applied_filters as $af ) {
 917+ if ( $af->filter->name == $f->name )
 918+ $header .= $this->printAppliedFilterLine( $af );
919919 }
920 - foreach ($this->remaining_filters as $rf) {
921 - if ($rf->name == $f->name)
922 - $header .= $this->printUnappliedFilterLine($rf, $cur_url);
 920+ foreach ( $this->remaining_filters as $rf ) {
 921+ if ( $rf->name == $f->name )
 922+ $header .= $this->printUnappliedFilterLine( $rf, $cur_url );
923923 }
924924 }
925925 $header .= " </div> <!-- drilldown-filters -->\n";
@@ -930,15 +930,15 @@
931931 */
932932 function linkParameters() {
933933 $params = array();
934 - if ($this->show_single_cat)
 934+ if ( $this->show_single_cat )
935935 $params['_single'] = null;
936936 $params['_cat'] = $this->category;
937 - if ($this->subcategory)
 937+ if ( $this->subcategory )
938938 $params['_subcat'] = $this->subcategory;
939 - foreach ($this->applied_filters as $i => $af) {
940 - if (count($af->values) == 1) {
941 - $key_string = str_replace(' ', '_', $af->filter->name);
942 - $value_string = str_replace(' ', '_', $af->values[0]->text);
 939+ foreach ( $this->applied_filters as $i => $af ) {
 940+ if ( count( $af->values ) == 1 ) {
 941+ $key_string = str_replace( ' ', '_', $af->filter->name );
 942+ $value_string = str_replace( ' ', '_', $af->values[0]->text );
943943 $params[$key_string] = $value_string;
944944 } else {
945945 // HACK - QueryPage's pagination-URL code,
@@ -946,9 +946,9 @@
947947 // two-dimensional arrays, which is what we
948948 // need - instead, add the brackets directly
949949 // to the key string
950 - foreach ($af->values as $i => $value) {
951 - $key_string = str_replace(' ', '_', $af->filter->name . "[$i]");
952 - $value_string = str_replace(' ', '_', $value->text);
 950+ foreach ( $af->values as $i => $value ) {
 951+ $key_string = str_replace( ' ', '_', $af->filter->name . "[$i]" );
 952+ $value_string = str_replace( ' ', '_', $value->text );
953953 $params[$key_string] = $value_string;
954954 }
955955 }
@@ -967,7 +967,7 @@
968968 ids.smw_id AS id,
969969 ids.smw_iw AS iw,
970970 ids.smw_sortkey AS sortkey\n";
971 - $sql .= $this->getSQLFromClause($this->category, $this->subcategory, $this->all_subcategories, $this->applied_filters);
 971+ $sql .= $this->getSQLFromClause( $this->category, $this->subcategory, $this->all_subcategories, $this->applied_filters );
972972 return $sql;
973973 }
974974
@@ -975,7 +975,7 @@
976976 return ' ORDER BY sortkey ';
977977 }
978978
979 - function formatResult($skin, $result) {
 979+ function formatResult( $skin, $result ) {
980980 $title = Title::makeTitle( $result->namespace, $result->value );
981981 return $skin->makeLinkObj( $title, $title->getText() );
982982 }
@@ -994,29 +994,29 @@
995995 protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
996996 global $wgContLang;
997997
998 - $all_display_params = SDUtils::getDisplayParamsForCategory($this->category);
 998+ $all_display_params = SDUtils::getDisplayParamsForCategory( $this->category );
999999 $querystring = null;
10001000 $printouts = $params = array();
10011001 // only one set of params is handled for now
1002 - if (count($all_display_params) > 0) {
1003 - $display_params = array_map('trim', $all_display_params[0]);
1004 - SMWQueryProcessor::processFunctionParams($display_params, $querystring, $params, $printouts);
 1002+ if ( count( $all_display_params ) > 0 ) {
 1003+ $display_params = array_map( 'trim', $all_display_params[0] );
 1004+ SMWQueryProcessor::processFunctionParams( $display_params, $querystring, $params, $printouts );
10051005 }
1006 - $query = SMWQueryProcessor::createQuery($querystring, $params);
1007 - if (array_key_exists('format', $params))
 1006+ $query = SMWQueryProcessor::createQuery( $querystring, $params );
 1007+ if ( array_key_exists( 'format', $params ) )
10081008 $format = $params['format'];
10091009 else
10101010 $format = 'category';
1011 - if (array_key_exists('mainlabel', $params)) {
 1011+ if ( array_key_exists( 'mainlabel', $params ) ) {
10121012 $mainlabel = $params['mainlabel'];
10131013 } else {
10141014 $mainlabel = '';
10151015 }
1016 - $r = $this->addSemanticResultWrapper($dbr, $res, $num, $query, $mainlabel, $printouts);
1017 - $printer = SMWQueryProcessor::getResultPrinter($format, SMWQueryProcessor::SPECIAL_PAGE, $r);
 1016+ $r = $this->addSemanticResultWrapper( $dbr, $res, $num, $query, $mainlabel, $printouts );
 1017+ $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE, $r );
10181018
1019 - $prresult = $printer->getResult($r, $params, SMW_OUTPUT_HTML);
1020 - if (is_array($prresult))
 1019+ $prresult = $printer->getResult( $r, $params, SMW_OUTPUT_HTML );
 1020+ if ( is_array( $prresult ) )
10211021 $prtext = $prresult[0];
10221022 else
10231023 $prtext = $prresult;
@@ -1026,9 +1026,9 @@
10271027 // headItems of $out.
10281028 // How else can we do this?
10291029 global $wgParser;
1030 - SMWOutputs::commitToParser($wgParser);
 1030+ SMWOutputs::commitToParser( $wgParser );
10311031 foreach ( $wgParser->mOutput->mHeadItems as $key => $item ) {
1032 - $out->addHeadItem($key, $item);
 1032+ $out->addHeadItem( $key, $item );
10331033 }
10341034 // Force one more parser function, so links appear.
10351035 $wgParser->replaceLinkHolders( $prtext );
@@ -1036,7 +1036,7 @@
10371037 $html = array();
10381038 $html[] = $prtext;
10391039
1040 - if( !$this->listoutput )
 1040+ if ( !$this->listoutput )
10411041 $html[] = $this->closeList();
10421042
10431043 $html = $this->listoutput
@@ -1048,19 +1048,19 @@
10491049 // add Ext library, to enable combobox, unless a map is being
10501050 // displayed - the Javascript for Ext conflicts with the
10511051 // Javascript for the maps
1052 - if ($format != 'openlayers' || strpos($format, 'map') !== false) {
 1052+ if ( $format != 'openlayers' || strpos( $format, 'map' ) !== false ) {
10531053 global $sdgScriptPath;
10541054 $out->addLink( array(
10551055 'rel' => 'stylesheet',
10561056 'type' => 'text/css',
10571057 'media' => "screen",
10581058 'href' => $sdgScriptPath . '/skins/ext-all.css'
1059 - ));
 1059+ ) );
10601060 // overwrite style from ext-all.css, to set the correct
10611061 // image for the combobox arrow
1062 - $out->addScript("<style>.x-form-field-wrap .x-form-trigger{background:transparent url($sdgScriptPath/skins/trigger.gif) no-repeat 0 0;}</style>");
1063 - $out->addScript('<script type="text/javascript" src="' . $sdgScriptPath . '/libs/ext-base.js"></script>');
1064 - $out->addScript('<script type="text/javascript" src="' . $sdgScriptPath . '/libs/ext-all.js"></script>');
 1062+ $out->addScript( "<style>.x-form-field-wrap .x-form-trigger{background:transparent url($sdgScriptPath/skins/trigger.gif) no-repeat 0 0;}</style>" );
 1063+ $out->addScript( '<script type="text/javascript" src="' . $sdgScriptPath . '/libs/ext-base.js"></script>' );
 1064+ $out->addScript( '<script type="text/javascript" src="' . $sdgScriptPath . '/libs/ext-all.js"></script>' );
10651065 }
10661066 }
10671067
@@ -1069,70 +1069,70 @@
10701070 // semantic result printers.
10711071 // Code stolen largely from SMWSQLStore2QueryEngine->getInstanceQueryResult() method.
10721072 // (does this mean it will only work with certain semantic SQL stores?)
1073 - function addSemanticResultWrapper($dbr, $res, $num, $query, $mainlabel, $printouts) {
 1073+ function addSemanticResultWrapper( $dbr, $res, $num, $query, $mainlabel, $printouts ) {
10741074 $qr = array();
10751075 $count = 0;
10761076 $store = smwfGetStore();
1077 - while ( ($count < $num) && ($row = $dbr->fetchObject($res)) ) {
 1077+ while ( ( $count < $num ) && ( $row = $dbr->fetchObject( $res ) ) ) {
10781078 $count++;
1079 - $v = SMWWikiPageValue::makePage($row->t, $row->ns, $row->sortkey);
 1079+ $v = SMWWikiPageValue::makePage( $row->t, $row->ns, $row->sortkey );
10801080 $qr[] = $v;
1081 - $store->cacheSMWPageID($row->id,$row->t,$row->ns,$row->iw);
 1081+ $store->cacheSMWPageID( $row->id, $row->t, $row->ns, $row->iw );
10821082 }
1083 - if ($dbr->fetchObject($res)) {
 1083+ if ( $dbr->fetchObject( $res ) ) {
10841084 $count++;
10851085 }
1086 - $dbr->freeResult($res);
 1086+ $dbr->freeResult( $res );
10871087
1088 - $printrequest = new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, $mainlabel);
 1088+ $printrequest = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $mainlabel );
10891089 $main_printout = array();
10901090 $main_printout[$printrequest->getHash()] = $printrequest;
1091 - $printouts = array_merge($main_printout, $printouts);
 1091+ $printouts = array_merge( $main_printout, $printouts );
10921092
10931093 // for SMW 1.5+, handling is quite easy
1094 - if (! class_exists('SMWTemplateResultPrinter')) {
1095 - return new SMWQueryResult($printouts, $query, $qr, $store, ($count > $num) );
 1094+ if ( ! class_exists( 'SMWTemplateResultPrinter' ) ) {
 1095+ return new SMWQueryResult( $printouts, $query, $qr, $store, ( $count > $num ) );
10961096 }
1097 - $result = new SMWQueryResult($printouts, $query, ($count > $num) );
1098 - foreach ($qr as $qt) {
 1097+ $result = new SMWQueryResult( $printouts, $query, ( $count > $num ) );
 1098+ foreach ( $qr as $qt ) {
10991099 $row = array();
11001100 $cats = false;
1101 - foreach ($printouts as $pr) {
1102 - switch ($pr->getMode()) {
 1101+ foreach ( $printouts as $pr ) {
 1102+ switch ( $pr->getMode() ) {
11031103 case SMWPrintRequest::PRINT_THIS:
1104 - $row[] = new SMWResultArray(array($qt), $pr);
 1104+ $row[] = new SMWResultArray( array( $qt ), $pr );
11051105 break;
11061106 case SMWPrintRequest::PRINT_CATS:
1107 - if ($cats === false) {
1108 - $cats = $store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST'));
 1107+ if ( $cats === false ) {
 1108+ $cats = $store->getPropertyValues( $qt, SMWPropertyValue::makeProperty( '_INST' ) );
11091109 }
1110 - $row[] = new SMWResultArray($cats, $pr);
 1110+ $row[] = new SMWResultArray( $cats, $pr );
11111111 break;
11121112 case SMWPrintRequest::PRINT_PROP:
1113 - $row[] = new SMWResultArray($store->getPropertyValues($qt,$pr->getData(), null, $pr->getOutputFormat()), $pr);
 1113+ $row[] = new SMWResultArray( $store->getPropertyValues( $qt, $pr->getData(), null, $pr->getOutputFormat() ), $pr );
11141114 break;
11151115 case SMWPrintRequest::PRINT_CCAT:
1116 - if ($cats === false) {
1117 - $cats = $store->getPropertyValues($qt,SMWPropertyValue::makeProperty('_INST'));
 1116+ if ( $cats === false ) {
 1117+ $cats = $store->getPropertyValues( $qt, SMWPropertyValue::makeProperty( '_INST' ) );
11181118 }
11191119 $found = '0';
11201120 $prkey = $pr->getData()->getDBkey();
1121 - foreach ($cats as $cat) {
1122 - if ($cat->getDBkey() == $prkey) {
 1121+ foreach ( $cats as $cat ) {
 1122+ if ( $cat->getDBkey() == $prkey ) {
11231123 $found = '1';
11241124 break;
11251125 }
11261126 }
1127 - $dv = SMWDataValueFactory::newTypeIDValue('_boo');
1128 - $dv->setOutputFormat($pr->getOutputFormat());
1129 - $dv->setDBkeys(array($found));
1130 - $row[] = new SMWResultArray(array($dv), $pr);
 1127+ $dv = SMWDataValueFactory::newTypeIDValue( '_boo' );
 1128+ $dv->setOutputFormat( $pr->getOutputFormat() );
 1129+ $dv->setDBkeys( array( $found ) );
 1130+ $row[] = new SMWResultArray( array( $dv ), $pr );
11311131 break;
11321132 }
11331133 }
1134 - $result->addRow($row);
 1134+ $result->addRow( $row );
11351135 }
1136 - wfProfileOut('SMWSQLStore2Queries::getInstanceQueryResult (SMW)');
 1136+ wfProfileOut( 'SMWSQLStore2Queries::getInstanceQueryResult (SMW)' );
11371137 return $result;
11381138 }
11391139
Index: trunk/extensions/SemanticDrilldown/includes/SD_AppliedFilter.php
@@ -15,23 +15,23 @@
1616 var $lower_date_string;
1717 var $upper_date_string;
1818
19 - function create($filter, $values, $search_term = null, $lower_date = null, $upper_date = null) {
 19+ function create( $filter, $values, $search_term = null, $lower_date = null, $upper_date = null ) {
2020 $af = new SDAppliedFilter();
2121 $af->filter = $filter;
22 - $af->search_term = htmlspecialchars(str_replace('_', ' ', $search_term));
23 - if ($lower_date != null) {
 22+ $af->search_term = htmlspecialchars( str_replace( '_', ' ', $search_term ) );
 23+ if ( $lower_date != null ) {
2424 $af->lower_date = $lower_date;
25 - $af->lower_date_string = SDUtils::monthToString($lower_date['month']) . " " . $lower_date['day'] . ", " . $lower_date['year'];
 25+ $af->lower_date_string = SDUtils::monthToString( $lower_date['month'] ) . " " . $lower_date['day'] . ", " . $lower_date['year'];
2626 }
27 - if ($upper_date != null) {
 27+ if ( $upper_date != null ) {
2828 $af->upper_date = $upper_date;
29 - $af->upper_date_string = SDUtils::monthToString($upper_date['month']) . " " . $upper_date['day'] . ", " . $upper_date['year'];
 29+ $af->upper_date_string = SDUtils::monthToString( $upper_date['month'] ) . " " . $upper_date['day'] . ", " . $upper_date['year'];
3030 }
31 - if (! is_array($values)) {
32 - $values = array($values);
 31+ if ( ! is_array( $values ) ) {
 32+ $values = array( $values );
3333 }
34 - foreach ($values as $val) {
35 - $filter_val = SDFilterValue::create($val, $filter->time_period);
 34+ foreach ( $values as $val ) {
 35+ $filter_val = SDFilterValue::create( $val, $filter->time_period );
3636 $af->values[] = $filter_val;
3737 }
3838 return $af;
@@ -41,57 +41,57 @@
4242 * Returns a string that adds a check for this filter/value
4343 * combination to an SQL "WHERE" clause.
4444 */
45 - function checkSQL($value_field) {
 45+ function checkSQL( $value_field ) {
4646 $sql = "(";
4747 $dbr = wfGetDB( DB_SLAVE );
48 - if ($this->search_term != null) {
49 - if ($this->filter->is_relation) {
50 - $search_term = strtolower(str_replace(' ', '_', $this->search_term));
 48+ if ( $this->search_term != null ) {
 49+ if ( $this->filter->is_relation ) {
 50+ $search_term = strtolower( str_replace( ' ', '_', $this->search_term ) );
5151 $sql .= "LOWER($value_field) LIKE '%{$search_term}%'";
5252 } else {
53 - $search_term = strtolower($this->search_term);
 53+ $search_term = strtolower( $this->search_term );
5454 $sql .= "LOWER($value_field) LIKE '%{$search_term}%'";
5555 }
5656 }
57 - if ($this->lower_date != null) {
 57+ if ( $this->lower_date != null ) {
5858 $date_string = $this->lower_date['year'] . "-" . $this->lower_date['month'] . "-" . $this->lower_date['day'];
5959 $sql .= "date($value_field) >= date('$date_string') ";
6060 }
61 - if ($this->upper_date != null) {
62 - if ($this->lower_date != null) {
 61+ if ( $this->upper_date != null ) {
 62+ if ( $this->lower_date != null ) {
6363 $sql .= " AND ";
6464 }
6565 $date_string = $this->upper_date['year'] . "-" . $this->upper_date['month'] . "-" . $this->upper_date['day'];
6666 $sql .= "date($value_field) <= date('$date_string') ";
6767 }
68 - foreach ($this->values as $i => $fv) {
69 - if ($i > 0) {$sql .= " OR ";}
70 - if ($fv->is_other) {
 68+ foreach ( $this->values as $i => $fv ) {
 69+ if ( $i > 0 ) { $sql .= " OR "; }
 70+ if ( $fv->is_other ) {
7171 $sql .= "(! ($value_field IS NULL OR $value_field = '' ";
72 - foreach ($this->filter->possible_applied_filters as $paf) {
 72+ foreach ( $this->filter->possible_applied_filters as $paf ) {
7373 $sql .= " OR ";
74 - $sql .= $paf->checkSQL($value_field);
 74+ $sql .= $paf->checkSQL( $value_field );
7575 }
7676 $sql .= "))";
77 - } elseif ($fv->is_none) {
 77+ } elseif ( $fv->is_none ) {
7878 $sql .= "($value_field = '' OR $value_field IS NULL) ";
79 - } elseif ($fv->is_numeric) {
80 - if ($fv->lower_limit && $fv->upper_limit)
 79+ } elseif ( $fv->is_numeric ) {
 80+ if ( $fv->lower_limit && $fv->upper_limit )
8181 $sql .= "($value_field >= {$fv->lower_limit} AND $value_field <= {$fv->upper_limit}) ";
82 - elseif ($fv->lower_limit)
 82+ elseif ( $fv->lower_limit )
8383 $sql .= "$value_field > {$fv->lower_limit} ";
84 - elseif ($fv->upper_limit)
 84+ elseif ( $fv->upper_limit )
8585 $sql .= "$value_field < {$fv->upper_limit} ";
86 - } elseif ($this->filter->time_period != null) {
87 - if ($this->filter->time_period == wfMsg('sd_filter_month')) {
 86+ } elseif ( $this->filter->time_period != null ) {
 87+ if ( $this->filter->time_period == wfMsg( 'sd_filter_month' ) ) {
8888 $sql .= "YEAR($value_field) = {$fv->year} AND MONTH($value_field) = {$fv->month} ";
8989 } else {
9090 $sql .= "YEAR($value_field) = {$fv->year} ";
9191 }
9292 } else {
9393 $value = $fv->text;
94 - if ($this->filter->is_relation) {
95 - $value = str_replace(' ', '_', $value);
 94+ if ( $this->filter->is_relation ) {
 95+ $value = str_replace( ' ', '_', $value );
9696 }
9797 $sql .= "$value_field = '{$dbr->strencode($value)}'";
9898 }
@@ -105,21 +105,21 @@
106106 * Gets an array of all values that the property belonging to this
107107 * filter has, for pages in the passed-in category.
108108 */
109 - function getAllOrValues($category) {
 109+ function getAllOrValues( $category ) {
110110 $possible_values = array();
111 - $property_value = str_replace(' ', '_', $this->filter->property);
 111+ $property_value = str_replace( ' ', '_', $this->filter->property );
112112 $dbr = wfGetDB( DB_SLAVE );
113 - if ($this->filter->is_relation) {
114 - $property_table_name = $dbr->tableName('smw_rels2');
 113+ if ( $this->filter->is_relation ) {
 114+ $property_table_name = $dbr->tableName( 'smw_rels2' );
115115 $property_table_nickname = "r";
116116 $value_field = 'o_ids.smw_title';
117117 } else {
118 - $property_table_name = $dbr->tableName('smw_atts2');
 118+ $property_table_name = $dbr->tableName( 'smw_atts2' );
119119 $property_table_nickname = "a";
120120 $value_field = 'value_xsd';
121121 }
122 - if ($this->filter->time_period != null) {
123 - if ($this->filter->time_period == wfMsg('sd_filter_month')) {
 122+ if ( $this->filter->time_period != null ) {
 123+ if ( $this->filter->time_period == wfMsg( 'sd_filter_month' ) ) {
124124 $value_field = "YEAR(value_xsd), MONTH(value_xsd)";
125125 } else {
126126 $value_field = "YEAR(value_xsd)";
@@ -131,7 +131,7 @@
132132 $sql = " SELECT $value_field
133133 FROM $property_table_name $property_table_nickname
134134 JOIN $smw_ids p_ids ON $property_table_nickname.p_id = p_ids.smw_id\n";
135 - if ($this->filter->is_relation) {
 135+ if ( $this->filter->is_relation ) {
136136 $sql .= " JOIN $smw_ids o_ids ON $property_table_nickname.o_id = o_ids.smw_id\n";
137137 }
138138 $sql .= " JOIN $smw_insts insts ON $property_table_nickname.s_id = insts.s_id
@@ -141,16 +141,16 @@
142142 AND cat_ids.smw_title = '$category'
143143 GROUP BY $value_field
144144 ORDER BY $value_field";
145 - $res = $dbr->query($sql);
146 - while ($row = $dbr->fetchRow($res)) {
147 - if ($this->filter->time_period == wfMsg('sd_filter_month'))
148 - $value_string = SDUtils::monthToString($row[1]) . " " . $row[0];
 145+ $res = $dbr->query( $sql );
 146+ while ( $row = $dbr->fetchRow( $res ) ) {
 147+ if ( $this->filter->time_period == wfMsg( 'sd_filter_month' ) )
 148+ $value_string = SDUtils::monthToString( $row[1] ) . " " . $row[0];
149149 else
150150 // why is trim() necessary here???
151 - $value_string = str_replace('_', ' ', trim($row[0]));
 151+ $value_string = str_replace( '_', ' ', trim( $row[0] ) );
152152 $possible_values[] = $value_string;
153153 }
154 - $dbr->freeResult($res);
 154+ $dbr->freeResult( $res );
155155 return $possible_values;
156156 }
157157
Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php
@@ -18,58 +18,58 @@
1919 var $allowed_values;
2020 var $possible_applied_filters = array();
2121
22 - function load($filter_name) {
 22+ function load( $filter_name ) {
2323 $f = new SDFilter();
2424 $f->name = $filter_name;
25 - $properties_used = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_CP', SD_SP_COVERS_PROPERTY, SMW_NS_PROPERTY);
26 - if (count($properties_used) > 0) {
 25+ $properties_used = SDUtils::getValuesForProperty( $filter_name, SD_NS_FILTER, '_SD_CP', SD_SP_COVERS_PROPERTY, SMW_NS_PROPERTY );
 26+ if ( count( $properties_used ) > 0 ) {
2727 $f->property = $properties_used[0];
2828 }
2929 $f->is_relation = true;
30 - $proptitle = Title::newFromText($f->property, SMW_NS_PROPERTY);
31 - if ($proptitle != null) {
 30+ $proptitle = Title::newFromText( $f->property, SMW_NS_PROPERTY );
 31+ if ( $proptitle != null ) {
3232 $store = smwfGetStore();
33 - if (class_exists('SMWPropertyValue')) {
34 - $types = $store->getPropertyValues($proptitle, SMWPropertyValue::makeUserProperty('Has type'));
 33+ if ( class_exists( 'SMWPropertyValue' ) ) {
 34+ $types = $store->getPropertyValues( $proptitle, SMWPropertyValue::makeUserProperty( 'Has type' ) );
3535 } else {
36 - $types = $store->getSpecialValues($proptitle, SMW_SP_HAS_TYPE);
 36+ $types = $store->getSpecialValues( $proptitle, SMW_SP_HAS_TYPE );
3737 }
3838 global $smwgContLang;
3939 $datatypeLabels = $smwgContLang->getDatatypeLabels();
40 - if (count($types) > 0) {
41 - if ($types[0]->getWikiValue() != $datatypeLabels['_wpg']) {
 40+ if ( count( $types ) > 0 ) {
 41+ if ( $types[0]->getWikiValue() != $datatypeLabels['_wpg'] ) {
4242 $f->is_relation = false;
4343 }
44 - if ($types[0]->getWikiValue() == $datatypeLabels['_boo']) {
 44+ if ( $types[0]->getWikiValue() == $datatypeLabels['_boo'] ) {
4545 $f->is_boolean = true;
4646 }
47 - if ($types[0]->getWikiValue() == $datatypeLabels['_dat']) {
 47+ if ( $types[0]->getWikiValue() == $datatypeLabels['_dat'] ) {
4848 $f->is_date = true;
4949 }
5050 }
5151 }
52 - $categories = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_VC', SD_SP_GETS_VALUES_FROM_CATEGORY, NS_CATEGORY);
53 - $time_periods = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_TP', SD_SP_USES_TIME_PERIOD, null);
54 - if (count($categories) > 0) {
 52+ $categories = SDUtils::getValuesForProperty( $filter_name, SD_NS_FILTER, '_SD_VC', SD_SP_GETS_VALUES_FROM_CATEGORY, NS_CATEGORY );
 53+ $time_periods = SDUtils::getValuesForProperty( $filter_name, SD_NS_FILTER, '_SD_TP', SD_SP_USES_TIME_PERIOD, null );
 54+ if ( count( $categories ) > 0 ) {
5555 $f->category = $categories[0];
56 - $f->allowed_values = SDUtils::getCategoryChildren($f->category, false, 5);
57 - } elseif (count($time_periods) > 0) {
 56+ $f->allowed_values = SDUtils::getCategoryChildren( $f->category, false, 5 );
 57+ } elseif ( count( $time_periods ) > 0 ) {
5858 $f->time_period = $time_periods[0];
5959 $f->allowed_values = array();
60 - } elseif ($f->is_boolean) {
61 - $f->allowed_values = array('0', '1');
 60+ } elseif ( $f->is_boolean ) {
 61+ $f->allowed_values = array( '0', '1' );
6262 } else {
63 - $values = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_V', SD_SP_HAS_VALUE, null);
 63+ $values = SDUtils::getValuesForProperty( $filter_name, SD_NS_FILTER, '_SD_V', SD_SP_HAS_VALUE, null );
6464 $f->allowed_values = $values;
6565 }
66 - $input_types = SDUtils::getValuesForProperty($filter_name, SD_NS_FILTER, '_SD_IT', SD_SP_HAS_INPUT_TYPE, null);
67 - if (count($input_types) > 0) {
 66+ $input_types = SDUtils::getValuesForProperty( $filter_name, SD_NS_FILTER, '_SD_IT', SD_SP_HAS_INPUT_TYPE, null );
 67+ if ( count( $input_types ) > 0 ) {
6868 $f->input_type = $input_types[0];
6969 }
7070 // set list of possible applied filters if allowed values
7171 // array was set
72 - foreach($f->allowed_values as $allowed_value) {
73 - $f->possible_applied_filters[] = SDAppliedFilter::create($f, $allowed_value);
 72+ foreach ( $f->allowed_values as $allowed_value ) {
 73+ $f->possible_applied_filters[] = SDAppliedFilter::create( $f, $allowed_value );
7474 }
7575 return $f;
7676 }
@@ -81,16 +81,16 @@
8282 */
8383 function getTimePeriodValues() {
8484 $possible_dates = array();
85 - $property_value = str_replace(' ', '_', $this->property);
 85+ $property_value = str_replace( ' ', '_', $this->property );
8686 $dbr = wfGetDB( DB_SLAVE );
87 - if ($this->time_period == wfMsg('sd_filter_month')) {
 87+ if ( $this->time_period == wfMsg( 'sd_filter_month' ) ) {
8888 $fields = "YEAR(value_xsd), MONTH(value_xsd)";
8989 } else {
9090 $fields = "YEAR(value_xsd)";
9191 }
9292 $smw_attributes = $dbr->tableName( 'smw_atts2' );
9393 $smw_ids = $dbr->tableName( 'smw_ids' );
94 - $sql =<<<END
 94+ $sql = <<<END
9595 SELECT $fields, count(*)
9696 FROM semantic_drilldown_values sdv
9797 JOIN $smw_attributes a ON sdv.id = a.s_id
@@ -100,18 +100,18 @@
101101 ORDER BY $fields
102102
103103 END;
104 - $res = $dbr->query($sql);
105 - while ($row = $dbr->fetchRow($res)) {
106 - if ($this->time_period == wfMsg('sd_filter_month')) {
 104+ $res = $dbr->query( $sql );
 105+ while ( $row = $dbr->fetchRow( $res ) ) {
 106+ if ( $this->time_period == wfMsg( 'sd_filter_month' ) ) {
107107 global $sdgMonthValues;
108 - $date_string = SDUtils::monthToString($row[1]) . " " . $row[0];
 108+ $date_string = SDUtils::monthToString( $row[1] ) . " " . $row[0];
109109 $possible_dates[$date_string] = $row[2];
110110 } else {
111111 $date_string = $row[0];
112112 $possible_dates[$date_string] = $row[1];
113113 }
114114 }
115 - $dbr->freeResult($res);
 115+ $dbr->freeResult( $res );
116116 return $possible_dates;
117117 }
118118
@@ -121,33 +121,33 @@
122122 * that match that value.
123123 */
124124 function getAllValues() {
125 - if ($this->time_period != null)
 125+ if ( $this->time_period != null )
126126 return $this->getTimePeriodValues();
127127
128128 $possible_values = array();
129 - $property_value = str_replace(' ', '_', $this->property);
 129+ $property_value = str_replace( ' ', '_', $this->property );
130130 $dbr = wfGetDB( DB_SLAVE );
131 - if ($this->is_relation) {
132 - $property_table_name = $dbr->tableName('smw_rels2');
 131+ if ( $this->is_relation ) {
 132+ $property_table_name = $dbr->tableName( 'smw_rels2' );
133133 $property_table_nickname = "r";
134134 $value_field = 'o_ids.smw_title';
135135 } else {
136 - $property_table_name = $dbr->tableName('smw_atts2');
 136+ $property_table_name = $dbr->tableName( 'smw_atts2' );
137137 $property_table_nickname = "a";
138138 $value_field = 'value_xsd';
139139 }
140140 $smw_ids = $dbr->tableName( 'smw_ids' );
141141 $prop_ns = SMW_NS_PROPERTY;
142 - $sql =<<<END
 142+ $sql = <<<END
143143 SELECT $value_field, count(DISTINCT sdv.id)
144144 FROM semantic_drilldown_values sdv
145145 JOIN $property_table_name $property_table_nickname ON sdv.id = $property_table_nickname.s_id
146146
147147 END;
148 - if ($this->is_relation) {
 148+ if ( $this->is_relation ) {
149149 $sql .= " JOIN $smw_ids o_ids ON r.o_id = o_ids.smw_id";
150150 }
151 - $sql .=<<<END
 151+ $sql .= <<<END
152152 JOIN $smw_ids p_ids ON $property_table_nickname.p_id = p_ids.smw_id
153153 WHERE p_ids.smw_title = '$property_value'
154154 AND p_ids.smw_namespace = $prop_ns
@@ -156,12 +156,12 @@
157157 ORDER BY $value_field
158158
159159 END;
160 - $res = $dbr->query($sql);
161 - while ($row = $dbr->fetchRow($res)) {
162 - $value_string = str_replace('_', ' ', $row[0]);
 160+ $res = $dbr->query( $sql );
 161+ while ( $row = $dbr->fetchRow( $res ) ) {
 162+ $value_string = str_replace( '_', ' ', $row[0] );
163163 $possible_values[$value_string] = $row[1];
164164 }
165 - $dbr->freeResult($res);
 165+ $dbr->freeResult( $res );
166166 return $possible_values;
167167 }
168168
@@ -175,7 +175,7 @@
176176 function createTempTable() {
177177 $dbr = wfGetDB( DB_SLAVE );
178178 $smw_ids = $dbr->tableName( 'smw_ids' );
179 - if ($this->is_relation) {
 179+ if ( $this->is_relation ) {
180180 $table_name = $dbr->tableName( 'smw_rels2' );
181181 $property_field = 'p_id';
182182 $value_field = 'o_ids.smw_title';
@@ -184,19 +184,19 @@
185185 $property_field = 'p_id';
186186 $value_field = 'value_xsd';
187187 }
188 - $query_property = str_replace(' ', '_', $this->property);
189 - $sql =<<<END
 188+ $query_property = str_replace( ' ', '_', $this->property );
 189+ $sql = <<<END
190190 CREATE TEMPORARY TABLE semantic_drilldown_filter_values
191191 AS SELECT s_id AS id, $value_field AS value
192192 FROM $table_name
193193 JOIN $smw_ids p_ids ON $table_name.p_id = p_ids.smw_id
194194
195195 END;
196 - if ($this->is_relation) {
 196+ if ( $this->is_relation ) {
197197 $sql .= " JOIN $smw_ids o_ids ON $table_name.o_id = o_ids.smw_id\n";
198198 }
199199 $sql .= " WHERE p_ids.smw_title = '$query_property'";
200 - $dbr->query($sql);
 200+ $dbr->query( $sql );
201201 }
202202
203203 /**
@@ -205,6 +205,6 @@
206206 function dropTempTable() {
207207 $dbr = wfGetDB( DB_SLAVE );
208208 $sql = "DROP TEMPORARY TABLE semantic_drilldown_filter_values";
209 - $dbr->query($sql);
 209+ $dbr->query( $sql );
210210 }
211211 }
Index: trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php
@@ -5,32 +5,32 @@
66 * @author Yaron Koren
77 */
88
9 -if (!defined('MEDIAWIKI')) die();
 9+if ( !defined( 'MEDIAWIKI' ) ) die();
1010
11 -define('SD_VERSION','0.7.1');
 11+define( 'SD_VERSION', '0.7.1' );
1212
1313 // constants for special properties
14 -define('SD_SP_HAS_FILTER', 1);
15 -define('SD_SP_COVERS_PROPERTY', 2);
16 -define('SD_SP_HAS_VALUE', 3);
17 -define('SD_SP_GETS_VALUES_FROM_CATEGORY', 4);
18 -define('SD_SP_USES_TIME_PERIOD', 5);
19 -define('SD_SP_REQUIRES_FILTER', 6);
20 -define('SD_SP_HAS_LABEL', 7);
21 -define('SD_SP_HAS_DRILLDOWN_TITLE', 8);
22 -define('SD_SP_HAS_INPUT_TYPE', 9);
23 -define('SD_SP_HAS_DISPLAY_PARAMETERS', 10);
 14+define( 'SD_SP_HAS_FILTER', 1 );
 15+define( 'SD_SP_COVERS_PROPERTY', 2 );
 16+define( 'SD_SP_HAS_VALUE', 3 );
 17+define( 'SD_SP_GETS_VALUES_FROM_CATEGORY', 4 );
 18+define( 'SD_SP_USES_TIME_PERIOD', 5 );
 19+define( 'SD_SP_REQUIRES_FILTER', 6 );
 20+define( 'SD_SP_HAS_LABEL', 7 );
 21+define( 'SD_SP_HAS_DRILLDOWN_TITLE', 8 );
 22+define( 'SD_SP_HAS_INPUT_TYPE', 9 );
 23+define( 'SD_SP_HAS_DISPLAY_PARAMETERS', 10 );
2424
25 -$wgExtensionCredits['specialpage'][]= array(
 25+$wgExtensionCredits['specialpage'][] = array(
2626 'path' => __FILE__,
2727 'name' => 'Semantic Drilldown',
2828 'version' => SD_VERSION,
29 - 'author' => array('Yaron Koren', 'David Loomer'),
 29+ 'author' => array( 'Yaron Koren', 'David Loomer' ),
3030 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown',
3131 'descriptionmsg' => 'semanticdrilldown-desc',
3232 );
3333
34 -require_once($sdgIP . '/languages/SD_Language.php');
 34+require_once( $sdgIP . '/languages/SD_Language.php' );
3535
3636 $wgExtensionMessagesFiles['SemanticDrilldown'] = $sdgIP . '/languages/SD_Messages.php';
3737 $wgExtensionAliasesFiles['SemanticDrilldown'] = $sdgIP . '/languages/SD_Aliases.php';
@@ -68,17 +68,17 @@
6969 global $sdgNamespaceIndex, $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $smwgNamespacesWithSemanticLinks;
7070 global $wgLanguageCode, $sdgContLang;
7171
72 - if (!isset($sdgNamespaceIndex)) {
 72+ if ( !isset( $sdgNamespaceIndex ) ) {
7373 $sdgNamespaceIndex = 170;
7474 }
7575
76 - define('SD_NS_FILTER', $sdgNamespaceIndex);
77 - define('SD_NS_FILTER_TALK', $sdgNamespaceIndex+1);
 76+ define( 'SD_NS_FILTER', $sdgNamespaceIndex );
 77+ define( 'SD_NS_FILTER_TALK', $sdgNamespaceIndex + 1 );
7878
79 - sdfInitContentLanguage($wgLanguageCode);
 79+ sdfInitContentLanguage( $wgLanguageCode );
8080
8181 // Register namespace identifiers
82 - if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); }
 82+ if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); }
8383 $wgExtraNamespaces = $wgExtraNamespaces + $sdgContLang->getNamespaces();
8484 $wgNamespaceAliases = $wgNamespaceAliases + $sdgContLang->getNamespaceAliases();
8585
@@ -99,25 +99,25 @@
100100 /**********************************************/
101101
102102 /**
103 - * Initialise a global language object for content language. This
 103+ * Initialize a global language object for content language. This
104104 * must happen early on, even before user language is known, to
105105 * determine labels for additional namespaces. In contrast, messages
106 - * can be initialised much later when they are actually needed.
 106+ * can be initialized much later when they are actually needed.
107107 */
108 -function sdfInitContentLanguage($langcode) {
 108+function sdfInitContentLanguage( $langcode ) {
109109 global $sdgIP, $sdgContLang;
110110
111 - if (!empty($sdgContLang)) { return; }
 111+ if ( !empty( $sdgContLang ) ) { return; }
112112
113113 $sdContLangClass = 'SD_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
114114
115 - if (file_exists($sdgIP . '/languages/'. $sdContLangClass . '.php')) {
116 - include_once( $sdgIP . '/languages/'. $sdContLangClass . '.php' );
 115+ if ( file_exists( $sdgIP . '/languages/' . $sdContLangClass . '.php' ) ) {
 116+ include_once( $sdgIP . '/languages/' . $sdContLangClass . '.php' );
117117 }
118118
119119 // fallback if language not supported
120 - if ( !class_exists($sdContLangClass)) {
121 - include_once($sdgIP . '/languages/SD_LanguageEn.php');
 120+ if ( !class_exists( $sdContLangClass ) ) {
 121+ include_once( $sdgIP . '/languages/SD_LanguageEn.php' );
122122 $sdContLangClass = 'SD_LanguageEn';
123123 }
124124
@@ -125,22 +125,22 @@
126126 }
127127
128128 /**
129 - * Initialise the global language object for user language. This
130 - * must happen after the content language was initialised, since
 129+ * Initialize the global language object for user language. This
 130+ * must happen after the content language was initialized, since
131131 * this language is used as a fallback.
132132 */
133 -function sdfInitUserLanguage($langcode) {
 133+function sdfInitUserLanguage( $langcode ) {
134134 global $sdgIP, $sdgLang;
135135
136 - if (!empty($sdgLang)) { return; }
 136+ if ( !empty( $sdgLang ) ) { return; }
137137
138138 $sdLangClass = 'SD_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
139 - if (file_exists($sdgIP . '/languages/'. $sdLangClass . '.php')) {
140 - include_once( $sdgIP . '/languages/'. $sdLangClass . '.php' );
 139+ if ( file_exists( $sdgIP . '/languages/' . $sdLangClass . '.php' ) ) {
 140+ include_once( $sdgIP . '/languages/' . $sdLangClass . '.php' );
141141 }
142142
143143 // fallback if language not supported
144 - if ( !class_exists($sdLangClass)) {
 144+ if ( !class_exists( $sdLangClass ) ) {
145145 include_once( $sdgIP . '/languages/SD_LanguageEn.php' );
146146 $sdLangClass = 'SD_LanguageEn';
147147 }
@@ -157,54 +157,54 @@
158158 global $sdgIP, $wgMessageCache;
159159
160160 # add messages
161 - require($sdgIP . '/languages/SD_Messages.php');
162 - foreach($messages as $key => $value) {
163 - $wgMessageCache->addMessages($messages[$key], $key);
 161+ require( $sdgIP . '/languages/SD_Messages.php' );
 162+ foreach ( $messages as $key => $value ) {
 163+ $wgMessageCache->addMessages( $messages[$key], $key );
164164 }
165165 }
166166
167167 function sdfInitProperties() {
168168 global $sdgContLang, $wgLanguageCode;
169169 $sd_property_vals = array(
170 - SD_SP_HAS_FILTER => array('_SD_F', '_wpg'),
171 - SD_SP_COVERS_PROPERTY => array('_SD_CP', '_wpp'),
172 - SD_SP_HAS_VALUE => array('_SD_V', '_str'),
173 - SD_SP_GETS_VALUES_FROM_CATEGORY => array('_SD_VC', '_wpc'),
174 - SD_SP_USES_TIME_PERIOD => array('_SD_TP', '_str'),
175 - SD_SP_HAS_INPUT_TYPE => array('_SD_IT', '_str'),
176 - SD_SP_REQUIRES_FILTER => array('_SD_RF', '_wpg'),
177 - SD_SP_HAS_LABEL => array('_SD_L', '_str'),
178 - SD_SP_HAS_DRILLDOWN_TITLE => array('_SD_DT', '_str'),
179 - SD_SP_HAS_DISPLAY_PARAMETERS => array('_SD_DP', '_str'),
 170+ SD_SP_HAS_FILTER => array( '_SD_F', '_wpg' ),
 171+ SD_SP_COVERS_PROPERTY => array( '_SD_CP', '_wpp' ),
 172+ SD_SP_HAS_VALUE => array( '_SD_V', '_str' ),
 173+ SD_SP_GETS_VALUES_FROM_CATEGORY => array( '_SD_VC', '_wpc' ),
 174+ SD_SP_USES_TIME_PERIOD => array( '_SD_TP', '_str' ),
 175+ SD_SP_HAS_INPUT_TYPE => array( '_SD_IT', '_str' ),
 176+ SD_SP_REQUIRES_FILTER => array( '_SD_RF', '_wpg' ),
 177+ SD_SP_HAS_LABEL => array( '_SD_L', '_str' ),
 178+ SD_SP_HAS_DRILLDOWN_TITLE => array( '_SD_DT', '_str' ),
 179+ SD_SP_HAS_DISPLAY_PARAMETERS => array( '_SD_DP', '_str' ),
180180 );
181181 // register main property labels
182182 $sd_prop_labels = $sdgContLang->getPropertyLabels();
183 - foreach ($sd_prop_labels as $prop_id => $prop_alias) {
 183+ foreach ( $sd_prop_labels as $prop_id => $prop_alias ) {
184184 $prop_vals = $sd_property_vals[$prop_id];
185 - SMWPropertyValue::registerProperty($prop_vals[0], $prop_vals[1], $prop_alias, true);
 185+ SMWPropertyValue::registerProperty( $prop_vals[0], $prop_vals[1], $prop_alias, true );
186186 }
187187 // if it's not English, add the English-language aliases as well
188 - if ($wgLanguageCode != 'en') {
 188+ if ( $wgLanguageCode != 'en' ) {
189189 $sd_prop_aliases = $sdgContLang->getPropertyAliases();
190 - foreach ($sd_prop_aliases as $prop_alias => $prop_id) {
 190+ foreach ( $sd_prop_aliases as $prop_alias => $prop_id ) {
191191 $prop_vals = $sd_property_vals[$prop_id];
192 - SMWPropertyValue::registerPropertyAlias($prop_vals[0], $prop_alias);
 192+ SMWPropertyValue::registerPropertyAlias( $prop_vals[0], $prop_alias );
193193 }
194194 }
195195 return true;
196196 }
197197
198 -function sdfAddToAdminLinks(&$admin_links_tree) {
199 - $browse_search_section = $admin_links_tree->getSection(wfMsg('adminlinks_browsesearch'));
200 - $sd_row = new ALRow('sd');
201 - $sd_row->addItem(ALItem::newFromSpecialPage('BrowseData'));
202 - $sd_row->addItem(ALItem::newFromSpecialPage('Filters'));
203 - $sd_row->addItem(ALItem::newFromSpecialPage('CreateFilter'));
204 - $sd_name = wfMsg('specialpages-group-sd_group');
205 - $sd_docu_label = wfMsg('adminlinks_documentation', $sd_name);
206 - $sd_row->addItem(AlItem::newFromExternalLink("http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown", $sd_docu_label));
 198+function sdfAddToAdminLinks( &$admin_links_tree ) {
 199+ $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) );
 200+ $sd_row = new ALRow( 'sd' );
 201+ $sd_row->addItem( ALItem::newFromSpecialPage( 'BrowseData' ) );
 202+ $sd_row->addItem( ALItem::newFromSpecialPage( 'Filters' ) );
 203+ $sd_row->addItem( ALItem::newFromSpecialPage( 'CreateFilter' ) );
 204+ $sd_name = wfMsg( 'specialpages-group-sd_group' );
 205+ $sd_docu_label = wfMsg( 'adminlinks_documentation', $sd_name );
 206+ $sd_row->addItem( AlItem::newFromExternalLink( "http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown", $sd_docu_label ) );
207207
208 - $browse_search_section->addRow($sd_row);
 208+ $browse_search_section->addRow( $sd_row );
209209
210210 return true;
211211 }
Index: trunk/extensions/SemanticDrilldown/includes/SD_Settings.php
@@ -1,53 +1,53 @@
22 <?php
33
4 -###
 4+# ##
55 # This is the path to your installation of Semantic Drilldown as
66 # seen from the web. Change it if required ($wgScriptPath is the
77 # path to the base directory of your wiki). No final slash.
8 -##
 8+# #
99 $sdgScriptPath = $wgScriptPath . '/extensions/SemanticDrilldown';
10 -##
 10+# #
1111
12 -###
 12+# ##
1313 # This is the path to your installation of Semantic Drilldown as
1414 # seen on your local filesystem. Used against some PHP file path
1515 # issues.
16 -##
 16+# #
1717 $sdgIP = $IP . '/extensions/SemanticDrilldown';
18 -##
 18+# #
1919
2020
2121 // PHP fails to find relative includes at some level of inclusion:
22 -//$pathfix = $IP . $sdgScriptPath;
 22+// $pathfix = $IP . $sdgScriptPath;
2323
2424 // load global functions
25 -require_once('SD_GlobalFunctions.php');
 25+require_once( 'SD_GlobalFunctions.php' );
2626
27 -###
 27+# ##
2828 # If you already have custom namespaces on your site, insert
2929 # $sdgNamespaceIndex = ???;
3030 # into your LocalSettings.php *before* including this file.
3131 # The number ??? must be the smallest even namespace number
3232 # that is not in use yet. However, it should not be smaller
3333 # than 170.
34 -##
35 -if (!isset($sdgNamespaceIndex)) {
36 - sdfInitNamespaces(170);
 34+# #
 35+if ( !isset( $sdgNamespaceIndex ) ) {
 36+ sdfInitNamespaces( 170 );
3737 } else {
3838 sdfInitNamespaces();
3939 }
4040
41 -###
42 -## List separator character
43 -###
 41+# ##
 42+# # List separator character
 43+# ##
4444 $sdgListSeparator = ",";
4545
46 -###
47 -## Variables for display
48 -###
 46+# ##
 47+# # Variables for display
 48+# ##
4949 $sdgNumResultsPerPage = 250;
5050 // set these to a positive value to trigger the "tag cloud" display
51 -$sdgFiltersSmallestFontSize=-1;
52 -$sdgFiltersLargestFontSize=-1;
 51+$sdgFiltersSmallestFontSize = - 1;
 52+$sdgFiltersLargestFontSize = - 1;
5353 // print categories list as tabs
5454 $sdgShowCategoriesAsTabs = false;
Index: trunk/extensions/SemanticDrilldown/includes/SD_FilterValue.php
@@ -16,48 +16,48 @@
1717 var $year = null;
1818 var $month = null;
1919
20 - function create($actual_val, $filter_time_period = null) {
 20+ function create( $actual_val, $filter_time_period = null ) {
2121 $fv = new SDFilterValue();
22 - $fv->text = htmlspecialchars($actual_val);
 22+ $fv->text = htmlspecialchars( $actual_val );
2323
24 - if ($fv->text == ' none')
 24+ if ( $fv->text == ' none' )
2525 $fv->is_none = true;
26 - if ($fv->text == ' other')
 26+ if ( $fv->text == ' other' )
2727 $fv->is_other = true;
2828 // set other fields, if it's a date or number range
29 - if ($filter_time_period != null) {
30 - if ($filter_time_period == wfMsg('sd_filter_month')) {
31 - list($month_str, $year) = explode(' ', $fv->text);
32 - $fv->month = SDUtils::stringToMonth($month_str);
 29+ if ( $filter_time_period != null ) {
 30+ if ( $filter_time_period == wfMsg( 'sd_filter_month' ) ) {
 31+ list( $month_str, $year ) = explode( ' ', $fv->text );
 32+ $fv->month = SDUtils::stringToMonth( $month_str );
3333 $fv->year = $year;
3434 } else {
3535 $fv->year = $fv->text;
3636 }
3737 } else {
3838 // SMW 1.0 HTML-encodes the value; un-encode it here
39 - $originals = array('&lt;', '&gt;');
40 - $replacements = array('<', '>');
41 - $fv->text = str_replace($originals, $replacements, $fv->text);
42 - if ($fv->text == '') {
 39+ $originals = array( '&lt;', '&gt;' );
 40+ $replacements = array( '<', '>' );
 41+ $fv->text = str_replace( $originals, $replacements, $fv->text );
 42+ if ( $fv->text == '' ) {
4343 // do nothing
44 - } elseif ($fv->text{0} == '<') {
45 - $possible_number = str_replace(',', '', trim(substr($fv->text, 1)));
46 - if (is_numeric($possible_number)) {
 44+ } elseif ( $fv->text { 0 } == '<' ) {
 45+ $possible_number = str_replace( ',', '', trim( substr( $fv->text, 1 ) ) );
 46+ if ( is_numeric( $possible_number ) ) {
4747 $fv->upper_limit = $possible_number;
4848 $fv->is_numeric = true;
4949 }
50 - } elseif ($fv->text{0} == '>') {
51 - $possible_number = str_replace(',', '', trim(substr($fv->text, 1)));
52 - if (is_numeric($possible_number)) {
 50+ } elseif ( $fv->text { 0 } == '>' ) {
 51+ $possible_number = str_replace( ',', '', trim( substr( $fv->text, 1 ) ) );
 52+ if ( is_numeric( $possible_number ) ) {
5353 $fv->lower_limit = $possible_number;
5454 $fv->is_numeric = true;
5555 }
5656 } else {
57 - $elements = explode('-', $fv->text);
58 - if (count($elements) == 2) {
59 - $first_elem = str_replace(',', '', trim($elements[0]));
60 - $second_elem = str_replace(',', '', trim($elements[1]));
61 - if (is_numeric($first_elem) && is_numeric($second_elem)) {
 57+ $elements = explode( '-', $fv->text );
 58+ if ( count( $elements ) == 2 ) {
 59+ $first_elem = str_replace( ',', '', trim( $elements[0] ) );
 60+ $second_elem = str_replace( ',', '', trim( $elements[1] ) );
 61+ if ( is_numeric( $first_elem ) && is_numeric( $second_elem ) ) {
6262 $fv->lower_limit = $first_elem;
6363 $fv->upper_limit = $second_elem;
6464 $fv->is_numeric = true;
@@ -71,23 +71,23 @@
7272 /*
7373 * Used in sorting, when BrowseDataPage creates a new URL
7474 */
75 - function compare($fv1, $fv2) {
76 - if ($fv1->is_none) return 1;
77 - if ($fv2->is_none) return -1;
78 - if ($fv1->is_other) return 1;
79 - if ($fv2->is_other) return -1;
80 - if ($fv1->year != null && $fv2->year != null) {
81 - if ($fv1->year == $fv2->year) {
82 - if ($fv1->month == $fv1->month) return 0;
83 - return ($fv1->month > $fv2->month) ? 1 : -1;
 75+ function compare( $fv1, $fv2 ) {
 76+ if ( $fv1->is_none ) return 1;
 77+ if ( $fv2->is_none ) return - 1;
 78+ if ( $fv1->is_other ) return 1;
 79+ if ( $fv2->is_other ) return - 1;
 80+ if ( $fv1->year != null && $fv2->year != null ) {
 81+ if ( $fv1->year == $fv2->year ) {
 82+ if ( $fv1->month == $fv1->month ) return 0;
 83+ return ( $fv1->month > $fv2->month ) ? 1 : - 1;
8484 }
85 - return ($fv1->year > $fv2->year) ? 1 : -1;
 85+ return ( $fv1->year > $fv2->year ) ? 1 : - 1;
8686 }
87 - if ($fv1->is_numeric) {
88 - if ($fv1->lower_limit == null) return -1;
89 - return ($fv1->lower_limit > $fv2->lower_limit) ? 1 : -1;
 87+ if ( $fv1->is_numeric ) {
 88+ if ( $fv1->lower_limit == null ) return - 1;
 89+ return ( $fv1->lower_limit > $fv2->lower_limit ) ? 1 : - 1;
9090 }
91 - if ($fv1->text == $fv2->text) return 0;
92 - return ($fv1->text > $fv2->text) ? 1 : -1;
 91+ if ( $fv1->text == $fv2->text ) return 0;
 92+ return ( $fv1->text > $fv2->text ) ? 1 : - 1;
9393 }
9494 }

Status & tagging log