Foxtrott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/171948
Change subject: Some refactoring of the MainContent component
......................................................................
Some refactoring of the MainContent component
Change-Id: Id3b2b7c46d8da27260d62c05c42817e46b3bb64c
---
M docs/contribute.md
M src/Components/MainContent.php
2 files changed, 51 insertions(+), 21 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/chameleon
refs/changes/48/171948/1
diff --git a/docs/contribute.md b/docs/contribute.md
index 3aa7a5b..db218f0 100644
--- a/docs/contribute.md
+++ b/docs/contribute.md
@@ -35,8 +35,8 @@
The Chameleon skin is hosted on the Wikimedia Git server. To provide patches
you
need to get a developer account. MediaWiki has a [tutorial][gerrit-tutorial] to
-get you started. Alternatively you may use the [Gerrit Patch Uploader][patch
-uploader].
+get you started. Alternatively you may use the
+[Gerrit Patch Uploader][patch uploader].
A few points to ease the process
* Please ensure that patches are based on the current master. If in doubt,
diff --git a/src/Components/MainContent.php b/src/Components/MainContent.php
index 05995b8..b05d996 100644
--- a/src/Components/MainContent.php
+++ b/src/Components/MainContent.php
@@ -67,12 +67,29 @@
)
) . $skintemplate->get( 'userlangattributes' ) .
'></div>';
+ $ret .= $this->buildContentHeader();
+ $ret .= $this->buildContentBody();
+ $ret .= $this->buildCategoryLinks();
+ $ret .= $this->buildDataAfterContent();
- // START contentHeader
- $ret .= $this->indent( 1 ) . '<div class ="contentHeader">' .
+ $ret .= $this->indent( -1 ) . '</div>' . "\n";
+ // END content
+
+ return $ret;
+ }
+
+ /**
+ * @return string
+ */
+ protected function buildContentHeader() {
+
+ $skintemplate = $this->getSkinTemplate();
+ $idRegistry = IdRegistry::getRegistry();
+
+ $ret = $this->indent( 1 ) . '<div class ="contentHeader">' .
$this->indent( 1 ) . '<!-- title of the page -->' .
- $this->indent() . $idRegistry->element('h1', array(
'id' => 'firstHeading','class'=>'firstHeading') , $skintemplate->get( 'title' )
) .
+ $this->indent() . $idRegistry->element( 'h1', array(
'id' => 'firstHeading', 'class' => 'firstHeading' ), $skintemplate->get(
'title' ) ) .
$this->indent() . '<!-- tagline; usually goes something
like "From WikiName" primary purpose of this seems to be for printing to
identify the source of the content -->' .
$this->indent() . $idRegistry->element( 'div', array(
'id'=> 'siteSub' ), $skintemplate->getMsg( 'tagline' )->escaped() );
@@ -94,38 +111,51 @@
}
// TODO: Do we need this? Seems to be an accessibility thing.
It's used in vector to jump to the nav wich is at the bottom of the document,
but our nav is usually at the top
- $ret .= $idRegistry->element( 'div', array( 'id' =>
'jump-to-nav', 'class' => 'mw-jump' ),
+ $ret .= $idRegistry->element( 'div', array( 'id' =>
'jump-to-nav', 'class' => 'mw-jump' ),
$skintemplate->getMsg( 'jumpto' )->escaped() . '<a
href="#mw-navigation">' . $skintemplate->getMsg( 'jumptonavigation'
)->escaped() . '</a>' .
$skintemplate->getMsg( 'comma-separator' )->escaped() .
'<a href="#p-search">' . $skintemplate->getMsg( 'jumptosearch' )->escaped() .
'</a>'
);
$ret .= $this->indent( -1 ) . '</div>';
- // END contentHeader
+ return $ret;
+ }
-
- // START content body
- $ret .= $idRegistry->element( 'div', array( 'id' =>
'bodyContent' ),
+ /**
+ * @return string
+ */
+ protected function buildContentBody() {
+ return IdRegistry::getRegistry()->element( 'div', array( 'id'
=> 'bodyContent' ),
$this->indent() . '<!-- body text -->' . "\n" .
- $this->indent() . $skintemplate->get( 'bodytext' )
+ $this->indent() . $this->getSkinTemplate()->get(
'bodytext' )
);
- // END content body
+ }
+ /**
+ * @return string
+ */
+ protected function buildCategoryLinks() {
// TODO: Category links should be a separate component, but
// * dataAfterContent should come after the the category links.
// * only one extension is known to use it dataAfterContent and
it is geared specifically towards MonoBook
// => provide an attribut hideCatLinks for the XML and -if
present- hide category links and assume somebody knows what they are doing
- $ret .= $this->indent() . '<!-- category links -->' .
- $this->indent() . $skintemplate->get(
'catlinks' );
+ return
+ $this->indent() . '<!-- category links -->' .
+ $this->indent() . $this->getSkinTemplate()->get(
'catlinks' );
+ }
+ /**
+ * @return string
+ */
+ protected function buildDataAfterContent() {
- if ( $skintemplate->get( 'dataAfterContent' ) ) {
- $ret .= $this->indent() . '<!-- data blocks which
should go somewhere after the body text, but not before the catlinks block-->' .
- $this->indent() . $skintemplate->get(
'dataAfterContent' );
+ $skinTemplate = $this->getSkinTemplate();
+
+ if ( $skinTemplate->get( 'dataAfterContent' ) ) {
+ return
+ $this->indent() . '<!-- data blocks which
should go somewhere after the body text, but not before the catlinks block-->' .
+ $this->indent() . $skinTemplate->get(
'dataAfterContent' );
}
- $ret .= $this->indent( -1 ) . '</div>' . "\n";
- // END content
-
- return $ret;
+ return '';
}
}
--
To view, visit https://gerrit.wikimedia.org/r/171948
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3b2b7c46d8da27260d62c05c42817e46b3bb64c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits