Skip to content

Commit

Permalink
Add top & footer widget locations
Browse files Browse the repository at this point in the history
  • Loading branch information
partydragen committed Jul 20, 2024
1 parent 771d21d commit 69d4e41
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 3 deletions.
15 changes: 15 additions & 0 deletions core/migrations/20240720110121_change_widgets_location_length.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class ChangeWidgetsLocationLength extends AbstractMigration
{
public function change(): void
{
$table = $this->table('nl2_widgets');
$table->changeColumn('location', 'string', ['length' => 16, 'default' => 'right']);
$table->update();
}
}
4 changes: 3 additions & 1 deletion core/templates/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Made by Samerton
* https://github.com/NamelessMC/Nameless/
* NamelessMC version 2.0.0-pr8
* NamelessMC version 2.2.0
*
* License: MIT
*
Expand Down Expand Up @@ -190,6 +190,8 @@
),
'INTERNET_EXPLORER_HEADER' => $language->get('general', 'internet_explorer_header'),
'INTERNET_EXPLORER_INFO' => $language->get('general', 'internet_explorer_info'),
'WIDGETS_TOP' => $widgets->getWidgets('top'),
'WIDGETS_FOOTER' => $widgets->getWidgets('footer'),
]);

if ($user->isLoggedIn()) {
Expand Down
2 changes: 2 additions & 0 deletions custom/panel_templates/Default/core/widgets_edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<select name="location" class="form-control" id="inputLocation">
<option value="right" {if $LOCATION eq 'right' } selected{/if}>{$RIGHT}</option>
<option value="left" {if $LOCATION eq 'left' } selected{/if}>{$LEFT}</option>
<option value="top" {if $LOCATION eq 'top' } selected{/if}>{$TOP}</option>
<option value="footer" {if $LOCATION eq 'footer' } selected{/if}>{$FOOTER}</option>
</select>
</div>

Expand Down
5 changes: 5 additions & 0 deletions custom/templates/DefaultRevamp/footer.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{if count($WIDGETS_FOOTER)}
{foreach from=$WIDGETS_FOOTER item=widget}
{$widget}
{/foreach}
{/if}
</div>
</div>

Expand Down
6 changes: 6 additions & 0 deletions custom/templates/DefaultRevamp/navbar.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,9 @@
{$MAINTENANCE_ENABLED}
</div>
{/if}

{if count($WIDGETS_TOP)}
{foreach from=$WIDGETS_TOP item=widget}
{$widget}
{/foreach}
{/if}
2 changes: 2 additions & 0 deletions modules/Core/language/en_UK.json
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@
"admin/debugging_enabled": "Debugging is enabled, sensitive information may be exposed to unauthorised visitors. Debugging should only be used for development, not on public sites.",
"admin/require_minecraft_username_on_registration": "Require Minecraft Username on registration?",
"admin/integration_settings_does_not_exist": "Integration settings file for integration {{integration}} does not exist",
"admin/top": "Top",
"admin/footer": "Footer",
"api/account_validated": "Account validated successfully",
"api/finish_registration_email": "Please check your emails to complete registration.",
"api/finish_registration_link": "Please click on the following link to complete registration:",
Expand Down
6 changes: 4 additions & 2 deletions modules/Core/pages/panel/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
$order = ($_POST['order'] ?? 10);

$location = Input::get('location');
if (!in_array($location, ['left', 'right'])) {
if (!in_array($location, ['left', 'right', 'top', 'footer'])) {
$location = 'right';
}

Expand Down Expand Up @@ -191,7 +191,7 @@
}

$location = Output::getClean($widget_instance->getLocation());
if (!in_array($location, ['left', 'right'])) {
if (!in_array($location, ['left', 'right', 'top', 'footer'])) {
$location = 'right';
}

Expand All @@ -208,6 +208,8 @@
'WIDGET_LOCATION' => $language->get('admin', 'widget_location'),
'LEFT' => $language->get('admin', 'left'),
'RIGHT' => $language->get('admin', 'right'),
'TOP' => $language->get('admin', 'top'),
'FOOTER' => $language->get('admin', 'footer'),
'ACTIVE_PAGES' => $active_pages,
'POSSIBLE_PAGES' => $pages->returnWidgetPages(),
'MODULE' => $language->get('admin', 'module'),
Expand Down

0 comments on commit 69d4e41

Please sign in to comment.