Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/64088
Change subject: Make special page headers work on desktop / skin cleanup
......................................................................
Make special page headers work on desktop / skin cleanup
Begin a migration of code from Skin to Template
Change-Id: Ifdf0ce35afe9313f7b0657ef09592f78b591668a
---
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMobile.php
M includes/skins/SkinMobileTemplate.php
3 files changed, 71 insertions(+), 75 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/88/64088/1
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 46ebb9a..384f1f1 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -36,11 +36,43 @@
'id'=> 'mw-mf-main-menu-button',
) )
);
+
+ $sk = $this->getSkin();
+ $out = $sk->getOutput();
+ $title = $sk->getTitle();
+ $isSpecialPage = $title->isSpecialPage();
+
+ if ( $title->isSpecial( 'Userlogin' ) ) {
+ if ( $sk->getRequest()->getVal( 'type' ) == 'signup' ) {
+ $key = 'mobile-frontend-sign-up-heading';
+ } else {
+ $key = 'mobile-frontend-sign-in-heading';
+ }
+ $pageHeading = wfMessage( $key )->plain();
+ } else if ( $title->isMainPage() ) {
+ $user = $sk->getUser();
+ $pageHeading = $user->isLoggedIn() ?
+ wfMessage(
'mobile-frontend-logged-in-homepage-notification', $user->getName() )->text() :
'';
+ } else {
+ $pageHeading = $out->getPageTitle();
+ }
+
+ $htmlHeader = $out->getProperty( 'mobile.htmlHeader' );
+ if ( $title->isSpecialPage() ) {
+ $preBodyText = '';
+ if ( !$htmlHeader ) {
+ $htmlHeader = Html::element( 'h1', array(),
$pageHeading );
+ }
+ $this->set( 'header', $htmlHeader );
+ } else {
+ $preBodyText = Html::rawElement( 'h1',
+ $title->isMainPage() ? array() : array( 'id' =>
'section_0' ), $pageHeading );
+ }
+ $this->set( 'prebodytext', $preBodyText );
}
public function prepareData() {
- $this->set( 'isSpecialPage', Title::newFromText( $this->data[
'title' ] )->isSpecialPage() );
- $this->set( 'prebodytext', '<h1>' . $this->data[ 'title' ] .
'</h1>' );
+ $this->set( 'talk', '' );
}
private function prepareBannerData() {
@@ -122,7 +154,7 @@
}
protected function renderFooter( $data ) {
- if ( !$data['isSpecialPage'] ) {
+ if ( !$this->getSkin()->getTitle()->isSpecialPage() ) {
?>
<div id="footer">
<?php
@@ -186,6 +218,7 @@
<div id="content" class="content">
<?php
echo
$data['prebodytext'];
+ echo $data['talk'];
echo $data[ 'bodytext'
];
echo
$this->renderLanguages( $languageData );
echo
$data['postbodytext'];
diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index b0155f7..93e7d82 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -163,6 +163,7 @@
}
/**
+ * FIXME: migrate to MinervaTemplate / SkinMobileTemplate
* Prepares the header and the content of a page
* Stores in QuickTemplate prebodytext, postbodytext keys
* @param QuickTemplate
@@ -170,56 +171,11 @@
function prepareTemplatePageContent( QuickTemplate $tpl ) {
$title = $this->getTitle();
$isSpecialPage = $title->isSpecialPage();
- $isMainPage = $title->isMainPage();
$user = $this->getUser();
- $userLogin = $title->isSpecial( 'Userlogin' );
- $out = $this->getOutput();
$ctx = MobileContext::singleton();
- $inAlpha = $ctx->isAlphaGroupMember();
- if ( $userLogin ) {
- $pageHeading = $this->getLoginPageHeading();
- } else {
- $pageHeading = $out->getPageTitle();
- }
-
- $preBodyText = '';
$postBodyText = '';
if ( !$isSpecialPage ) {
- $headingOptions = array();
- if ( $isMainPage ) {
- $pageHeading = $user->isLoggedIn() ?
- wfMessage(
'mobile-frontend-logged-in-homepage-notification', $user->getName() )->text() :
'';
- } else {
- $headingOptions = array( 'id' => 'section_0' );
- }
- // prepend heading to articles
- if ( $pageHeading ) {
- $preBodyText = Html::rawElement( 'h1',
$headingOptions, $pageHeading );
- // talk page link for logged in alpha users
- if ( $inAlpha && $user->isLoggedIn() &&
!$title->isTalkPage() ) {
- $talkTitle = $title->getTalkPage();
- if ( $talkTitle->getArticleID() ) {
- $dbr = wfGetDB( DB_SLAVE );
- $numTopics = $dbr->selectField(
'page_props', 'pp_value',
- array( 'pp_page' =>
$talkTitle->getArticleID(), 'pp_propname' => 'page_top_level_section_count' ),
- __METHOD__
- );
- } else {
- $numTopics = 0;
- }
- if ( $numTopics ) {
- $talkLabel =
$this->getLanguage()->formatNum( $numTopics );
- } else {
- $talkLabel = wfMessage(
'mobile-frontend-talk-overlay-header' );
- }
- // @todo: Redlink support when we have
good editing
- $preBodyText .= Html::element( 'a',
- array( 'href' =>
$talkTitle->getLocalURL(), 'id' => 'talk' ),
- $talkLabel );
- }
- }
-
// add last modified timestamp
$timestamp = Revision::getTimestampFromId(
$this->getTitle(), $this->getRevisionId() );
$lastModified = wfMessage(
'mobile-frontend-last-modified-date',
@@ -234,30 +190,7 @@
'href' => $historyUrl
), $lastModified );
}
-
- $htmlHeader = $this->getOutput()->getProperty(
'mobile.htmlHeader' );
- if ( $isSpecialPage ) {
- if ( !$htmlHeader ) {
- $htmlHeader = Html::element( 'h1', array(),
$pageHeading );
- }
- $tpl->set( 'specialPageHeader', $htmlHeader );
- }
-
- $tpl->set( 'prebodytext', $preBodyText );
$tpl->set( 'postbodytext', $postBodyText );
- }
-
- /**
- * Determines what the heading of the login page should be based on the
context
- * @return string
- */
- protected function getLoginPageHeading() {
- if ( $this->getRequest()->getVal( 'type' ) == 'signup' ) {
- $key = 'mobile-frontend-sign-up-heading';
- } else {
- $key = 'mobile-frontend-sign-in-heading';
- }
- return wfMessage( $key )->plain();
}
protected function attachResources( Title $title, QuickTemplate $tpl,
IDeviceProperties $device ) {
diff --git a/includes/skins/SkinMobileTemplate.php
b/includes/skins/SkinMobileTemplate.php
index 1696f27..3d0f259 100644
--- a/includes/skins/SkinMobileTemplate.php
+++ b/includes/skins/SkinMobileTemplate.php
@@ -30,18 +30,48 @@
parent::__construct();
}
+ protected function prepareTalkData() {
+ $ctx = MobileContext::singleton();
+ $inAlpha = $ctx->isAlphaGroupMember();
+ $sk = $this->getSkin();
+ $title = $sk->getTitle();
+ $user = $sk->getUser();
+
+ // talk page link for logged in alpha users
+ if ( !$title->isSpecialPage() && $inAlpha &&
$user->isLoggedIn() && !$title->isTalkPage() ) {
+ $talkTitle = $title->getTalkPage();
+ if ( $talkTitle->getArticleID() ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $numTopics = $dbr->selectField( 'page_props',
'pp_value',
+ array( 'pp_page' =>
$talkTitle->getArticleID(), 'pp_propname' => 'page_top_level_section_count' ),
+ __METHOD__
+ );
+ } else {
+ $numTopics = 0;
+ }
+ if ( $numTopics ) {
+ $talkLabel = $lang->formatNum( $numTopics );
+ } else {
+ $talkLabel = wfMessage(
'mobile-frontend-talk-overlay-header' );
+ }
+ // @todo: Redlink support when we have good editing
+ $talk = Html::element( 'a',
+ array( 'href' => $talkTitle->getLocalURL(),
'id' => 'talk' ),
+ $talkLabel );
+ } else {
+ $talk = '';
+ }
+ $this->set( 'talk', $talk );
+ }
public function prepareData() {
global $wgExtensionAssetsPath;
$data = $this->data;
wfProfileIn( __METHOD__ );
$this->setRef( 'wgExtensionAssetsPath', $wgExtensionAssetsPath
);
-
+ $this->prepareTalkData();
$this->set( 'bodytext', $data['bodytext'] );
$this->set( 'bottomscripts', $data['bottomScripts'] );
- if ( isset( $data['specialPageHeader'] ) ) {
- $this->set( 'header', $data['specialPageHeader'] );
- }
wfProfileOut( __METHOD__ );
}
--
To view, visit https://gerrit.wikimedia.org/r/64088
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifdf0ce35afe9313f7b0657ef09592f78b591668a
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