Index: trunk/extensions/SemanticResultFormats/Calendar/SRF_Calendar.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | |
23 | 23 | $this->mTemplate = trim( $params['template'] ); |
24 | 24 | $this->mUserParam = trim( $params['userparam'] ); |
25 | | - |
| 25 | + |
26 | 26 | if ( $params['lang'] !== false ) { |
27 | 27 | global $wgLang; |
28 | 28 | // Store the actual user's language, so we can revert |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | */ |
54 | 54 | protected function getResultText( SMWQueryResult $res, $outputmode ) { |
55 | 55 | $events = array(); |
56 | | - |
| 56 | + |
57 | 57 | // Print all result rows. |
58 | 58 | while ( $row = $res->getNext() ) { |
59 | 59 | $dates = array(); |
— | — | @@ -61,15 +61,15 @@ |
62 | 62 | if ( $this->mTemplate != '' ) { |
63 | 63 | // Build template code |
64 | 64 | $this->hasTemplates = true; |
65 | | - |
| 65 | + |
66 | 66 | if ( $this->mUserParam ) { |
67 | 67 | $text = "|userparam=$this->mUserParam"; |
68 | 68 | } |
69 | | - |
| 69 | + |
70 | 70 | foreach ( $row as $i => $field ) { |
71 | 71 | $pr = $field->getPrintRequest(); |
72 | 72 | $text .= '|' . ( $i + 1 ) . '='; |
73 | | - |
| 73 | + |
74 | 74 | while ( ( $object = $field->getNextDataValue() ) !== false ) { |
75 | 75 | if ( $object->getTypeID() == '_dat' ) { |
76 | 76 | $text .= $object->getLongWikiText(); |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | } else { |
85 | 85 | $text .= $object->getShortText( $outputmode, null ); |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | if ( $pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_dat' ) { |
89 | 89 | $dates[] = $this->formatDateStr( $object ); |
90 | 90 | } |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | // value - cycle through all the values |
103 | 103 | // for this property. |
104 | 104 | $textForProperty = ''; |
105 | | - |
| 105 | + |
106 | 106 | while ( ( $object = $field->getNextDataValue() ) !== false ) { |
107 | 107 | if ( $object->getTypeID() == '_dat' ) { |
108 | 108 | // Don't add date values to the display. |
— | — | @@ -110,14 +110,14 @@ |
111 | 111 | $title = Title::newFromText( $object->getShortWikiText( false ) ); |
112 | 112 | } else { |
113 | 113 | $numNonDateProperties++; |
114 | | - |
| 114 | + |
115 | 115 | // handling of "headers=" param |
116 | 116 | if ( $this->mShowHeaders == SMW_HEADERS_SHOW ) { |
117 | 117 | $textForProperty .= $pr->getHTMLText( smwfGetLinker() ) . ' '; |
118 | 118 | } elseif ( $this->mShowHeaders == SMW_HEADERS_PLAIN ) { |
119 | 119 | $textForProperty .= $pr->getLabel() . ' '; |
120 | 120 | } |
121 | | - |
| 121 | + |
122 | 122 | // If $this->mShowHeaders == SMW_HEADERS_HIDE, print nothing. |
123 | 123 | // handling of "link=" param |
124 | 124 | if ( $this->mLinkOthers ) { |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | $dates[] = $this->formatDateStr( $object ); |
136 | 136 | } |
137 | 137 | } |
138 | | - |
| 138 | + |
139 | 139 | // Add the text for this property to |
140 | 140 | // the main text, adding on parentheses |
141 | 141 | // or commas as needed. |
— | — | @@ -149,27 +149,17 @@ |
150 | 150 | $text .= ')'; |
151 | 151 | } |
152 | 152 | } |
153 | | - |
| 153 | + |
154 | 154 | if ( count( $dates ) > 0 ) { |
155 | 155 | // Handle the 'color=' value, whether it came |
156 | 156 | // from a compound query or a regular one. |
157 | | - // handling is different for SMW 1.5+ |
158 | | - $realFunction = array( $field, 'getResultSubject' ); |
159 | | - if ( is_callable( $realFunction ) ) { |
160 | | - $res_subject = $field->getResultSubject(); |
161 | | - if ( isset( $res_subject->display_options ) |
162 | | - && is_array( $res_subject->display_options ) |
163 | | - && array_key_exists( 'color', $res_subject->display_options ) ) { |
164 | | - $color = $res_subject->display_options['color']; |
165 | | - } |
166 | | - } elseif ( property_exists( $row[0], 'display_options' ) ) { |
167 | | - if ( is_array( $row[0]->display_options ) && array_key_exists( 'color', $row[0]->display_options ) ) { |
168 | | - $color = $row[0]->display_options['color']; |
169 | | - } |
170 | | - } elseif ( array_key_exists( 'color', $this->m_params ) ) { |
171 | | - $color = $this->m_params['color']; |
| 157 | + $res_subject = $field->getResultSubject(); |
| 158 | + if ( isset( $res_subject->display_options ) |
| 159 | + && is_array( $res_subject->display_options ) |
| 160 | + && array_key_exists( 'color', $res_subject->display_options ) ) { |
| 161 | + $color = $res_subject->display_options['color']; |
172 | 162 | } |
173 | | - |
| 163 | + |
174 | 164 | foreach ( $dates as $date ) { |
175 | 165 | $events[] = array( $title, $text, $date, $color ); |
176 | 166 | } |
— | — | @@ -177,16 +167,16 @@ |
178 | 168 | } |
179 | 169 | |
180 | 170 | $result = $this->displayCalendar( $events ); |
181 | | - |
| 171 | + |
182 | 172 | // Go back to the actual user's language, in case a different |
183 | 173 | // language had been specified for this calendar. |
184 | 174 | if ( ! is_null( $this->mRealUserLang ) ) { |
185 | 175 | global $wgLang; |
186 | 176 | $wgLang = $this->mRealUserLang; |
187 | 177 | } |
188 | | - |
| 178 | + |
189 | 179 | global $wgParser; |
190 | | - |
| 180 | + |
191 | 181 | if ( is_null( $wgParser->getTitle() ) ) { |
192 | 182 | return $result; |
193 | 183 | } else { |
— | — | @@ -205,11 +195,11 @@ |
206 | 196 | '7' => 'july', |
207 | 197 | '8' => 'august', |
208 | 198 | '9' => 'september', |
209 | | - '10' => 'october', |
| 199 | + '10' => 'october', |
210 | 200 | '11' => 'november', |
211 | 201 | '12' => 'december', |
212 | 202 | ); |
213 | | - |
| 203 | + |
214 | 204 | return wfMsgForContent( array_key_exists( $int, $months ) ? $months[$int] : 'january' ); |
215 | 205 | } |
216 | 206 | |
— | — | @@ -240,7 +230,7 @@ |
241 | 231 | $additional_query_string = ''; |
242 | 232 | $hidden_inputs = ''; |
243 | 233 | $in_special_page = is_null( $page_title ) || $page_title->isSpecialPage(); |
244 | | - |
| 234 | + |
245 | 235 | if ( $in_special_page ) { |
246 | 236 | global $wgTitle; |
247 | 237 | $page_title = $wgTitle; |
— | — | @@ -259,7 +249,7 @@ |
260 | 250 | } |
261 | 251 | } |
262 | 252 | } |
263 | | - |
| 253 | + |
264 | 254 | foreach ( $request_values as $key => $value ) { |
265 | 255 | if ( $key != 'month' && $key != 'year' |
266 | 256 | // values from 'RunQuery' |
— | — | @@ -321,7 +311,7 @@ |
322 | 312 | $cur_month_num = $wgRequest->getVal( 'month' ); |
323 | 313 | } |
324 | 314 | } |
325 | | - |
| 315 | + |
326 | 316 | $cur_month = self::intToMonth( $cur_month_num ); |
327 | 317 | $cur_year = date( 'Y', time() ); |
328 | 318 | if ( $wgRequest->getCheck( 'year' ) ) { |
— | — | @@ -330,7 +320,7 @@ |
331 | 321 | $cur_year = $wgRequest->getVal( 'year' ); |
332 | 322 | } |
333 | 323 | } |
334 | | - |
| 324 | + |
335 | 325 | if ( $cur_month_num == '1' ) { |
336 | 326 | $prev_month_num = '12'; |
337 | 327 | $prev_year = $cur_year - 1; |
— | — | @@ -338,7 +328,7 @@ |
339 | 329 | $prev_month_num = $cur_month_num - 1; |
340 | 330 | $prev_year = $cur_year; |
341 | 331 | } |
342 | | - |
| 332 | + |
343 | 333 | if ( $cur_month_num == '12' ) { |
344 | 334 | $next_month_num = '1'; |
345 | 335 | $next_year = $cur_year + 1; |
— | — | @@ -346,16 +336,16 @@ |
347 | 337 | $next_month_num = $cur_month_num + 1; |
348 | 338 | $next_year = $cur_year; |
349 | 339 | } |
350 | | - |
| 340 | + |
351 | 341 | // There's no year '0' - change it to '1' or '-1'. |
352 | 342 | if ( $cur_year == '0' ) { $cur_year = '1'; } |
353 | 343 | if ( $next_year == '0' ) { $next_year = '1'; } |
354 | 344 | if ( $prev_year == '0' ) { $prev_year = '-1'; } |
355 | | - |
| 345 | + |
356 | 346 | $prev_month_url = $page_title->getLocalURL( "month=$prev_month_num&year=$prev_year" . $additional_query_string ); |
357 | 347 | $next_month_url = $page_title->getLocalURL( "month=$next_month_num&year=$next_year" . $additional_query_string ); |
358 | 348 | $today_url = $page_title->getLocalURL( $additional_query_string ); |
359 | | - |
| 349 | + |
360 | 350 | $today_text = wfMsg( 'srfc_today' ); |
361 | 351 | $prev_month_text = wfMsg( 'srfc_previousmonth' ); |
362 | 352 | $next_month_text = wfMsg( 'srfc_nextmonth' ); |
— | — | @@ -502,20 +492,20 @@ |
503 | 493 | */ |
504 | 494 | public function getParameters() { |
505 | 495 | $params = parent::getParameters(); |
506 | | - |
| 496 | + |
507 | 497 | $params['lang'] = new Parameter( 'lang' ); |
508 | 498 | $params['lang']->setMessage( 'srf_paramdesc_calendarlang' ); |
509 | 499 | $params['lang']->setDefault( false, false ); |
510 | | - |
| 500 | + |
511 | 501 | $params['template'] = new Parameter( 'template' ); |
512 | 502 | $params['template']->setDefault( '' ); |
513 | | - |
| 503 | + |
514 | 504 | $params['userparam'] = new Parameter( 'userparam' ); |
515 | 505 | $params['userparam']->setDefault( '' ); |
516 | | - |
| 506 | + |
517 | 507 | $params['color'] = new Parameter( 'color' ); |
518 | 508 | $params['color']->setDefault( '' ); |
519 | | - |
| 509 | + |
520 | 510 | return $params; |
521 | 511 | } |
522 | 512 | |