Skip to content

Commit

Permalink
Update logic and styles of mw-portlet-dropdown
Browse files Browse the repository at this point in the history
Bug: #48
Change-Id: Ic4cdacdd809eb5eaaba607134f315524dfcb2196
  • Loading branch information
winstonsung committed Sep 22, 2024
1 parent bbe891f commit 4d20d7e
Show file tree
Hide file tree
Showing 7 changed files with 983 additions and 951 deletions.
69 changes: 43 additions & 26 deletions includes/SkinLakeus.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,61 @@ public function getTemplateData(): array {
// this is a Config object
$config = $this->getConfig();

$data["html-articlecount"] = SiteStats::articles();
$data['html-articlecount'] = SiteStats::articles();
// trying to overwrite
$data["msg-lakeus-articlecount"] = $this->msg( 'lakeus-articlecount' )
$data['msg-lakeus-articlecount'] = $this->msg( 'lakeus-articlecount' )
->numParams( SiteStats::articles() )->parse();
$showRepositoryLink = $config->get( 'LakeusShowRepositoryLink' );
if ( $showRepositoryLink ) {
$data["html-repository-link"] = '<a href="https://github.com/lakejason0/mediawiki-skins-Lakeus">' .
$show_repository_link = $config->get( 'LakeusShowRepositoryLink' );
if ( $show_repository_link ) {
$data['html-repository-link'] = '<a href="https://github.com/lakejason0/mediawiki-skins-Lakeus">' .
$this->msg( 'lakeus-footermessage' )->plain() . '</a>';
$data["is-repository-link-shown"] = true;
$data['is-repository-link-shown'] = true;
}
$data["is-notice-with-border"] = $config->get( 'LakeusSiteNoticeHasBorder' );
$data["is-portlet-animated"] = $config->get( 'LakeusShouldAnimatePortlets' );
$data["is-sticky-toc-shown"] = $config->get( 'LakeusShowStickyTOC' );
$data['is-notice-with-border'] = $config->get( 'LakeusSiteNoticeHasBorder' );
$data['is-portlet-animated'] = $config->get( 'LakeusShouldAnimatePortlets' );
$data['is-sticky-toc-shown'] = $config->get( 'LakeusShowStickyTOC' );

$pageToolsKey = array_search(
$page_tools_key = array_search(
'p-tb',
array_column( $data["data-portlets-sidebar"]["array-portlets-rest"], 'id' )
array_column( $data['data-portlets-sidebar']['array-portlets-rest'], 'id' )
);
$data["data-portlets"]["data-page-tools"] =
$data["data-portlets-sidebar"]["array-portlets-rest"][$pageToolsKey];
unset( $data["data-portlets-sidebar"]["array-portlets-rest"][$pageToolsKey] );
$data["data-portlets-sidebar"]["array-portlets-rest"] = array_values(
$data["data-portlets-sidebar"]["array-portlets-rest"]
$data['data-portlets']['data-page-tools'] =
$data['data-portlets-sidebar']['array-portlets-rest'][$page_tools_key];
unset( $data['data-portlets-sidebar']['array-portlets-rest'][$page_tools_key] );
$data['data-portlets-sidebar']['array-portlets-rest'] = array_values(
$data['data-portlets-sidebar']['array-portlets-rest']
);

if ( empty( $data["data-toc"]["array-sections"] ) ) {
unset( $data["data-toc"] );
$dropdown_portlet_keys = [
'data-user-menu',
'data-actions',
'data-page-tools',
'data-variants',
'data-languages',
];
foreach ( $dropdown_portlet_keys as $portlet_key ) {
if ( isset( $data['data-portlets'][$portlet_key] ) ) {
$data['data-portlets'][$portlet_key]['class'] = str_replace(
'mw-portlet mw-portlet-',
'mw-portlet mw-portlet-dropdown mw-portlet-',
$data['data-portlets'][$portlet_key]['class']
);
}
}

if ( empty( $data['data-toc']['array-sections'] ) ) {
unset( $data['data-toc'] );
}

$customIndicators = $config->get( 'LakeusCustomIndicators' );
$idTracker = [];
foreach ( $data["array-indicators"] as $item ) {
$idTracker[$item["id"]] = true;
$custom_indicators = $config->get( 'LakeusCustomIndicators' );
$id_tracker = [];
foreach ( $data['array-indicators'] as $item ) {
$id_tracker[$item['id']] = true;
}
foreach ( $customIndicators as $indicator ) {
if ( !isset( $idTracker[ $indicator["id"] ] ) ) {
$data["array-indicators"][] = $indicator;
$idTracker[ $indicator["id"] ] = true;
foreach ( $custom_indicators as $indicator ) {
if ( !isset( $id_tracker[ $indicator['id'] ] ) ) {
$data['array-indicators'][] = $indicator;
$id_tracker[ $indicator['id'] ] = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions includes/templates/ContentActions.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="content__actions">
{{#data-portlets.data-views}}{{>Portlet}}{{/data-portlets.data-views}}
{{>Dropdown}}{{#data-portlets.data-actions}}{{>Portlet}}{{/data-portlets.data-actions}}
{{>Dropdown}}{{#data-portlets.data-page-tools}}{{>Portlet}}{{/data-portlets.data-page-tools}}
{{#data-portlets.data-actions}}{{>Portlet}}{{/data-portlets.data-actions}}
{{#data-portlets.data-page-tools}}{{>Portlet}}{{/data-portlets.data-page-tools}}
{{>Languages}}
</div>
3 changes: 0 additions & 3 deletions includes/templates/Dropdown.mustache

This file was deleted.

4 changes: 2 additions & 2 deletions includes/templates/Languages.mustache
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{>Dropdown}}{{#data-portlets.data-variants}}{{>Portlet}}{{/data-portlets.data-variants}}
{{>Dropdown}}{{#data-portlets.data-languages}}{{>Portlet}}{{/data-portlets.data-languages}}
{{#data-portlets.data-variants}}{{>Portlet}}{{/data-portlets.data-variants}}
{{#data-portlets.data-languages}}{{>Portlet}}{{/data-portlets.data-languages}}
File renamed without changes.
6 changes: 3 additions & 3 deletions includes/templates/UserTools.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div id="p-user-tools">
{{>Notifications}}
{{>InterfacePreferences}}
{{>Dropdown}}{{>PersonalMenu}}
{{>Notifications}}
{{>InterfacePreferences}}
{{>UserMenu}}
</div>
Loading

0 comments on commit 4d20d7e

Please sign in to comment.