Foxtrott has submitted this change and it was merged.

Change subject: 'class' attribute for all components
......................................................................


'class' attribute for all components

The 'class' attribute in the XML layout spec is now observed by all components.

The attribute is not a parameter to the component constructor anymore. Instead 
it is directly
taken from the DOMElement which is a parameter to the component constructor 
itself, making the
additional 'class' parameter redundent except in special cases. For these 
special cases an
addClass and a setClass method were added to the Component class.

Change-Id: I9034b488a67c0b061045c066c4b7ec251dc7cf1d
---
M components/Cell.php
M components/Component.php
M components/FooterIcons.php
M components/FooterInfo.php
M components/FooterPlaces.php
M components/Grid.php
M components/MainContent.php
M components/NavHead.php
M components/NavbarHorizontal.php
M components/NewtalkNotifier.php
M components/PersonalTools.php
M components/Row.php
M components/SiteNotice.php
M components/TabList.php
M components/ToolbarHorizontal.php
15 files changed, 50 insertions(+), 21 deletions(-)

Approvals:
  Foxtrott: Verified; Looks good to me, approved



diff --git a/components/Cell.php b/components/Cell.php
index 865e825..f9982fc 100644
--- a/components/Cell.php
+++ b/components/Cell.php
@@ -36,7 +36,7 @@
  */
 class Cell extends Container {
 
-       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0, $class = '' ) {
+       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0 ) {
 
                $span = $domElement->getAttribute( 'span' );
 
@@ -44,7 +44,9 @@
                        $span = '12';
                }
 
-               parent::__construct( $template, $domElement, $indent, 
"col-lg-$span $class" );
+               parent::__construct( $template, $domElement, $indent );
+
+               $this->addClass( "col-lg-$span" );
        }
 
 }
diff --git a/components/Component.php b/components/Component.php
index eb77569..d5acf1b 100644
--- a/components/Component.php
+++ b/components/Component.php
@@ -45,12 +45,12 @@
         * @param int               $indent
         * @param string            $class
         */
-       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0, $class = '' ) {
+       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0 ) {
 
                $this->mSkinTemplate = $template;
                $this->mIndent       = $indent;
-               $this->mClass        = $class;
                $this->mDomElement   = $domElement;
+               $this->mClass        = $domElement !== null ? 
$domElement->getAttribute( 'class' ) : '';
        }
 
        /**
@@ -82,6 +82,28 @@
        }
 
        /**
+        * Sets the class string that should be assigned to the top-level html 
element of this component
+        *
+        * @param $class
+        * @return string
+        */
+       public function setClass( $class ) {
+
+               $this->mClass = $class;
+       }
+
+       /**
+        * Adds the given class to the class string that should be assigned to 
the top-level html element of this component
+        *
+        * @param $class
+        * @return string
+        */
+       public function addClass( $class ) {
+
+               $this->mClass .= ' ' . $class;
+       }
+
+       /**
         * Returns the DOMElement from the description XML file associated with 
this element.
         *
         * @return \DOMElement
diff --git a/components/FooterIcons.php b/components/FooterIcons.php
index bc1c663..0e77cc7 100644
--- a/components/FooterIcons.php
+++ b/components/FooterIcons.php
@@ -48,7 +48,7 @@
                if ( $icons !== null && count( $icons ) > 0 ) {
 
                        $ret = $this->indent() . '<!-- footer icons -->' .
-                                  $this->indent() . '<ul class="list-inline 
pull-right footer-icons" id="footer-icons" >';
+                                  $this->indent() . '<ul class="list-inline 
pull-right footer-icons ' . $this->getClass() . '" id="footer-icons" >';
 
                        $this->indent( 1 );
                        foreach ( $icons as $blockName => $footerIcons ) {
diff --git a/components/FooterInfo.php b/components/FooterInfo.php
index 442690c..aa154f2 100644
--- a/components/FooterInfo.php
+++ b/components/FooterInfo.php
@@ -46,7 +46,7 @@
        public function getHtml() {
 
                $ret = $this->indent() . '<!-- footer links -->' .
-                          $this->indent() . '<ul class="list-unstyled 
footer-info small" id="footer-info" >';
+                          $this->indent() . '<ul class="list-unstyled 
footer-info small ' . $this->getClass() . '" id="footer-info" >';
 
                $footerlinks = $this->getSkinTemplate()->getFooterLinks();
                $this->indent( 1 );
diff --git a/components/FooterPlaces.php b/components/FooterPlaces.php
index b4d10e1..b7d02b6 100644
--- a/components/FooterPlaces.php
+++ b/components/FooterPlaces.php
@@ -48,7 +48,7 @@
                if ( array_key_exists( 'places', $footerlinks ) ) {
 
                        $ret = $this->indent() . '<!-- places -->' .
-                                  $this->indent() . '<ul class="list-inline 
footer-places" id="footer-places">';
+                                  $this->indent() . '<ul class="list-inline 
footer-places ' . $this->getClass() . '" id="footer-places">';
 
                        $this->indent( 1 );
                        foreach ( $footerlinks[ 'places' ] as $key ) {
diff --git a/components/Grid.php b/components/Grid.php
index ccd11bb..f18be70 100644
--- a/components/Grid.php
+++ b/components/Grid.php
@@ -36,8 +36,9 @@
  */
 class Grid extends Container {
 
-       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0, $class = '' ) {
+       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0 ) {
 
-               parent::__construct( $template, $domElement, $indent, 
"container $class" );
+               parent::__construct( $template, $domElement, $indent );
+               $this->addClass( 'container' );
        }
 }
diff --git a/components/MainContent.php b/components/MainContent.php
index 5438187..378c6f5 100644
--- a/components/MainContent.php
+++ b/components/MainContent.php
@@ -48,7 +48,7 @@
 
                $ret = $this->indent() . '<div id="mw-js-message" 
style="display:none;" ' . $skintemplate->get( 'userlangattributes' ) . 
'></div>' .
                           $this->indent() . '<!-- start the content area -->' .
-                          $this->indent() . '<div id="content" 
class="mw-body">' .
+                          $this->indent() . '<div id="content" class="mw-body 
' . $this->getClass() . '">' .
                           $this->indent( 1 ) . '<div class ="contentHeader">' .
                           $this->indent( 1 ) . '<!-- title of the page -->' .
                           $this->indent() . '<h1 id="firstHeading" 
class="firstHeading">' . $skintemplate->get( 'title' ) . '</h1>' .
diff --git a/components/NavHead.php b/components/NavHead.php
index 770b2bd..06a1a26 100644
--- a/components/NavHead.php
+++ b/components/NavHead.php
@@ -49,11 +49,13 @@
 
                $ret = $this->indent() . '<!-- navigation bar -->' .
                           $this->indent() . '<nav class="navbar navbar-default 
p-navbar" role="navigation" id="p-navbar" >';
+//             $this->indent() . '<nav class="navbar navbar-default p-navbar ' 
. $this->getClass() . '" role="navigation" id="p-navbar" >';
 
                $this->indent( 1 );
 
                // add logo
-               $logo = new Logo( $this->getSkinTemplate(), null, 
$this->getIndent(), 'navbar-brand' );
+               $logo = new Logo( $this->getSkinTemplate(), null, 
$this->getIndent() );
+               $logo->addClass( 'navbar-brand' );
                $ret .= $logo->getHtml();
 
                // add nav menu
@@ -63,7 +65,8 @@
                $ret .= $this->makePersonalTools();
 
                // add search form
-               $search = new SearchForm( $this->getSkinTemplate(), null, 
$this->getIndent(), 'navbar-form' );
+               $search = new SearchForm( $this->getSkinTemplate(), null, 
$this->getIndent() );
+               $search->addClass( 'navbar-form' );
                $ret .= $search->getHtml();
 
                $ret .= $this->indent( -1 ) . '</nav>' . "\n";
diff --git a/components/NavbarHorizontal.php b/components/NavbarHorizontal.php
index 3a9054f..6688951 100644
--- a/components/NavbarHorizontal.php
+++ b/components/NavbarHorizontal.php
@@ -48,7 +48,7 @@
        public function getHtml() {
 
                $ret = $this->indent() . '<!-- navigation bar -->' .
-                          $this->indent() . '<nav class="navbar navbar-default 
p-navbar" role="navigation" id="p-navbar" >' .
+                          $this->indent() . '<nav class="navbar navbar-default 
p-navbar ' . $this->getClass() . '" role="navigation" id="p-navbar" >' .
                           $this->indent( 1 ) . '<ul class="nav navbar-nav">';
 
                $this->indent( 1 );
diff --git a/components/NewtalkNotifier.php b/components/NewtalkNotifier.php
index 2259fea..8b240e3 100644
--- a/components/NewtalkNotifier.php
+++ b/components/NewtalkNotifier.php
@@ -43,7 +43,7 @@
 
                if ( $this->getSkinTemplate()->data[ 'newtalk' ] ) {
                        return $this->indent() . '<!-- message to a user about 
new messages on their talkpage -->' .
-                                  $this->indent() . '<span 
class="usermessage">' . $this->getSkinTemplate()->data[ 'newtalk' ] . '</span>';
+                                  $this->indent() . '<span class="usermessage 
' . $this->getClass() . '">' . $this->getSkinTemplate()->data[ 'newtalk' ] . 
'</span>';
                } else {
                        return '';
                }
diff --git a/components/PersonalTools.php b/components/PersonalTools.php
index 8416d85..facd147 100644
--- a/components/PersonalTools.php
+++ b/components/PersonalTools.php
@@ -42,11 +42,11 @@
        public function getHtml() {
 
                $ret = $this->indent() . '<!-- personal tools -->' .
-                          $this->indent() . '<div class="p-personal" 
id="p-personal" >';
+                          $this->indent() . '<div class="p-personal ' . 
$this->getClass() . '" id="p-personal" >';
 
                // include message to a user about new messages on their 
talkpage
                // TODO: make including the NewTalkNotifier dependent on an 
option (PREPEND, APPEND, OFF)
-               $newtalkNotifier = new NewtalkNotifier( 
$this->getSkinTemplate(), $this->getIndent() + 2 );
+               $newtalkNotifier = new NewtalkNotifier( 
$this->getSkinTemplate(), null, $this->getIndent() + 2 );
 
                $ret .= $this->indent( 1 ) . '<ul class="p-personal-tools 
list-inline pull-right" >';
 
diff --git a/components/Row.php b/components/Row.php
index 0daebf8..a4991fd 100644
--- a/components/Row.php
+++ b/components/Row.php
@@ -36,8 +36,9 @@
  */
 class Row extends Container {
 
-       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0, $class = '' ) {
+       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0 ) {
 
-               parent::__construct( $template, $domElement, $indent, "row 
$class" );
+               parent::__construct( $template, $domElement, $indent );
+               $this->addClass( 'row' );
        }
 }
diff --git a/components/SiteNotice.php b/components/SiteNotice.php
index f52f241..06f78b2 100644
--- a/components/SiteNotice.php
+++ b/components/SiteNotice.php
@@ -45,7 +45,7 @@
 
                if ( $siteNotice ) {
                        return $this->indent() . '<!-- sitenotice -->' .
-                                  $this->indent() . '<div id="siteNotice" 
class="siteNotice" >' . $siteNotice . '</div>'
+                                  $this->indent() . '<div id="siteNotice" 
class="siteNotice ' . $this->getClass() . '" >' . $siteNotice . '</div>'
                                   . "\n";
                } else {
                        return "\n";
diff --git a/components/TabList.php b/components/TabList.php
index 054820f..525167b 100644
--- a/components/TabList.php
+++ b/components/TabList.php
@@ -44,7 +44,7 @@
        public function getHtml() {
 
                $ret = $this->indent() . '<!-- Content navigation -->' .
-                          $this->indent() . '<ul class="list-inline 
p-contentnavigation text-center" id="p-contentnavigation">';
+                          $this->indent() . '<ul class="list-inline 
p-contentnavigation text-center ' . $this->getClass() . '" 
id="p-contentnavigation">';
 
                $navigation = $this->getSkinTemplate()->data[ 
'content_navigation' ];
 
diff --git a/components/ToolbarHorizontal.php b/components/ToolbarHorizontal.php
index d168d3f..1ac02a7 100644
--- a/components/ToolbarHorizontal.php
+++ b/components/ToolbarHorizontal.php
@@ -48,7 +48,7 @@
                $skinTemplate = $this->getSkinTemplate();
 
                $ret = $this->indent() . '<!-- ' . htmlspecialchars( 
$skinTemplate->getMsg( 'toolbox' )->text() ) . '-->' .
-                          $this->indent() . '<nav class="navbar navbar-default 
p-tb" id="p-tb" ' . Linker::tooltip( 'p-tb' ) . ' >' .
+                          $this->indent() . '<nav class="navbar navbar-default 
p-tb ' . $this->getClass() . '" id="p-tb" ' . Linker::tooltip( 'p-tb' ) . ' >' .
                           $this->indent( 1 ) . '<ul class="nav navbar-nav 
small">';
 
                // insert toolbox items

-- 
To view, visit https://gerrit.wikimedia.org/r/114635
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9034b488a67c0b061045c066c4b7ec251dc7cf1d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to