2019-08-15 17:40:13 +00:00
|
|
|
<?php
|
2019-12-25 23:20:04 +00:00
|
|
|
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
2019-08-15 17:40:13 +00:00
|
|
|
/**
|
|
|
|
* BaseTemplate class for the Citizen skin
|
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
|
|
|
class CitizenTemplate extends BaseTemplate {
|
2020-06-05 21:07:11 +00:00
|
|
|
/** @var array of alternate message keys for menu labels */
|
|
|
|
private const MENU_LABEL_KEYS = [
|
|
|
|
'tb' => 'toolbox',
|
|
|
|
'personal' => 'personaltools',
|
|
|
|
];
|
|
|
|
|
2019-08-15 17:40:13 +00:00
|
|
|
/**
|
|
|
|
* Outputs the entire contents of the page
|
|
|
|
*/
|
|
|
|
public function execute() {
|
2020-06-02 06:23:11 +00:00
|
|
|
// Naming conventions for Mustache parameters:
|
|
|
|
// - Prefix "is" for boolean values.
|
|
|
|
// - Prefix "msg-" for interface messages.
|
|
|
|
// - Prefix "html-" for raw HTML (in front of other keys, if applicable).
|
|
|
|
// - Prefix "data-" for an array of template parameters that should be passed directly
|
|
|
|
// to a template partial.
|
|
|
|
// - Prefix "array-" for lists of any values.
|
|
|
|
//
|
|
|
|
// Source of value (first or second segment)
|
|
|
|
// - Segment "page-" for data relating to the current page (e.g. Title, WikiPage, or OutputPage).
|
|
|
|
// - Segment "hook-" for any thing generated from a hook.
|
|
|
|
// It should be followed by the name of the hook in hyphenated lowercase.
|
|
|
|
//
|
|
|
|
// Conditionally used values must use null to indicate absence (not false or '').
|
|
|
|
$params = [
|
|
|
|
'html-headelement' => $this->get( 'headelement', '' ),
|
2020-06-04 03:39:50 +00:00
|
|
|
|
2020-06-04 19:04:03 +00:00
|
|
|
'msg-sitetitle' => $this->getMsg( 'sitetitle' )->text(),
|
|
|
|
'html-mainpage-attributes' => Xml::expandAttributes(
|
|
|
|
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [
|
|
|
|
'href' => Skin::makeMainPageUrl(),
|
|
|
|
]
|
|
|
|
),
|
|
|
|
|
2020-06-04 06:36:06 +00:00
|
|
|
'data-header' => [
|
|
|
|
'msg-citizen-header-menu-toggle' => $this->getMsg( 'citizen-header-menu-toggle' )->text(),
|
2020-06-04 19:04:03 +00:00
|
|
|
'data-menu' => $this->buildMenu(),
|
2020-06-04 06:36:06 +00:00
|
|
|
'msg-citizen-header-search-toggle' => $this->getMsg( 'citizen-header-search-toggle' )->text(),
|
2020-06-06 00:12:39 +00:00
|
|
|
'data-extratools' => $this->getExtraTools(),
|
2020-06-04 06:36:06 +00:00
|
|
|
'data-searchbox' => $this->buildSearchbox(),
|
|
|
|
],
|
2020-06-04 03:39:50 +00:00
|
|
|
|
2020-06-02 06:23:11 +00:00
|
|
|
'html-sitenotice' => $this->get( 'sitenotice', null ),
|
|
|
|
'html-indicators' => $this->getIndicators(),
|
2020-06-06 00:12:39 +00:00
|
|
|
|
|
|
|
'data-pagetools' => $this->buildPageTools(),
|
|
|
|
|
2020-06-02 06:23:11 +00:00
|
|
|
// From Skin::getNewtalks(). Always returns string, cast to null if empty
|
|
|
|
'html-newtalk' => $this->get( 'newtalk', '' ) ?: null,
|
|
|
|
'page-langcode' => $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(),
|
|
|
|
|
|
|
|
// Remember that the string '0' is a valid title.
|
|
|
|
// From OutputPage::getPageTitle, via ::setPageTitle().
|
|
|
|
'html-title' => $this->get( 'title', '' ),
|
|
|
|
|
|
|
|
'html-prebodyhtml' => $this->get( 'prebodyhtml', '' ),
|
|
|
|
'msg-tagline' => $this->getMsg( 'tagline' )->text(),
|
|
|
|
// TODO: mediawiki/SkinTemplate should expose langCode and langDir properly.
|
|
|
|
'html-userlangattributes' => $this->get( 'userlangattributes', '' ),
|
|
|
|
// From OutputPage::getSubtitle()
|
|
|
|
'html-subtitle' => $this->get( 'subtitle', '' ),
|
|
|
|
|
|
|
|
// TODO: Use directly Skin::getUndeleteLink() directly.
|
|
|
|
// Always returns string, cast to null if empty.
|
|
|
|
'html-undelete' => $this->get( 'undelete', null ) ?: null,
|
|
|
|
|
|
|
|
// Result of OutputPage::addHTML calls
|
|
|
|
'html-bodycontent' => $this->get( 'bodycontent' ),
|
|
|
|
|
|
|
|
'html-printfooter' => $this->get( 'printfooter', null ),
|
2020-06-06 00:12:39 +00:00
|
|
|
|
|
|
|
'data-pagelinks' => $this->buildPageLinks(),
|
|
|
|
|
2020-06-02 06:23:11 +00:00
|
|
|
'html-catlinks' => $this->get( 'catlinks', '' ),
|
|
|
|
'html-dataAfterContent' => $this->get( 'dataAfterContent', '' ),
|
|
|
|
// From MWDebug::getHTMLDebugLog (when $wgShowDebug is enabled)
|
|
|
|
'html-debuglog' => $this->get( 'debughtml', '' ),
|
|
|
|
|
|
|
|
// From BaseTemplate::getTrail (handles bottom JavaScript)
|
|
|
|
'html-printtail' => $this->getTrail() . '</body></html>',
|
2020-06-04 03:39:50 +00:00
|
|
|
|
2020-06-02 06:23:11 +00:00
|
|
|
'data-footer' => [
|
|
|
|
'html-userlangattributes' => $this->get( 'userlangattributes', '' ),
|
|
|
|
'html-lastmodified' => $this->getLastMod(),
|
2020-06-03 03:22:09 +00:00
|
|
|
'msg-sitetitle' => $this->getMsg( 'sitetitle' )->text(),
|
2020-06-02 06:23:11 +00:00
|
|
|
'msg-citizen-footer-desc' => $this->getMsg( 'citizen-footer-desc' )->text(),
|
|
|
|
'array-footer-rows' => $this->getFooterRows(),
|
|
|
|
'msg-citizen-footer-tagline' => $this->getMsg( 'citizen-footer-tagline' )->text(),
|
|
|
|
'array-footer-icons' => $this->getFooterIconsRow(),
|
|
|
|
],
|
|
|
|
|
2020-06-04 19:04:03 +00:00
|
|
|
'data-bottombar' => $this->buildBottombar(),
|
|
|
|
];
|
|
|
|
|
|
|
|
// Prepare and output the HTML response
|
|
|
|
$templates = new TemplateParser( __DIR__ . '/templates' );
|
|
|
|
echo $templates->processTemplate( 'skin', $params );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the navigation menu
|
2020-06-05 22:25:24 +00:00
|
|
|
* Based on Vector (be3843e)
|
2020-06-04 19:04:03 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function buildMenu() : array {
|
2020-06-05 21:07:11 +00:00
|
|
|
$skin = $this->getSkin();
|
|
|
|
$portals = $skin->buildSidebar();
|
|
|
|
$props = [];
|
2020-06-04 19:04:03 +00:00
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
// Render portals
|
|
|
|
foreach ( $portals as $name => $content ) {
|
|
|
|
if ( $content === false ) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-06-04 19:04:03 +00:00
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
// Numeric strings gets an integer when set as key, cast back - T73639
|
|
|
|
$name = (string)$name;
|
2020-06-04 19:04:03 +00:00
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
switch ( $name ) {
|
|
|
|
case 'SEARCH':
|
|
|
|
break;
|
|
|
|
case 'TOOLBOX':
|
|
|
|
$portal = $this->getMenuData( 'tb', $this->getToolbox() );
|
|
|
|
// Run deprecated hooks.
|
|
|
|
$citizenTemplate = $this;
|
|
|
|
ob_start();
|
|
|
|
// Use SidebarBeforeOutput instead.
|
|
|
|
Hooks::run( 'SkinTemplateToolboxEnd', [ &$citizenTemplate, true ] );
|
|
|
|
$htmlhookitems = ob_get_clean();
|
|
|
|
$portal['html-items'] .= $htmlhookitems;
|
|
|
|
$props[] = $portal;
|
|
|
|
break;
|
|
|
|
case 'LANGUAGES':
|
|
|
|
$languages = $skin->getLanguages();
|
2020-06-05 21:08:41 +00:00
|
|
|
$portal = $this->getMenuData( 'lang', $languages );
|
2020-06-05 21:07:11 +00:00
|
|
|
// The language portal will be added provided either
|
|
|
|
// languages exist or there is a value in html-after-portal
|
|
|
|
// for example to show the add language wikidata link (T252800)
|
|
|
|
if ( count( $languages ) || $portal['html-after-portal'] ) {
|
|
|
|
$props[] = $portal;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Historically some portals have been defined using HTML rather than arrays.
|
|
|
|
// Let's move away from that to a uniform definition.
|
|
|
|
if ( !is_array( $content ) ) {
|
|
|
|
$html = $content;
|
|
|
|
$content = [];
|
|
|
|
wfDeprecated(
|
|
|
|
"`content` field in portal $name must be array."
|
|
|
|
. "Previously it could be a string but this is no longer supported.",
|
|
|
|
'1.35.0'
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$html = false;
|
|
|
|
}
|
|
|
|
$portal = $this->getMenuData( $name, $content );
|
|
|
|
if ( $html ) {
|
|
|
|
$portal['html-items'] .= $html;
|
|
|
|
}
|
|
|
|
$props[] = $portal;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-06-04 19:04:03 +00:00
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
$firstPortal = $props[0] ?? null;
|
|
|
|
if ( $firstPortal ) {
|
|
|
|
$firstPortal[ 'class' ] .= ' portal-first';
|
2020-06-05 22:55:04 +00:00
|
|
|
// Hide label for first portal
|
|
|
|
$firstPortal[ 'label-class' ] .= 'screen-reader-text';
|
2020-06-05 21:07:11 +00:00
|
|
|
}
|
2020-06-04 19:04:03 +00:00
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
$personalTools = $this->getPersonalTools();
|
|
|
|
// Move the Echo badges and ULS out of default list
|
|
|
|
if ( isset( $personalTools['notifications-alert'] ) ) {
|
|
|
|
unset( $personalTools['notifications-alert'] );
|
|
|
|
}
|
|
|
|
if ( isset( $personalTools['notifications-notice'] ) ) {
|
|
|
|
unset( $personalTools['notifications-notice'] );
|
|
|
|
}
|
|
|
|
if ( isset( $personalTools['uls'] ) ) {
|
|
|
|
unset( $personalTools['uls'] );
|
|
|
|
}
|
2020-06-04 19:04:03 +00:00
|
|
|
|
2020-06-05 22:55:04 +00:00
|
|
|
$personalToolsPortal = $this->getMenuData( 'personal', $personalTools );
|
|
|
|
// Hide label for personal tools
|
|
|
|
$personalToolsPortal[ 'label-class' ] .= 'screen-reader-text';
|
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
return [
|
2020-06-04 19:04:03 +00:00
|
|
|
'data-logo' => $this->buildLogo(),
|
2020-06-05 21:07:11 +00:00
|
|
|
'data-portals-first' => $firstPortal,
|
2020-06-05 22:55:04 +00:00
|
|
|
'array-portals-rest' => array_slice( $props, 1 ),
|
|
|
|
'data-personal-menu' => $personalToolsPortal,
|
2020-06-04 19:04:03 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the logo
|
|
|
|
* TODO: Use standardize classes and IDs
|
|
|
|
* TODO: Rebuild icon function based on Desktop Improvement Project
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function buildLogo() : array {
|
|
|
|
$props = [
|
2020-06-02 06:23:11 +00:00
|
|
|
'msg-sitetitle' => $this->getMsg( 'sitetitle' )->text(),
|
2020-06-03 03:37:28 +00:00
|
|
|
'html-mainpage-attributes' => Xml::expandAttributes(
|
|
|
|
Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [
|
|
|
|
'href' => Skin::makeMainPageUrl(),
|
|
|
|
]
|
|
|
|
),
|
2020-06-02 06:23:11 +00:00
|
|
|
];
|
2020-06-04 19:04:03 +00:00
|
|
|
return $props;
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 22:25:24 +00:00
|
|
|
/**
|
2020-06-06 00:12:39 +00:00
|
|
|
* Echo notification badges and ULS button
|
2020-06-05 22:25:24 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2020-06-06 00:12:39 +00:00
|
|
|
private function getExtratools() {
|
2020-06-05 22:25:24 +00:00
|
|
|
$personalTools = $this->getPersonalTools();
|
|
|
|
|
|
|
|
// Create the Echo badges and ULS
|
|
|
|
$extraTools = [];
|
|
|
|
if ( isset( $personalTools['notifications-alert'] ) ) {
|
|
|
|
$extraTools['notifications-alert'] = $personalTools['notifications-alert'];
|
|
|
|
}
|
|
|
|
if ( isset( $personalTools['notifications-notice'] ) ) {
|
|
|
|
$extraTools['notifications-notice'] = $personalTools['notifications-notice'];
|
|
|
|
}
|
|
|
|
if ( isset( $personalTools['uls'] ) ) {
|
|
|
|
$extraTools['uls'] = $personalTools['uls'];
|
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
$html = $this->getMenuData( 'personal-extra', $extraTools );
|
2020-06-05 22:25:24 +00:00
|
|
|
|
2020-06-05 22:55:04 +00:00
|
|
|
// Hide label for extra tools
|
2020-06-06 00:12:39 +00:00
|
|
|
$html[ 'label-class' ] .= 'screen-reader-text';
|
2020-06-05 22:55:04 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
return $html;
|
2020-06-05 22:25:24 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 06:36:06 +00:00
|
|
|
/**
|
|
|
|
* Render the search box
|
|
|
|
* TODO: Use standardized classes and IDs
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function buildSearchbox() : array {
|
|
|
|
$config = $this->config;
|
|
|
|
$props = [
|
|
|
|
'form-action' => $config->get( 'Script' ),
|
2020-06-06 18:47:03 +00:00
|
|
|
'html-input' => $this->makeSearchInput( [ 'id' => 'searchInput' ] ),
|
2020-06-04 06:36:06 +00:00
|
|
|
'html-button-search' => $this->makeSearchButton(
|
|
|
|
'image',
|
2020-06-06 18:47:03 +00:00
|
|
|
[ 'id' => 'searchButton',
|
2020-06-04 06:36:06 +00:00
|
|
|
'src' => $this->getSkin()->getSkinStylePath( 'resources/images/icons/search.svg' ),
|
|
|
|
]
|
|
|
|
),
|
2020-06-04 17:16:51 +00:00
|
|
|
'msg-search' => $this->getMsg( 'search' )->text(),
|
2020-06-04 06:36:06 +00:00
|
|
|
'page-title' => SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey(),
|
|
|
|
];
|
|
|
|
return $props;
|
|
|
|
}
|
|
|
|
|
2019-08-15 17:40:13 +00:00
|
|
|
/**
|
2020-06-06 00:12:39 +00:00
|
|
|
* Render page-related tools
|
2019-12-25 23:20:04 +00:00
|
|
|
* Possible visibility conditions:
|
|
|
|
* * true: always visible (bool)
|
|
|
|
* * false: never visible (bool)
|
|
|
|
* * 'login': only visible if logged in (string)
|
|
|
|
* * 'permission-*': only visible if user has permission
|
|
|
|
* e.g. permission-edit = only visible if user can edit pages
|
2019-08-15 17:40:13 +00:00
|
|
|
* @return string html
|
|
|
|
*/
|
2020-06-06 00:12:39 +00:00
|
|
|
protected function buildPageTools() {
|
|
|
|
$config = $this->config;
|
|
|
|
$skin = $this->getSkin();
|
|
|
|
$condition = $config->get( 'CitizenShowPageTools' );
|
|
|
|
$contentNavigation = $this->data['content_navigation'];
|
|
|
|
$props = [];
|
2019-12-25 23:20:04 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
// Login-based condition, return true if condition is met
|
2019-12-25 23:20:04 +00:00
|
|
|
if ( $condition === 'login' ) {
|
2020-06-06 00:12:39 +00:00
|
|
|
$condition = $skin()->getUser()->isLoggedIn();
|
2019-12-25 23:20:04 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
// Permission-based condition, return true if condition is met
|
2019-12-25 23:20:04 +00:00
|
|
|
if ( is_string( $condition ) && strpos( $condition, 'permission' ) === 0 ) {
|
|
|
|
$permission = substr( $condition, 11 );
|
|
|
|
try {
|
|
|
|
$condition = MediaWikiServices::getInstance()->getPermissionManager()->userCan(
|
2020-06-06 00:12:39 +00:00
|
|
|
$permission, $skin->getUser(), $skin->getTitle() );
|
2019-12-25 23:20:04 +00:00
|
|
|
} catch ( Exception $e ) {
|
|
|
|
$condition = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $condition === true ) {
|
2019-08-15 17:40:13 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
$actionhtml = $this->getMenuData( 'views', $contentNavigation[ 'views' ] ?? [] );
|
|
|
|
$actionmorehtml = $this->getMenuData( 'actions', $contentNavigation[ 'actions' ] ?? [] );
|
2019-08-15 17:40:13 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
if ( $actionhtml ) {
|
|
|
|
$actionhtml[ 'label-class' ] .= 'screen-reader-text';
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
if ( $actionmorehtml ) {
|
|
|
|
$actionmorehtml[ 'label-class' ] .= 'screen-reader-text';
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
$props = [
|
2020-06-06 00:13:26 +00:00
|
|
|
'data-page-actions' => $actionhtml,
|
|
|
|
'data-page-actions-more' => $actionmorehtml,
|
2020-06-06 00:12:39 +00:00
|
|
|
];
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
return $props;
|
|
|
|
}
|
2019-08-15 17:40:13 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
/**
|
|
|
|
* Render page-related links at the bottom
|
|
|
|
* @return string html
|
|
|
|
*/
|
|
|
|
private function buildPageLinks() : array {
|
|
|
|
$contentNavigation = $this->data['content_navigation'];
|
2019-08-15 17:40:13 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
$namespaceshtml = $this->getMenuData( 'namespaces', $contentNavigation[ 'namespaces' ] ?? [] );
|
|
|
|
$variantshtml = $this->getMenuData( 'variants', $contentNavigation[ 'variants' ] ?? [] );
|
2019-08-15 17:40:13 +00:00
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
if ( $namespaceshtml ) {
|
|
|
|
$namespaceshtml[ 'label-class' ] .= 'screen-reader-text';
|
2019-12-25 23:20:04 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
if ( $variantshtml ) {
|
|
|
|
$variantshtml[ 'label-class' ] .= 'screen-reader-text';
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-06 00:12:39 +00:00
|
|
|
$props = [
|
|
|
|
'data-namespaces' => $namespaceshtml,
|
|
|
|
'data-variants' => $variantshtml,
|
|
|
|
];
|
|
|
|
|
|
|
|
return $props;
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
|
2020-06-05 21:07:11 +00:00
|
|
|
/**
|
2020-06-06 00:12:39 +00:00
|
|
|
* Render the bottom bar
|
|
|
|
* TODO: Convert button text to i18n message.
|
|
|
|
* TODO: Refactor the bottom bar to be customizable
|
2020-06-05 21:07:11 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2020-06-06 00:12:39 +00:00
|
|
|
private function buildBottombar() : array {
|
|
|
|
$config = $this->config;
|
|
|
|
$buttonEnabled = $config->get( 'CitizenEnableButton' );
|
|
|
|
if ( $buttonEnabled === false ) {
|
|
|
|
return '';
|
|
|
|
}
|
2020-06-05 21:07:11 +00:00
|
|
|
$props = [
|
2020-06-06 00:12:39 +00:00
|
|
|
'html-citizen-bottombar-button-href' => $config->get( 'CitizenButtonLink' ),
|
|
|
|
'html-citizen-bottombar-button-title' => $config->get( 'CitizenButtonTitle' ),
|
|
|
|
'html-citizen-bottombar-button-text' => $config->get( 'CitizenButtonText' ),
|
2020-06-05 21:07:11 +00:00
|
|
|
];
|
|
|
|
return $props;
|
|
|
|
}
|
|
|
|
|
2019-08-15 17:40:13 +00:00
|
|
|
/**
|
2020-06-02 06:23:11 +00:00
|
|
|
* Get last modified message
|
2019-08-15 17:40:13 +00:00
|
|
|
* @return string html
|
|
|
|
*/
|
2020-06-02 06:23:11 +00:00
|
|
|
private function getLastMod() {
|
2020-06-05 22:55:04 +00:00
|
|
|
$lastMod = null;
|
2020-06-02 06:23:11 +00:00
|
|
|
$footerLinks = $this->getFooterLinks();
|
|
|
|
|
|
|
|
if ( isset( $footerLinks['info'] ) ) {
|
|
|
|
if ( in_array( 'lastmod', $footerLinks['info'] ) ) {
|
|
|
|
$key = array_search( 'lastmod', $footerLinks['info'] );
|
2020-06-05 22:55:04 +00:00
|
|
|
$lastMod = $this->get( $footerLinks['info'][$key], '' );
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-02 06:23:11 +00:00
|
|
|
|
2020-06-05 22:55:04 +00:00
|
|
|
return $lastMod;
|
2020-06-02 06:23:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get rows that make up the footer
|
|
|
|
* @return array for use in Mustache template describing the footer elements.
|
|
|
|
*/
|
|
|
|
private function getFooterRows() : array {
|
|
|
|
$footerRows = [];
|
|
|
|
$footerLinks = $this->getFooterLinks();
|
|
|
|
|
|
|
|
foreach ( $footerLinks as $category => $links ) {
|
|
|
|
$items = [];
|
|
|
|
$rowId = "footer-$category";
|
|
|
|
|
|
|
|
// Unset footer-info
|
|
|
|
if ( $category !== 'info' ) {
|
|
|
|
foreach ( $links as $link ) {
|
|
|
|
$items[] = [
|
|
|
|
'id' => "$rowId-$link",
|
|
|
|
'html' => $this->get( $link, '' ),
|
|
|
|
];
|
2020-01-07 18:34:43 +00:00
|
|
|
}
|
2020-06-02 06:23:11 +00:00
|
|
|
|
|
|
|
$footerRows[] = [
|
|
|
|
'id' => $rowId,
|
|
|
|
'className' => '',
|
|
|
|
'array-items' => $items
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append footer-info after links
|
|
|
|
if ( isset( $footerLinks['info'] ) ) {
|
|
|
|
$items = [];
|
|
|
|
$rowId = "footer-info";
|
|
|
|
|
|
|
|
foreach ( $footerLinks['info'] as $link ) {
|
|
|
|
// Unset lastmod from footer link
|
|
|
|
if ( $link !== 'lastmod' ) {
|
|
|
|
$items[] = [
|
|
|
|
'id' => "$rowId-$link",
|
|
|
|
'html' => $this->get( $link, '' ),
|
|
|
|
];
|
2020-01-07 18:34:43 +00:00
|
|
|
}
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
2020-06-02 06:23:11 +00:00
|
|
|
|
|
|
|
$footerRows[] = [
|
|
|
|
'id' => $rowId,
|
|
|
|
'className' => '',
|
|
|
|
'array-items' => $items
|
|
|
|
];
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
2020-06-02 06:23:11 +00:00
|
|
|
|
|
|
|
return $footerRows;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get footer icons
|
|
|
|
* @return array for use in Mustache template describing the footer icons.
|
|
|
|
*/
|
|
|
|
private function getFooterIconsRow() : array {
|
|
|
|
$footerRows = [];
|
|
|
|
|
|
|
|
// If footer icons are enabled append to the end of the rows
|
|
|
|
$footerIcons = $this->getFooterIcons( 'icononly' );
|
|
|
|
if ( count( $footerIcons ) > 0 ) {
|
|
|
|
$items = [];
|
|
|
|
foreach ( $footerIcons as $blockName => $blockIcons ) {
|
|
|
|
$html = '';
|
|
|
|
foreach ( $blockIcons as $icon ) {
|
|
|
|
$html .= $this->getSkin()->makeFooterIcon( $icon );
|
|
|
|
}
|
|
|
|
$items[] = [
|
|
|
|
'id' => 'footer-' . htmlspecialchars( $blockName ) . 'ico',
|
|
|
|
'html' => $html,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$footerRows[] = [
|
|
|
|
'id' => 'footer-icons',
|
|
|
|
'className' => 'noprint',
|
|
|
|
'array-items' => $items,
|
|
|
|
];
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
2020-06-02 06:23:11 +00:00
|
|
|
|
|
|
|
return $footerRows;
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|
2020-06-06 00:12:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $label to be used to derive the id and human readable label of the menu
|
|
|
|
* If the key has an entry in the constant MENU_LABEL_KEYS then that message will be used for the
|
|
|
|
* human readable text instead.
|
|
|
|
* @param array $urls to convert to list items stored as string in html-items key
|
|
|
|
* @param array $options (optional) to be passed to makeListItem
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function getMenuData(
|
|
|
|
string $label,
|
|
|
|
array $urls = [],
|
|
|
|
array $options = []
|
|
|
|
) : array {
|
|
|
|
// For some menu items, there is no language key corresponding with its menu key.
|
|
|
|
// These inconsitencies are captured in MENU_LABEL_KEYS
|
|
|
|
$msgObj = $this->getMsg( self::MENU_LABEL_KEYS[ $label ] ?? $label );
|
|
|
|
$props = [
|
|
|
|
'id' => "p-$label",
|
|
|
|
'label-class' => null,
|
|
|
|
'label-id' => "p-{$label}-label",
|
|
|
|
// If no message exists fallback to plain text (T252727)
|
|
|
|
'label' => $msgObj->exists() ? $msgObj->text() : $label,
|
|
|
|
'html-items' => '',
|
|
|
|
'html-tooltip' => Linker::tooltip( 'p-' . $label ),
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ( $urls as $key => $item ) {
|
|
|
|
$props['html-items'] .= $this->makeListItem( $key, $item, $options );
|
|
|
|
}
|
|
|
|
|
|
|
|
$props['html-after-portal'] = $this->getAfterPortlet( $label );
|
|
|
|
|
|
|
|
// Mark the portal as empty if it has no content
|
|
|
|
$class = ( count( $urls ) == 0 && !$props['html-after-portal'] )
|
|
|
|
? ' mw-portal-empty' : '';
|
|
|
|
$props['class'] = $class;
|
|
|
|
return $props;
|
|
|
|
}
|
2019-08-15 17:40:13 +00:00
|
|
|
}
|