Foxtrott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122115

Change subject: Introduce IdRegistry; Code restructuring
......................................................................

Introduce IdRegistry; Code restructuring

* introduces an ID registry to avoid two HTMLelements with the same ID
* adds an 'includes' directory and moves 'components' dir there
* renames 'css' dir to 'styles'
* splits Chameleon.skin.php

Change-Id: Id62c13e6c83d60d210f45b8ecb9c729d4927941d
---
D Chameleon.skin.php
M chameleon.php
A includes/ChameleonTemplate.php
A includes/IdRegistry.php
A includes/SkinChameleon.php
R includes/components/Cell.php
R includes/components/Component.php
R includes/components/Container.php
R includes/components/FooterIcons.php
R includes/components/FooterInfo.php
R includes/components/FooterPlaces.php
R includes/components/Grid.php
R includes/components/Html.php
R includes/components/Logo.php
R includes/components/MainContent.php
R includes/components/NavbarHorizontal.php
R includes/components/NewtalkNotifier.php
R includes/components/PageTools.php
R includes/components/PersonalTools.php
R includes/components/Row.php
R includes/components/SearchBar.php
R includes/components/SiteNotice.php
R includes/components/Structure.php
R includes/components/ToolbarHorizontal.php
R styles/screen.less
25 files changed, 364 insertions(+), 203 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/chameleon 
refs/changes/15/122115/1

diff --git a/Chameleon.skin.php b/Chameleon.skin.php
deleted file mode 100644
index dee36c4..0000000
--- a/Chameleon.skin.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-/**
- * Skin file for Chameleon skin
- *
- * @copyright (C) 2013, Stephan Gambke
- * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public 
License, version 3 (or later)
- *
- * This file is part of the MediaWiki skin Chameleon.
- * The Chameleon skin is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The Chameleon skin is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * @file
- * @ingroup Skins
- */
-
-namespace {
-
-       /**
-        * SkinTemplate class for Chameleon skin
-        *
-        * @ingroup Skins
-        */
-       class SkinChameleon extends SkinTemplate {
-
-               var $skinname = 'chameleon';
-               var $stylename = 'chameleon';
-               var $template = '\skins\chameleon\ChameleonTemplate';
-               var $useHeadElement = true;
-
-               /**
-                * @param $out OutputPage object
-                */
-               function setupSkinUserCss( OutputPage $out ) {
-
-                       parent::setupSkinUserCss( $out );
-
-                       // load Bootstrap styles
-                       $out->addModuleStyles( 'ext.bootstrap' );
-               }
-
-               /**
-                * @param \OutputPage $out
-                */
-               function initPage( OutputPage $out ) {
-
-                       parent::initPage( $out );
-
-                       // load Bootstrap scripts
-                       $out->addModules( array( 'ext.bootstrap' ) );
-
-                       // Enable responsive behaviour on mobile browsers
-                       $out->addMeta( 'viewport', 'width=device-width, 
initial-scale=1.0' );
-               }
-       }
-
-}
-
-namespace skins\chameleon {
-
-       use BaseTemplate;
-       use DOMDocument;
-       use skins\chameleon\components\Container;
-
-       /**
-        * BaseTemplate class for Chameleon skin
-        *
-        * @ingroup Skins
-        */
-       class ChameleonTemplate extends BaseTemplate {
-
-               // the root component of the page; should be of type Container
-               private $mRootComponent = null;
-
-               /**
-                * Outputs the entire contents of the page
-                */
-               public function execute() {
-
-                       // Suppress warnings to prevent notices about missing 
indexes in $this->data
-                       wfSuppressWarnings();
-
-                       // output the head element
-                       // The headelement defines the <body> tag itself, it 
shouldn't be included in the html text
-                       // To add attributes or classes to the body tag 
override addToBodyAttributes() in SkinChameleon
-                       $this->html( 'headelement' );
-                       echo $this->getRootComponent()->getHtml();
-                       $this->printTrail(); ?>
-
-</body>
-</html><?php
-                       wfRestoreWarnings();
-               }
-
-               protected function getRootComponent() {
-
-                       global $egChameleonLayoutFile;
-
-                       if ( $this->mRootComponent === null ) {
-
-                               $doc = new DOMDocument();
-
-                               $doc->load( $egChameleonLayoutFile ); //TODO: 
error handling (file not found, file empty)
-
-                               $doc->normalizeDocument();
-
-                               // TODO: only create new root component the 
first time
-                               $roots = $doc->getElementsByTagName( 
'structure' );
-
-                               if ( $roots->length > 0 ) {
-
-                                       $this->mRootComponent = 
$this->getComponent( $roots->item( 0 ) );
-
-                               } else {
-                                       // TODO: catch other errors, e.g. 
malformed XML
-                                       throw new \MWException( 'XML 
description is missing an element: structure' );
-                               }
-                       }
-
-                       return $this->mRootComponent;
-
-               }
-
-               /**
-                * @param \DOMElement $description
-                */
-               public function getComponent( \DOMElement $description, $indent 
= 0, $htmlClassAttribute = '' ) {
-
-                       $class = 'skins\\chameleon\\components\\';
-
-                       switch ($description->nodeName) {
-                       case 'structure':
-                               $class .= 'Structure';
-                               break;
-                       case 'grid':
-                               $class .= 'Grid';
-                               break;
-                       case 'row':
-                               $class .= 'Row';
-                               break;
-                       case 'cell':
-                               $class .= 'Cell';
-                               break;
-                       default:
-                               if ( $description->hasAttribute('type')) {
-                                       $class .= 
$description->getAttribute('type');
-                               } else {
-                                       $class .= 'Container';
-                               }
-                       }
-
-                       if ( class_exists( $class ) && is_subclass_of( $class, 
'skins\\chameleon\\components\\Component' )) {
-                               return new $class( $this, $description, 
$indent, $htmlClassAttribute );
-                       } else {
-                               return new Container( $this, $description, 
$indent, $htmlClassAttribute );
-                       }
-               }
-       }
-
-}
diff --git a/chameleon.php b/chameleon.php
index 47a9dc8..dbaab4f 100644
--- a/chameleon.php
+++ b/chameleon.php
@@ -58,7 +58,9 @@
 $wgValidSkinNames['chameleon'] = 'Chameleon';
 
 // register skin class (must be 'Skin' . SkinName)
-$wgAutoloadClasses['SkinChameleon'] = dirname( __FILE__ ) . 
'/Chameleon.skin.php';
+$wgAutoloadClasses['SkinChameleon'] = dirname( __FILE__ ) . 
'/includes/SkinChameleon.php';
+$wgAutoloadClasses['skins\\chameleon\\ChameleonTemplate'] = dirname( __FILE__ 
) . '/includes/ChameleonTemplate.php';
+$wgAutoloadClasses['skins\\chameleon\\IdRegistry'] = dirname( __FILE__ ) . 
'/includes/IdRegistry.php';
 
 
 $egChameleonLayoutFile= dirname( __FILE__ ) . '/layouts/standard.xml';
@@ -87,7 +89,7 @@
 );
 
 foreach ( $chameleonComponents as $component ) {
-       $wgAutoloadClasses['skins\\chameleon\\components\\' . $component] = 
dirname( __FILE__ ) . '/components/' . $component. '.php';
+       $wgAutoloadClasses['skins\\chameleon\\components\\' . $component] = 
dirname( __FILE__ ) . '/includes/components/' . $component. '.php';
 }
 
 // register message file for i18n
@@ -95,4 +97,4 @@
 
 // register Bootstrap modules (for now, just register everything)
 Bootstrap::getBootstrap()->addAllBootstrapModules();
-Bootstrap::getBootstrap()->addExternalModule( __DIR__, '/css/screen.less' );
+Bootstrap::getBootstrap()->addExternalModule( __DIR__, '/styles/screen.less' );
diff --git a/includes/ChameleonTemplate.php b/includes/ChameleonTemplate.php
new file mode 100644
index 0000000..06162cd
--- /dev/null
+++ b/includes/ChameleonTemplate.php
@@ -0,0 +1,124 @@
+<?php
+/**
+ * File holding the ChameleonTemplate class
+ *
+ * @copyright (C) 2013, Stephan Gambke
+ * @license       http://www.gnu.org/licenses/gpl-3.0.html GNU General Public 
License, version 3 (or later)
+ *
+ * This file is part of the MediaWiki skin Chameleon.
+ * The Chameleon skin is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The Chameleon skin is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @file
+ * @ingroup       Skins
+ */
+
+namespace skins\chameleon;
+
+use BaseTemplate;
+use DOMDocument;
+use skins\chameleon\components\Container;
+
+/**
+ * BaseTemplate class for the Chameleon skin
+ *
+ * @ingroup Skins
+ */
+class ChameleonTemplate extends BaseTemplate {
+
+       // the root component of the page; should be of type Container
+       private $mRootComponent = null;
+
+       /**
+        * Outputs the entire contents of the page
+        */
+       public function execute() {
+
+               // Suppress warnings to prevent notices about missing indexes 
in $this->data
+               wfSuppressWarnings();
+
+               // output the head element
+               // The headelement defines the <body> tag itself, it shouldn't 
be included in the html text
+               // To add attributes or classes to the body tag override 
addToBodyAttributes() in SkinChameleon
+               $this->html( 'headelement' );
+               echo $this->getRootComponent()->getHtml();
+               $this->printTrail();
+               echo "</body>\n</html>";
+
+               wfRestoreWarnings();
+       }
+
+       protected function getRootComponent() {
+
+               global $egChameleonLayoutFile;
+
+               if ( $this->mRootComponent === null ) {
+
+                       $doc = new DOMDocument();
+
+                       $doc->load( $egChameleonLayoutFile ); //TODO: error 
handling (file not found, file empty)
+
+                       $doc->normalizeDocument();
+
+                       // TODO: only create new root component the first time
+                       $roots = $doc->getElementsByTagName( 'structure' );
+
+                       if ( $roots->length > 0 ) {
+
+                               $this->mRootComponent = $this->getComponent( 
$roots->item( 0 ) );
+
+                       } else {
+                               // TODO: catch other errors, e.g. malformed XML
+                               throw new \MWException( 'XML description is 
missing an element: structure' );
+                       }
+               }
+
+               return $this->mRootComponent;
+
+       }
+
+       /**
+        * @param \DOMElement $description
+        */
+       public function getComponent( \DOMElement $description, $indent = 0, 
$htmlClassAttribute = '' ) {
+
+               $class = 'skins\\chameleon\\components\\';
+
+               switch ( $description->nodeName ) {
+                       case 'structure':
+                               $class .= 'Structure';
+                               break;
+                       case 'grid':
+                               $class .= 'Grid';
+                               break;
+                       case 'row':
+                               $class .= 'Row';
+                               break;
+                       case 'cell':
+                               $class .= 'Cell';
+                               break;
+                       default:
+                               if ( $description->hasAttribute( 'type' ) ) {
+                                       $class .= $description->getAttribute( 
'type' );
+                               } else {
+                                       $class .= 'Container';
+                               }
+               }
+
+               if ( class_exists( $class ) && is_subclass_of( $class, 
'skins\\chameleon\\components\\Component' ) ) {
+                       return new $class( $this, $description, $indent, 
$htmlClassAttribute );
+               } else {
+                       return new Container( $this, $description, $indent, 
$htmlClassAttribute );
+               }
+       }
+}
diff --git a/includes/IdRegistry.php b/includes/IdRegistry.php
new file mode 100644
index 0000000..285c29d
--- /dev/null
+++ b/includes/IdRegistry.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * File holding the IdRegistry class
+ *
+ * @copyright (C) 2014, Stephan Gambke
+ * @license       http://www.gnu.org/licenses/gpl-3.0.html GNU General Public 
License, version 3 (or later)
+ *
+ * This file is part of the MediaWiki extension Chameleon.
+ * The Chameleon extension is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The Chameleon extension is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @file
+ * @ingroup       Skins
+ */
+
+
+namespace skins\chameleon;
+
+/**
+ * Class IdRegistry provides a registry and access methods to ensure each id 
is only used once per HTML page.
+ *
+ * @package skins\chameleon
+ */
+class IdRegistry {
+
+       private static $sInstance;
+
+       /**
+        * @return IdRegistry
+        */
+       public static function getRegistry() {
+
+               if ( IdRegistry::$sInstance === null ) {
+                       IdRegistry::$sInstance = new IdRegistry();
+               }
+
+               return IdRegistry::$sInstance;
+
+       }
+
+
+       private $mRegistry = array();
+
+       public function getId( $id = null, $component=null ) {
+
+               if ( empty( $id ) ) {
+
+                       // no specific id requested, just return a unique string
+                       return base_convert( uniqid(), 16, 36 );
+
+               } else if ( array_key_exists( $id, $this->mRegistry ) ) {
+
+                       // specific id requested, but already in use
+                       // return a string derived from the id and a unique 
string
+                       $key = "$id-" . base_convert( uniqid(), 16, 36 );
+                       $this->mRegistry[ $id ][ $key ] = $component;
+                       return $key;
+
+               } else {
+
+                       // specific id requested that is not yet in use
+                       // return the id
+                       $this->mRegistry[ $id ][ $id ] = $component;
+                       return $id;
+
+               }
+       }
+
+} 
\ No newline at end of file
diff --git a/includes/SkinChameleon.php b/includes/SkinChameleon.php
new file mode 100644
index 0000000..5bda258
--- /dev/null
+++ b/includes/SkinChameleon.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * File holding the SkinChameleon class
+ *
+ * @copyright (C) 2014, Stephan Gambke
+ * @license       http://www.gnu.org/licenses/gpl-3.0.html GNU General Public 
License, version 3 (or later)
+ *
+ * This file is part of the MediaWiki extension Chameleon.
+ * The Chameleon extension is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The Chameleon extension is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @file
+ * @ingroup       Skins
+ */
+
+
+/**
+ * SkinTemplate class for the Chameleon skin
+ *
+ * @ingroup Skins
+ */
+class SkinChameleon extends SkinTemplate {
+
+       var $skinname = 'chameleon';
+       var $stylename = 'chameleon';
+       var $template = '\skins\chameleon\ChameleonTemplate';
+       var $useHeadElement = true;
+
+       /**
+        * @param $out OutputPage object
+        */
+       function setupSkinUserCss( OutputPage $out ) {
+
+               parent::setupSkinUserCss( $out );
+
+               // load Bootstrap styles
+               $out->addModuleStyles( 'ext.bootstrap' );
+       }
+
+       /**
+        * @param \OutputPage $out
+        */
+       function initPage( OutputPage $out ) {
+
+               parent::initPage( $out );
+
+               // load Bootstrap scripts
+               $out->addModules( array( 'ext.bootstrap' ) );
+
+               // Enable responsive behaviour on mobile browsers
+               $out->addMeta( 'viewport', 'width=device-width, 
initial-scale=1.0' );
+       }
+}
diff --git a/components/Cell.php b/includes/components/Cell.php
similarity index 100%
rename from components/Cell.php
rename to includes/components/Cell.php
diff --git a/components/Component.php b/includes/components/Component.php
similarity index 96%
rename from components/Component.php
rename to includes/components/Component.php
index d9c0f90..c1e05b2 100644
--- a/components/Component.php
+++ b/includes/components/Component.php
@@ -43,9 +43,10 @@
         * @param ChameleonTemplate $template
         * @param \DOMElement|null  $domElement
         * @param int               $indent
-        * @param string            $class
+        *
+        * @internal param string $class
         */
-       public function __construct( ChameleonTemplate $template, $domElement, 
$indent = 0 ) {
+       public function __construct( ChameleonTemplate $template, \DOMElement 
$domElement = null, $indent = 0 ) {
 
                $this->mSkinTemplate = $template;
                $this->mIndent       = $indent;
diff --git a/components/Container.php b/includes/components/Container.php
similarity index 87%
rename from components/Container.php
rename to includes/components/Container.php
index 3224510..d49c0a0 100644
--- a/components/Container.php
+++ b/includes/components/Container.php
@@ -30,6 +30,11 @@
 /**
  * The Container class.
  *
+ * It will wrap its content elements in a DIV.
+ *
+ * Supported attributes:
+ * - class
+ *
  * @ingroup Skins
  */
 class Container extends Structure {
@@ -41,7 +46,7 @@
         */
        public function getHtml(){
 
-               $ret = $this->indent() . '<div class="' . 
$this->getClassString() . '" >';
+               $ret = $this->indent() . \Html::openElement( 'div', array( 
'class' => $this->getClassString() ) );
 
                $ret .= parent::getHtml();
 
diff --git a/components/FooterIcons.php b/includes/components/FooterIcons.php
similarity index 100%
rename from components/FooterIcons.php
rename to includes/components/FooterIcons.php
diff --git a/components/FooterInfo.php b/includes/components/FooterInfo.php
similarity index 80%
rename from components/FooterInfo.php
rename to includes/components/FooterInfo.php
index 5ea4dcd..508fa2a 100644
--- a/components/FooterInfo.php
+++ b/includes/components/FooterInfo.php
@@ -24,6 +24,8 @@
  */
 
 namespace skins\chameleon\components;
+use skins\chameleon\ChameleonTemplate;
+use skins\chameleon\IdRegistry;
 
 
 /**
@@ -38,6 +40,11 @@
  */
 class FooterInfo extends Component {
 
+       public function __construct( ChameleonTemplate $template, \DOMElement 
$domElement = null, $indent = 0 ) {
+               parent::__construct( $template, $domElement , $indent );
+               $this->addClasses( 'list-unstyled small' );
+       }
+
        /**
         * Builds the HTML code for this component
         *
@@ -46,7 +53,12 @@
        public function getHtml() {
 
                $ret = $this->indent() . '<!-- footer links -->' .
-                          $this->indent() . '<ul class="list-unstyled 
footer-info small ' . $this->getClassString() . '" id="footer-info" >';
+                       $this->indent() .
+                       \Html::openElement( 'ul', array(
+                                       'class' =>  'footer-info ' . 
$this->getClassString(),
+                                       'id' => 
IdRegistry::getRegistry()->getId( 'footer-info' ),
+                               )
+                       );
 
                $footerlinks = $this->getSkinTemplate()->getFooterLinks();
                $this->indent( 1 );
diff --git a/components/FooterPlaces.php b/includes/components/FooterPlaces.php
similarity index 100%
rename from components/FooterPlaces.php
rename to includes/components/FooterPlaces.php
diff --git a/components/Grid.php b/includes/components/Grid.php
similarity index 100%
rename from components/Grid.php
rename to includes/components/Grid.php
diff --git a/components/Html.php b/includes/components/Html.php
similarity index 86%
rename from components/Html.php
rename to includes/components/Html.php
index fb06575..e2a3227 100644
--- a/components/Html.php
+++ b/includes/components/Html.php
@@ -41,11 +41,15 @@
         */
        public function getHtml() {
 
-               $dom = $this->getDomElement()->ownerDocument;
                $ret = '';
 
-               foreach ( $this->getDomElement()->childNodes as $node ) {
-                       $ret .= $dom->saveHTML( $node );
+               if ( $this->getDomElement() !== null ) {
+
+                       $dom = $this->getDomElement()->ownerDocument;
+
+                       foreach ( $this->getDomElement()->childNodes as $node ) 
{
+                               $ret .= $dom->saveHTML( $node );
+                       }
                }
 
                return $ret;
diff --git a/components/Logo.php b/includes/components/Logo.php
similarity index 63%
rename from components/Logo.php
rename to includes/components/Logo.php
index 4accf9b..0704304 100644
--- a/components/Logo.php
+++ b/includes/components/Logo.php
@@ -26,6 +26,7 @@
 namespace skins\chameleon\components;
 
 use Linker;
+use skins\chameleon\IdRegistry;
 
 /**
  * The Logo class.
@@ -43,13 +44,29 @@
         */
        public function getHtml() {
 
-               $attribs  = array( 'href' => $this->getSkinTemplate()->data[ 
'nav_urls' ][ 'mainpage' ][ 'href' ] ) + Linker::tooltipAndAccesskeyAttribs( 
'p-logo' );
-               $contents = \Html::element( 'img', array( 'src' => 
$this->getSkinTemplate()->data[ 'logopath' ], 'alt' => $GLOBALS[ 'wgSitename' ] 
) );
+               $attribs  = array_merge(
+                       array( 'href' => $this->getSkinTemplate()->data[ 
'nav_urls' ][ 'mainpage' ][ 'href' ] ),
+                       Linker::tooltipAndAccesskeyAttribs( 'p-logo' )
+               );
 
-               return $this->indent() . '<!-- logo and main page link -->' .
-                          $this->indent() . '<div id="p-logo" class="p-logo ' 
. $this->getClassString() . '" role="banner">' .
-                          $this->indent( 1 ) . \Html::rawElement( 'a', 
$attribs, $contents ) .
-                          $this->indent( -1 ) . '</div>' . "\n";
+               $contents = \Html::element( 'img',
+                       array(
+                               'src' => $this->getSkinTemplate()->data[ 
'logopath' ],
+                               'alt' => $GLOBALS[ 'wgSitename' ]
+                       )
+               );
+
+               return
+                       $this->indent() . '<!-- logo and main page link -->' .
+                       $this->indent() . \Html::openElement( 'div',
+                               array(
+                                       'id'    => 
IdRegistry::getRegistry()->getId( 'p-logo' ),
+                                       'class' => 'p-logo ' . 
$this->getClassString(),
+                                       'role'  => 'banner'
+                               )
+                       ) .
+                       $this->indent( 1 ) . \Html::rawElement( 'a', $attribs, 
$contents ) .
+                       $this->indent( -1 ) . '</div>' . "\n";
        }
 
 }
diff --git a/components/MainContent.php b/includes/components/MainContent.php
similarity index 61%
rename from components/MainContent.php
rename to includes/components/MainContent.php
index 62793ae..2126f56 100644
--- a/components/MainContent.php
+++ b/includes/components/MainContent.php
@@ -24,6 +24,7 @@
  */
 
 namespace skins\chameleon\components;
+use skins\chameleon\IdRegistry;
 
 /**
  * The NavbarHorizontal class.
@@ -46,22 +47,30 @@
 
                $skintemplate = $this->getSkinTemplate();
 
-               $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->getClassString() . '">' .
-                          $this->indent( 1 ) . '<div class ="contentHeader">' .
-                          $this->indent( 1 ) . '<!-- title of the page -->' .
-                          $this->indent() . '<h1 id="firstHeading" 
class="firstHeading">' . $skintemplate->get( 'title' ) . '</h1>' .
-                          $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() . '<div id="siteSub" >' . 
$skintemplate->getMsg( 'tagline' ) . '</div>';
+               $ret =
+                       $this->indent() . '<div id="' . 
IdRegistry::getRegistry()->getId( 'mw-js-message' ) . '" style="display:none;" 
' . $skintemplate->get( 'userlangattributes' ) . '></div>' .
+                       $this->indent() . '<!-- start the content area -->' .
+                       $this->indent() .
+                       \Html::openElement( 'div',
+                               array(
+                                       'id'    => 
IdRegistry::getRegistry()->getId( 'content' ),
+                                       'class' => 'mw_body ' . 
$this->getClassString(),
+                               )
+                       ) .
+                       $this->indent( 1 ) . '<div class ="contentHeader">' .
+                       $this->indent( 1 ) . '<!-- title of the page -->' .
+                       $this->indent() . '<h1 id="' . 
IdRegistry::getRegistry()->getId( 'firstHeading' ) . '" class="firstHeading">' 
. $skintemplate->get( 'title' ) . '</h1>' .
+                       $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() . '<div id="' . 
IdRegistry::getRegistry()->getId( 'siteSub' ) . '" >' . $skintemplate->getMsg( 
'tagline' ) . '</div>';
 
                if ( $skintemplate->data[ 'subtitle' ] ) {
-                       $ret .= $this->indent() . '<!-- subtitle line; used for 
various things like the subpage hierarchy -->' .
-                                       $this->indent() . '<div id="contentSub" 
class="small">' . $skintemplate->get( 'subtitle' ) . '</div>';
+                       $ret .=
+                               $this->indent() . '<!-- subtitle line; used for 
various things like the subpage hierarchy -->' .
+                               $this->indent() . '<div id="' . 
IdRegistry::getRegistry()->getId( 'contentSub' ) . '" class="small">' . 
$skintemplate->get( 'subtitle' ) . '</div>';
                }
 
                if ( $skintemplate->data[ 'undelete' ] ) {
-                       $ret .= $this->indent() . '<!-- undelete message -->' . 
'<div id="contentSub2">' . $skintemplate->get( 'undelete' ) . '</div>';
+                       $ret .= $this->indent() . '<!-- undelete message -->' . 
'<div id="' . IdRegistry::getRegistry()->getId( 'contentSub2' ) . '">' . 
$skintemplate->get( 'undelete' ) . '</div>';
                }
 
                $ret .= $this->indent( -1 ) . '</div>' .
diff --git a/components/NavbarHorizontal.php 
b/includes/components/NavbarHorizontal.php
similarity index 92%
rename from components/NavbarHorizontal.php
rename to includes/components/NavbarHorizontal.php
index 0fac234..2714f63 100644
--- a/components/NavbarHorizontal.php
+++ b/includes/components/NavbarHorizontal.php
@@ -27,6 +27,7 @@
 
 use Linker;
 use Sanitizer;
+use skins\chameleon\IdRegistry;
 
 /**
  * The NavbarHorizontal class.
@@ -51,7 +52,12 @@
 
                $this->mHtml =
                        $this->indent() . '<!-- navigation bar -->' .
-                       $this->indent() . '<nav class="navbar navbar-default 
p-navbar ' . $this->getClassString() . '" role="navigation" id="p-navbar" >' .
+                       $this->indent() .
+                       \HTML::openElement( 'nav', array(
+                                       'class' => 'navbar navbar-default 
p-navbar ' . $this->getClassString(),
+                                       'role' => 'navigation',
+                                       'id' => 
IdRegistry::getRegistry()->getId('p-navbar')
+                               )) .
                        $this->indent( 1 ) . '<ul class="nav navbar-nav">';
 
                // add components
@@ -108,9 +114,10 @@
        protected function getPageTools() {
 
                $pageTools = new PageTools( $this->getSkinTemplate(), null, 
$this->indent( 1 ) );
-               $pageTools->addClasses( 'dropdown-menu' );
+
                $pageTools->setFlat( true );
-               $pageTools->removeClasses( 'text-center' );
+               $pageTools->removeClasses( 'text-center list-inline' );
+               $pageTools->addClasses( 'dropdown-menu' );
 
                $ret = $this->indent() . '<!-- page tools -->' .
                        $this->indent() . \Html::openElement( 'li', array( 
'class' => 'dropdown' ) );
@@ -159,7 +166,6 @@
                        $this->indent() . \Html::openElement( 'li',
                                array(
                                        'class' => 'dropdown',
-                                       'id'    => Sanitizer::escapeId( $box[ 
'id' ] ),
                                        'title' => Linker::titleAttrib( $box[ 
'id' ] )
                                )
                        );
@@ -172,7 +178,13 @@
                                htmlspecialchars( $box[ 'header' ] ) . ' <b 
class="caret"></b></a>';
 
                        // open list of dropdown menu items
-                       $ret .= $this->indent() . '<ul class="dropdown-menu">';
+                       $ret .= $this->indent() .
+                       $this->indent() . \Html::openElement( 'ul',
+                               array(
+                                       'class' => 'dropdown-menu ' . 
Sanitizer::escapeId( $box[ 'id' ] ),
+                                       'id'    => 
IdRegistry::getRegistry()->getId( Sanitizer::escapeId( $box[ 'id' ] ) ),
+                               )
+                       );
 
                        // output dropdown menu items
                        $this->indent( 1 );
diff --git a/components/NewtalkNotifier.php 
b/includes/components/NewtalkNotifier.php
similarity index 100%
rename from components/NewtalkNotifier.php
rename to includes/components/NewtalkNotifier.php
diff --git a/components/PageTools.php b/includes/components/PageTools.php
similarity index 89%
rename from components/PageTools.php
rename to includes/components/PageTools.php
index d8ce59e..8272b96 100644
--- a/components/PageTools.php
+++ b/includes/components/PageTools.php
@@ -44,7 +44,9 @@
 
                parent::__construct( $template, $domElement, $indent );
 
-               $this->addClasses( 'text-center' );
+               // add classes for the normal case where the page tools are 
displayed as a first class element;
+               // these classes should be removed if the page tools are part 
of another element, e.g. nav bar
+               $this->addClasses( 'list-inline text-center' );
        }
 
        /**
@@ -55,7 +57,7 @@
        public function getHtml() {
 
                $ret = $this->indent() . '<!-- Content navigation -->' .
-                          $this->indent() . '<ul class="list-inline 
p-contentnavigation ' . $this->getClassString() . '" id="p-contentnavigation">';
+                          $this->indent() . '<ul class="p-contentnavigation ' 
. $this->getClassString() . '" id="p-contentnavigation">';
 
                $navigation = $this->getSkinTemplate()->data[ 
'content_navigation' ];
 
diff --git a/components/PersonalTools.php 
b/includes/components/PersonalTools.php
similarity index 100%
rename from components/PersonalTools.php
rename to includes/components/PersonalTools.php
diff --git a/components/Row.php b/includes/components/Row.php
similarity index 100%
rename from components/Row.php
rename to includes/components/Row.php
diff --git a/components/SearchBar.php b/includes/components/SearchBar.php
similarity index 100%
rename from components/SearchBar.php
rename to includes/components/SearchBar.php
diff --git a/components/SiteNotice.php b/includes/components/SiteNotice.php
similarity index 100%
rename from components/SiteNotice.php
rename to includes/components/SiteNotice.php
diff --git a/components/Structure.php b/includes/components/Structure.php
similarity index 100%
rename from components/Structure.php
rename to includes/components/Structure.php
diff --git a/components/ToolbarHorizontal.php 
b/includes/components/ToolbarHorizontal.php
similarity index 100%
rename from components/ToolbarHorizontal.php
rename to includes/components/ToolbarHorizontal.php
diff --git a/css/screen.less b/styles/screen.less
similarity index 100%
rename from css/screen.less
rename to styles/screen.less

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id62c13e6c83d60d210f45b8ecb9c729d4927941d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Foxtrott <s7ep...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to