Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93018
Change subject: WIP: Allow users to modify their UserProfile intro
......................................................................
WIP: Allow users to modify their UserProfile intro
Change-Id: I0efd9b61d0c706f3eeff84643d8f091c64bb643b
---
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMinerva.php
M includes/specials/MobileSpecialPage.php
M includes/specials/SpecialUserProfile.php
M less/specials/userprofile.less
5 files changed, 61 insertions(+), 28 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/18/93018/1
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 2e4bedd..222dcac 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -81,7 +81,7 @@
}
protected function renderFooter( $data ) {
- if ( !$this->isSpecialPage ) {
+ if ( !$data[ 'hideFooter' ] ) {
?>
<div id="footer">
<?php
@@ -213,7 +213,7 @@
<div class="header">
<?php
$this->html( 'menuButton' );
- if ( $this->isSpecialPage ) {
+ if ( $data[ 'hideSearch' ] ) {
echo
$data['specialPageHeader'];
} else {
?>
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index d456d82..9dbc298 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -367,6 +367,8 @@
$this->prepareUserButton( $tpl );
$tpl->set( 'unstyledContent', $out->getProperty(
'unstyledContent' ) );
+ $tpl->set( 'hideFooter', $out->getProperty( 'hideFooter' ) );
+ $tpl->set( 'hideSearch', $out->getProperty( 'hideSearch' ) );
$this->prepareDiscoveryTools( $tpl );
$this->preparePersonalTools( $tpl );
}
diff --git a/includes/specials/MobileSpecialPage.php
b/includes/specials/MobileSpecialPage.php
index 5dfb3e0..4c67f24 100644
--- a/includes/specials/MobileSpecialPage.php
+++ b/includes/specials/MobileSpecialPage.php
@@ -7,14 +7,23 @@
*/
protected $listed = false;
/**
- * @var bool: Whether the special page's content should be wrapped in
div.content
+ * @var bool: Whether the special page's div.content should be omitted
*/
protected $unstyledContent = true;
+ /**
+ * @var bool: Whether the site footer should be hidden
+ */
+ protected $hideFooter = true;
+ /**
+ * @var bool: Whether the search box should be hidden
+ */
+ protected $hideSearch = true;
/* Executes the page when available in the current $mode */
public function executeWhenAvailable( $subPage ) {}
public function execute( $subPage ) {
+ $this->setHeaders();
$ctx = MobileContext::singleton();
if ( $this->mode !== 'stable' ) {
if ( $this->mode === 'beta' &&
!$ctx->isBetaGroupMember() ) {
@@ -33,8 +42,15 @@
parent::setHeaders();
$this->addModules();
+ $out = $this->getOutput();
if ( $this->unstyledContent ) {
- $this->getOutput()->setProperty( 'unstyledContent',
true );
+ $out->setProperty( 'unstyledContent', true );
+ }
+ if ( $this->hideFooter ) {
+ $out->setProperty( 'hideFooter', true );
+ }
+ if ( $this->hideSearch ) {
+ $out->setProperty( 'hideSearch', true );
}
}
diff --git a/includes/specials/SpecialUserProfile.php
b/includes/specials/SpecialUserProfile.php
index 77b9ae8..87c1cfa 100644
--- a/includes/specials/SpecialUserProfile.php
+++ b/includes/specials/SpecialUserProfile.php
@@ -11,6 +11,16 @@
* @var MobileUserInfo
*/
private $userInfo;
+ /**
+ * Show the site footer
+ * @var Boolean
+ */
+ protected $hideFooter = false;
+ /**
+ * Show the search bar in the header
+ * @var Boolean
+ */
+ protected $hideSearch = false;
public function __construct() {
parent::__construct( 'UserProfile' );
@@ -58,6 +68,11 @@
return $img;
}
+ protected function getUserHeader() {
+ $heading = Html::element( 'h1', array(),
$this->targetUser->getName() );
+ return $heading;
+ }
+
protected function getUserSummary() {
$registered = $this->targetUser->getRegistration();
$editCount = $this->targetUser->getEditCount();
@@ -75,7 +90,9 @@
return Html::openElement( 'div', array( 'class' => 'section
section-registered' ) ) .
Html::element( 'p', array( 'class' => 'statement' ),
- $this->msg( 'mobile-frontend-profile-registration',
$name )->numParams( $daysAgo, $editCount )->parse() ) .
+ // FIXME: There's probably a cleaner way to do this.
+ $this->getWikiPageText(
$this->targetUser->getUserPage()->getPrefixedText().'/ProfileIntro' ) ) .
+ //$this->msg( 'mobile-frontend-profile-registration',
$name )->numParams( $daysAgo, $editCount )->parse() ) .
Html::element( 'p', array( 'class' =>
'secondary-statement section-end' ), $role ) .
Html::closeElement( 'div' );
}
@@ -128,25 +145,6 @@
return $html;
}
- protected function setUserProfileUIElements() {
- // replace secondary icon
- $attrs = array(
- 'class' => 'talk',
- 'id' => 'secondary-button',
- 'href' =>
$this->targetUser->getTalkPage()->getLocalUrl(),
- );
- $secondaryButton = Html::element( 'a', $attrs, $this->msg(
'mobile-frontend-profile-usertalk' ) );
-
- // define heading
- $heading = Html::element( 'h1', array(),
$this->targetUser->getName() );
-
- // set values
- /** @var SkinMobile $skin */
- $skin = $this->getSkin();
- $skin->setTemplateVariable( 'secondaryButton', $secondaryButton
);
- $skin->setTemplateVariable( 'specialPageHeader', $heading );
- }
-
// FIXME: Change this into 404 error
protected function getHtmlNoArg() {
$html = Html::element( 'p', array(), $this->msg(
'mobile-frontend-profile-noargs' ) );
@@ -184,12 +182,12 @@
if ( $this->targetUser->getId() ) {
// prepare content
$this->userInfo = new MobileUserInfo(
$this->targetUser );
- $this->setUserProfileUIElements();
$link = Linker::link(
$this->targetUser->getUserPage(),
$this->msg(
'mobile-frontend-profile-userpage-link' )->escaped(),
array( 'class' => 'statement section
user-page section-end' )
);
$html = Html::openElement( 'div', array(
'class' => 'profile' ) )
+ . $this->getUserHeader()
. $this->getUserSummary()
. $this->getRecentActivityHtml()
. $this->getLastThanks()
@@ -204,4 +202,24 @@
wfProfileOut( __METHOD__ );
$out->addHtml( $html );
}
+
+ /**
+ * Retrieve the text of a WikiPage
+ * @param string $wikiPageTitle The title of the WikiPage
+ * @return string The text of the page
+ */
+ private function getWikiPageText( $wikiPageTitle ) {
+ $text = '';
+ $title = Title::newFromText( $wikiPageTitle );
+ if ( $title ) {
+ $wikiPage = WikiPage::newFromID( $title->getArticleID()
);
+ if ( $wikiPage ) {
+ $content = $wikiPage->getContent();
+ if ( $content ) {
+ $text = ContentHandler::getContentText(
$content );
+ }
+ }
+ }
+ return $text;
+ }
}
diff --git a/less/specials/userprofile.less b/less/specials/userprofile.less
index b5e1c96..9da9f7e 100644
--- a/less/specials/userprofile.less
+++ b/less/specials/userprofile.less
@@ -1,9 +1,6 @@
@import "../mixins.less";
.profile {
- // FIXME: reconsider top margin for all pages?
- margin-top: 1.5em;
-
.last-upload {
margin-top: 0.6em;
}
--
To view, visit https://gerrit.wikimedia.org/r/93018
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0efd9b61d0c706f3eeff84643d8f091c64bb643b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits