Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/187948

Change subject: Hygiene: Move SpecialNearby registration out of extension 
function
......................................................................

Hygiene: Move SpecialNearby registration out of extension function

If the special page is enabled or not is now handeld in the special page
itself. This change removes MobileFrontends extension function!

See also:
        If1a25593ff38270a1a3d356e996f6325d34504f8
        I0a0a60894a924823bd3cbb72df5dceebc745bc6b
        I5c2c5f90d7c9af2714e4d0ed6218f326b4185d45

Change-Id: I346c42e4298f7d72cf1e835aee9c2c7a5f156ade
---
M MobileFrontend.php
M includes/specials/MobileSpecialPage.php
M includes/specials/SpecialNearby.php
3 files changed, 32 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/48/187948/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index f30cf69..b2a4572 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -167,9 +167,11 @@
        'MobileOptions' => 'SpecialMobileOptions',
        'MobileMenu' => 'SpecialMobileMenu',
        'MobileLanguages' => 'SpecialMobileLanguages',
+       'Nearby' => 'SpecialNearby',
        'Uploads' => 'SpecialUploads',
        'UserProfile' => 'SpecialUserProfile',
 ) );
+$wgSpecialPageGroups['Nearby'] = 'pages';
 
 // Register Minerva as a valid skin
 $wgValidSkinNames['minerva'] = "Minerva";
@@ -184,14 +186,10 @@
  * Setup MobileFrontend, load global components
  */
 function efMobileFrontend_Setup() {
-       global $wgMFNearby, $wgSpecialPages, $wgSpecialPageGroups, 
$wgResourceLoaderLESSVars,
+       global $wgResourceLoaderLESSVars,
                $wgResourceLoaderLESSImportPaths,
                $wgMFDeviceWidthTablet, $wgMFDeviceWidthMobileSmall, 
$wgResourceModules, $wgMobileVEModules;
 
-       if ( $wgMFNearby ) {
-               $wgSpecialPages['Nearby'] = 'SpecialNearby';
-               $wgSpecialPageGroups['Nearby'] = 'pages';
-       }
        // Set LESS global variables
        $localBasePath = dirname( __DIR__ );
        $wgResourceLoaderLESSImportPaths = array_merge( 
$wgResourceLoaderLESSImportPaths, array(
diff --git a/includes/specials/MobileSpecialPage.php 
b/includes/specials/MobileSpecialPage.php
index df0b918..f3fedd1 100644
--- a/includes/specials/MobileSpecialPage.php
+++ b/includes/specials/MobileSpecialPage.php
@@ -24,13 +24,24 @@
        }
 
        /**
+        * Enables a special page to check several things (like configuration 
variables)
+        * to disable himself if needed.
+        * @return boolean
+        */
+       protected function pageEnabled() {
+               return true;
+       }
+
+       /**
         * Checks the availability of the special page in actual mode and 
display the page, if available
         * @param string $subPage parameter submitted as "subpage"
         */
        public function execute( $subPage ) {
                $ctx = MobileContext::singleton();
                $this->getOutput()->setProperty( 'desktopUrl', 
$this->getDesktopUrl( $subPage ) );
-               if ( !$ctx->shouldDisplayMobileView() && 
!$this->hasDesktopVersion ) {
+               if ( !$this->pageEnabled() ) {
+                       $this->getOutput()->showErrorPage( 'nosuchspecialpage', 
'nospecialpagetext' );
+               } elseif ( !$ctx->shouldDisplayMobileView() && 
!$this->hasDesktopVersion ) {
                        $this->renderUnavailableBanner( $this->msg( 
'mobile-frontend-requires-mobile' ) );
                } elseif ( $this->mode !== 'stable' ) {
                        if ( $this->mode === 'beta' && 
!$ctx->isBetaGroupMember() ) {
diff --git a/includes/specials/SpecialNearby.php 
b/includes/specials/SpecialNearby.php
index 70d819b..3588a19 100644
--- a/includes/specials/SpecialNearby.php
+++ b/includes/specials/SpecialNearby.php
@@ -10,12 +10,28 @@
        /** @var boolean $hasDesktopVersion Does this special page has a 
desktop version? */
        protected $hasDesktopVersion = true;
 
+       /** @var GlobalVarConfig $config Instance of MobileFrontends config 
object */
+       private $config = null;
+
        /**
         * Construct function
         */
        public function __construct() {
                parent::__construct( 'Nearby' );
-               $this->listed = true;
+               $this->config = MobileContext::singleton()->getMFConfig();
+               // list this special page only, if Nearby is enabled in the 
configuration
+               if ( $this->config->get( 'MFNearby' ) ) {
+                       $this->listed = true;
+               }
+       }
+
+       /**
+        * Enables a special page to check several things (like configuration 
variables)
+        * to disable himself if needed.
+        * @return boolean
+        */
+       protected function pageEnabled() {
+               return $this->config->get( 'MFNearby' );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/187948
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I346c42e4298f7d72cf1e835aee9c2c7a5f156ade
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to