r49974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49973‎ | r49974 | r49975 >
Date:19:49, 27 April 2009
Author:yaron
Status:deferred
Tags:
Comment:
Changes to allow calendar to work in Special:Ask
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Calendar/SRF_Calendar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Calendar/SRF_Calendar.php
@@ -111,8 +111,11 @@
112112 }
113113
114114 $result = SRFCalendar::displayCalendar($events);
115 -
116 - return array($result, 'noparse' => 'true', 'isHTML' => 'true');
 115+ global $wgParser;
 116+ if (is_null($wgParser->getTitle()))
 117+ return $result;
 118+ else
 119+ return array($result, 'noparse' => 'true', 'isHTML' => 'true');
117120 }
118121
119122
@@ -154,8 +157,24 @@
155158 ));
156159 wfLoadExtensionMessages('SemanticResultFormats');
157160
 161+ // set variables differently depending on whether this is
 162+ // being called from an #ask call or the Special:Ask page
158163 $page_title = $wgParser->getTitle();
159 - $skin = $wgParser->getOptions()->getSkin();
 164+ $in_ask_page = is_null($page_title);
 165+ if ($in_ask_page) {
 166+ global $wgTitle;
 167+ $page_title = $wgTitle;
 168+ global $wgUser;
 169+ $skin = $wgUser->getSkin();
 170+ $additional_query_string = '';
 171+ foreach ($wgRequest->getValues() as $key => $value) {
 172+ if ($key != 'month' && $key != 'year')
 173+ $additional_query_string .= "&$key=$value";
 174+ }
 175+ } else {
 176+ $skin = $wgParser->getOptions()->getSkin();
 177+ $additional_query_string = '';
 178+ }
160179 // get all the date-based values we need - the current month
161180 // and year (i.e., the one the user is looking at - not
162181 // necessarily the "current" ones), the previous and next months
@@ -195,8 +214,8 @@
196215 if ($cur_year == "0") {$cur_year = "1"; }
197216 if ($next_year == "0") {$next_year = "1"; }
198217 if ($prev_year == "0") {$prev_year = "-1"; }
199 - $prev_month_url = $page_title->getLocalURL("month=$prev_month_num&year=$prev_year");
200 - $next_month_url = $page_title->getLocalURL("month=$next_month_num&year=$next_year");
 218+ $prev_month_url = $page_title->getLocalURL("month=$prev_month_num&year=$prev_year" . $additional_query_string);
 219+ $next_month_url = $page_title->getLocalURL("month=$next_month_num&year=$next_year" . $additional_query_string);
201220 $today_url = $page_title->getLocalURL();
202221 $today_text = wfMsg('srfc_today');
203222 $prev_month_text = wfMsg('srfc_previousmonth');

Status & tagging log