/** * 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>'); }
/** * 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; }
/** * @param mixed[] $menuDescription * * @return string */ protected function buildDropdownMenuStub($menuDescription) { return $this->indent() . \Html::rawElement('li', array('class' => '', 'title' => Linker::titleAttrib($menuDescription['id'])), '<a href="#">' . htmlspecialchars($menuDescription['header']) . '</a>'); }
/** * Creates HTML code for the wiki logo in a navbar * * @param \DOMElement $domElement * * @return String */ protected function getLogo(\DOMElement $domElement = null) { $logo = new Logo($this->getSkinTemplate(), $domElement, $this->getIndent()); $logo->addClasses('navbar-brand'); return \Html::rawElement('li', array(), $logo->getHtml()); }
/** * 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"; }