r110930 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110929‎ | r110930 | r110931 >
Date:13:49, 8 February 2012
Author:johnduhart
Status:deferred
Tags:
Comment:
Added an options class for managing options like no header and no logo
Modified paths:
  • /trunk/extensions/MobileFrontend2/MobileFrontend2.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_Detection.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php (added) (history)
  • /trunk/extensions/MobileFrontend2/skins/Mobile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend2/MobileFrontend2.php
@@ -27,6 +27,7 @@
2828
2929 $wgAutoloadClasses['MobileFrontend2_Detection'] = $dir . 'MobileFrontend2_Detection.php';
3030 $wgAutoloadClasses['MobileFrontend2_Hooks'] = $dir . 'MobileFrontend2_Hooks.php';
 31+$wgAutoloadClasses['MobileFrontend2_Options'] = $dir . 'MobileFrontend2_Options.php';
3132 $wgAutoloadClasses['MobileFrontend2_PostParse'] = $dir . 'MobileFrontend2_PostParse.php';
3233
3334 // Skins
Index: trunk/extensions/MobileFrontend2/skins/Mobile.php
@@ -129,10 +129,13 @@
130130 <?php $this->html( 'headscripts' ) ?>
131131 </head>
132132 <body>
 133+ <?php if ( !MobileFrontend2_Options::getHideSearch() ): ?>
133134 <!-- search/header -->
134135 <div id="header">
135136 <div id="searchbox">
 137+ <?php if ( !MobileFrontend2_Options::getHideLogo() ): ?>
136138 <img src="<?php $this->text( 'mobilelogopath' ) ?>" alt="Logo" id="logo" width="35" height="22" />
 139+ <?php endif ?>
137140 <form action="<?php $this->text( 'wgScript' ) ?>" class="search_bar" method="get">
138141 <input type="hidden" name="title" value="Special:Search" />
139142
@@ -144,6 +147,7 @@
145148 </form>
146149 </div>
147150 </div>
 151+ <?php endif ?>
148152
149153 <!-- content -->
150154 <div class="show" id="content_wrapper">
@@ -162,6 +166,7 @@
163167 <!-- /bodyContent -->
164168 </div>
165169
 170+ <?php if ( !MobileFrontend2_Options::getHideFooter() ): ?>
166171 <!-- footer -->
167172 <div id="footer">
168173 <div class="nav" id="footmenu">
@@ -177,6 +182,7 @@
178183 </div>
179184 </div>
180185 </div>
 186+ <?php endif ?>
181187
182188 <?php $this->html( 'bottomscripts' ) ?>
183189
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
@@ -0,0 +1,60 @@
 2+<?php
 3+
 4+class MobileFrontend2_Options {
 5+
 6+ /**
 7+ * Hide the search bar
 8+ *
 9+ * @var bool
 10+ */
 11+ protected static $hideSearch = false;
 12+
 13+ /**
 14+ * Hides the logo
 15+ *
 16+ * @var bool
 17+ */
 18+ protected static $hideLogo = false;
 19+
 20+ /**
 21+ * Hides the footer
 22+ *
 23+ * @var bool
 24+ */
 25+ protected static $hideFooter = false;
 26+
 27+ /**
 28+ * Detects options based on user preferences
 29+ */
 30+ public static function detect() {
 31+ $request = RequestContext::getMain()->getRequest();
 32+
 33+ self::$hideSearch = $request->getBool( 'hidesearch' );
 34+ self::$hideLogo = $request->getBool( 'hidelogo' );
 35+ // TODO: Previously this was lumped into hidelogo. Notify mobile team
 36+ self::$hideFooter = $request->getBool( 'hidefooter' );
 37+
 38+ // TODO: Hook for Wikimedia
 39+ }
 40+
 41+ /**
 42+ * @return boolean
 43+ */
 44+ public static function getHideLogo() {
 45+ return self::$hideLogo;
 46+ }
 47+
 48+ /**
 49+ * @return boolean
 50+ */
 51+ public static function getHideSearch() {
 52+ return self::$hideSearch;
 53+ }
 54+
 55+ /**
 56+ * @return boolean
 57+ */
 58+ public static function getHideFooter() {
 59+ return self::$hideFooter;
 60+ }
 61+}
Property changes on: trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
___________________________________________________________________
Added: svn:eol-style
162 + native
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Detection.php
@@ -49,6 +49,10 @@
5050 */
5151 private static function enable() {
5252 self::$enabled = true;
 53+
 54+ // Do some initialization
 55+ MobileFrontend2_Options::detect();
 56+
5357 return true;
5458 }
5559

Status & tagging log