Foxtrott has submitted this change and it was merged.
Change subject: Add show/hide switches for languages and tools to NavMenu and
ToolBar
......................................................................
Add show/hide switches for languages and tools to NavMenu and ToolBar
Allows to add attributes to the NavMenu definition:
<component type="NavMenu" flatten="navigation" showTools="no"
showLanguages="no"></component>
Allows to add attributes to the ToolBar definition:
<component type="ToolbarHorizontal" hideTools="no"
hideLanguages="no"></component>
Change-Id: I65e7c9e4d37c30953dbf998319e9dd71c688d262
---
M layouts/clean.xml
M layouts/fixedhead.xml
M layouts/navhead.xml
M layouts/standard.xml
M layouts/stickyhead.xml
M src/Components/NavMenu.php
M src/Components/ToolbarHorizontal.php
7 files changed, 90 insertions(+), 28 deletions(-)
Approvals:
Foxtrott: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/layouts/clean.xml b/layouts/clean.xml
index daa12a0..cce9efd 100644
--- a/layouts/clean.xml
+++ b/layouts/clean.xml
@@ -2,7 +2,7 @@
<!--
This file is part of the MediaWiki skin Chameleon.
-@copyright 2013 - 2014, Stephan Gambke
+@copyright 2013 - 2016, Stephan Gambke
@license GNU General Public License, version 3 (or any later version)
The Chameleon skin is free software: you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
<modification type="ShowOnlyFor"
permission="edit"></modification>
<modification type="Sticky" ></modification>
<component type="Logo" position="head"></component>
- <component type="NavMenu" flatten="navigation"></component>
- <component type="PageTools" position="right"
hideSelectedNameSpace="1"></component>
+ <component type="NavMenu" flatten="navigation" showTools="no"
showLanguages="no"></component>
+ <component type="PageTools" position="right"
hideSelectedNameSpace="yes"></component>
<component type="SearchBar" position="right"></component>
<component type="PersonalTools" position="right"></component>
</component>
@@ -45,7 +45,7 @@
<row>
<modification type="ShowOnlyFor"
permission="edit"></modification>
<cell span="12">
- <component type="ToolbarHorizontal"></component>
+ <component type="ToolbarHorizontal"
hideTools="no" hideLanguages="no"></component>
</cell>
</row>
diff --git a/layouts/fixedhead.xml b/layouts/fixedhead.xml
index 8b64e0e..3a47943 100644
--- a/layouts/fixedhead.xml
+++ b/layouts/fixedhead.xml
@@ -2,7 +2,7 @@
<!--
This file is part of the MediaWiki skin Chameleon.
-@copyright 2013 - 2014, Stephan Gambke
+@copyright 2013 - 2016, Stephan Gambke
@license GNU General Public License, version 3 (or any later version)
The Chameleon skin is free software: you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
<component type="NavbarHorizontal" fixed="1">
<component type="Logo" position="head"></component>
- <component type="NavMenu" flatten="navigation"></component>
- <component type="PageTools" position="right"
hideSelectedNameSpace="1"></component>
+ <component type="NavMenu" flatten="navigation" showTools="no"
showLanguages="no"></component>
+ <component type="PageTools" position="right"
hideSelectedNameSpace="yes"></component>
<component type="SearchBar" position="right"></component>
<component type="PersonalTools" position="right"></component>
</component>
@@ -47,7 +47,7 @@
<row>
<cell span="12">
- <component type="ToolbarHorizontal"></component>
+ <component type="ToolbarHorizontal"
hideTools="no" hideLanguages="no"></component>
</cell>
</row>
diff --git a/layouts/navhead.xml b/layouts/navhead.xml
index 6aa5f34..04eec0d 100644
--- a/layouts/navhead.xml
+++ b/layouts/navhead.xml
@@ -2,7 +2,7 @@
<!--
This file is part of the MediaWiki skin Chameleon.
-@copyright 2013 - 2014, Stephan Gambke
+@copyright 2013 - 2016, Stephan Gambke
@license GNU General Public License, version 3 (or any later version)
The Chameleon skin is free software: you can redistribute it and/or modify it
@@ -28,8 +28,8 @@
<cell span="12">
<component type="NavbarHorizontal">
<component type="Logo"
position="head"></component>
- <component type="NavMenu"
flatten="navigation"></component>
- <component type="PageTools"
position="right" hideSelectedNameSpace="1"></component>
+ <component type="NavMenu"
flatten="navigation" showTools="no" showLanguages="no" ></component>
+ <component type="PageTools"
position="right" hideSelectedNameSpace="yes"></component>
<component type="SearchBar"
position="right"></component>
<component type="PersonalTools"
position="right"></component>
</component>
@@ -50,7 +50,7 @@
<row>
<cell span="12">
- <component type="ToolbarHorizontal"></component>
+ <component type="ToolbarHorizontal"
hideTools="no" hideLanguages="no"></component>
</cell>
</row>
diff --git a/layouts/standard.xml b/layouts/standard.xml
index 6bbf0d8..67f11e2 100644
--- a/layouts/standard.xml
+++ b/layouts/standard.xml
@@ -2,7 +2,7 @@
<!--
This file is part of the MediaWiki skin Chameleon.
-@copyright 2013 - 2014, Stephan Gambke
+@copyright 2013 - 2016, Stephan Gambke
@license GNU General Public License, version 3 (or any later version)
The Chameleon skin is free software: you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
<row>
<cell span="12">
<component type="NavbarHorizontal">
- <component type="NavMenu"></component>
+ <component type="NavMenu"
showTools="no" showLanguages="no"></component>
</component>
</cell>
</row>
@@ -74,7 +74,7 @@
<row>
<cell span="12">
- <component type="ToolbarHorizontal"></component>
+ <component type="ToolbarHorizontal"
hideTools="no" hideLanguages="no"></component>
</cell>
</row>
diff --git a/layouts/stickyhead.xml b/layouts/stickyhead.xml
index 217e649..cdb3736 100644
--- a/layouts/stickyhead.xml
+++ b/layouts/stickyhead.xml
@@ -2,7 +2,7 @@
<!--
This file is part of the MediaWiki skin Chameleon.
-@copyright 2013 - 2014, Stephan Gambke
+@copyright 2013 - 2016, Stephan Gambke
@license GNU General Public License, version 3 (or any later version)
The Chameleon skin is free software: you can redistribute it and/or modify it
@@ -31,8 +31,8 @@
<component type="NavbarHorizontal" class="full-width">
<modification type="Sticky"></modification>
<component type="Logo" position="head"></component>
- <component type="NavMenu" flatten="navigation"></component>
- <component type="PageTools" position="right"
hideSelectedNameSpace="1"></component>
+ <component type="NavMenu" flatten="navigation" showTools="no"
showLanguages="no"></component>
+ <component type="PageTools" position="right"
hideSelectedNameSpace="yes"></component>
<component type="SearchBar" position="right"></component>
<component type="PersonalTools" position="right"></component>
</component>
@@ -52,7 +52,7 @@
<row>
<cell span="12">
- <component type="ToolbarHorizontal"></component>
+ <component type="ToolbarHorizontal"
hideTools="no" hideLanguages="no"></component>
</cell>
</row>
diff --git a/src/Components/NavMenu.php b/src/Components/NavMenu.php
index 2f403be..7eae4a3 100644
--- a/src/Components/NavMenu.php
+++ b/src/Components/NavMenu.php
@@ -4,7 +4,7 @@
*
* This file is part of the MediaWiki skin Chameleon.
*
- * @copyright 2013 - 2014, Stephan Gambke
+ * @copyright 2013 - 2016, Stephan Gambke
* @license GNU General Public License, version 3 (or any later version)
*
* The Chameleon skin is free software: you can redistribute it and/or modify
@@ -48,7 +48,7 @@
$ret = '';
$sidebar = $this->getSkinTemplate()->getSidebar( array(
- 'search' => false, 'toolbox' => false,
'languages' => false
+ 'search' => false, 'toolbox' =>
$this->showTools(), 'languages' => $this->showLanguages()
)
);
@@ -71,6 +71,20 @@
}
/**
+ * @return bool
+ */
+ private function showLanguages() {
+ return $this->getDomElement() !== null && filter_var(
$this->getDomElement()->getAttribute( 'showLanguages' ),
FILTER_VALIDATE_BOOLEAN );
+ }
+
+ /**
+ * @return bool
+ */
+ private function showTools() {
+ return $this->getDomElement() !== null && filter_var(
$this->getDomElement()->getAttribute( 'showTools' ), FILTER_VALIDATE_BOOLEAN );
+ }
+
+ /**
* Create a single dropdown
*
* @param string $menuName
diff --git a/src/Components/ToolbarHorizontal.php
b/src/Components/ToolbarHorizontal.php
index f7694e6..255cec1 100644
--- a/src/Components/ToolbarHorizontal.php
+++ b/src/Components/ToolbarHorizontal.php
@@ -4,7 +4,7 @@
*
* This file is part of the MediaWiki skin Chameleon.
*
- * @copyright 2013 - 2015, Stephan Gambke
+ * @copyright 2013 - 2016, Stephan Gambke
* @license GNU General Public License, version 3 (or any later version)
*
* The Chameleon skin is free software: you can redistribute it and/or modify
@@ -55,9 +55,35 @@
$this->indent() . '<nav class="navbar navbar-default
p-tb ' . $this->getClassString() . '" id="p-tb" ' . Linker::tooltip( 'p-tb' ) .
' >' .
$this->indent( 1 ) . '<ul class="nav navbar-nav
small">';
- // insert toolbox items
- // TODO: Do we need to care of dropdown menus here? E.g. RSS
feeds? See SkinTemplateToolboxEnd.php:1485
$this->indent( 1 );
+
+ // insert toolbox items
+ if ( !$this->hideTools() ) {
+ $ret .= $this->addTools( $skinTemplate );
+ }
+
+ // insert language links
+ if ( !$this->hideLanguages() ) {
+ $ret .= $this->addLanguageLinks( $skinTemplate );
+ }
+
+ $ret .= $this->indent( -1 ) . '</ul>' .
+ $this->indent( -1 ) . '</nav>' . "\n";
+
+ return $ret;
+ }
+
+ /**
+ * @param $skinTemplate
+ * @return string
+ * @throws \FatalError
+ * @throws \MWException
+ */
+ private function addTools( $skinTemplate ) {
+
+ $ret = '';
+
+ // TODO: Do we need to care of dropdown menus here? E.g. RSS
feeds? See SkinTemplateToolboxEnd.php:1485
foreach ( $skinTemplate->getToolbox() as $key => $tbitem ) {
$ret .= $this->indent() . $skinTemplate->makeListItem(
$key, $tbitem );
}
@@ -68,8 +94,18 @@
Hooks::run( 'SkinTemplateToolboxEnd', array( &$skinTemplate,
true ) );
$ret .= $this->indent() . ob_get_contents();
ob_end_clean();
+ return $ret;
+ }
- // insert language links
+ /**
+ * @param $skinTemplate
+ * @return string
+ * @throws \MWException
+ */
+ private function addLanguageLinks( $skinTemplate ) {
+
+ $ret = '';
+
if ( array_key_exists( 'language_urls', $skinTemplate->data )
&& $skinTemplate->data[ 'language_urls' ] ) {
$ret .= $this->indent() . '<li class="dropdown dropup
p-lang" id="p-lang" ' . Linker::tooltip( 'p-lang' ) . ' >' .
@@ -86,9 +122,21 @@
$this->indent( -1 ) . '</li>';
}
- $ret .= $this->indent( -1 ) . '</ul>' .
- $this->indent( -1 ) . '</nav>' . "\n";
-
return $ret;
}
+
+ /**
+ * @return bool
+ */
+ private function hideTools() {
+ return $this->getDomElement() !== null && filter_var(
$this->getDomElement()->getAttribute( 'hideTools' ), FILTER_VALIDATE_BOOLEAN );
+ }
+
+ /**
+ * @return bool
+ */
+ private function hideLanguages() {
+ return $this->getDomElement() !== null && filter_var(
$this->getDomElement()->getAttribute( 'hideLanguages' ),
FILTER_VALIDATE_BOOLEAN );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/273982
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I65e7c9e4d37c30953dbf998319e9dd71c688d262
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits