Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/94244
Change subject: Upstream: Mobile skin code to Minerva skin code
......................................................................
Upstream: Mobile skin code to Minerva skin code
Change-Id: I27a8d3d69df83c297bb08b38ed177105c9a1d8de
---
M includes/skins/SkinMinerva.php
M includes/skins/SkinMobile.php
2 files changed, 60 insertions(+), 61 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/44/94244/1
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 1113292..bb43e7e 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -9,6 +9,53 @@
public $skinname = 'minerva';
public $template = 'MinervaTemplate';
public $useHeadElement = true;
+ /* @var string describing the current stability of the skin, can be
overriden by derivative experimental skins */
+ protected $mode = 'stable';
+ /** @var array of classes that should be present on the body tag */
+ private $pageClassNames = array();
+
+ /**
+ * @param string $className: valid class name
+ */
+ protected function addPageClass( $className ) {
+ $this->pageClassNames[ $className ] = true;
+ }
+
+ /**
+ * Overrides Skin::doEditSectionLink
+ */
+ public function doEditSectionLink( Title $nt, $section, $tooltip =
null, $lang = false ) {
+ $lang = wfGetLangObj( $lang );
+ $message = wfMessage( 'mobile-frontend-editor-edit'
)->inLanguage( $lang )->text();
+ return Html::element( 'a', array(
+ 'href' => '#editor/' . $section,
+ 'data-section' => $section,
+ 'class' => 'edit-page'
+ ), $message );
+ }
+
+ /**
+ * Takes a title and returns classes to apply to the body tag
+ * @param $title Title
+ * @return String
+ */
+ public function getPageClasses( $title ) {
+ if ( $title->isMainPage() ) {
+ $className = 'page-Main_Page ';
+ } else if ( $title->isSpecialPage() ) {
+ $className = 'mw-mf-special ';
+ } else {
+ $className = '';
+ }
+ return $className . implode( ' ', array_keys(
$this->pageClassNames ) );
+ }
+
+ /**
+ * @return string: The current mode of the skin [stable|beta|alpha]
that is running
+ */
+ protected function getMode() {
+ return $this->mode;
+ }
/**
* @var MobileContext
@@ -17,6 +64,10 @@
public function __construct() {
$this->mobileContext = MobileContext::singleton();
+ $this->addPageClass( $this->getMode() );
+ if ( !$this->getUser()->isAnon() ) {
+ $this->addPageClass( 'is-authenticated' );
+ }
}
/**
@@ -238,6 +289,10 @@
return $link;
}
+ protected function getSearchPlaceHolderText() {
+ return wfMessage( 'mobile-frontend-placeholder' )->text();
+ }
+
public function prepareData( BaseTemplate $tpl ) {
global $wgMFEnableSiteNotice;
$title = $this->getTitle();
@@ -280,7 +335,7 @@
'autocomplete' => 'off',
// The placeholder gets fed to HTML::element later
which escapes all
// attribute values, so no need to escape the string
here.
- 'placeholder' => wfMessage(
'mobile-frontend-placeholder' )->text(),
+ 'placeholder' => $this->getSearchPlaceHolderText(),
);
$tpl->set( 'searchBox', $searchBox );
@@ -403,6 +458,7 @@
'wgPreferredVariant' =>
$title->getPageLanguage()->getPreferredVariant(),
'wgIsPageEditable' => $title->quickUserCan( 'edit',
$user ) || $userCanCreatePage,
'wgMFDeviceWidthTablet' => $wgMFDeviceWidthTablet,
+ 'wgMFMode' => $this->getMode(),
);
if ( !$user->isAnon() ) {
$vars['wgWatchedPageCache'] = array(
@@ -418,6 +474,9 @@
public function getDefaultModules() {
$modules = parent::getDefaultModules();
+ // flush unnecessary modules
+ $modules['content'] = array();
+ $modules['legacy'] = array();
$modules['mobile'] = array(
'mobile.head',
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 89ec96e..70376b8 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -9,37 +9,12 @@
public $template = 'MobileTemplate';
protected $hookOptions;
- protected $mode = 'stable';
protected $customisations = array();
-
- /** @var array of classes that should be present on the body tag */
- private $pageClassNames = array();
-
- protected function getMode() {
- return $this->mode;
- }
public function __construct( IContextSource $context ) {
parent::__construct();
$this->setContext( $context );
$this->addPageClass( 'mobile' );
- $this->addPageClass( $this->getMode() );
- if ( !$this->getUser()->isAnon() ) {
- $this->addPageClass( 'is-authenticated' );
- }
- }
-
- /**
- * Overrides Skin::doEditSectionLink
- */
- public function doEditSectionLink( Title $nt, $section, $tooltip =
null, $lang = false ) {
- $lang = wfGetLangObj( $lang );
- $message = wfMessage( 'mobile-frontend-editor-edit'
)->inLanguage( $lang )->text();
- return Html::element( 'a', array(
- 'href' => '#editor/' . $section,
- 'data-section' => $section,
- 'class' => 'edit-page'
- ), $message );
}
public function setTemplateVariable( $key, $val ) {
@@ -81,38 +56,8 @@
wfProfileOut( __METHOD__ );
}
- /**
- * @param string $className: valid class name
- */
- private function addPageClass( $className ) {
- $this->pageClassNames[ $className ] = true;
- }
-
- /**
- * Takes a title and returns classes to apply to the body tag
- * @param $title Title
- * @return String
- */
- public function getPageClasses( $title ) {
- if ( $title->isMainPage() ) {
- $className = 'page-Main_Page ';
- } else if ( $title->isSpecialPage() ) {
- $className = 'mw-mf-special ';
- } else {
- $className = '';
- }
- return $className . implode( ' ', array_keys(
$this->pageClassNames ) );
- }
-
- protected function getSearchPlaceHolderText() {
- return wfMessage( 'mobile-frontend-placeholder' )->text();
- }
-
public function prepareData( BaseTemplate $tpl ) {
parent::prepareData( $tpl );
- $search = $tpl->data['searchBox'];
- $search['placeholder'] = $this->getSearchPlaceHolderText();
- $tpl->set( 'searchBox', $search );
$this->applyCustomisations( $tpl );
}
@@ -126,7 +71,6 @@
);
$vars = parent::getSkinConfigVariables();
$vars['wgUseFormatCookie'] = $wgUseFormatCookie;
- $vars['wgMFMode'] = $this->getMode();
return $vars;
}
@@ -134,10 +78,6 @@
global $wgMFInfoboxLogging;
$out = $this->getOutput();
$modules = parent::getDefaultModules();
-
- // flush unnecessary modules
- $modules['content'] = array();
- $modules['legacy'] = array();
$this->addExternalModules( $out );
// FIXME: This is duplicate code of that in
MobileFrontend.hooks.php. Please apply hygiene.
--
To view, visit https://gerrit.wikimedia.org/r/94244
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I27a8d3d69df83c297bb08b38ed177105c9a1d8de
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits