(admin/configure-plugin): support multiple kind of plugins

This commit is contained in:
Kazhnuz 2025-01-18 17:24:54 +01:00
parent 098ef66839
commit e84397962a
15 changed files with 211 additions and 28 deletions

View file

@ -0,0 +1,26 @@
<?php defined('KOBLOG') or die('Koblog CMS.');
// ============================================================================
// Check role
// ============================================================================
checkRole(array('admin'));
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================
// Title of the page
$layout['title'] .= ' - '.$L->g('Sidebar');

View file

@ -29,6 +29,16 @@
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><span class="fa fa-users fa-fw"></span><?php $L->p('Users') ?></a>
</li>
<li class="nav-item mt-3">
<h4><?php $L->p('Customization') ?></h4>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><span class="fa fa-desktop fa-fw"></span><?php $L->p('Themes') ?></a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'sidebar' ?>"><span class="fa fa-list fa-fw"></span><?php $L->p('Sidebar') ?></a>
</li>
<li class="nav-item mt-3">
<h4><?php $L->p('Settings') ?></h4>
</li>
@ -38,9 +48,6 @@
<li class="nav-item">
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>"><span class="fa fa-puzzle-piece fa-fw"></span><?php $L->p('Plugins') ?></a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><span class="fa fa-desktop fa-fw"></span><?php $L->p('Themes') ?></a>
</li>
<?php endif; ?>

View file

@ -2,12 +2,27 @@
<?php echo Bootstrap::formOpen(array('id'=>'jsform', 'class'=>'plugin-form')); ?>
<?php
$returnPage = "plugins";
switch ($plugin->type()) {
case 'theme':
$returnPage = "themes";
break;
case 'widget':
$returnPage = "sidebar";
break;
default:
break;
}
?>
<div class="d-flex justify-content-between mb-2">
<?php echo Bootstrap::pageTitle(array('title'=>$plugin->name(), 'icon'=>'cog')); ?>
<?php if ($plugin->formButtons()): ?>
<div>
<button type="submit" class="btn btn-primary" name="save"><?php $L->p('Save') ?></button>
<a class="btn btn-secondary" href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>" role="button"><?php $L->p('Cancel') ?></a>
<a class="btn btn-secondary" href="<?php echo HTML_PATH_ADMIN_ROOT.$returnPage ?>" role="button"><?php $L->p('Cancel') ?></a>
</div>
<?php endif; ?>
</div>

View file

@ -3,10 +3,10 @@
<?php echo Bootstrap::formOpen(array('id'=>'jsform', 'class'=>'tab-content')); ?>
<div class="d-flex justify-content-between mb-2">
<?php echo Bootstrap::pageTitle(array('title'=>$L->g('Plugins position'), 'icon'=>'tags')); ?>
<?php echo Bootstrap::pageTitle(array('title'=>$L->g('Reorder sidebar'), 'icon'=>'list')); ?>
<div>
<button type="button" class="btn btn-primary jsbuttonSave" name="save"><?php $L->p('Save') ?></button>
<a class="btn btn-secondary" href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>" role="button"><?php $L->p('Cancel') ?></a>
<a class="btn btn-secondary" href="<?php echo HTML_PATH_ADMIN_ROOT.'sidebar' ?>" role="button"><?php $L->p('Cancel') ?></a>
</div>
</div>

View file

@ -1,20 +1,8 @@
<?php
echo "<div class='d-flex justify-content-between align-content-center'>";
echo Bootstrap::pageTitle(array('title' => $L->g('Plugins'), 'icon' => 'puzzle-piece'));
echo "<div>";
echo Bootstrap::link(array(
'title' => $L->g('Change the position of the plugins'),
'href' => HTML_PATH_ADMIN_ROOT . 'plugins-position',
'icon' => 'arrows',
'class' => 'btn btn-outline-secondary'
));
echo "</div></div>";
echo Bootstrap::formTitle(array('title' => $L->g('Search plugins')));
?>
@ -49,7 +37,7 @@ echo ' </h6><table class="table m-0">
// Show installed plugins
foreach ($pluginsInstalled as $plugin) {
if ($plugin->type() == 'theme') {
if ($plugin->type() == 'theme' || $plugin->type() == 'widget') {
// Do not display theme's plugins
continue;
}
@ -98,7 +86,7 @@ echo ' </h6><table class="table m-0">
$pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled);
foreach ($pluginsNotInstalled as $plugin) {
if ($plugin->type() == 'theme') {
if ($plugin->type() == 'theme' || $plugin->type() == 'widget') {
// Do not display theme's plugins
continue;
}

View file

@ -0,0 +1,138 @@
<?php
echo "<div class='d-flex justify-content-between align-content-center'>";
echo Bootstrap::pageTitle(array('title' => $L->g('Sidebar'), 'icon' => 'list'));
echo "<div>";
echo Bootstrap::link(array(
'title' => $L->g('Reorder sidebar'),
'href' => HTML_PATH_ADMIN_ROOT . 'plugins-position',
'icon' => 'arrows',
'class' => 'btn btn-outline-secondary'
));
echo "</div></div>";
?>
<p class="alert alert-info"><?php echo $L->g("Activate or deactivate here plugins that'll be shown in the sidebar") ?></p>
<?php
echo Bootstrap::formTitle(array('title' => $L->g('Search plugins')));
?>
<input type="text" dir="auto" class="form-control mb-3" id="search" placeholder="<?php $L->p('Search') ?>">
<script>
$(document).ready(function() {
$("#search").on("keyup", function() {
var textToSearch = $(this).val().toLowerCase();
$(".searchItem").each(function() {
var item = $(this);
item.hide();
item.find(".searchText").each(function() {
var element = $(this).text().toLowerCase();
if (element.indexOf(textToSearch) != -1) {
item.show();
}
});
});
});
});
</script>
<?php
echo '<div class="card mb-3"><h6 class="card-header">';
echo $L->g('Enabled plugins');
echo ' </h6><table class="table m-0">
<tbody>
';
// Show installed plugins
foreach ($pluginsInstalled as $plugin) {
if ($plugin->type() != 'widget') {
// Do not display theme's plugins
continue;
}
echo '<tr id="' . $plugin->className() . '" class="searchItem card-tablebody">';
echo '<td class="align-middle pt-3 pb-3 w-25">
<div class="searchText">' . $plugin->name() . '</div>
<div class="mt-1">';
if (method_exists($plugin, 'form')) {
echo '<a class="me-3" href="' . HTML_PATH_ADMIN_ROOT . 'configure-plugin/' . $plugin->className() . '">' . $L->g('Settings') . '</a>';
}
echo '<a href="' . HTML_PATH_ADMIN_ROOT . 'uninstall-plugin/' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>';
echo '</div>';
echo '</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo $plugin->description();
echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">';
echo '<span>' . $plugin->version() . '</span>';
echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">
<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a>
</td>';
echo '</tr>';
}
echo '
</tbody>
</table>
</div>
';
echo '<div class="card mb-3"><h6 class="card-header">';
echo $L->g('Disabled plugins');
echo ' </h6><table class="table m-0">
<tbody>
';
// Plugins not installed
$pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled);
foreach ($pluginsNotInstalled as $plugin) {
if ($plugin->type() != 'widget') {
continue;
}
echo '<tr id="' . $plugin->className() . '" class="searchItem">';
echo '<td class="align-middle pt-3 pb-3 w-25">
<div class="searchText">' . $plugin->name() . '</div>
<div class="mt-1">
<a href="' . HTML_PATH_ADMIN_ROOT . 'install-plugin/' . $plugin->className() . '">' . $L->g('Activate') . '</a>
</div>
</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo $plugin->description();
echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">';
echo '<span>' . $plugin->version() . '</span>';
echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">
<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a>
</td>';
echo '</tr>';
}
echo '
</tbody>
</table>
</div>
';

View file

@ -60,6 +60,7 @@
"language": "Langue",
"plugin": "Plugin",
"plugins": "Plugins",
"activate-or-deactivate-here-plugins-that'll-be-shown-in-the-sidebar":"Activez ou désactiver ici les plugins qui seront visible dans la sidebar du site",
"developers": "Développeurs",
"themes": "Thèmes",
"about": "À Propos",

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}

View file

@ -6,5 +6,6 @@
"releaseDate": "2024-08-23",
"license": "MIT",
"compatible": "kb_0.0.1",
"notes": ""
"notes": "",
"type": "widget"
}