/**
  * @covers ::getHtml
  * @dataProvider domElementProviderFromSyntheticLayoutFiles
  *
  * @param \DOMElement $domElement
  */
 public function testGetHtml_OnSyntheticLayoutXml(\DOMElement $domElement)
 {
     $chameleonTemplate = $this->getChameleonSkinTemplateStub();
     $expected = '';
     foreach ($domElement->childNodes as $child) {
         $expected .= $domElement->ownerDocument->saveHTML($child);
     }
     $instance = new Html($chameleonTemplate, $domElement);
     $actual = $instance->getHtml();
     $this->assertEquals($expected, $actual);
 }
 /**
  * Builds the HTML code for this component
  *
  * @return String the HTML code
  */
 public function getHtml()
 {
     $skintemplate = $this->getSkinTemplate();
     $idRegistry = IdRegistry::getRegistry();
     // START content
     $ret = $this->indent() . '<!-- start the content area -->' . $this->indent() . $idRegistry->openElement('div', array('id' => 'content', 'class' => 'mw-body ' . $this->getClassString())) . $idRegistry->element('a', array('id' => 'top')) . $this->indent() . '<div ' . \Html::expandAttributes(array('id' => $idRegistry->getId('mw-js-message'), 'style' => 'display:none;')) . $skintemplate->get('userlangattributes') . '></div>';
     // START contentHeader
     $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() . '<!-- 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());
     if ($skintemplate->get('subtitle')) {
         // TODO: should not use class 'small', better use class 'contentSub' and do styling in a less file
         $ret .= $this->indent() . '<!-- subtitle line; used for various things like the subpage hierarchy -->' . $this->indent() . $idRegistry->element('div', array('id' => 'contentSub', 'class' => 'small'), $skintemplate->get('subtitle'));
     }
     if ($skintemplate->get('undelete')) {
         // TODO: should not use class 'small', better use class 'contentSub2' and do styling in a less file
         $ret .= $this->indent() . '<!-- undelete message -->' . $this->indent() . $idRegistry->element('div', array('id' => 'contentSub2', 'class' => 'small'), $skintemplate->get('undelete'));
     }
     // 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'), $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
     // START content body
     $ret .= $idRegistry->element('div', array('id' => 'bodyContent'), $this->indent() . '<!-- body text -->' . "\n" . $this->indent() . $skintemplate->get('bodytext'));
     // END content body
     // 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');
     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');
     }
     $ret .= $this->indent(-1) . '</div>' . "\n";
     // END content
     return $ret;
 }
 /**
  * This method basically replicates SkinTemplate::makeSearchButton, but uses buttons instead of inputs to ensure
  * proper styling by Bootstrap
  *
  * @param string $mode 'go' or 'fulltext', optional, default='fulltext'
  *
  * @return string
  */
 private function getSearchButton($mode = 'fulltext')
 {
     if ($mode === 'go') {
         $buttonAttrs = array('value' => $this->getSkinTemplate()->translator->translate('searcharticle'), 'id' => IdRegistry::getRegistry()->getId('searchGoButton'), 'name' => 'go');
         $glyphicon = 'share-alt';
     } else {
         $buttonAttrs = array('value' => $this->getSkinTemplate()->translator->translate('searchbutton'), 'id' => IdRegistry::getRegistry()->getId('mw-searchButton'), 'name' => 'fulltext');
         $glyphicon = 'search';
     }
     $buttonAttrs = array_merge($buttonAttrs, Linker::tooltipAndAccesskeyAttribs("search-{$mode}"), array('type' => 'submit', 'class' => $buttonAttrs['id'] . ' btn btn-default'));
     return \Html::rawElement('button', $buttonAttrs, '<span class="glyphicon glyphicon-' . $glyphicon . '"></span>');
 }
 /**
  * Builds the HTML code for this component
  *
  * @return String the HTML code
  */
 public function getHtml()
 {
     $skintemplate = $this->getSkinTemplate();
     $idRegistry = IdRegistry::getRegistry();
     // START content
     $ret = $this->indent() . '<!-- start the content area -->' . $this->indent() . $idRegistry->openElement('div', array('id' => 'content', 'class' => 'mw-body ' . $this->getClassString())) . $idRegistry->element('a', array('id' => 'top')) . $this->indent() . '<div ' . \Html::expandAttributes(array('id' => $idRegistry->getId('mw-js-message'), 'style' => 'display:none;')) . $skintemplate->get('userlangattributes') . '></div>';
     $ret .= $this->buildContentHeader();
     $ret .= $this->buildContentBody();
     $ret .= $this->buildCategoryLinks();
     $ret .= $this->indent(-1) . '</div>' . "\n";
     // END content
     return $ret;
 }
 /**
  * Builds the HTML code for this component
  *
  * @return String the HTML code
  */
 public function getHtml()
 {
     $ret = $this->indent() . '<!-- footer links -->' . $this->indent() . \Html::openElement('ul', array('class' => 'footer-info ' . $this->getClassString(), 'id' => IdRegistry::getRegistry()->getId('footer-info')));
     $footerlinks = $this->getSkinTemplate()->getFooterLinks();
     $this->indent(1);
     foreach ($footerlinks as $category => $links) {
         if ($category !== 'places') {
             $ret .= $this->indent() . '<!-- ' . htmlspecialchars($category) . ' -->';
             foreach ($links as $key) {
                 $ret .= $this->indent() . '<li>' . $this->getSkinTemplate()->get($key) . '</li>';
             }
         }
     }
     $ret .= $this->indent(-1) . '</ul>' . "\n";
     return $ret;
 }
 /**
  * @param string $category
  *
  * @return string
  */
 protected function buildTabGroupOpeningTags($category)
 {
     // output the name of the current category (e.g. 'namespaces', 'views', ...)
     $ret = $this->indent() . \Html::openElement('li', array('id' => IdRegistry::getRegistry()->getId('p-' . $category))) . $this->indent(1) . '<ul class="list-inline" >';
     $this->indent(1);
     return $ret;
 }
 /**
  * Create a single dropdown
  *
  * @param string $boxName
  * @param array  $box
  * @param bool   $flatten
  *
  * @return string
  */
 protected function getDropdownForNavMenu($boxName, $box, $flatten = false)
 {
     // open list item containing the dropdown
     $ret = $this->indent() . '<!-- ' . $boxName . ' -->';
     $menuitems = '';
     // build the list of submenu items
     if (is_array($box['content']) && count($box['content']) > 0) {
         $this->indent($flatten ? 0 : 2);
         foreach ($box['content'] as $key => $item) {
             $menuitems .= $this->indent() . $this->getSkinTemplate()->makeListItem($key, $item);
         }
         $this->indent($flatten ? 0 : -2);
     } else {
         $menuitems .= $this->indent() . '<!-- empty -->';
     }
     if ($flatten) {
         // if the menu is to be flattened, just return the introducing comment and the list of menu items as is
         $ret .= $menuitems;
     } elseif (!is_array($box['content']) || count($box['content']) === 0) {
         //if the menu is not to be flattened, but is empty, return an inert link
         $ret .= $this->indent() . \Html::rawElement('li', array('class' => '', 'title' => Linker::titleAttrib($box['id'])), '<a href="#">' . htmlspecialchars($box['header']) . '</a>');
     } else {
         // open list item containing the dropdown
         $ret .= $this->indent() . \Html::openElement('li', array('class' => 'dropdown', 'title' => Linker::titleAttrib($box['id'])));
         // add the dropdown toggle
         $ret .= $this->indent(1) . '<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . htmlspecialchars($box['header']) . ' <b class="caret"></b></a>';
         // open list of dropdown menu items
         $ret .= $this->indent() . $this->indent() . \Html::openElement('ul', array('class' => 'dropdown-menu ' . $box['id'], 'id' => IdRegistry::getRegistry()->getId($box['id'])));
         // add list of menu items
         $ret .= $menuitems;
         // close list of dropdown menu items and the list item containing the dropdown
         $ret .= $this->indent() . '</ul>' . $this->indent(-1) . '</li>';
     }
     return $ret;
 }
 /**
  * Create a dropdown containing the page tools (page, talk, edit, history, ...)
  *
  * @param \DOMElement $domElement
  *
  * @return string
  */
 protected function getPageTools(\DOMElement $domElement = null)
 {
     $pageTools = new PageTools($this->getSkinTemplate(), $domElement, $this->getIndent());
     $pageTools->setFlat(true);
     $pageTools->removeClasses('text-center list-inline');
     $pageTools->addClasses('dropdown-menu');
     $ret = $pageTools->getHtml();
     if ($ret !== '') {
         $ret = $this->indent() . '<!-- page tools -->' . $this->indent() . \Html::openElement('li', array('class' => 'dropdown')) . $this->indent(1) . '<a data-toggle="dropdown" class="dropdown-toggle" href="#">Page Tools <b class="caret"></b></a>' . $ret . $this->indent(-1) . '</li>' . "\n";
     }
     return $ret;
 }
 /**
  * @param mixed[] $menuDescription
  *
  * @return string
  */
 protected function buildDropdownOpeningTags($menuDescription)
 {
     // open list item containing the dropdown
     $ret = $this->indent() . \Html::openElement('li', array('class' => 'dropdown', 'title' => Linker::titleAttrib($menuDescription['id'])));
     // add the dropdown toggle
     $ret .= $this->indent(1) . '<a href="#" class="dropdown-toggle" data-toggle="dropdown">' . htmlspecialchars($menuDescription['header']) . ' <b class="caret"></b></a>';
     // open list of dropdown menu items
     $ret .= $this->indent() . $this->indent() . \Html::openElement('ul', array('class' => 'dropdown-menu ' . $menuDescription['id'], 'id' => IdRegistry::getRegistry()->getId($menuDescription['id'])));
     return $ret;
 }
 /**
  * Builds the HTML code for this component
  *
  * @return String the HTML code
  */
 public function getHtml()
 {
     $attribs = array_merge(array('href' => $this->getSkinTemplate()->data['nav_urls']['mainpage']['href']), Linker::tooltipAndAccesskeyAttribs('p-logo'));
     $contents = \Html::element('img', array('src' => $this->getSkinTemplate()->data['logopath'], 'alt' => $this->getSkinTemplate()->data['sitename']));
     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";
 }
 /**
  * Builds the HTML code for this component
  *
  * @return String the HTML code
  */
 public function getHtml()
 {
     $navigation = $this->getSkinTemplate()->data['content_navigation'];
     $hideSelectedNameSpace = false;
     if ($this->getDomElement() !== null) {
         $hideSelectedNameSpace = filter_var($this->getDomElement()->getAttribute('hideSelectedNameSpace'), FILTER_VALIDATE_BOOLEAN);
     }
     if ($hideSelectedNameSpace) {
         $namespacekey = $this->getNamespaceKey();
         unset($navigation['namespaces'][$namespacekey]);
     }
     $ret = '';
     $this->indent(2);
     foreach ($navigation as $category => $tabs) {
         // TODO: visually group all links of one category (e.g. some space between categories)
         if (empty($tabs)) {
             continue;
         }
         $ret .= $this->indent() . '<!-- ' . $category . ' -->';
         if (!$this->mFlat) {
             // output the name of the current category (e.g. 'namespaces', 'views', ...)
             $ret .= $this->indent() . \Html::openElement('li', array('id' => IdRegistry::getRegistry()->getId('p-' . $category))) . $this->indent(1) . '<ul class="list-inline" >';
             $this->indent(1);
         }
         foreach ($tabs as $key => $tab) {
             // skip redundant links (i.e. the 'view' link)
             // TODO: make this dependent on an option
             if (array_key_exists('redundant', $tab) && $tab['redundant'] === true) {
                 continue;
             }
             // apply a link class if specified, e.g. for the currently active namespace
             $options = array();
             if (array_key_exists('class', $tab)) {
                 $options['link-class'] = $tab['class'];
             }
             $ret .= $this->indent() . $this->getSkinTemplate()->makeListItem($key, $tab, $options);
         }
         if (!$this->mFlat) {
             $ret .= $this->indent(-1) . '</ul>' . $this->indent(-1) . '</li>';
         }
     }
     $this->indent(-2);
     if ($ret !== '') {
         $ret = $this->indent(1) . '<!-- Content navigation -->' . $this->indent() . \Html::openElement('ul', array('class' => 'p-contentnavigation ' . $this->getClassString(), 'id' => IdRegistry::getRegistry()->getId('p-contentnavigation'))) . $ret . $this->indent() . '</ul>';
     }
     return $ret;
 }