r102476 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102475‎ | r102476 | r102477 >
Date:01:37, 9 November 2011
Author:khorn
Status:ok (Comments)
Tags:fundraising 
Comment:
As part of the language cleanup, fixes the way we calculate the thank you and fail redirects.
This also means we can now set either one to false for a gateway.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
@@ -88,8 +88,10 @@
8989 break;
9090 }
9191
92 - $wgOut->addHTML( "<br>Redirecting to page $go" );
93 - $wgOut->redirect( $go );
 92+ if ($go) {
 93+ $wgOut->addHTML( "<br>Redirecting to page $go" );
 94+ $wgOut->redirect( $go );
 95+ } //TODO: There really should be an else here.
9496 }
9597 }
9698 } else {
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -247,23 +247,57 @@
248248 );
249249 }
250250
 251+ /**
 252+ * getThankYouPage should either return a full page url, or false.
 253+ * @global type $wgLang
 254+ * @return mixed Page URL in string format, or false if none is set.
 255+ */
251256 function getThankYouPage() {
252 - global $wgLang;
253 - $language = $wgLang->getCode();
254 - $page = self::getGlobal( "ThankYouPage" ) . "/$language";
255 -// $returnTitle = Title::newFromText( $page );
256 -// $returnto = $returnTitle->getFullURL();
 257+ $page = self::getGlobal( "ThankYouPage" );
 258+ if ( $page ) {
 259+ $page = $this->appendLanguageAndMakeURL( $page );
 260+ }
257261 return $page;
258262 }
259263
 264+ /**
 265+ * getFailPage should either return a full page url, or false.
 266+ * @global type $wgLang
 267+ * @return mixed Page URL in string format, or false if none is set.
 268+ */
260269 function getFailPage() {
261 - global $wgLang;
262 - $language = $wgLang->getCode();
263 - $page = self::getGlobal( "FailPage" ) . "/$language";
264 - $returnTitle = Title::newFromText( $page );
265 - $returnto = $returnTitle->getFullURL();
266 - return $returnto;
 270+ $page = self::getGlobal( "FailPage" );
 271+ if ( $page ) {
 272+ $page = $this->appendLanguageAndMakeURL( $page );
 273+ }
 274+ return $page;
267275 }
 276+
 277+ /**
 278+ * For pages we intend to redirect to. This function will take either a full
 279+ * URL or a page title, and turn it into a URL with the appropriate language
 280+ * appended onto the end.
 281+ * @param string $url Either a wiki page title, or a URL to an external wiki
 282+ * page title.
 283+ * @return string A URL
 284+ */
 285+ function appendLanguageAndMakeURL( $url ){
 286+ $language = $this->getData_Raw( 'language' );
 287+ //make sure we don't already have the language in there...
 288+ $dirs = explode('/', $url);
 289+ if ( !is_array($dirs) || !in_array( $language, $dirs ) ){
 290+ $url = $url . "/$language";
 291+ }
 292+
 293+ error_log("Position: " . strpos( $url, 'http' ));
 294+ if ( strpos( $url, 'http' ) === 0) {
 295+ return $url;
 296+ } else { //this isn't a url yet.
 297+ $returnTitle = Title::newFromText( $url );
 298+ $url = $returnTitle->getFullURL();
 299+ return $url;
 300+ }
 301+ }
268302
269303 /**
270304 * Checks the edit tokens in the user's session against the one gathered

Follow-up revisions

RevisionCommit summaryAuthorDate
r102479Made sure everybody is getting the correctly formatted Thank You and Fail pag...khorn01:57, 9 November 2011
r102732MFT r100644, r100785, r101785, r102120, r102318, r102332, r102341, r102342, r...awjrichards01:31, 11 November 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   22:49, 9 November 2011

Could you mark the methods as public or protected?

protected function appendLanguageAndMakeURL()

#Comment by Jpostlethwaite (talk | contribs)   22:52, 9 November 2011

It looks like you did in a subsequent revision r102479.

Status & tagging log