Mailing List Archive

[MediaWiki-commits] [Gerrit] mediawiki...MobileFrontend[master]: Remove MobilePreferences in favor of core
Jdlrobson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/406123 )

Change subject: Remove MobilePreferences in favor of core
......................................................................

Remove MobilePreferences in favor of core

Change-Id: I01a377494d77d39c5a620907dd22cec888a6f7b8
Depends-On: I6766b4ef5a99c66ebb54079b07739315294c86a7
Depends-On: Idbf62486c787179ee67deb22e4644f4fc742d9db
---
M extension.json
M includes/MobileFrontend.hooks.php
D includes/specials/SpecialMobilePreferences.php
3 files changed, 0 insertions(+), 110 deletions(-)


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

diff --git a/extension.json b/extension.json
index d45c9f3..b65224b 100644
--- a/extension.json
+++ b/extension.json
@@ -76,7 +76,6 @@
"SpecialNearby": "includes/specials/SpecialNearby.php",
"SpecialMobileLanguages": "includes/specials/SpecialMobileLanguages.php",
"SpecialMobileCite": "includes/specials/SpecialMobileCite.php",
- "SpecialMobilePreferences": "includes/specials/SpecialMobilePreferences.php",
"MobileSpecialPage": "includes/specials/MobileSpecialPage.php",
"MobileSpecialPageFeed": "includes/specials/MobileSpecialPageFeed.php",
"MFResourceLoaderParsedMessageModule": "includes/modules/MFResourceLoaderParsedMessageModule.php",
diff --git a/includes/MobileFrontend.hooks.php b/includes/MobileFrontend.hooks.php
index 457ca02..a4604ec 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -488,7 +488,6 @@
// Replace the standard watchlist view with our custom one
$list['Watchlist'] = 'SpecialMobileWatchlist';
$list['EditWatchlist'] = 'SpecialMobileEditWatchlist';
- $list['Preferences'] = 'SpecialMobilePreferences';

/* Special:MobileContributions redefines Special:History in
* such a way that for Special:Contributions/Foo, Foo is a
diff --git a/includes/specials/SpecialMobilePreferences.php b/includes/specials/SpecialMobilePreferences.php
deleted file mode 100644
index 58ea8c0..0000000
--- a/includes/specials/SpecialMobilePreferences.php
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/**
- * Overrides Special:Preferences in mobile mode.
- */
-class SpecialMobilePreferences extends SpecialPreferences {
-
- protected $validTabs = [.
- 'personal',
- 'dateformat',
- 'skin',
- 'files',
- 'rc',
- ];
-
- /**
- * Builds the preferences form for the given section.
- *
- * @param string $key A valid section key, which can be rendered
- * @return PreferencesForm
- */
- public function getPreferencesForm( $key ) {
- $user = $this->getUser();
- $ctx = $this->getContext();
-
- // load any preferences element
- $removePrefs = Preferences::getPreferences( $user, $ctx );
- // check, if the element shouldn't be rendered
- foreach ( $removePrefs as $formElement => $formDescriptor ) {
- if (
- // we render only preferences, which are in a specific section, ...
- isset( $formDescriptor['section'] ) &&
- (
- // ...which is specified by the given $key
- $formDescriptor['section'] === $key ||
- strpos( $formDescriptor['section'], $key ) !== false
- )
- ) {
- // remove the preferences element from the array of elements, which are removed
- unset( $removePrefs[$formElement] );
- }
- }
- // we need the keys only
- $removePrefs = array_keys( $removePrefs );
-
- // get the form element (the $removePrefs param specifies, which elements shouldn't be rendered)
- $htmlForm = Preferences::getFormObject( $user, $ctx, 'PreferencesForm', $removePrefs );
- $htmlForm->suppressReset();
- $htmlForm->setModifiedUser( $user );
- $htmlForm->setId( 'mw-prefs-form' );
- $htmlForm->setSubmitText( $ctx->msg( 'saveprefs' )->text() );
- $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] );
- $htmlForm->setAction( SpecialPage::getTitleFor( $this->getName(), $key )->getLocalUrl() );
- return $htmlForm;
- }
-
- /**
- * @param string $par Key of section to display
- *
- * @throws MWException
- * @throws ReadOnlyError
- * @throws UserNotLoggedIn
- */
- public function execute( $par = '' ) {
- $this->setHeaders();
- $this->outputHeader();
- $out = $this->getOutput();
-
- // Prevent hijacked user scripts from sniffing passwords etc.
- $out->disallowUserJs();
-
- $this->requireLogin( 'prefsnologintext2' );
- $this->checkReadOnly();
-
- if ( $this->getRequest()->getCheck( 'success' ) ) {
- $out->addHtml( MobileUI::successBox( $this->msg( 'savedprefs' )->escaped() ) );
- }
-
- // combine our valid tabs array with all available tabs on the preferences form
- $form = Preferences::getFormObject( $this->getUser(), $this->getContext() );
- $validForRendering = $this->validTabs + $form->getPreferenceSections();
-
- // if the requested tab can be rendered, render it, no matter, if it's visible on
- // the main entry point (Special:MobilePreferences)
- if ( $par && in_array( $par, $validForRendering ) ) {
- $htmlForm = $this->getPreferencesForm( $par );
- $htmlForm->setSubmitCallback( [ 'Preferences', 'tryUISubmit' ] );
- $htmlForm->show();
- } else {
- foreach ( $this->validTabs as $tabName ) {
- // hidden tabs allow a user to navigate to the section of the preferences page,
- // but shouldn't be visible on the main entry point (Special:Preferences)
- $attrs = [.
- 'class' => $baseClass = MobileUI::buttonClass( 'block' ),
- 'href' => SpecialPage::getTitleFor( $this->getName(), $tabName )->getLocalUrl(),
- ];
- $button = Html::element( 'a', $attrs, $this->msg( "prefs-$tabName" ) );
- $out->addHtml( $button );
- }
- }
- }
-
- /**
- * @return string[]
- */
- public function getSubpagesForPrefixSearch() {
- return $this->validTabs;
- }
-}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I01a377494d77d39c5a620907dd22cec888a6f7b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrobson@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits