2014-08-07 07:40:21 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* MonoBook nouveau.
|
|
|
|
*
|
|
|
|
* Translated from gwicke's previous TAL template version to remove
|
|
|
|
* dependency on PHPTAL.
|
|
|
|
*
|
|
|
|
* This program 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 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
|
|
|
class MonoBookTemplate extends BaseTemplate {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Template filter callback for MonoBook skin.
|
|
|
|
* Takes an associative array of data set from a SkinTemplate-based
|
|
|
|
* class, and a wrapper for MediaWiki's localization database, and
|
|
|
|
* outputs a formatted page.
|
|
|
|
*/
|
2016-03-07 08:33:45 -05:00
|
|
|
public function execute() {
|
2018-03-21 19:19:40 -04:00
|
|
|
// Open html, body elements, etc
|
|
|
|
$html = $this->get( 'headelement' );
|
|
|
|
$html .= Html::openElement( 'div', [ 'id' => 'globalWrapper' ] );
|
|
|
|
|
|
|
|
$html .= Html::openElement( 'div', [ 'id' => 'column-content' ] );
|
|
|
|
$html .= Html::rawElement( 'div', [ 'id' => 'content', 'class' => 'mw-body', 'role' => 'main' ],
|
|
|
|
Html::element( 'a', [ 'id' => 'top' ] ) .
|
|
|
|
$this->getIfExists( 'sitenotice', [
|
|
|
|
'wrapper' => 'div',
|
|
|
|
'parameters' => [ 'id' => 'siteNotice', 'class' => 'mw-body-content' ]
|
|
|
|
] ) .
|
|
|
|
$this->getIndicators() .
|
|
|
|
$this->getIfExists( 'title', [
|
|
|
|
'loose' => true,
|
|
|
|
'wrapper' => 'h1',
|
|
|
|
'parameters' => [
|
|
|
|
'id' => 'firstHeading',
|
|
|
|
'class' => 'firstHeading',
|
|
|
|
'lang' => $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode()
|
|
|
|
]
|
|
|
|
] ) .
|
|
|
|
Html::rawElement( 'div', [ 'id' => 'bodyContent', 'class' => 'mw-body-content' ],
|
|
|
|
Html::rawElement( 'div', [ 'id' => 'siteSub' ], $this->getMsg( 'tagline' )->parse() ) .
|
|
|
|
Html::rawElement(
|
|
|
|
'div',
|
|
|
|
[ 'id' => 'contentSub', 'lang' => $this->get( 'userlang' ), 'dir' => $this->get( 'dir' ) ],
|
|
|
|
$this->get( 'subtitle' )
|
|
|
|
) .
|
2018-06-19 19:43:01 -04:00
|
|
|
$this->getIfExists( 'undelete', [ 'wrapper' => 'div', 'parameters' => [
|
|
|
|
'id' => 'contentSub2'
|
|
|
|
] ] ) .
|
|
|
|
$this->getIfExists( 'newtalk', [ 'wrapper' => 'div', 'parameters' => [
|
|
|
|
'class' => 'usermessage'
|
|
|
|
] ] ) .
|
2018-05-23 20:29:48 -04:00
|
|
|
Html::element( 'div', [ 'id' => 'jump-to-nav' ] ) .
|
|
|
|
Html::element( 'a', [ 'href' => '#column-one', 'class' => 'mw-jump-link' ],
|
|
|
|
$this->getMsg( 'monobook-jumptonavigation' )->text()
|
|
|
|
) .
|
|
|
|
Html::element( 'a', [ 'href' => '#searchInput', 'class' => 'mw-jump-link' ],
|
|
|
|
$this->getMsg( 'monobook-jumptosearch' )->text()
|
2018-03-21 19:19:40 -04:00
|
|
|
) .
|
|
|
|
'<!-- start content -->' .
|
|
|
|
|
|
|
|
$this->get( 'bodytext' ) .
|
|
|
|
$this->getIfExists( 'catlinks' ) .
|
|
|
|
|
|
|
|
'<!-- end content -->' .
|
|
|
|
$this->getClear()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$html .= $this->deprecatedHookHack( 'MonoBookAfterContent' );
|
2019-06-20 13:43:25 -04:00
|
|
|
$html .= $this->getIfExists( 'dataAfterContent' ) . $this->getClear();
|
2018-03-21 19:19:40 -04:00
|
|
|
$html .= Html::closeElement( 'div' );
|
|
|
|
|
|
|
|
$html .= Html::rawElement( 'div',
|
|
|
|
[
|
|
|
|
'id' => 'column-one',
|
|
|
|
'lang' => $this->get( 'userlang' ),
|
|
|
|
'dir' => $this->get( 'dir' )
|
|
|
|
],
|
|
|
|
Html::element( 'h2', [], $this->getMsg( 'navigation-heading' )->text() ) .
|
2018-05-01 15:44:43 -04:00
|
|
|
$this->getCactions() .
|
2018-03-21 19:19:40 -04:00
|
|
|
$this->getBox( 'personal', $this->getPersonalTools(), 'personaltools' ) .
|
|
|
|
Html::rawElement( 'div', [ 'class' => 'portlet', 'id' => 'p-logo', 'role' => 'banner' ],
|
|
|
|
Html::element( 'a',
|
|
|
|
[
|
2014-08-07 07:40:21 -04:00
|
|
|
'href' => $this->data['nav_urls']['mainpage']['href'],
|
2014-09-22 14:05:59 -04:00
|
|
|
'class' => 'mw-wiki-logo',
|
2017-05-16 12:53:26 -04:00
|
|
|
]
|
|
|
|
+ Linker::tooltipAndAccesskeyAttribs( 'p-logo' )
|
2018-03-21 19:19:40 -04:00
|
|
|
)
|
|
|
|
) .
|
2018-05-01 15:44:43 -04:00
|
|
|
Html::rawElement( 'div', [ 'id' => 'sidebar' ], $this->getRenderedSidebar() ) .
|
|
|
|
$this->getMobileNavigationIcon(
|
|
|
|
'sidebar',
|
|
|
|
$this->getMsg( 'jumptonavigation' )->text()
|
|
|
|
) .
|
|
|
|
$this->getMobileNavigationIcon(
|
|
|
|
'p-personal',
|
|
|
|
$this->getMsg( 'monobook-jumptopersonal' )->text()
|
|
|
|
) .
|
|
|
|
$this->getMobileNavigationIcon(
|
|
|
|
'globalWrapper',
|
|
|
|
$this->getMsg( 'monobook-jumptotop' )->text()
|
|
|
|
)
|
2018-03-21 19:19:40 -04:00
|
|
|
);
|
|
|
|
$html .= '<!-- end of the left (by default at least) column -->';
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-21 19:19:40 -04:00
|
|
|
$html .= $this->getClear();
|
|
|
|
$html .= $this->getSimpleFooter();
|
|
|
|
$html .= Html::closeElement( 'div' );
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-21 19:19:40 -04:00
|
|
|
$html .= $this->getTrail();
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-21 19:19:40 -04:00
|
|
|
$html .= Html::closeElement( 'body' );
|
|
|
|
$html .= Html::closeElement( 'html' );
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-21 19:19:40 -04:00
|
|
|
// The unholy echo
|
|
|
|
echo $html;
|
2017-06-23 16:05:30 -04:00
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-05-01 15:44:43 -04:00
|
|
|
/**
|
|
|
|
* Create a wrapped link to create a mobile toggle/jump icon
|
|
|
|
* Needs to be an on-page link (as opposed to drawing something on the fly for an
|
|
|
|
* onclick event) for no-js support.
|
|
|
|
*
|
|
|
|
* @param string $target link target
|
|
|
|
* @param string $title icon title
|
|
|
|
*
|
|
|
|
* @return string html empty link block
|
|
|
|
*/
|
|
|
|
protected function getMobileNavigationIcon( $target, $title ) {
|
|
|
|
return Html::element( 'a', [
|
|
|
|
'href' => "#$target",
|
|
|
|
'title' => $title,
|
|
|
|
'class' => 'menu-toggle',
|
|
|
|
'id' => "$target-toggle"
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate the cactions (content actions) tabs, as well as a second set of spoof tabs for mobile
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getCactions() {
|
|
|
|
$html = '';
|
|
|
|
$allTabs = $this->data['content_actions'];
|
|
|
|
$tabCount = count( $allTabs );
|
|
|
|
|
|
|
|
// Normal cactions
|
|
|
|
if ( $tabCount > 2 ) {
|
|
|
|
$html .= $this->getBox( 'cactions', $allTabs, 'monobook-cactions-label' );
|
|
|
|
} else {
|
|
|
|
// Is redundant with spoof, hide normal cactions entirely in mobile
|
|
|
|
$html .= $this->getBox( 'cactions', $allTabs, 'monobook-cactions-label',
|
|
|
|
[ 'extra-classes' => 'nomobile' ]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mobile cactions tabs
|
|
|
|
$tabs = $this->data['content_navigation']['namespaces'];
|
|
|
|
foreach ( $tabs as $tab => $attribs ) {
|
|
|
|
$tabs[$tab]['id'] = $attribs['id'] . '-mobile';
|
|
|
|
$tabs[$tab]['title'] = $attribs['text'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $tabCount !== 1 ) {
|
|
|
|
// Is not special page or stuff, append a 'more'
|
|
|
|
$tabs['more'] = [
|
|
|
|
'text' => $this->getMsg( 'monobook-more-actions' )->text(),
|
|
|
|
'href' => '#p-cactions',
|
|
|
|
'id' => 'ca-more'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$tabs['toolbox'] = [
|
|
|
|
'text' => $this->getMsg( 'toolbox' )->text(),
|
|
|
|
'href' => '#p-tb',
|
|
|
|
'id' => 'ca-tools',
|
|
|
|
'title' => $this->getMsg( 'toolbox' )->text()
|
|
|
|
];
|
|
|
|
if ( $this->data['language_urls'] !== false ) {
|
|
|
|
$tabs['languages'] = [
|
|
|
|
'text' => $this->getMsg( 'otherlanguages' )->text(),
|
|
|
|
'href' => '#p-lang',
|
|
|
|
'id' => 'ca-languages',
|
|
|
|
'title' => $this->getMsg( 'otherlanguages' )->text()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= $this->getBox( 'cactions-mobile', $tabs, 'monobook-cactions-label' );
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
2014-08-07 07:40:21 -04:00
|
|
|
/**
|
2018-03-17 00:14:26 -04:00
|
|
|
* Generate the full sidebar
|
|
|
|
*
|
|
|
|
* @return string html
|
2014-08-07 07:40:21 -04:00
|
|
|
*/
|
2018-03-17 00:14:26 -04:00
|
|
|
protected function getRenderedSidebar() {
|
|
|
|
$sidebar = $this->data['sidebar'];
|
|
|
|
$html = '';
|
|
|
|
|
2014-08-07 07:40:21 -04:00
|
|
|
if ( !isset( $sidebar['SEARCH'] ) ) {
|
|
|
|
$sidebar['SEARCH'] = true;
|
|
|
|
}
|
|
|
|
if ( !isset( $sidebar['TOOLBOX'] ) ) {
|
|
|
|
$sidebar['TOOLBOX'] = true;
|
|
|
|
}
|
|
|
|
if ( !isset( $sidebar['LANGUAGES'] ) ) {
|
|
|
|
$sidebar['LANGUAGES'] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( $sidebar as $boxName => $content ) {
|
|
|
|
if ( $content === false ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-01-10 15:39:20 -05:00
|
|
|
// Numeric strings gets an integer when set as key, cast back - T73639
|
|
|
|
$boxName = (string)$boxName;
|
|
|
|
|
2014-08-07 07:40:21 -04:00
|
|
|
if ( $boxName == 'SEARCH' ) {
|
2018-03-17 00:14:26 -04:00
|
|
|
$html .= $this->getSearchBox();
|
2014-08-07 07:40:21 -04:00
|
|
|
} elseif ( $boxName == 'TOOLBOX' ) {
|
2018-03-17 00:14:26 -04:00
|
|
|
$html .= $this->getToolboxBox();
|
2014-08-07 07:40:21 -04:00
|
|
|
} elseif ( $boxName == 'LANGUAGES' ) {
|
2018-03-17 00:14:26 -04:00
|
|
|
$html .= $this->getLanguageBox();
|
2014-08-07 07:40:21 -04:00
|
|
|
} else {
|
2018-03-17 00:14:26 -04:00
|
|
|
$html .= $this->getBox(
|
|
|
|
$boxName,
|
|
|
|
$content,
|
|
|
|
null,
|
|
|
|
[ 'extra-classes' => 'generated-sidebar' ]
|
|
|
|
);
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
|
|
|
}
|
2018-03-17 00:14:26 -04:00
|
|
|
|
|
|
|
return $html;
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
/**
|
|
|
|
* Generate the search, using config options for buttons (?)
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getSearchBox() {
|
|
|
|
$html = '';
|
|
|
|
|
|
|
|
if ( $this->config->get( 'UseTwoButtonsSearchForm' ) ) {
|
2018-11-02 18:48:31 -04:00
|
|
|
$optionButtons = "\u{00A0} " . $this->makeSearchButton(
|
2018-03-17 00:14:26 -04:00
|
|
|
'fulltext',
|
|
|
|
[ 'id' => 'mw-searchButton', 'class' => 'searchButton' ]
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$optionButtons = Html::rawElement( 'div', [],
|
|
|
|
Html::rawElement( 'a', [ 'href' => $this->get( 'searchaction' ), 'rel' => 'search' ],
|
|
|
|
$this->getMsg( 'powersearch-legend' )->escaped()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$searchInputId = 'searchInput';
|
|
|
|
$searchForm = Html::rawElement( 'form', [
|
|
|
|
'action' => $this->get( 'wgScript' ),
|
|
|
|
'id' => 'searchform'
|
|
|
|
],
|
|
|
|
Html::hidden( 'title', $this->get( 'searchtitle' ) ) .
|
|
|
|
$this->makeSearchInput( [ 'id' => $searchInputId ] ) .
|
|
|
|
$this->makeSearchButton( 'go', [ 'id' => 'searchGoButton', 'class' => 'searchButton' ] ) .
|
|
|
|
$optionButtons
|
|
|
|
);
|
|
|
|
|
|
|
|
$html .= $this->getBox( 'search', $searchForm, null, [
|
|
|
|
'search-input-id' => $searchInputId,
|
|
|
|
'role' => 'search',
|
|
|
|
'body-id' => 'searchBody'
|
|
|
|
] );
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
/**
|
|
|
|
* Generate the toolbox, complete with all three old hooks
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getToolboxBox() {
|
|
|
|
$html = '';
|
|
|
|
$skin = $this;
|
|
|
|
|
|
|
|
$html .= $this->getBox( 'tb', $this->getToolbox(), 'toolbox', [ 'hooks' => [
|
|
|
|
// Deprecated hooks
|
|
|
|
'MonoBookTemplateToolboxEnd' => [ &$skin ],
|
|
|
|
'SkinTemplateToolboxEnd' => [ &$skin, true ]
|
|
|
|
] ] );
|
|
|
|
|
2018-03-21 19:19:40 -04:00
|
|
|
$html .= $this->deprecatedHookHack( 'MonoBookAfterToolbox' );
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
return $html;
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
/**
|
|
|
|
* Generate the languages box
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getLanguageBox() {
|
|
|
|
$html = '';
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
if ( $this->data['language_urls'] !== false ) {
|
|
|
|
$html .= $this->getBox( 'lang', $this->data['language_urls'], 'otherlanguages' );
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
return $html;
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-03-17 00:14:26 -04:00
|
|
|
* Generate a sidebar box using getPortlet(); prefill some common stuff
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param array|string $contents
|
2019-07-09 18:19:28 -04:00
|
|
|
* @param-taint $contents escapes_htmlnoent
|
2018-03-17 00:14:26 -04:00
|
|
|
* @param null|string|array|bool $msg
|
|
|
|
* @param array $setOptions
|
|
|
|
*
|
|
|
|
* @return string html
|
2014-08-07 07:40:21 -04:00
|
|
|
*/
|
2018-03-17 00:14:26 -04:00
|
|
|
protected function getBox( $name, $contents, $msg = null, $setOptions = [] ) {
|
2019-06-20 13:58:46 -04:00
|
|
|
$options = array_merge( [
|
2018-03-17 00:14:26 -04:00
|
|
|
'class' => 'portlet',
|
|
|
|
'body-class' => 'pBody',
|
|
|
|
'text-wrapper' => ''
|
2019-06-20 13:58:46 -04:00
|
|
|
], $setOptions );
|
2018-03-17 00:14:26 -04:00
|
|
|
|
2018-03-21 19:19:40 -04:00
|
|
|
// Do some special stuff for the personal menu
|
|
|
|
if ( $name == 'personal' ) {
|
|
|
|
$prependiture = '';
|
|
|
|
|
|
|
|
// Extension:UniversalLanguageSelector order - T121793
|
|
|
|
if ( array_key_exists( 'uls', $contents ) ) {
|
|
|
|
$prependiture .= $this->makeListItem( 'uls', $contents['uls'] );
|
|
|
|
unset( $contents['uls'] );
|
|
|
|
}
|
|
|
|
if ( !$this->getSkin()->getUser()->isLoggedIn() &&
|
|
|
|
User::groupHasPermission( '*', 'edit' )
|
|
|
|
) {
|
|
|
|
$prependiture .= Html::rawElement(
|
|
|
|
'li',
|
|
|
|
[ 'id' => 'pt-anonuserpage' ],
|
|
|
|
$this->getMsg( 'notloggedin' )->escaped()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$options['list-prepend'] = $prependiture;
|
|
|
|
}
|
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
return $this->getPortlet( $name, $contents, $msg, $options );
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
/**
|
|
|
|
* Generates a block of navigation links with a header
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param array|string $content array of links for use with makeListItem, or a block of text
|
|
|
|
* @param null|string|array $msg
|
|
|
|
* @param array $setOptions random crap to rename/do/whatever
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getPortlet( $name, $content, $msg = null, $setOptions = [] ) {
|
|
|
|
// random stuff to override with any provided options
|
2019-06-20 13:58:46 -04:00
|
|
|
$options = array_merge( [
|
2018-03-17 00:14:26 -04:00
|
|
|
// handle role=search a little differently
|
|
|
|
'role' => 'navigation',
|
|
|
|
'search-input-id' => 'searchInput',
|
|
|
|
// extra classes/ids
|
|
|
|
'id' => 'p-' . $name,
|
|
|
|
'class' => 'mw-portlet',
|
|
|
|
'extra-classes' => '',
|
|
|
|
'body-id' => null,
|
|
|
|
'body-class' => 'mw-portlet-body',
|
|
|
|
'body-extra-classes' => '',
|
|
|
|
// wrapper for individual list items
|
|
|
|
'text-wrapper' => [ 'tag' => 'span' ],
|
|
|
|
// old toolbox hook support (use: [ 'SkinTemplateToolboxEnd' => [ &$skin, true ] ])
|
2018-03-21 19:19:40 -04:00
|
|
|
'hooks' => '',
|
|
|
|
// option to stick arbitrary stuff at the beginning of the ul
|
|
|
|
'list-prepend' => ''
|
2019-06-20 13:58:46 -04:00
|
|
|
], $setOptions );
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
// Handle the different $msg possibilities
|
|
|
|
if ( $msg === null ) {
|
|
|
|
$msg = $name;
|
|
|
|
$msgParams = [];
|
|
|
|
} elseif ( is_array( $msg ) ) {
|
|
|
|
$msgString = array_shift( $msg );
|
|
|
|
$msgParams = $msg;
|
|
|
|
$msg = $msgString;
|
|
|
|
} else {
|
|
|
|
$msgParams = [];
|
|
|
|
}
|
|
|
|
$msgObj = $this->getMsg( $msg, $msgParams );
|
|
|
|
if ( $msgObj->exists() ) {
|
|
|
|
$msgString = $msgObj->parse();
|
|
|
|
} else {
|
|
|
|
$msgString = htmlspecialchars( $msg );
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-04-13 19:08:19 -04:00
|
|
|
$labelId = Sanitizer::escapeIdForAttribute( "p-$name-label" );
|
2018-03-17 00:14:26 -04:00
|
|
|
|
|
|
|
if ( is_array( $content ) ) {
|
|
|
|
$contentText = Html::openElement( 'ul',
|
|
|
|
[ 'lang' => $this->get( 'userlang' ), 'dir' => $this->get( 'dir' ) ]
|
|
|
|
);
|
2018-03-21 19:19:40 -04:00
|
|
|
$contentText .= $options['list-prepend'];
|
2018-03-17 00:14:26 -04:00
|
|
|
foreach ( $content as $key => $item ) {
|
|
|
|
if ( is_array( $options['text-wrapper'] ) ) {
|
|
|
|
$contentText .= $this->makeListItem(
|
|
|
|
$key,
|
|
|
|
$item,
|
|
|
|
[ 'text-wrapper' => $options['text-wrapper'] ]
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$contentText .= $this->makeListItem(
|
|
|
|
$key,
|
|
|
|
$item
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-03-21 19:19:40 -04:00
|
|
|
// Compatibility with extensions still using SkinTemplateToolboxEnd or similar
|
|
|
|
if ( is_array( $options['hooks'] ) ) {
|
|
|
|
foreach ( $options['hooks'] as $hook => $hookOptions ) {
|
|
|
|
$contentText .= $this->deprecatedHookHack( $hook, $hookOptions );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
$contentText .= Html::closeElement( 'ul' );
|
|
|
|
} else {
|
|
|
|
$contentText = $content;
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
// Special handling for role=search
|
|
|
|
$divOptions = [
|
|
|
|
'role' => $options['role'],
|
|
|
|
'class' => $this->mergeClasses( $options['class'], $options['extra-classes'] ),
|
2018-04-13 19:08:19 -04:00
|
|
|
'id' => Sanitizer::escapeIdForAttribute( $options['id'] ),
|
2018-03-17 00:14:26 -04:00
|
|
|
'title' => Linker::titleAttrib( $options['id'] )
|
|
|
|
];
|
|
|
|
if ( $options['role'] !== 'search' ) {
|
|
|
|
$divOptions['aria-labelledby'] = $labelId;
|
|
|
|
}
|
|
|
|
$labelOptions = [
|
|
|
|
'id' => $labelId,
|
|
|
|
'lang' => $this->get( 'userlang' ),
|
|
|
|
'dir' => $this->get( 'dir' )
|
|
|
|
];
|
|
|
|
if ( $options['role'] == 'search' ) {
|
|
|
|
$msgString = Html::rawElement( 'label', [ 'for' => $options['search-input-id'] ], $msgString );
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
$bodyDivOptions = [
|
|
|
|
'class' => $this->mergeClasses( $options['body-class'], $options['body-extra-classes'] )
|
|
|
|
];
|
|
|
|
if ( is_string( $options['body-id'] ) ) {
|
|
|
|
$bodyDivOptions['id'] = $options['body-id'];
|
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
$html = Html::rawElement( 'div', $divOptions,
|
|
|
|
Html::rawElement( 'h3', $labelOptions, $msgString ) .
|
|
|
|
Html::rawElement( 'div', $bodyDivOptions,
|
|
|
|
$contentText .
|
|
|
|
$this->getAfterPortlet( $name )
|
|
|
|
)
|
|
|
|
);
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
return $html;
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-03-17 00:14:26 -04:00
|
|
|
* Helper function for getPortlet
|
|
|
|
*
|
|
|
|
* Merge all provided css classes into a single array
|
|
|
|
* Account for possible different input methods matching what Html::element stuff takes
|
|
|
|
*
|
|
|
|
* @param string|array $class base portlet/body class
|
|
|
|
* @param string|array $extraClasses any extra classes to also include
|
|
|
|
*
|
|
|
|
* @return array all classes to apply
|
2014-08-07 07:40:21 -04:00
|
|
|
*/
|
2018-03-17 00:14:26 -04:00
|
|
|
protected function mergeClasses( $class, $extraClasses ) {
|
|
|
|
if ( !is_array( $class ) ) {
|
|
|
|
$class = [ $class ];
|
|
|
|
}
|
|
|
|
if ( !is_array( $extraClasses ) ) {
|
|
|
|
$extraClasses = [ $extraClasses ];
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
|
|
|
|
2018-03-17 00:14:26 -04:00
|
|
|
return array_merge( $class, $extraClasses );
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
2018-03-21 19:19:40 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrapper to catch output of old hooks expecting to write directly to page
|
|
|
|
* We no longer do things that way.
|
|
|
|
*
|
|
|
|
* @param string $hook event
|
2019-06-20 15:06:08 -04:00
|
|
|
* @param mixed $hookOptions args
|
2018-03-21 19:19:40 -04:00
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function deprecatedHookHack( $hook, $hookOptions = [] ) {
|
|
|
|
$hookContents = '';
|
|
|
|
ob_start();
|
|
|
|
Hooks::run( $hook, $hookOptions );
|
|
|
|
$hookContents = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
if ( !trim( $hookContents ) ) {
|
|
|
|
$hookContents = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $hookContents;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple wrapper for random if-statement-wrapped $this->data things
|
|
|
|
*
|
|
|
|
* @param string $object name of thing
|
|
|
|
* @param array $setOptions
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getIfExists( $object, $setOptions = [] ) {
|
|
|
|
$options = [
|
|
|
|
'loose' => false,
|
|
|
|
'wrapper' => 'none',
|
|
|
|
'parameters' => []
|
|
|
|
];
|
|
|
|
foreach ( $setOptions as $key => $value ) {
|
|
|
|
$options[$key] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
$html = '';
|
|
|
|
|
|
|
|
if ( ( $options['loose'] && $this->data[$object] != '' ) ||
|
|
|
|
( !$options['loose'] && $this->data[$object] ) ) {
|
|
|
|
if ( $options['wrapper'] == 'none' ) {
|
|
|
|
$html .= $this->get( $object );
|
|
|
|
} else {
|
|
|
|
$html .= Html::rawElement(
|
|
|
|
$options['wrapper'],
|
|
|
|
$options['parameters'],
|
|
|
|
$this->get( $object )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renderer for getFooterIcons and getFooterLinks as a generic footer block
|
|
|
|
*
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
protected function getSimpleFooter() {
|
|
|
|
$validFooterIcons = $this->getFooterIcons( 'icononly' );
|
|
|
|
$validFooterLinks = $this->getFooterLinks( 'flat' );
|
|
|
|
|
|
|
|
$html = '';
|
|
|
|
|
|
|
|
$html .= Html::openElement( 'div', [
|
|
|
|
'id' => 'footer',
|
|
|
|
'role' => 'contentinfo',
|
|
|
|
'lang' => $this->get( 'userlang' ),
|
|
|
|
'dir' => $this->get( 'dir' )
|
|
|
|
] );
|
|
|
|
|
|
|
|
foreach ( $validFooterIcons as $blockName => $footerIcons ) {
|
|
|
|
$html .= Html::openElement( 'div', [
|
|
|
|
'id' => Sanitizer::escapeIdForAttribute( "f-{$blockName}ico" ),
|
|
|
|
'class' => 'footer-icons'
|
|
|
|
] );
|
|
|
|
foreach ( $footerIcons as $icon ) {
|
|
|
|
$html .= $this->getSkin()->makeFooterIcon( $icon );
|
|
|
|
}
|
|
|
|
$html .= Html::closeElement( 'div' );
|
|
|
|
}
|
|
|
|
if ( count( $validFooterLinks ) > 0 ) {
|
|
|
|
$html .= Html::openElement( 'ul', [ 'id' => 'f-list' ] );
|
|
|
|
foreach ( $validFooterLinks as $aLink ) {
|
|
|
|
$html .= Html::rawElement(
|
|
|
|
'li',
|
|
|
|
[ 'id' => Sanitizer::escapeIdForAttribute( $aLink ) ],
|
|
|
|
$this->get( $aLink )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$html .= Html::closeElement( 'ul' );
|
|
|
|
}
|
|
|
|
$html .= Html::closeElement( 'div' );
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2017-06-23 16:05:30 -04:00
|
|
|
}
|