r106725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106724‎ | r106725 | r106726 >
Date:23:39, 19 December 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Reuse $title->isMainPage()

Move seperate if to elseif

Fix spaces to tabs
Modified paths:
  • /trunk/extensions/MobileFrontend/DisableTemplate.php (modified) (history)
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)
  • /trunk/extensions/MobileFrontend/MobileFrontendTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontendTemplate.php
@@ -1,51 +1,51 @@
22 <?php
33
44 if( !defined( 'MEDIAWIKI' ) ) {
5 - die( -1 );
 5+ die( -1 );
66 }
77
88 abstract class MobileFrontendTemplate {
99 public $data;
10 -
 10+
1111 /**
12 - * Constructor
13 - */
 12+ * Constructor
 13+ */
1414 public function __construct() {
1515 $this->data = array();
1616 }
17 -
 17+
1818 /**
19 - * Sets the value $value to $name
20 - * @param $name
21 - * @param $value
22 - */
23 - public function set( $name, $value ) {
24 - $this->data[$name] = $value;
25 - }
 19+ * Sets the value $value to $name
 20+ * @param $name
 21+ * @param $value
 22+ */
 23+ public function set( $name, $value ) {
 24+ $this->data[$name] = $value;
 25+ }
2626
2727 /**
28 - * Sets the value $value to $name
29 - * @param $name
30 - * @param $value
31 - */
32 - public function setByArray( $options ) {
 28+ * Sets the value $value to $name
 29+ * @param $name
 30+ * @param $value
 31+ */
 32+ public function setByArray( $options ) {
3333 foreach ($options as $name => $value ) {
3434 $this->set( $name, $value );
3535 }
36 - }
 36+ }
3737
3838 /**
39 - * Gets the value of $name
40 - * @param $name
41 - * @return string
42 - */
43 - public function get( $name ) {
44 - return $this->data[$name];
45 - }
 39+ * Gets the value of $name
 40+ * @param $name
 41+ * @return string
 42+ */
 43+ public function get( $name ) {
 44+ return $this->data[$name];
 45+ }
4646
47 - /**
48 - * Main function, used by classes that subclass MobileFrontendTemplate
49 - * to show the actual HTML output
50 - */
51 - abstract public function getHTML();
52 -}
\ No newline at end of file
 47+ /**
 48+ * Main function, used by classes that subclass MobileFrontendTemplate
 49+ * to show the actual HTML output
 50+ */
 51+ abstract public function getHTML();
 52+}
Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -519,7 +519,7 @@
520520
521521 self::$title = $out->getTitle();
522522
523 - if ( Title::newMainPage()->equals( self::$title ) ) {
 523+ if ( self::$title->isMainPage() ) {
524524 self::$isMainPage = true;
525525 }
526526 if ( self::$title->getNamespace() == NS_FILE ) {
@@ -537,9 +537,7 @@
538538 $location = str_replace( '&mfi=1', '', str_replace( '&mfi=0', '', $location ) );
539539 $location = $this->getRelativeURL( $location );
540540 $wgRequest->response()->header( 'Location: ' . $location . '&mfi=0' );
541 - }
542 -
543 - if ( self::$disableImages == 0 ) {
 541+ } elseif ( self::$disableImages == 0 ) {
544542 $disableImages = $wgRequest->getCookie( 'disableImages' );
545543 if ( $disableImages ) {
546544 self::$disableImages = $disableImages;
@@ -752,6 +750,9 @@
753751 return true;
754752 }
755753
 754+ /**
 755+ * @return Mixed
 756+ */
756757 private function getOptInOutCookie() {
757758 global $wgRequest;
758759 wfProfileIn( __METHOD__ );
Index: trunk/extensions/MobileFrontend/DisableTemplate.php
@@ -5,11 +5,10 @@
66 }
77
88 class DisableTemplate extends MobileFrontendTemplate {
9 -
 9+
1010 public function getHTML() {
1111
12 - $currentURL = $this->data['currentURL'];
13 - $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $currentURL );
 12+ $currentURL = str_replace( '&mobileaction=disable_mobile_site', '', $this->data['currentURL'] ); // TODO: $currentURl is unused
1413 $mobileRedirectFormAction = $this->data['mobileRedirectFormAction'];
1514
1615 $disableHtml = <<<HTML
@@ -20,7 +19,7 @@
2120 {$this->data['explainDisable']}
2221 </p>
2322 <div id='disableButtons'>
24 - <form action='{$this->data['mobileRedirectFormAction']}' method='get'>
 23+ <form action='{$mobileRedirectFormAction}' method='get'>
2524 <input name='to' type='hidden' value='{$this->data['currentURL']}' />
2625 <input name='expires_in_days' type='hidden' value='3650' />
2726 <button id='disableButton' type='submit'>{$this->data['disableButton']}</button>

Comments

#Comment by Catrope (talk | contribs)   19:25, 21 December 2011
-				<form action='{$this->data['mobileRedirectFormAction']}' method='get'>
+				<form action='{$mobileRedirectFormAction}' method='get'>

(not this revision's fault) There should probably be escaping here. Even if stuff is being escaped before being thrown into $this->data , which I doubt, that's wrong and the escaping should be done right before output instead.

Status & tagging log