Index: trunk/extensions/SemanticDrilldown/specials/SD_Filters.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | 11 | class SDFilters extends SpecialPage { |
12 | 12 | |
— | — | @@ -13,8 +13,8 @@ |
14 | 14 | * Constructor |
15 | 15 | */ |
16 | 16 | function SDFilters() { |
17 | | - SpecialPage::SpecialPage('Filters'); |
18 | | - wfLoadExtensionMessages('SemanticDrilldown'); |
| 17 | + SpecialPage::SpecialPage( 'Filters' ); |
| 18 | + wfLoadExtensionMessages( 'SemanticDrilldown' ); |
19 | 19 | } |
20 | 20 | |
21 | 21 | function execute( $par ) { |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | function isSyndicated() { return false; } |
37 | 37 | |
38 | 38 | function getPageHeader() { |
39 | | - $header = '<p>' . wfMsg('sd_filters_docu') . "</p><br />\n"; |
| 39 | + $header = '<p>' . wfMsg( 'sd_filters_docu' ) . "</p><br />\n"; |
40 | 40 | return $header; |
41 | 41 | } |
42 | 42 | |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | return false; |
61 | 61 | } |
62 | 62 | |
63 | | - function formatResult($skin, $result) { |
| 63 | + function formatResult( $skin, $result ) { |
64 | 64 | $title = Title::makeTitle( SD_NS_FILTER, $result->value ); |
65 | 65 | $text = $skin->makeLinkObj( $title, $title->getText() ); |
66 | 66 | return $text; |
Index: trunk/extensions/SemanticDrilldown/specials/SD_CreateFilter.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Yaron Koren |
8 | 8 | */ |
9 | 9 | |
10 | | -if (!defined('MEDIAWIKI')) die(); |
| 10 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
11 | 11 | |
12 | 12 | class SDCreateFilter extends SpecialPage { |
13 | 13 | |
— | — | @@ -14,8 +14,8 @@ |
15 | 15 | * Constructor |
16 | 16 | */ |
17 | 17 | public function SDCreateFilter() { |
18 | | - SpecialPage::SpecialPage('CreateFilter'); |
19 | | - wfLoadExtensionMessages('SemanticDrilldown'); |
| 18 | + SpecialPage::SpecialPage( 'CreateFilter' ); |
| 19 | + wfLoadExtensionMessages( 'SemanticDrilldown' ); |
20 | 20 | } |
21 | 21 | |
22 | 22 | function execute( $par ) { |
— | — | @@ -24,51 +24,51 @@ |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
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 ) { |
29 | 29 | global $sdgContLang; |
30 | 30 | |
31 | 31 | $sd_props = $sdgContLang->getPropertyLabels(); |
32 | 32 | $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' ) { |
35 | 35 | $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' ) { |
38 | 38 | // do nothing |
39 | | - } elseif ($values_source == 'dates') { |
| 39 | + } elseif ( $values_source == 'dates' ) { |
40 | 40 | $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' ) { |
43 | 43 | // replace the comma substitution character that has no |
44 | 44 | // chance of being included in the values list - namely, |
45 | 45 | // the ASCII beep |
46 | 46 | 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 ); |
49 | 49 | $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 ) { |
52 | 52 | $filter_values_tag .= ", "; |
53 | 53 | } |
54 | 54 | // 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 ) ); |
56 | 56 | $filter_values_tag .= "[[" . $sd_props[SD_SP_HAS_VALUE] . "::$filter_value]]"; |
57 | 57 | } |
58 | | - $text .= " " . wfMsgForContent('sd_filter_hasvalues', $filter_values_tag); |
| 58 | + $text .= " " . wfMsgForContent( 'sd_filter_hasvalues', $filter_values_tag ); |
59 | 59 | } |
60 | | - if ($input_type != '') { |
| 60 | + if ( $input_type != '' ) { |
61 | 61 | $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\"" ); |
63 | 63 | } |
64 | | - if ($required_filter != '') { |
| 64 | + if ( $required_filter != '' ) { |
65 | 65 | $sd_namespace_labels = $sdgContLang->getNamespaces(); |
66 | 66 | $filter_namespace = $sd_namespace_labels[SD_NS_FILTER]; |
67 | 67 | $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 ); |
69 | 69 | } |
70 | | - if ($filter_label != '') { |
| 70 | + if ( $filter_label != '' ) { |
71 | 71 | $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 ); |
73 | 73 | } |
74 | 74 | return $text; |
75 | 75 | } |
— | — | @@ -77,34 +77,34 @@ |
78 | 78 | global $wgOut, $wgRequest, $wgUser, $sdgScriptPath; |
79 | 79 | |
80 | 80 | # 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' ); |
90 | 90 | |
91 | | - $save_button_text = wfMsg('savearticle'); |
92 | | - $preview_button_text = wfMsg('preview'); |
| 91 | + $save_button_text = wfMsg( 'savearticle' ); |
| 92 | + $preview_button_text = wfMsg( 'preview' ); |
93 | 93 | $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 ) { |
97 | 97 | # 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' ); |
100 | 100 | } else { |
101 | 101 | # redirect to wiki interface |
102 | 102 | $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 ); |
105 | 105 | // HTML-encode |
106 | | - $full_text = str_replace('"', '"', $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( '"', '"', $full_text ); |
| 107 | + $text = SDUtils::printRedirectForm( $title, $full_text, "", $save_page, $preview_page, false, false, false ); |
| 108 | + $wgOut->addHTML( $text ); |
109 | 109 | return; |
110 | 110 | } |
111 | 111 | } |
— | — | @@ -113,10 +113,10 @@ |
114 | 114 | global $wgContLang; |
115 | 115 | $mw_namespace_labels = $wgContLang->getNamespaces(); |
116 | 116 | $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 |
121 | 121 | <form action="" method="post"> |
122 | 122 | <input type="hidden" name="title" value="$special_namespace:CreateFilter"> |
123 | 123 | <p>$name_label <input size="25" name="filter_name" value=""> |
— | — | @@ -126,29 +126,29 @@ |
127 | 127 | |
128 | 128 | END; |
129 | 129 | $all_properties = SDUtils::getSemanticProperties(); |
130 | | - foreach ($all_properties as $property_name) { |
| 130 | + foreach ( $all_properties as $property_name ) { |
131 | 131 | $text .= " <option>$property_name</option>\n"; |
132 | 132 | } |
133 | 133 | |
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' ); |
138 | 138 | // need both label and value, in case user's language is different |
139 | 139 | // 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' ); |
146 | 146 | // 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 |
153 | 153 | </select> |
154 | 154 | </p> |
155 | 155 | <p><input type="radio" name="values_source" checked value="property"> |
— | — | @@ -160,11 +160,11 @@ |
161 | 161 | |
162 | 162 | END; |
163 | 163 | $categories = SDUtils::getTopLevelCategories(); |
164 | | - foreach ($categories as $category) { |
165 | | - $category = str_replace('_', ' ', $category); |
| 164 | + foreach ( $categories as $category ) { |
| 165 | + $category = str_replace( '_', ' ', $category ); |
166 | 166 | $text .= " <option>$category</option>\n"; |
167 | 167 | } |
168 | | - $text .=<<<END |
| 168 | + $text .= <<<END |
169 | 169 | </select> |
170 | 170 | </p> |
171 | 171 | <p><input type="radio" name="values_source" value="dates"> |
— | — | @@ -190,11 +190,11 @@ |
191 | 191 | |
192 | 192 | END; |
193 | 193 | $filters = SDUtils::getFilters(); |
194 | | - foreach ($filters as $filter) { |
195 | | - $filter = str_replace('_', ' ', $filter); |
| 194 | + foreach ( $filters as $filter ) { |
| 195 | + $filter = str_replace( '_', ' ', $filter ); |
196 | 196 | $text .= " <option>$filter</option>\n"; |
197 | 197 | } |
198 | | - $text .=<<<END |
| 198 | + $text .= <<<END |
199 | 199 | </select> |
200 | 200 | </p> |
201 | 201 | <p>$label_label <input size="25" name="filter_label" value=""></p> |
— | — | @@ -212,6 +212,6 @@ |
213 | 213 | 'type' => 'text/css', |
214 | 214 | 'media' => "screen", |
215 | 215 | 'href' => $sdgScriptPath . "/skins/SD_main.css" |
216 | | - )); |
217 | | - $wgOut->addHTML($text); |
| 216 | + ) ); |
| 217 | + $wgOut->addHTML( $text ); |
218 | 218 | } |
Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | * @author Yaron Koren |
9 | 9 | */ |
10 | 10 | |
11 | | -if (!defined('MEDIAWIKI')) die(); |
| 11 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
12 | 12 | |
13 | 13 | class SDBrowseData extends IncludableSpecialPage { |
14 | 14 | |
— | — | @@ -15,15 +15,15 @@ |
16 | 16 | * Constructor |
17 | 17 | */ |
18 | 18 | public function __construct() { |
19 | | - parent::__construct('BrowseData'); |
20 | | - wfLoadExtensionMessages('SemanticDrilldown'); |
| 19 | + parent::__construct( 'BrowseData' ); |
| 20 | + wfLoadExtensionMessages( 'SemanticDrilldown' ); |
21 | 21 | } |
22 | 22 | |
23 | 23 | function execute( $query ) { |
24 | 24 | global $wgRequest, $wgOut, $wgTitle; |
25 | 25 | global $sdgScriptPath, $sdgContLang, $sdgNumResultsPerPage; |
26 | 26 | |
27 | | - if ($wgTitle->getNamespace() != NS_SPECIAL) { |
| 27 | + if ( $wgTitle->getNamespace() != NS_SPECIAL ) { |
28 | 28 | global $wgParser; |
29 | 29 | $wgParser->disableCache(); |
30 | 30 | } |
— | — | @@ -34,20 +34,20 @@ |
35 | 35 | 'type' => 'text/css', |
36 | 36 | 'media' => "screen", |
37 | 37 | 'href' => $mainCssDir . 'SD_main.css' |
38 | | - )); |
| 38 | + ) ); |
39 | 39 | $wgOut->addLink( array( |
40 | 40 | 'rel' => 'stylesheet', |
41 | 41 | 'type' => 'text/css', |
42 | 42 | 'media' => "screen", |
43 | 43 | 'href' => $mainCssDir . 'xtheme-gray.css' |
44 | | - )); |
| 44 | + ) ); |
45 | 45 | $wgOut->addLink( array( |
46 | 46 | 'rel' => 'stylesheet', |
47 | 47 | 'type' => 'text/css', |
48 | 48 | 'media' => "screen", |
49 | 49 | 'href' => $mainCssDir . 'combos.css' |
50 | | - )); |
51 | | - $javascript_text =<<<END |
| 50 | + ) ); |
| 51 | + $javascript_text = <<<END |
52 | 52 | function toggleFilterDiv(element_id, label_element) { |
53 | 53 | element = document.getElementById(element_id); |
54 | 54 | if (element.style.display == "none") { |
— | — | @@ -67,97 +67,97 @@ |
68 | 68 | } |
69 | 69 | |
70 | 70 | 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" ); |
72 | 72 | |
73 | 73 | // set default |
74 | | - if ($sdgNumResultsPerPage == null) |
| 74 | + if ( $sdgNumResultsPerPage == null ) |
75 | 75 | $sdgNumResultsPerPage = 250; |
76 | | - list( $limit, $offset ) = wfCheckLimits($sdgNumResultsPerPage, 'sdlimit'); |
| 76 | + list( $limit, $offset ) = wfCheckLimits( $sdgNumResultsPerPage, 'sdlimit' ); |
77 | 77 | $filters = array(); |
78 | 78 | |
79 | 79 | // get information on current category, subcategory and filters |
80 | 80 | // that have already been applied from the query string |
81 | | - $category = str_replace('_', ' ', $wgRequest->getVal('_cat')); |
| 81 | + $category = str_replace( '_', ' ', $wgRequest->getVal( '_cat' ) ); |
82 | 82 | // 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] : ''; |
86 | 86 | } |
87 | | - if (! $category) { |
88 | | - $category_title = wfMsg('browsedata'); |
| 87 | + if ( ! $category ) { |
| 88 | + $category_title = wfMsg( 'browsedata' ); |
89 | 89 | } 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] ); |
93 | 93 | } else { |
94 | 94 | $category_title = wfMsg( 'browsedata' ) . html_entity_decode( wfMsg( 'colon-separator' ) ) . str_replace( '_', ' ', $category ); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | // if no category was specified, go with the first |
98 | 98 | // category on the site, alphabetically |
99 | | - if (! $category) { |
| 99 | + if ( ! $category ) { |
100 | 100 | $categories = SDUtils::getTopLevelCategories(); |
101 | | - if (count($categories) > 0) { |
| 101 | + if ( count( $categories ) > 0 ) { |
102 | 102 | $category = $categories[0]; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | | - $wgOut->setPageTitle($category_title); |
107 | | - $subcategory = $wgRequest->getVal('_subcat'); |
| 106 | + $wgOut->setPageTitle( $category_title ); |
| 107 | + $subcategory = $wgRequest->getVal( '_subcat' ); |
108 | 108 | |
109 | | - $filters = SDUtils::loadFiltersForCategory($category); |
| 109 | + $filters = SDUtils::loadFiltersForCategory( $category ); |
110 | 110 | |
111 | 111 | $filters_used = array(); |
112 | | - foreach ($filters as $i => $filter) |
| 112 | + foreach ( $filters as $i => $filter ) |
113 | 113 | $filter_used[] = false; |
114 | 114 | $applied_filters = array(); |
115 | 115 | $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 ); |
124 | 124 | } |
125 | | - $applied_filters[] = SDAppliedFilter::create($filter, $vals_array); |
| 125 | + $applied_filters[] = SDAppliedFilter::create( $filter, $vals_array ); |
126 | 126 | $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 ); |
129 | 129 | $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 ); |
132 | 132 | $filter_used[$i] = true; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | // add every unused filter to the $remaining_filters array, |
136 | 136 | // 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 ); |
139 | 139 | $matched_all_required_filters = true; |
140 | | - foreach ($required_filters as $required_filter) { |
| 140 | + foreach ( $required_filters as $required_filter ) { |
141 | 141 | $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 ) { |
144 | 144 | $found_match = true; |
145 | 145 | } |
146 | 146 | } |
147 | | - if (! $found_match) { |
| 147 | + if ( ! $found_match ) { |
148 | 148 | $matched_all_required_filters = false; |
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | } |
152 | | - if ($matched_all_required_filters) { |
153 | | - if (! $filter_used[$i]) |
| 152 | + if ( $matched_all_required_filters ) { |
| 153 | + if ( ! $filter_used[$i] ) |
154 | 154 | $remaining_filters[] = $filter; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
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 ); |
160 | 160 | $num = $rep->doQuery( $offset, $limit ); |
161 | | - $wgOut->addHTML("\n </div> <!-- drilldown-results -->\n"); |
| 161 | + $wgOut->addHTML( "\n </div> <!-- drilldown-results -->\n" ); |
162 | 162 | return $num; |
163 | 163 | } |
164 | 164 | } |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | /** |
176 | 176 | * Initialize the variables of this page |
177 | 177 | */ |
178 | | - function __construct($category, $subcategory, $applied_filters, $remaining_filters) { |
| 178 | + function __construct( $category, $subcategory, $applied_filters, $remaining_filters ) { |
179 | 179 | $this->category = $category; |
180 | 180 | $this->subcategory = $subcategory; |
181 | 181 | $this->applied_filters = $applied_filters; |
— | — | @@ -184,44 +184,44 @@ |
185 | 185 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
186 | 186 | $page = $dbr->tableName( 'page' ); |
187 | 187 | $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 ); |
190 | 190 | else |
191 | | - $actual_cat = str_replace(' ', '_', $this->category); |
| 191 | + $actual_cat = str_replace( ' ', '_', $this->category ); |
192 | 192 | // get the two arrays for subcategories - one for only the |
193 | 193 | // immediate subcategories, for display, and the other for |
194 | 194 | // 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 ); |
197 | 197 | } |
198 | 198 | |
199 | | - function makeBrowseURL($category, $applied_filters = array(), $subcategory = null) { |
| 199 | + function makeBrowseURL( $category, $applied_filters = array(), $subcategory = null ) { |
200 | 200 | global $wgTitle; |
201 | 201 | $url = $wgTitle->getFullURL() . '/' . $category; |
202 | | - if ($this->show_single_cat) { |
203 | | - $url .= (strpos($url, '?')) ? '&' : '?'; |
| 202 | + if ( $this->show_single_cat ) { |
| 203 | + $url .= ( strpos( $url, '?' ) ) ? '&' : '?'; |
204 | 204 | $url .= "_single"; |
205 | 205 | } |
206 | | - if ($subcategory) { |
207 | | - $url .= (strpos($url, '?')) ? '&' : '?'; |
| 206 | + if ( $subcategory ) { |
| 207 | + $url .= ( strpos( $url, '?' ) ) ? '&' : '?'; |
208 | 208 | $url .= "_subcat=" . $subcategory; |
209 | 209 | } |
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 ) { |
212 | 212 | // 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 ) ); |
216 | 216 | } 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 ) ); |
221 | 221 | } |
222 | 222 | } |
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 ) ); |
226 | 226 | } |
227 | 227 | } |
228 | 228 | return $url; |
— | — | @@ -232,17 +232,17 @@ |
233 | 233 | * set of filters selected by the user - used for displaying |
234 | 234 | * all remaining filters |
235 | 235 | */ |
236 | | - function createTempTable($category, $subcategory, $subcategories, $applied_filters) { |
| 236 | + function createTempTable( $category, $subcategory, $subcategories, $applied_filters ) { |
237 | 237 | $dbr = wfGetDB( DB_SLAVE ); |
238 | | - $sql =<<<END |
| 238 | + $sql = <<<END |
239 | 239 | CREATE TEMPORARY TABLE semantic_drilldown_values ( |
240 | 240 | id INT NOT NULL, |
241 | 241 | INDEX id_index (id) |
242 | 242 | ) AS SELECT ids.smw_id AS id |
243 | 243 | |
244 | 244 | 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 ); |
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
— | — | @@ -251,12 +251,12 @@ |
252 | 252 | * selected filters, plus the one new filter (with value) that |
253 | 253 | * was passed in to this function. |
254 | 254 | */ |
255 | | - function getSQLFromClauseForField($new_filter) { |
| 255 | + function getSQLFromClauseForField( $new_filter ) { |
256 | 256 | $sql = "FROM semantic_drilldown_values sdv |
257 | 257 | LEFT OUTER JOIN semantic_drilldown_filter_values sdfv |
258 | 258 | ON sdv.id = sdfv.id |
259 | 259 | WHERE "; |
260 | | - $sql .= $new_filter->checkSQL("sdfv.value"); |
| 260 | + $sql .= $new_filter->checkSQL( "sdfv.value" ); |
261 | 261 | return $sql; |
262 | 262 | } |
263 | 263 | |
— | — | @@ -265,20 +265,20 @@ |
266 | 266 | * of a new filter passed in, it's a subcategory, plus all that |
267 | 267 | * subcategory's child subcategories, to ensure completeness. |
268 | 268 | */ |
269 | | - function getSQLFromClauseForCategory($subcategory, $child_subcategories) { |
| 269 | + function getSQLFromClauseForCategory( $subcategory, $child_subcategories ) { |
270 | 270 | $dbr = wfGetDB( DB_SLAVE ); |
271 | 271 | $smw_insts = $dbr->tableName( 'smw_inst2' ); |
272 | 272 | $smw_ids = $dbr->tableName( 'smw_ids' ); |
273 | 273 | $ns_cat = NS_CATEGORY; |
274 | | - $subcategory = str_replace("'", "\'", $subcategory); |
| 274 | + $subcategory = str_replace( "'", "\'", $subcategory ); |
275 | 275 | $sql = "FROM semantic_drilldown_values sdv |
276 | 276 | JOIN $smw_insts inst |
277 | 277 | ON sdv.id = inst.s_id |
278 | 278 | WHERE inst.o_id IN |
279 | 279 | (SELECT smw_id FROM $smw_ids |
280 | 280 | 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 ); |
283 | 283 | $sql .= "OR smw_title = '$subcat' "; |
284 | 284 | } |
285 | 285 | $sql .= ")) "; |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | * to get all pages that match a certain set of criteria for |
292 | 292 | * category, subcategory and filters |
293 | 293 | */ |
294 | | - function getSQLFromClause($category, $subcategory, $subcategories, $applied_filters) { |
| 294 | + function getSQLFromClause( $category, $subcategory, $subcategories, $applied_filters ) { |
295 | 295 | $dbr = wfGetDB( DB_SLAVE ); |
296 | 296 | $smw_ids = $dbr->tableName( 'smw_ids' ); |
297 | 297 | $smw_insts = $dbr->tableName( 'smw_inst2' ); |
— | — | @@ -303,18 +303,18 @@ |
304 | 304 | JOIN $smw_insts insts |
305 | 305 | ON ids.smw_id = insts.s_id |
306 | 306 | AND ids.smw_namespace != $cat_ns "; |
307 | | - foreach ($applied_filters as $i => $af) { |
| 307 | + foreach ( $applied_filters as $i => $af ) { |
308 | 308 | // if any of this filter's values is 'none', |
309 | 309 | // include another table to get this information |
310 | 310 | $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' ) { |
313 | 313 | $includes_none = true; |
314 | 314 | break; |
315 | 315 | } |
316 | 316 | } |
317 | | - if ($includes_none) { |
318 | | - if ($af->filter->is_relation) { |
| 317 | + if ( $includes_none ) { |
| 318 | + if ( $af->filter->is_relation ) { |
319 | 319 | $property_table_name = $smw_rels; |
320 | 320 | $property_table_nickname = "nr$i"; |
321 | 321 | $property_field = 'p_id'; |
— | — | @@ -323,8 +323,8 @@ |
324 | 324 | $property_table_nickname = "na$i"; |
325 | 325 | $property_field = 'p_id'; |
326 | 326 | } |
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 ); |
329 | 329 | $sql .= "LEFT OUTER JOIN |
330 | 330 | (SELECT s_id |
331 | 331 | FROM $property_table_name |
— | — | @@ -332,14 +332,14 @@ |
333 | 333 | ON ids.smw_id = $property_table_nickname.s_id "; |
334 | 334 | } |
335 | 335 | } |
336 | | - foreach ($applied_filters as $i => $af) { |
| 336 | + foreach ( $applied_filters as $i => $af ) { |
337 | 337 | $sql .= "\n "; |
338 | | - if ($af->filter->is_relation) { |
339 | | - if ($includes_none) { |
| 338 | + if ( $af->filter->is_relation ) { |
| 339 | + if ( $includes_none ) { |
340 | 340 | $sql .= "LEFT OUTER "; |
341 | 341 | } |
342 | 342 | $sql .= "JOIN $smw_rels r$i ON ids.smw_id = r$i.s_id\n "; |
343 | | - if ($includes_none) { |
| 343 | + if ( $includes_none ) { |
344 | 344 | $sql .= "LEFT OUTER "; |
345 | 345 | } |
346 | 346 | $sql .= "JOIN $smw_ids o_ids$i ON r$i.o_id = o_ids$i.smw_id "; |
— | — | @@ -347,25 +347,25 @@ |
348 | 348 | $sql .= "JOIN $smw_atts a$i ON ids.smw_id = a$i.s_id "; |
349 | 349 | } |
350 | 350 | } |
351 | | - if ($subcategory) |
352 | | - $actual_cat = str_replace(' ', '_', $subcategory); |
| 351 | + if ( $subcategory ) |
| 352 | + $actual_cat = str_replace( ' ', '_', $subcategory ); |
353 | 353 | 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 ); |
356 | 356 | $sql .= "WHERE insts.o_id IN |
357 | 357 | (SELECT smw_id FROM $smw_ids cat_ids |
358 | 358 | 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 ); |
361 | 361 | $sql .= " OR smw_title = '{$subcat}'"; |
362 | 362 | } |
363 | 363 | $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 ) { |
367 | 367 | $property_field = "r$i.p_id"; |
368 | 368 | $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 ) { |
370 | 370 | $sql .= " OR $property_field IS NULL"; |
371 | 371 | } |
372 | 372 | $sql .= ")\n AND "; |
— | — | @@ -375,7 +375,7 @@ |
376 | 376 | $sql .= "\n AND $property_field = (SELECT smw_id FROM $smw_ids WHERE smw_title = '$property_value' AND smw_namespace = $prop_ns) AND "; |
377 | 377 | $value_field = "a$i.value_xsd"; |
378 | 378 | } |
379 | | - $sql .= $af->checkSQL($value_field); |
| 379 | + $sql .= $af->checkSQL( $value_field ); |
380 | 380 | } |
381 | 381 | return $sql; |
382 | 382 | } |
— | — | @@ -384,16 +384,16 @@ |
385 | 385 | * Gets the number of pages matching both the currently-selected |
386 | 386 | * set of filters and either a new subcategory or a new filter. |
387 | 387 | */ |
388 | | - function getNumResults($subcategory, $subcategories, $new_filter = null) { |
| 388 | + function getNumResults( $subcategory, $subcategories, $new_filter = null ) { |
389 | 389 | $dbr = wfGetDB( DB_SLAVE ); |
390 | 390 | $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 ); |
393 | 393 | 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 ); |
398 | 398 | return $row[0]; |
399 | 399 | } |
400 | 400 | |
— | — | @@ -405,38 +405,38 @@ |
406 | 406 | |
407 | 407 | function isSyndicated() { return false; } |
408 | 408 | |
409 | | - function printCategoriesList($categories) { |
| 409 | + function printCategoriesList( $categories ) { |
410 | 410 | global $sdgShowCategoriesAsTabs; |
411 | 411 | |
412 | | - $choose_category_text = wfMsg('sd_browsedata_choosecategory'); |
413 | | - if ($sdgShowCategoriesAsTabs) { |
| 412 | + $choose_category_text = wfMsg( 'sd_browsedata_choosecategory' ); |
| 413 | + if ( $sdgShowCategoriesAsTabs ) { |
414 | 414 | $cats_wrapper_class = "drilldown-categories-tabs-wrapper"; |
415 | 415 | $cats_list_class = "drilldown-categories-tabs"; |
416 | 416 | } else { |
417 | 417 | $cats_wrapper_class = "drilldown-categories-wrapper"; |
418 | 418 | $cats_list_class = "drilldown-categories"; |
419 | 419 | } |
420 | | - $text =<<<END |
| 420 | + $text = <<<END |
421 | 421 | |
422 | 422 | <div id="$cats_wrapper_class"> |
423 | 423 | <p id="categories-header">$choose_category_text:</p> |
424 | 424 | <ul id="$cats_list_class"> |
425 | 425 | |
426 | 426 | 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 ) { |
431 | 431 | $text .= ' <li class="category selected">'; |
432 | 432 | $text .= $category_str; |
433 | 433 | } else { |
434 | 434 | $text .= ' <li class="category">'; |
435 | | - $category_url = $this->makeBrowseURL($category); |
| 435 | + $category_url = $this->makeBrowseURL( $category ); |
436 | 436 | $text .= "<a href=\"$category_url\" title=\"$choose_category_text\">$category_str</a>"; |
437 | 437 | } |
438 | 438 | $text .= "</li>\n"; |
439 | 439 | } |
440 | | - $text .=<<<END |
| 440 | + $text .= <<<END |
441 | 441 | </li> |
442 | 442 | </ul> |
443 | 443 | </div> |
— | — | @@ -445,12 +445,12 @@ |
446 | 446 | return $text; |
447 | 447 | } |
448 | 448 | |
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 ) { |
452 | 452 | $filter_label = $labels_for_filter[0]; |
453 | 453 | } else { |
454 | | - $filter_label = str_replace('_', ' ', $filter_name); |
| 454 | + $filter_label = str_replace( '_', ' ', $filter_name ); |
455 | 455 | } |
456 | 456 | return $filter_label; |
457 | 457 | } |
— | — | @@ -459,17 +459,17 @@ |
460 | 460 | * Print a "nice" version of the value for a filter, if it's some |
461 | 461 | * special case like 'other', 'none', a boolean, etc. |
462 | 462 | */ |
463 | | - function printFilterValue($filter, $value) { |
464 | | - $value = str_replace('_', ' ', $value); |
| 463 | + function printFilterValue( $filter, $value ) { |
| 464 | + $value = str_replace( '_', ' ', $value ); |
465 | 465 | // 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 ); |
474 | 474 | else |
475 | 475 | return $value; |
476 | 476 | } |
— | — | @@ -478,71 +478,71 @@ |
479 | 479 | * Print the line showing 'OR' values for a filter that already has |
480 | 480 | * at least one value set |
481 | 481 | */ |
482 | | - function printAppliedFilterLine($af) { |
| 482 | + function printAppliedFilterLine( $af ) { |
483 | 483 | global $sdgScriptPath; |
484 | 484 | |
485 | 485 | $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 ) |
489 | 489 | $current_filter_values = $af2->values; |
490 | 490 | } |
491 | | - if ($af->filter->allowed_values != null) |
| 491 | + if ( $af->filter->allowed_values != null ) |
492 | 492 | $or_values = $af->filter->allowed_values; |
493 | 493 | 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 ) { |
496 | 496 | // HACK - printComboBoxInput() needs values as the |
497 | 497 | // *keys* of the array |
498 | 498 | $filter_values = array(); |
499 | | - foreach ($or_values as $or_value) { |
| 499 | + foreach ( $or_values as $or_value ) { |
500 | 500 | $filter_values[$or_value] = ''; |
501 | 501 | } |
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 ); |
503 | 503 | 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 ); |
506 | 506 | return $results_line; |
507 | 507 | } |
508 | 508 | // add 'Other' and 'None', regardless of whether either has |
509 | 509 | // 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 ) |
511 | 511 | $or_values[] = '_other'; |
512 | 512 | $or_values[] = '_none'; |
513 | | - foreach ($or_values as $i => $value) { |
514 | | - if ($i > 0) { $results_line .= " · "; } |
515 | | - $filter_text = $this->printFilterValue($af->filter, $value); |
| 513 | + foreach ( $or_values as $i => $value ) { |
| 514 | + if ( $i > 0 ) { $results_line .= " · "; } |
| 515 | + $filter_text = $this->printFilterValue( $af->filter, $value ); |
516 | 516 | $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 ) ); |
521 | 521 | } |
522 | 522 | } |
523 | 523 | // show the list of OR values, only linking |
524 | 524 | // the ones that haven't been used yet |
525 | 525 | $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 ) { |
528 | 528 | $found_match = true; |
529 | 529 | break; |
530 | 530 | } |
531 | 531 | } |
532 | | - if ($found_match) { |
| 532 | + if ( $found_match ) { |
533 | 533 | $results_line .= "\n $filter_text"; |
534 | 534 | } 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>'; |
537 | 537 | } |
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 ) { |
540 | 540 | $af2->values = $current_filter_values; |
541 | 541 | } |
542 | 542 | } |
543 | 543 | } |
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 |
547 | 547 | <div class="drilldown-filter-label"> |
548 | 548 | <a onclick="toggleFilterDiv('$results_div_id', this)" style="cursor: default;"><img src="$sdgScriptPath/skins/right-arrow.png"></a> |
549 | 549 | $filter_label: <span class="drilldown-filter-notes">($add_another_str)</span> |
— | — | @@ -554,56 +554,56 @@ |
555 | 555 | return $text; |
556 | 556 | } |
557 | 557 | |
558 | | - function printUnappliedFilterValues($cur_url, $f, $filter_values) { |
| 558 | + function printUnappliedFilterValues( $cur_url, $f, $filter_values ) { |
559 | 559 | global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize; |
560 | 560 | |
561 | 561 | $results_line = ""; |
562 | 562 | // set font-size values for filter "tag cloud", if the |
563 | 563 | // 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 ); |
570 | 570 | } |
571 | 571 | // now print the values |
572 | 572 | $num_printed_values = 0; |
573 | | - foreach ($filter_values as $value_str => $num_results) { |
574 | | - if ($num_printed_values++ > 0) { $results_line .= " · "; } |
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 .= " · "; } |
| 575 | + $filter_text = $this->printFilterValue( $f, $value_str ); |
576 | 576 | $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>'; |
581 | 581 | } 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>'; |
583 | 583 | } |
584 | 584 | } |
585 | 585 | return $results_line; |
586 | 586 | } |
587 | 587 | |
588 | | - function printComboBoxInput($filter_name, $filter_values, $cur_value = null) { |
| 588 | + function printComboBoxInput( $filter_name, $filter_values, $cur_value = null ) { |
589 | 589 | global $wgRequest; |
590 | 590 | |
591 | | - $filter_name = str_replace(' ', '_', $filter_name); |
| 591 | + $filter_name = str_replace( ' ', '_', $filter_name ); |
592 | 592 | $input_id = "_search_$filter_name"; |
593 | | - $text =<<<END |
| 593 | + $text = <<<END |
594 | 594 | |
595 | 595 | <script> |
596 | 596 | Ext.onReady(function(){ |
597 | 597 | var {$filter_name}_values = [ |
598 | 598 | |
599 | 599 | 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 ); |
604 | 604 | $text .= " ['$display_value', '$display_value'],\n"; |
605 | 605 | } |
606 | 606 | } |
607 | | - $text .=<<<END |
| 607 | + $text .= <<<END |
608 | 608 | ] |
609 | 609 | |
610 | 610 | var comboFromArray = new Ext.form.ComboBox({ |
— | — | @@ -618,15 +618,15 @@ |
619 | 619 | |
620 | 620 | END; |
621 | 621 | |
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 |
625 | 625 | <input type="hidden" name="$key" value="$val" /> |
626 | 626 | |
627 | 627 | END; |
628 | 628 | } |
629 | | - $search_label = wfMsg('searchresultshead'); |
630 | | - $text .=<<<END |
| 629 | + $search_label = wfMsg( 'searchresultshead' ); |
| 630 | + $text .= <<<END |
631 | 631 | <input type="submit" value="$search_label" /> |
632 | 632 | </form> |
633 | 633 | |
— | — | @@ -634,31 +634,31 @@ |
635 | 635 | return $text; |
636 | 636 | } |
637 | 637 | |
638 | | - function printDateInput($input_name, $cur_value = null) { |
| 638 | + function printDateInput( $input_name, $cur_value = null ) { |
639 | 639 | $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' ) |
652 | 652 | ); |
653 | 653 | |
654 | | - if (is_array($cur_value) && array_key_exists('month', $cur_value)) |
| 654 | + if ( is_array( $cur_value ) && array_key_exists( 'month', $cur_value ) ) |
655 | 655 | $selected_month = $cur_value['month']; |
656 | 656 | else |
657 | 657 | $selected_month = null; |
658 | 658 | $text = ' <select name="' . $input_name . "[month]\">\n"; |
659 | | - foreach ($month_names as $i => $name) { |
| 659 | + foreach ( $month_names as $i => $name ) { |
660 | 660 | // 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" : ""; |
663 | 663 | $text .= " <option value=\"$month_value\" $selected_str>$name</option>\n"; |
664 | 664 | } |
665 | 665 | $text .= " </select>\n"; |
— | — | @@ -667,27 +667,27 @@ |
668 | 668 | return $text; |
669 | 669 | } |
670 | 670 | |
671 | | - function printDateRangeInput($filter_name, $lower_date = null, $upper_date = null) { |
| 671 | + function printDateRangeInput( $filter_name, $lower_date = null, $upper_date = null ) { |
672 | 672 | global $wgRequest; |
673 | 673 | |
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 |
679 | 679 | <form method="get"> |
680 | 680 | <p>$start_label $start_month_input |
681 | 681 | $end_label $end_month_input</p> |
682 | 682 | |
683 | 683 | END; |
684 | | - foreach ($wgRequest->getValues() as $key => $val) { |
685 | | - $text .=<<<END |
| 684 | + foreach ( $wgRequest->getValues() as $key => $val ) { |
| 685 | + $text .= <<<END |
686 | 686 | <input type="hidden" name="$key" value="$val" /> |
687 | 687 | |
688 | 688 | END; |
689 | 689 | } |
690 | | - $search_label = wfMsg('searchresultshead'); |
691 | | - $text .=<<<END |
| 690 | + $search_label = wfMsg( 'searchresultshead' ); |
| 691 | + $text .= <<<END |
692 | 692 | <p><input type="submit" value="$search_label" /></p> |
693 | 693 | </form> |
694 | 694 | |
— | — | @@ -699,22 +699,22 @@ |
700 | 700 | * Print the line showing 'AND' values for a filter that has not |
701 | 701 | * been applied to the drilldown |
702 | 702 | */ |
703 | | - function printUnappliedFilterLine($f, $cur_url) { |
| 703 | + function printUnappliedFilterLine( $f, $cur_url ) { |
704 | 704 | global $sdgScriptPath; |
705 | 705 | global $sdgFiltersSmallestFontSize, $sdgFiltersLargestFontSize; |
706 | 706 | |
707 | 707 | $f->createTempTable(); |
708 | 708 | $found_results_for_filter = false; |
709 | | - if (count($f->allowed_values) == 0) { |
| 709 | + if ( count( $f->allowed_values ) == 0 ) { |
710 | 710 | $filter_values = $f->getAllValues(); |
711 | | - if (count($filter_values) > 0) |
| 711 | + if ( count( $filter_values ) > 0 ) |
712 | 712 | $found_results_for_filter = true; |
713 | 713 | } else { |
714 | 714 | $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 ) { |
719 | 719 | $filter_values[$value] = $num_results; |
720 | 720 | } |
721 | 721 | } |
— | — | @@ -722,59 +722,59 @@ |
723 | 723 | // now get values for 'Other' and 'None', as well |
724 | 724 | // - don't show 'Other' if filter values were |
725 | 725 | // 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 ) { |
730 | 730 | $filter_values['_other'] = $num_results; |
731 | 731 | } |
732 | 732 | } |
733 | 733 | // show 'None' only if any other results have been found, and |
734 | 734 | // 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 ) { |
741 | 741 | $filter_values['_none'] = $num_results; |
742 | 742 | } |
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
746 | | - $filter_name = urlencode(str_replace(' ', '_', $f->name)); |
| 746 | + $filter_name = urlencode( str_replace( ' ', '_', $f->name ) ); |
747 | 747 | $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' ) . ')'; |
750 | 750 | // for backward compatibility, also check against |
751 | 751 | // 'sd_filter_freetext' (i.e. 'text' in English), which was |
752 | 752 | // 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 ); |
756 | 756 | $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 ); |
759 | 759 | $normal_filter = false; |
760 | 760 | } else |
761 | | - $results_line = $this->printUnappliedFilterValues($cur_url, $f, $filter_values); |
| 761 | + $results_line = $this->printUnappliedFilterValues( $cur_url, $f, $filter_values ); |
762 | 762 | |
763 | 763 | $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 |
767 | 767 | <div class="drilldown-filter-label"> |
768 | 768 | |
769 | 769 | END; |
770 | 770 | // no point showing "minimize" arrow if it's just a |
771 | 771 | // single text or date input |
772 | | - if ($normal_filter) { |
773 | | - $text .=<<<END |
| 772 | + if ( $normal_filter ) { |
| 773 | + $text .= <<<END |
774 | 774 | <a onclick="toggleFilterDiv('$results_div_id', this)" style="cursor: default;"><img src="$sdgScriptPath/skins/down-arrow.png"></a> |
775 | 775 | |
776 | 776 | END; |
777 | 777 | } |
778 | | - $text .=<<<END |
| 778 | + $text .= <<<END |
779 | 779 | $filter_label: |
780 | 780 | </div> |
781 | 781 | <div class="drilldown-filter-values" id="$results_div_id">$results_line |
— | — | @@ -793,84 +793,84 @@ |
794 | 794 | $skin = $wgUser->getSkin(); |
795 | 795 | $categories = SDUtils::getTopLevelCategories(); |
796 | 796 | // if there are no categories, escape quickly |
797 | | - if (count($categories) == 0) { |
| 797 | + if ( count( $categories ) == 0 ) { |
798 | 798 | return ""; |
799 | 799 | } |
800 | | - $subcategory_text = wfMsg('sd_browsedata_subcategory'); |
| 800 | + $subcategory_text = wfMsg( 'sd_browsedata_subcategory' ); |
801 | 801 | |
802 | 802 | $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 ); |
806 | 806 | } |
807 | 807 | // if there are no subcategories or filters for this |
808 | 808 | // category, escape now that we've (possibly) printed the |
809 | 809 | // 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 ) ) { |
813 | 813 | return $header; |
814 | 814 | } |
815 | 815 | $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>'; |
819 | 819 | } else |
820 | | - $header .= str_replace('_', ' ', $this->category); |
821 | | - if ($this->subcategory) { |
| 820 | + $header .= str_replace( '_', ' ', $this->category ); |
| 821 | + if ( $this->subcategory ) { |
822 | 822 | $header .= " > "; |
823 | 823 | $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>'; |
827 | 827 | } |
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 ); |
831 | 831 | // add an "x" to remove this filter, if it has more |
832 | 832 | // than one value |
833 | | - if (count($this->applied_filters[$i]->values) > 1) { |
| 833 | + if ( count( $this->applied_filters[$i]->values ) > 1 ) { |
834 | 834 | $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> : '; |
839 | 839 | } else { |
840 | 840 | $header .= "$filter_label: "; |
841 | 841 | } |
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 ); |
845 | 845 | $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>'; |
850 | 850 | } |
851 | | - if ($af->search_term != null) { |
| 851 | + if ( $af->search_term != null ) { |
852 | 852 | $temp_filters_array = $this->applied_filters; |
853 | 853 | $removed_search_term = $temp_filters_array[$i]->search_term; |
854 | 854 | $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 ); |
856 | 856 | $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 ) { |
859 | 859 | $header .= "\n <span class=\"drilldown-header-value\">" . $af->lower_date_string . " - " . $af->upper_date_string . "</span>"; |
860 | 860 | } |
861 | 861 | } |
862 | 862 | $header .= "</div>\n"; |
863 | | - $drilldown_description = wfMsg('sd_browsedata_docu'); |
| 863 | + $drilldown_description = wfMsg( 'sd_browsedata_docu' ); |
864 | 864 | $header .= " <p>$drilldown_description</p>\n"; |
865 | 865 | // display the list of subcategories on one line, and below |
866 | 866 | // it every filter, each on its own line; each line will |
867 | 867 | // contain the possible values, and, in parentheses, the |
868 | 868 | // number of pages that match that value |
869 | 869 | $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 ); |
873 | 873 | $num_printed_values = 0; |
874 | | - if (count($this->next_level_subcategories) > 0) { |
| 874 | + if ( count( $this->next_level_subcategories ) > 0 ) { |
875 | 875 | $results_line = ""; |
876 | 876 | // loop through to create an array of subcategory |
877 | 877 | // names and their number of values, then loop through |
— | — | @@ -878,47 +878,47 @@ |
879 | 879 | // instead of once, to be able to print a tag-cloud |
880 | 880 | // display if necessary |
881 | 881 | $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 ); |
885 | 885 | $subcat_values[$subcat] = $num_results; |
886 | 886 | } |
887 | 887 | // get necessary values for creating the tag cloud, |
888 | 888 | // 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 ); |
895 | 895 | } |
896 | 896 | |
897 | | - foreach ($subcat_values as $subcat => $num_results) { |
898 | | - if ($num_results > 0) { |
899 | | - if ($num_printed_values++ > 0) { $results_line .= " · "; } |
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 .= " · "; } |
| 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>'; |
905 | 905 | } 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>'; |
907 | 907 | } |
908 | 908 | } |
909 | 909 | } |
910 | | - if ($results_line != "") { |
| 910 | + if ( $results_line != "" ) { |
911 | 911 | $header .= " <p><strong>$subcategory_text:</strong> $results_line</p>\n"; |
912 | 912 | } |
913 | 913 | } |
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 ); |
919 | 919 | } |
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 ); |
923 | 923 | } |
924 | 924 | } |
925 | 925 | $header .= " </div> <!-- drilldown-filters -->\n"; |
— | — | @@ -930,15 +930,15 @@ |
931 | 931 | */ |
932 | 932 | function linkParameters() { |
933 | 933 | $params = array(); |
934 | | - if ($this->show_single_cat) |
| 934 | + if ( $this->show_single_cat ) |
935 | 935 | $params['_single'] = null; |
936 | 936 | $params['_cat'] = $this->category; |
937 | | - if ($this->subcategory) |
| 937 | + if ( $this->subcategory ) |
938 | 938 | $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 ); |
943 | 943 | $params[$key_string] = $value_string; |
944 | 944 | } else { |
945 | 945 | // HACK - QueryPage's pagination-URL code, |
— | — | @@ -946,9 +946,9 @@ |
947 | 947 | // two-dimensional arrays, which is what we |
948 | 948 | // need - instead, add the brackets directly |
949 | 949 | // 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 ); |
953 | 953 | $params[$key_string] = $value_string; |
954 | 954 | } |
955 | 955 | } |
— | — | @@ -967,7 +967,7 @@ |
968 | 968 | ids.smw_id AS id, |
969 | 969 | ids.smw_iw AS iw, |
970 | 970 | 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 ); |
972 | 972 | return $sql; |
973 | 973 | } |
974 | 974 | |
— | — | @@ -975,7 +975,7 @@ |
976 | 976 | return ' ORDER BY sortkey '; |
977 | 977 | } |
978 | 978 | |
979 | | - function formatResult($skin, $result) { |
| 979 | + function formatResult( $skin, $result ) { |
980 | 980 | $title = Title::makeTitle( $result->namespace, $result->value ); |
981 | 981 | return $skin->makeLinkObj( $title, $title->getText() ); |
982 | 982 | } |
— | — | @@ -994,29 +994,29 @@ |
995 | 995 | protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) { |
996 | 996 | global $wgContLang; |
997 | 997 | |
998 | | - $all_display_params = SDUtils::getDisplayParamsForCategory($this->category); |
| 998 | + $all_display_params = SDUtils::getDisplayParamsForCategory( $this->category ); |
999 | 999 | $querystring = null; |
1000 | 1000 | $printouts = $params = array(); |
1001 | 1001 | // 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 ); |
1005 | 1005 | } |
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 ) ) |
1008 | 1008 | $format = $params['format']; |
1009 | 1009 | else |
1010 | 1010 | $format = 'category'; |
1011 | | - if (array_key_exists('mainlabel', $params)) { |
| 1011 | + if ( array_key_exists( 'mainlabel', $params ) ) { |
1012 | 1012 | $mainlabel = $params['mainlabel']; |
1013 | 1013 | } else { |
1014 | 1014 | $mainlabel = ''; |
1015 | 1015 | } |
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 ); |
1018 | 1018 | |
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 ) ) |
1021 | 1021 | $prtext = $prresult[0]; |
1022 | 1022 | else |
1023 | 1023 | $prtext = $prresult; |
— | — | @@ -1026,9 +1026,9 @@ |
1027 | 1027 | // headItems of $out. |
1028 | 1028 | // How else can we do this? |
1029 | 1029 | global $wgParser; |
1030 | | - SMWOutputs::commitToParser($wgParser); |
| 1030 | + SMWOutputs::commitToParser( $wgParser ); |
1031 | 1031 | foreach ( $wgParser->mOutput->mHeadItems as $key => $item ) { |
1032 | | - $out->addHeadItem($key, $item); |
| 1032 | + $out->addHeadItem( $key, $item ); |
1033 | 1033 | } |
1034 | 1034 | // Force one more parser function, so links appear. |
1035 | 1035 | $wgParser->replaceLinkHolders( $prtext ); |
— | — | @@ -1036,7 +1036,7 @@ |
1037 | 1037 | $html = array(); |
1038 | 1038 | $html[] = $prtext; |
1039 | 1039 | |
1040 | | - if( !$this->listoutput ) |
| 1040 | + if ( !$this->listoutput ) |
1041 | 1041 | $html[] = $this->closeList(); |
1042 | 1042 | |
1043 | 1043 | $html = $this->listoutput |
— | — | @@ -1048,19 +1048,19 @@ |
1049 | 1049 | // add Ext library, to enable combobox, unless a map is being |
1050 | 1050 | // displayed - the Javascript for Ext conflicts with the |
1051 | 1051 | // Javascript for the maps |
1052 | | - if ($format != 'openlayers' || strpos($format, 'map') !== false) { |
| 1052 | + if ( $format != 'openlayers' || strpos( $format, 'map' ) !== false ) { |
1053 | 1053 | global $sdgScriptPath; |
1054 | 1054 | $out->addLink( array( |
1055 | 1055 | 'rel' => 'stylesheet', |
1056 | 1056 | 'type' => 'text/css', |
1057 | 1057 | 'media' => "screen", |
1058 | 1058 | 'href' => $sdgScriptPath . '/skins/ext-all.css' |
1059 | | - )); |
| 1059 | + ) ); |
1060 | 1060 | // overwrite style from ext-all.css, to set the correct |
1061 | 1061 | // 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>' ); |
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
— | — | @@ -1069,70 +1069,70 @@ |
1070 | 1070 | // semantic result printers. |
1071 | 1071 | // Code stolen largely from SMWSQLStore2QueryEngine->getInstanceQueryResult() method. |
1072 | 1072 | // (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 ) { |
1074 | 1074 | $qr = array(); |
1075 | 1075 | $count = 0; |
1076 | 1076 | $store = smwfGetStore(); |
1077 | | - while ( ($count < $num) && ($row = $dbr->fetchObject($res)) ) { |
| 1077 | + while ( ( $count < $num ) && ( $row = $dbr->fetchObject( $res ) ) ) { |
1078 | 1078 | $count++; |
1079 | | - $v = SMWWikiPageValue::makePage($row->t, $row->ns, $row->sortkey); |
| 1079 | + $v = SMWWikiPageValue::makePage( $row->t, $row->ns, $row->sortkey ); |
1080 | 1080 | $qr[] = $v; |
1081 | | - $store->cacheSMWPageID($row->id,$row->t,$row->ns,$row->iw); |
| 1081 | + $store->cacheSMWPageID( $row->id, $row->t, $row->ns, $row->iw ); |
1082 | 1082 | } |
1083 | | - if ($dbr->fetchObject($res)) { |
| 1083 | + if ( $dbr->fetchObject( $res ) ) { |
1084 | 1084 | $count++; |
1085 | 1085 | } |
1086 | | - $dbr->freeResult($res); |
| 1086 | + $dbr->freeResult( $res ); |
1087 | 1087 | |
1088 | | - $printrequest = new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, $mainlabel); |
| 1088 | + $printrequest = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $mainlabel ); |
1089 | 1089 | $main_printout = array(); |
1090 | 1090 | $main_printout[$printrequest->getHash()] = $printrequest; |
1091 | | - $printouts = array_merge($main_printout, $printouts); |
| 1091 | + $printouts = array_merge( $main_printout, $printouts ); |
1092 | 1092 | |
1093 | 1093 | // 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 ) ); |
1096 | 1096 | } |
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 ) { |
1099 | 1099 | $row = array(); |
1100 | 1100 | $cats = false; |
1101 | | - foreach ($printouts as $pr) { |
1102 | | - switch ($pr->getMode()) { |
| 1101 | + foreach ( $printouts as $pr ) { |
| 1102 | + switch ( $pr->getMode() ) { |
1103 | 1103 | case SMWPrintRequest::PRINT_THIS: |
1104 | | - $row[] = new SMWResultArray(array($qt), $pr); |
| 1104 | + $row[] = new SMWResultArray( array( $qt ), $pr ); |
1105 | 1105 | break; |
1106 | 1106 | 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' ) ); |
1109 | 1109 | } |
1110 | | - $row[] = new SMWResultArray($cats, $pr); |
| 1110 | + $row[] = new SMWResultArray( $cats, $pr ); |
1111 | 1111 | break; |
1112 | 1112 | 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 ); |
1114 | 1114 | break; |
1115 | 1115 | 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' ) ); |
1118 | 1118 | } |
1119 | 1119 | $found = '0'; |
1120 | 1120 | $prkey = $pr->getData()->getDBkey(); |
1121 | | - foreach ($cats as $cat) { |
1122 | | - if ($cat->getDBkey() == $prkey) { |
| 1121 | + foreach ( $cats as $cat ) { |
| 1122 | + if ( $cat->getDBkey() == $prkey ) { |
1123 | 1123 | $found = '1'; |
1124 | 1124 | break; |
1125 | 1125 | } |
1126 | 1126 | } |
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 ); |
1131 | 1131 | break; |
1132 | 1132 | } |
1133 | 1133 | } |
1134 | | - $result->addRow($row); |
| 1134 | + $result->addRow( $row ); |
1135 | 1135 | } |
1136 | | - wfProfileOut('SMWSQLStore2Queries::getInstanceQueryResult (SMW)'); |
| 1136 | + wfProfileOut( 'SMWSQLStore2Queries::getInstanceQueryResult (SMW)' ); |
1137 | 1137 | return $result; |
1138 | 1138 | } |
1139 | 1139 | |
Index: trunk/extensions/SemanticDrilldown/includes/SD_AppliedFilter.php |
— | — | @@ -15,23 +15,23 @@ |
16 | 16 | var $lower_date_string; |
17 | 17 | var $upper_date_string; |
18 | 18 | |
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 ) { |
20 | 20 | $af = new SDAppliedFilter(); |
21 | 21 | $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 ) { |
24 | 24 | $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']; |
26 | 26 | } |
27 | | - if ($upper_date != null) { |
| 27 | + if ( $upper_date != null ) { |
28 | 28 | $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']; |
30 | 30 | } |
31 | | - if (! is_array($values)) { |
32 | | - $values = array($values); |
| 31 | + if ( ! is_array( $values ) ) { |
| 32 | + $values = array( $values ); |
33 | 33 | } |
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 ); |
36 | 36 | $af->values[] = $filter_val; |
37 | 37 | } |
38 | 38 | return $af; |
— | — | @@ -41,57 +41,57 @@ |
42 | 42 | * Returns a string that adds a check for this filter/value |
43 | 43 | * combination to an SQL "WHERE" clause. |
44 | 44 | */ |
45 | | - function checkSQL($value_field) { |
| 45 | + function checkSQL( $value_field ) { |
46 | 46 | $sql = "("; |
47 | 47 | $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 ) ); |
51 | 51 | $sql .= "LOWER($value_field) LIKE '%{$search_term}%'"; |
52 | 52 | } else { |
53 | | - $search_term = strtolower($this->search_term); |
| 53 | + $search_term = strtolower( $this->search_term ); |
54 | 54 | $sql .= "LOWER($value_field) LIKE '%{$search_term}%'"; |
55 | 55 | } |
56 | 56 | } |
57 | | - if ($this->lower_date != null) { |
| 57 | + if ( $this->lower_date != null ) { |
58 | 58 | $date_string = $this->lower_date['year'] . "-" . $this->lower_date['month'] . "-" . $this->lower_date['day']; |
59 | 59 | $sql .= "date($value_field) >= date('$date_string') "; |
60 | 60 | } |
61 | | - if ($this->upper_date != null) { |
62 | | - if ($this->lower_date != null) { |
| 61 | + if ( $this->upper_date != null ) { |
| 62 | + if ( $this->lower_date != null ) { |
63 | 63 | $sql .= " AND "; |
64 | 64 | } |
65 | 65 | $date_string = $this->upper_date['year'] . "-" . $this->upper_date['month'] . "-" . $this->upper_date['day']; |
66 | 66 | $sql .= "date($value_field) <= date('$date_string') "; |
67 | 67 | } |
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 ) { |
71 | 71 | $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 ) { |
73 | 73 | $sql .= " OR "; |
74 | | - $sql .= $paf->checkSQL($value_field); |
| 74 | + $sql .= $paf->checkSQL( $value_field ); |
75 | 75 | } |
76 | 76 | $sql .= "))"; |
77 | | - } elseif ($fv->is_none) { |
| 77 | + } elseif ( $fv->is_none ) { |
78 | 78 | $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 ) |
81 | 81 | $sql .= "($value_field >= {$fv->lower_limit} AND $value_field <= {$fv->upper_limit}) "; |
82 | | - elseif ($fv->lower_limit) |
| 82 | + elseif ( $fv->lower_limit ) |
83 | 83 | $sql .= "$value_field > {$fv->lower_limit} "; |
84 | | - elseif ($fv->upper_limit) |
| 84 | + elseif ( $fv->upper_limit ) |
85 | 85 | $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' ) ) { |
88 | 88 | $sql .= "YEAR($value_field) = {$fv->year} AND MONTH($value_field) = {$fv->month} "; |
89 | 89 | } else { |
90 | 90 | $sql .= "YEAR($value_field) = {$fv->year} "; |
91 | 91 | } |
92 | 92 | } else { |
93 | 93 | $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 ); |
96 | 96 | } |
97 | 97 | $sql .= "$value_field = '{$dbr->strencode($value)}'"; |
98 | 98 | } |
— | — | @@ -105,21 +105,21 @@ |
106 | 106 | * Gets an array of all values that the property belonging to this |
107 | 107 | * filter has, for pages in the passed-in category. |
108 | 108 | */ |
109 | | - function getAllOrValues($category) { |
| 109 | + function getAllOrValues( $category ) { |
110 | 110 | $possible_values = array(); |
111 | | - $property_value = str_replace(' ', '_', $this->filter->property); |
| 111 | + $property_value = str_replace( ' ', '_', $this->filter->property ); |
112 | 112 | $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' ); |
115 | 115 | $property_table_nickname = "r"; |
116 | 116 | $value_field = 'o_ids.smw_title'; |
117 | 117 | } else { |
118 | | - $property_table_name = $dbr->tableName('smw_atts2'); |
| 118 | + $property_table_name = $dbr->tableName( 'smw_atts2' ); |
119 | 119 | $property_table_nickname = "a"; |
120 | 120 | $value_field = 'value_xsd'; |
121 | 121 | } |
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' ) ) { |
124 | 124 | $value_field = "YEAR(value_xsd), MONTH(value_xsd)"; |
125 | 125 | } else { |
126 | 126 | $value_field = "YEAR(value_xsd)"; |
— | — | @@ -131,7 +131,7 @@ |
132 | 132 | $sql = " SELECT $value_field |
133 | 133 | FROM $property_table_name $property_table_nickname |
134 | 134 | 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 ) { |
136 | 136 | $sql .= " JOIN $smw_ids o_ids ON $property_table_nickname.o_id = o_ids.smw_id\n"; |
137 | 137 | } |
138 | 138 | $sql .= " JOIN $smw_insts insts ON $property_table_nickname.s_id = insts.s_id |
— | — | @@ -141,16 +141,16 @@ |
142 | 142 | AND cat_ids.smw_title = '$category' |
143 | 143 | GROUP BY $value_field |
144 | 144 | 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]; |
149 | 149 | else |
150 | 150 | // why is trim() necessary here??? |
151 | | - $value_string = str_replace('_', ' ', trim($row[0])); |
| 151 | + $value_string = str_replace( '_', ' ', trim( $row[0] ) ); |
152 | 152 | $possible_values[] = $value_string; |
153 | 153 | } |
154 | | - $dbr->freeResult($res); |
| 154 | + $dbr->freeResult( $res ); |
155 | 155 | return $possible_values; |
156 | 156 | } |
157 | 157 | |
Index: trunk/extensions/SemanticDrilldown/includes/SD_Filter.php |
— | — | @@ -18,58 +18,58 @@ |
19 | 19 | var $allowed_values; |
20 | 20 | var $possible_applied_filters = array(); |
21 | 21 | |
22 | | - function load($filter_name) { |
| 22 | + function load( $filter_name ) { |
23 | 23 | $f = new SDFilter(); |
24 | 24 | $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 ) { |
27 | 27 | $f->property = $properties_used[0]; |
28 | 28 | } |
29 | 29 | $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 ) { |
32 | 32 | $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' ) ); |
35 | 35 | } else { |
36 | | - $types = $store->getSpecialValues($proptitle, SMW_SP_HAS_TYPE); |
| 36 | + $types = $store->getSpecialValues( $proptitle, SMW_SP_HAS_TYPE ); |
37 | 37 | } |
38 | 38 | global $smwgContLang; |
39 | 39 | $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'] ) { |
42 | 42 | $f->is_relation = false; |
43 | 43 | } |
44 | | - if ($types[0]->getWikiValue() == $datatypeLabels['_boo']) { |
| 44 | + if ( $types[0]->getWikiValue() == $datatypeLabels['_boo'] ) { |
45 | 45 | $f->is_boolean = true; |
46 | 46 | } |
47 | | - if ($types[0]->getWikiValue() == $datatypeLabels['_dat']) { |
| 47 | + if ( $types[0]->getWikiValue() == $datatypeLabels['_dat'] ) { |
48 | 48 | $f->is_date = true; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
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 ) { |
55 | 55 | $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 ) { |
58 | 58 | $f->time_period = $time_periods[0]; |
59 | 59 | $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' ); |
62 | 62 | } 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 ); |
64 | 64 | $f->allowed_values = $values; |
65 | 65 | } |
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 ) { |
68 | 68 | $f->input_type = $input_types[0]; |
69 | 69 | } |
70 | 70 | // set list of possible applied filters if allowed values |
71 | 71 | // 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 ); |
74 | 74 | } |
75 | 75 | return $f; |
76 | 76 | } |
— | — | @@ -81,16 +81,16 @@ |
82 | 82 | */ |
83 | 83 | function getTimePeriodValues() { |
84 | 84 | $possible_dates = array(); |
85 | | - $property_value = str_replace(' ', '_', $this->property); |
| 85 | + $property_value = str_replace( ' ', '_', $this->property ); |
86 | 86 | $dbr = wfGetDB( DB_SLAVE ); |
87 | | - if ($this->time_period == wfMsg('sd_filter_month')) { |
| 87 | + if ( $this->time_period == wfMsg( 'sd_filter_month' ) ) { |
88 | 88 | $fields = "YEAR(value_xsd), MONTH(value_xsd)"; |
89 | 89 | } else { |
90 | 90 | $fields = "YEAR(value_xsd)"; |
91 | 91 | } |
92 | 92 | $smw_attributes = $dbr->tableName( 'smw_atts2' ); |
93 | 93 | $smw_ids = $dbr->tableName( 'smw_ids' ); |
94 | | - $sql =<<<END |
| 94 | + $sql = <<<END |
95 | 95 | SELECT $fields, count(*) |
96 | 96 | FROM semantic_drilldown_values sdv |
97 | 97 | JOIN $smw_attributes a ON sdv.id = a.s_id |
— | — | @@ -100,18 +100,18 @@ |
101 | 101 | ORDER BY $fields |
102 | 102 | |
103 | 103 | 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' ) ) { |
107 | 107 | global $sdgMonthValues; |
108 | | - $date_string = SDUtils::monthToString($row[1]) . " " . $row[0]; |
| 108 | + $date_string = SDUtils::monthToString( $row[1] ) . " " . $row[0]; |
109 | 109 | $possible_dates[$date_string] = $row[2]; |
110 | 110 | } else { |
111 | 111 | $date_string = $row[0]; |
112 | 112 | $possible_dates[$date_string] = $row[1]; |
113 | 113 | } |
114 | 114 | } |
115 | | - $dbr->freeResult($res); |
| 115 | + $dbr->freeResult( $res ); |
116 | 116 | return $possible_dates; |
117 | 117 | } |
118 | 118 | |
— | — | @@ -121,33 +121,33 @@ |
122 | 122 | * that match that value. |
123 | 123 | */ |
124 | 124 | function getAllValues() { |
125 | | - if ($this->time_period != null) |
| 125 | + if ( $this->time_period != null ) |
126 | 126 | return $this->getTimePeriodValues(); |
127 | 127 | |
128 | 128 | $possible_values = array(); |
129 | | - $property_value = str_replace(' ', '_', $this->property); |
| 129 | + $property_value = str_replace( ' ', '_', $this->property ); |
130 | 130 | $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' ); |
133 | 133 | $property_table_nickname = "r"; |
134 | 134 | $value_field = 'o_ids.smw_title'; |
135 | 135 | } else { |
136 | | - $property_table_name = $dbr->tableName('smw_atts2'); |
| 136 | + $property_table_name = $dbr->tableName( 'smw_atts2' ); |
137 | 137 | $property_table_nickname = "a"; |
138 | 138 | $value_field = 'value_xsd'; |
139 | 139 | } |
140 | 140 | $smw_ids = $dbr->tableName( 'smw_ids' ); |
141 | 141 | $prop_ns = SMW_NS_PROPERTY; |
142 | | - $sql =<<<END |
| 142 | + $sql = <<<END |
143 | 143 | SELECT $value_field, count(DISTINCT sdv.id) |
144 | 144 | FROM semantic_drilldown_values sdv |
145 | 145 | JOIN $property_table_name $property_table_nickname ON sdv.id = $property_table_nickname.s_id |
146 | 146 | |
147 | 147 | END; |
148 | | - if ($this->is_relation) { |
| 148 | + if ( $this->is_relation ) { |
149 | 149 | $sql .= " JOIN $smw_ids o_ids ON r.o_id = o_ids.smw_id"; |
150 | 150 | } |
151 | | - $sql .=<<<END |
| 151 | + $sql .= <<<END |
152 | 152 | JOIN $smw_ids p_ids ON $property_table_nickname.p_id = p_ids.smw_id |
153 | 153 | WHERE p_ids.smw_title = '$property_value' |
154 | 154 | AND p_ids.smw_namespace = $prop_ns |
— | — | @@ -156,12 +156,12 @@ |
157 | 157 | ORDER BY $value_field |
158 | 158 | |
159 | 159 | 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] ); |
163 | 163 | $possible_values[$value_string] = $row[1]; |
164 | 164 | } |
165 | | - $dbr->freeResult($res); |
| 165 | + $dbr->freeResult( $res ); |
166 | 166 | return $possible_values; |
167 | 167 | } |
168 | 168 | |
— | — | @@ -175,7 +175,7 @@ |
176 | 176 | function createTempTable() { |
177 | 177 | $dbr = wfGetDB( DB_SLAVE ); |
178 | 178 | $smw_ids = $dbr->tableName( 'smw_ids' ); |
179 | | - if ($this->is_relation) { |
| 179 | + if ( $this->is_relation ) { |
180 | 180 | $table_name = $dbr->tableName( 'smw_rels2' ); |
181 | 181 | $property_field = 'p_id'; |
182 | 182 | $value_field = 'o_ids.smw_title'; |
— | — | @@ -184,19 +184,19 @@ |
185 | 185 | $property_field = 'p_id'; |
186 | 186 | $value_field = 'value_xsd'; |
187 | 187 | } |
188 | | - $query_property = str_replace(' ', '_', $this->property); |
189 | | - $sql =<<<END |
| 188 | + $query_property = str_replace( ' ', '_', $this->property ); |
| 189 | + $sql = <<<END |
190 | 190 | CREATE TEMPORARY TABLE semantic_drilldown_filter_values |
191 | 191 | AS SELECT s_id AS id, $value_field AS value |
192 | 192 | FROM $table_name |
193 | 193 | JOIN $smw_ids p_ids ON $table_name.p_id = p_ids.smw_id |
194 | 194 | |
195 | 195 | END; |
196 | | - if ($this->is_relation) { |
| 196 | + if ( $this->is_relation ) { |
197 | 197 | $sql .= " JOIN $smw_ids o_ids ON $table_name.o_id = o_ids.smw_id\n"; |
198 | 198 | } |
199 | 199 | $sql .= " WHERE p_ids.smw_title = '$query_property'"; |
200 | | - $dbr->query($sql); |
| 200 | + $dbr->query( $sql ); |
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
— | — | @@ -205,6 +205,6 @@ |
206 | 206 | function dropTempTable() { |
207 | 207 | $dbr = wfGetDB( DB_SLAVE ); |
208 | 208 | $sql = "DROP TEMPORARY TABLE semantic_drilldown_filter_values"; |
209 | | - $dbr->query($sql); |
| 209 | + $dbr->query( $sql ); |
210 | 210 | } |
211 | 211 | } |
Index: trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php |
— | — | @@ -5,32 +5,32 @@ |
6 | 6 | * @author Yaron Koren |
7 | 7 | */ |
8 | 8 | |
9 | | -if (!defined('MEDIAWIKI')) die(); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
10 | 10 | |
11 | | -define('SD_VERSION','0.7.1'); |
| 11 | +define( 'SD_VERSION', '0.7.1' ); |
12 | 12 | |
13 | 13 | // 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 ); |
24 | 24 | |
25 | | -$wgExtensionCredits['specialpage'][]= array( |
| 25 | +$wgExtensionCredits['specialpage'][] = array( |
26 | 26 | 'path' => __FILE__, |
27 | 27 | 'name' => 'Semantic Drilldown', |
28 | 28 | 'version' => SD_VERSION, |
29 | | - 'author' => array('Yaron Koren', 'David Loomer'), |
| 29 | + 'author' => array( 'Yaron Koren', 'David Loomer' ), |
30 | 30 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Drilldown', |
31 | 31 | 'descriptionmsg' => 'semanticdrilldown-desc', |
32 | 32 | ); |
33 | 33 | |
34 | | -require_once($sdgIP . '/languages/SD_Language.php'); |
| 34 | +require_once( $sdgIP . '/languages/SD_Language.php' ); |
35 | 35 | |
36 | 36 | $wgExtensionMessagesFiles['SemanticDrilldown'] = $sdgIP . '/languages/SD_Messages.php'; |
37 | 37 | $wgExtensionAliasesFiles['SemanticDrilldown'] = $sdgIP . '/languages/SD_Aliases.php'; |
— | — | @@ -68,17 +68,17 @@ |
69 | 69 | global $sdgNamespaceIndex, $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespacesWithSubpages, $smwgNamespacesWithSemanticLinks; |
70 | 70 | global $wgLanguageCode, $sdgContLang; |
71 | 71 | |
72 | | - if (!isset($sdgNamespaceIndex)) { |
| 72 | + if ( !isset( $sdgNamespaceIndex ) ) { |
73 | 73 | $sdgNamespaceIndex = 170; |
74 | 74 | } |
75 | 75 | |
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 ); |
78 | 78 | |
79 | | - sdfInitContentLanguage($wgLanguageCode); |
| 79 | + sdfInitContentLanguage( $wgLanguageCode ); |
80 | 80 | |
81 | 81 | // Register namespace identifiers |
82 | | - if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); } |
| 82 | + if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); } |
83 | 83 | $wgExtraNamespaces = $wgExtraNamespaces + $sdgContLang->getNamespaces(); |
84 | 84 | $wgNamespaceAliases = $wgNamespaceAliases + $sdgContLang->getNamespaceAliases(); |
85 | 85 | |
— | — | @@ -99,25 +99,25 @@ |
100 | 100 | /**********************************************/ |
101 | 101 | |
102 | 102 | /** |
103 | | - * Initialise a global language object for content language. This |
| 103 | + * Initialize a global language object for content language. This |
104 | 104 | * must happen early on, even before user language is known, to |
105 | 105 | * 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. |
107 | 107 | */ |
108 | | -function sdfInitContentLanguage($langcode) { |
| 108 | +function sdfInitContentLanguage( $langcode ) { |
109 | 109 | global $sdgIP, $sdgContLang; |
110 | 110 | |
111 | | - if (!empty($sdgContLang)) { return; } |
| 111 | + if ( !empty( $sdgContLang ) ) { return; } |
112 | 112 | |
113 | 113 | $sdContLangClass = 'SD_Language' . str_replace( '-', '_', ucfirst( $langcode ) ); |
114 | 114 | |
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' ); |
117 | 117 | } |
118 | 118 | |
119 | 119 | // 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' ); |
122 | 122 | $sdContLangClass = 'SD_LanguageEn'; |
123 | 123 | } |
124 | 124 | |
— | — | @@ -125,22 +125,22 @@ |
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
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 |
131 | 131 | * this language is used as a fallback. |
132 | 132 | */ |
133 | | -function sdfInitUserLanguage($langcode) { |
| 133 | +function sdfInitUserLanguage( $langcode ) { |
134 | 134 | global $sdgIP, $sdgLang; |
135 | 135 | |
136 | | - if (!empty($sdgLang)) { return; } |
| 136 | + if ( !empty( $sdgLang ) ) { return; } |
137 | 137 | |
138 | 138 | $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' ); |
141 | 141 | } |
142 | 142 | |
143 | 143 | // fallback if language not supported |
144 | | - if ( !class_exists($sdLangClass)) { |
| 144 | + if ( !class_exists( $sdLangClass ) ) { |
145 | 145 | include_once( $sdgIP . '/languages/SD_LanguageEn.php' ); |
146 | 146 | $sdLangClass = 'SD_LanguageEn'; |
147 | 147 | } |
— | — | @@ -157,54 +157,54 @@ |
158 | 158 | global $sdgIP, $wgMessageCache; |
159 | 159 | |
160 | 160 | # 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 ); |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | 167 | function sdfInitProperties() { |
168 | 168 | global $sdgContLang, $wgLanguageCode; |
169 | 169 | $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' ), |
180 | 180 | ); |
181 | 181 | // register main property labels |
182 | 182 | $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 ) { |
184 | 184 | $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 ); |
186 | 186 | } |
187 | 187 | // if it's not English, add the English-language aliases as well |
188 | | - if ($wgLanguageCode != 'en') { |
| 188 | + if ( $wgLanguageCode != 'en' ) { |
189 | 189 | $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 ) { |
191 | 191 | $prop_vals = $sd_property_vals[$prop_id]; |
192 | | - SMWPropertyValue::registerPropertyAlias($prop_vals[0], $prop_alias); |
| 192 | + SMWPropertyValue::registerPropertyAlias( $prop_vals[0], $prop_alias ); |
193 | 193 | } |
194 | 194 | } |
195 | 195 | return true; |
196 | 196 | } |
197 | 197 | |
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 ) ); |
207 | 207 | |
208 | | - $browse_search_section->addRow($sd_row); |
| 208 | + $browse_search_section->addRow( $sd_row ); |
209 | 209 | |
210 | 210 | return true; |
211 | 211 | } |
Index: trunk/extensions/SemanticDrilldown/includes/SD_Settings.php |
— | — | @@ -1,53 +1,53 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -### |
| 4 | +# ## |
5 | 5 | # This is the path to your installation of Semantic Drilldown as |
6 | 6 | # seen from the web. Change it if required ($wgScriptPath is the |
7 | 7 | # path to the base directory of your wiki). No final slash. |
8 | | -## |
| 8 | +# # |
9 | 9 | $sdgScriptPath = $wgScriptPath . '/extensions/SemanticDrilldown'; |
10 | | -## |
| 10 | +# # |
11 | 11 | |
12 | | -### |
| 12 | +# ## |
13 | 13 | # This is the path to your installation of Semantic Drilldown as |
14 | 14 | # seen on your local filesystem. Used against some PHP file path |
15 | 15 | # issues. |
16 | | -## |
| 16 | +# # |
17 | 17 | $sdgIP = $IP . '/extensions/SemanticDrilldown'; |
18 | | -## |
| 18 | +# # |
19 | 19 | |
20 | 20 | |
21 | 21 | // PHP fails to find relative includes at some level of inclusion: |
22 | | -//$pathfix = $IP . $sdgScriptPath; |
| 22 | +// $pathfix = $IP . $sdgScriptPath; |
23 | 23 | |
24 | 24 | // load global functions |
25 | | -require_once('SD_GlobalFunctions.php'); |
| 25 | +require_once( 'SD_GlobalFunctions.php' ); |
26 | 26 | |
27 | | -### |
| 27 | +# ## |
28 | 28 | # If you already have custom namespaces on your site, insert |
29 | 29 | # $sdgNamespaceIndex = ???; |
30 | 30 | # into your LocalSettings.php *before* including this file. |
31 | 31 | # The number ??? must be the smallest even namespace number |
32 | 32 | # that is not in use yet. However, it should not be smaller |
33 | 33 | # than 170. |
34 | | -## |
35 | | -if (!isset($sdgNamespaceIndex)) { |
36 | | - sdfInitNamespaces(170); |
| 34 | +# # |
| 35 | +if ( !isset( $sdgNamespaceIndex ) ) { |
| 36 | + sdfInitNamespaces( 170 ); |
37 | 37 | } else { |
38 | 38 | sdfInitNamespaces(); |
39 | 39 | } |
40 | 40 | |
41 | | -### |
42 | | -## List separator character |
43 | | -### |
| 41 | +# ## |
| 42 | +# # List separator character |
| 43 | +# ## |
44 | 44 | $sdgListSeparator = ","; |
45 | 45 | |
46 | | -### |
47 | | -## Variables for display |
48 | | -### |
| 46 | +# ## |
| 47 | +# # Variables for display |
| 48 | +# ## |
49 | 49 | $sdgNumResultsPerPage = 250; |
50 | 50 | // set these to a positive value to trigger the "tag cloud" display |
51 | | -$sdgFiltersSmallestFontSize=-1; |
52 | | -$sdgFiltersLargestFontSize=-1; |
| 51 | +$sdgFiltersSmallestFontSize = - 1; |
| 52 | +$sdgFiltersLargestFontSize = - 1; |
53 | 53 | // print categories list as tabs |
54 | 54 | $sdgShowCategoriesAsTabs = false; |
Index: trunk/extensions/SemanticDrilldown/includes/SD_FilterValue.php |
— | — | @@ -16,48 +16,48 @@ |
17 | 17 | var $year = null; |
18 | 18 | var $month = null; |
19 | 19 | |
20 | | - function create($actual_val, $filter_time_period = null) { |
| 20 | + function create( $actual_val, $filter_time_period = null ) { |
21 | 21 | $fv = new SDFilterValue(); |
22 | | - $fv->text = htmlspecialchars($actual_val); |
| 22 | + $fv->text = htmlspecialchars( $actual_val ); |
23 | 23 | |
24 | | - if ($fv->text == ' none') |
| 24 | + if ( $fv->text == ' none' ) |
25 | 25 | $fv->is_none = true; |
26 | | - if ($fv->text == ' other') |
| 26 | + if ( $fv->text == ' other' ) |
27 | 27 | $fv->is_other = true; |
28 | 28 | // 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 ); |
33 | 33 | $fv->year = $year; |
34 | 34 | } else { |
35 | 35 | $fv->year = $fv->text; |
36 | 36 | } |
37 | 37 | } else { |
38 | 38 | // SMW 1.0 HTML-encodes the value; un-encode it here |
39 | | - $originals = array('<', '>'); |
40 | | - $replacements = array('<', '>'); |
41 | | - $fv->text = str_replace($originals, $replacements, $fv->text); |
42 | | - if ($fv->text == '') { |
| 39 | + $originals = array( '<', '>' ); |
| 40 | + $replacements = array( '<', '>' ); |
| 41 | + $fv->text = str_replace( $originals, $replacements, $fv->text ); |
| 42 | + if ( $fv->text == '' ) { |
43 | 43 | // 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 ) ) { |
47 | 47 | $fv->upper_limit = $possible_number; |
48 | 48 | $fv->is_numeric = true; |
49 | 49 | } |
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 ) ) { |
53 | 53 | $fv->lower_limit = $possible_number; |
54 | 54 | $fv->is_numeric = true; |
55 | 55 | } |
56 | 56 | } 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 ) ) { |
62 | 62 | $fv->lower_limit = $first_elem; |
63 | 63 | $fv->upper_limit = $second_elem; |
64 | 64 | $fv->is_numeric = true; |
— | — | @@ -71,23 +71,23 @@ |
72 | 72 | /* |
73 | 73 | * Used in sorting, when BrowseDataPage creates a new URL |
74 | 74 | */ |
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; |
84 | 84 | } |
85 | | - return ($fv1->year > $fv2->year) ? 1 : -1; |
| 85 | + return ( $fv1->year > $fv2->year ) ? 1 : - 1; |
86 | 86 | } |
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; |
90 | 90 | } |
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; |
93 | 93 | } |
94 | 94 | } |