MaxSem has submitted this change and it was merged.

Change subject: Make special pages declare their modules
......................................................................


Make special pages declare their modules

Remove code to do this in SkinMobile

Change-Id: Ifbd50a459e71b90ad662064486f3d1d329d9df7e
---
M includes/MobileFrontend.hooks.php
M includes/skins/SkinMobile.php
M includes/specials/SpecialMobileMenu.php
M includes/specials/SpecialMobileWatchlist.php
M includes/specials/UnlistedSpecialMobilePage.php
5 files changed, 27 insertions(+), 20 deletions(-)

Approvals:
  MaxSem: Verified; Looks good to me, approved



diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index ce11dfa..4678bf5 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -356,6 +356,10 @@
                if ( $special->getName() != 'Userlogin' || 
!$mobileContext->shouldDisplayMobileView() ) {
                        // no further processing necessary
                        return true;
+               } else {
+                       $out = $special->getContext()->getOutput();
+                       $out->addModules( 'mobile.userlogin.scripts' );
+                       $out->addModuleStyles( 'mobile.userlogin.styles' );
                }
 
                // make sure we're on https if we're supposed to be and 
currently aren't.
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index a783330..8fd29b9 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -365,25 +365,7 @@
                        $styles[] = 'mobile.file.styles';
                }
 
-               if ( $isSpecialPage ) {
-                       list( $name, /* $subpage */ ) = 
SpecialPageFactory::resolveAlias( $title->getDBkey() );
-                       $id = strtolower( $name );
-                       $specialStyleModuleName = 'mobile.' . $id . '.styles';
-                       $specialScriptModuleName = 'mobile.' . $id . '.scripts';
-
-                       if ( isset( $wgResourceModules[ $specialStyleModuleName 
] ) ) {
-                               $styles[] = $specialStyleModuleName;
-                       }
-
-                       if ( isset( $wgResourceModules[ 
$specialScriptModuleName ] ) ) {
-                               $module = $wgResourceModules[ 
$specialScriptModuleName ];
-                               if ( isset( $module['position'] ) && 
$module['position'] === 'top' ) {
-                                       $headModuleNames[] = 
$specialScriptModuleName;
-                               } else {
-                                       $moduleNames[] = 
$specialScriptModuleName;
-                               }
-                       }
-               } else {
+               if ( !$isSpecialPage ) {
                        $styles[] = 'mobile.styles.page';
                }
 
diff --git a/includes/specials/SpecialMobileMenu.php 
b/includes/specials/SpecialMobileMenu.php
index 1fe585e..ccfcc2f 100644
--- a/includes/specials/SpecialMobileMenu.php
+++ b/includes/specials/SpecialMobileMenu.php
@@ -1,6 +1,6 @@
 <?php
 
-class SpecialMobileMenu extends UnlistedSpecialPage {
+class SpecialMobileMenu extends UnlistedSpecialMobilePage {
        public function __construct() {
                parent::__construct( 'MobileMenu' );
        }
diff --git a/includes/specials/SpecialMobileWatchlist.php 
b/includes/specials/SpecialMobileWatchlist.php
index 5f6ff74..06a0ef7 100644
--- a/includes/specials/SpecialMobileWatchlist.php
+++ b/includes/specials/SpecialMobileWatchlist.php
@@ -22,6 +22,8 @@
 
                $user = $this->getUser();
                $output = $this->getOutput();
+               $output->addModuleStyles( 'mobile.watchlist.styles' );
+               $output->addModules( 'mobile.watchlist.scripts' );
                $req = $this->getRequest();
                $view = $req->getVal( 'watchlistview', 'a-z' );
                $this->fromPageTitle = Title::newFromText( $req->getVal( 
'from', false ) );
diff --git a/includes/specials/UnlistedSpecialMobilePage.php 
b/includes/specials/UnlistedSpecialMobilePage.php
index 644385e..ddb06f7 100644
--- a/includes/specials/UnlistedSpecialMobilePage.php
+++ b/includes/specials/UnlistedSpecialMobilePage.php
@@ -4,6 +4,25 @@
        public function __construct( $name, $restriction = '', $function = 
false, $file = 'default' ) {
                parent::__construct( $name, $restriction, false, $function, 
$file );
                $this->clearPageMargins();
+               $this->addModules( $name );
+       }
+
+       public function addModules( $name ) {
+               global $wgResourceModules;
+               $out = $this->getOutput();
+               $title = $this->getTitle();
+               list( $name, /* $subpage */ ) = 
SpecialPageFactory::resolveAlias( $title->getDBkey() );
+               $id = strtolower( $name );
+               $specialStyleModuleName = 'mobile.' . $id . '.styles';
+               $specialScriptModuleName = 'mobile.' . $id . '.scripts';
+
+               if ( isset( $wgResourceModules[ $specialStyleModuleName ] ) ) {
+                       $out->addModuleStyles( $specialStyleModuleName );
+               }
+
+               if ( isset( $wgResourceModules[ $specialScriptModuleName ] ) ) {
+                       $out->addModules( $specialScriptModuleName );
+               }
        }
 
        public function clearPageMargins() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifbd50a459e71b90ad662064486f3d1d329d9df7e
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: awjrichards <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to