Bug fixes on UI

This commit is contained in:
Diego Najar 2021-09-12 20:57:44 +02:00
parent 2eac988843
commit 6a0f32900b
5 changed files with 367 additions and 339 deletions

View file

@ -80,6 +80,7 @@ function table($type)
global $scheduled; global $scheduled;
global $static; global $static;
global $sticky; global $sticky;
global $unlisted;
if ($type == 'published') { if ($type == 'published') {
$list = $published; $list = $published;
@ -113,6 +114,14 @@ function table($type)
echo '</p>'; echo '</p>';
return false; return false;
} }
} elseif ($type == 'unlisted') {
$list = $unlisted;
if (empty($list)) {
echo '<p class="text-muted p-4">';
echo $L->g('There are no unlisted pages at this moment.');
echo '</p>';
return false;
}
} elseif ($type == 'sticky') { } elseif ($type == 'sticky') {
$list = $sticky; $list = $sticky;
if (empty($list)) { if (empty($list)) {
@ -234,6 +243,9 @@ function table($type)
} ?> } ?>
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link" id="unlisted-tab" data-bs-toggle="tab" href="#unlisted" role="tab" aria-controls="unlisted" aria-selected="true"><?php $L->p('Unlisted') ?></a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="draft-tab" data-bs-toggle="tab" href="#draft" role="tab" aria-controls="draft" aria-selected="true"><?php $L->p('Draft') ?></a> <a class="nav-link" id="draft-tab" data-bs-toggle="tab" href="#draft" role="tab" aria-controls="draft" aria-selected="true"><?php $L->p('Draft') ?></a>
</li> </li>
@ -295,6 +307,11 @@ function table($type)
<?php table('scheduled'); ?> <?php table('scheduled'); ?>
</div> </div>
<!-- TABS UNLISTED -->
<div class="tab-pane" id="unlisted" role="tabpanel">
<?php table('unlisted'); ?>
</div>
<!-- TABS DRAFT --> <!-- TABS DRAFT -->
<div class="tab-pane" id="draft" role="tabpanel"> <div class="tab-pane" id="draft" role="tabpanel">
<?php table('draft'); ?> <?php table('draft'); ?>

View file

@ -134,8 +134,11 @@
var args = { var args = {
title: $('#title').val(), title: $('#title').val(),
content: editorGetContent(), content: editorGetContent(),
coverImage: $('#coverImage').val(),
category: $('#category option:selected').val(), category: $('#category option:selected').val(),
tags: $('#tags').val() tags: $("#tags option:selected").map(function() {
return this.value
}).get().join(",")
} }
savePage(args); savePage(args);
disableBtnSave(); disableBtnSave();
@ -177,6 +180,7 @@
var args = { var args = {
title: $('#title').val(), title: $('#title').val(),
content: editorGetContent(), content: editorGetContent(),
coverImage: $('#coverImage').val(),
category: $('#category option:selected').val(), category: $('#category option:selected').val(),
tags: $("#tags option:selected").map(function() { tags: $("#tags option:selected").map(function() {
return this.value return this.value
@ -288,7 +292,9 @@
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
$('#btnSaveSeo').on('click', function() { $('#btnSaveSeo').on('click', function() {
var args = { var args = {
parent: $('#parent').val() noindex: $('input[name="noindex"]').is(':checked'),
nofollow: $('input[name="nofollow"]').is(':checked'),
noarchive: $('input[name="noarchive"]').is(':checked')
}; };
savePage(args); savePage(args);
disableBtnSave(); disableBtnSave();
@ -594,7 +600,8 @@
<!-- Cover Image --> <!-- Cover Image -->
<h6 class="text-uppercase"><?php $L->p('Cover Image') ?></h6> <h6 class="text-uppercase"><?php $L->p('Cover Image') ?></h6>
<div> <div>
<img id="jscoverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo (($pageKey && $page->coverImage()) ? $page->coverImage() : HTML_PATH_CORE_IMG . 'default.svg') ?>" /> <input id="coverImage" name="coverImage" data-save="true" type="hidden" value="<?php echo (($pageKey && $page->coverImage()) ? $page->coverImage(false) : '') ?>">
<img id="coverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo (($pageKey && $page->coverImage()) ? $page->coverImage() : HTML_PATH_CORE_IMG . 'default.svg') ?>" />
</div> </div>
<!-- End Cover Image --> <!-- End Cover Image -->

View file

@ -1,224 +1,233 @@
<div class="modal" id="modal-fileManager" tabindex="-1"> <div class="modal" id="modal-fileManager" tabindex="-1">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-body"> <div class="modal-body">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="d-flex align-items-center mb-4"> <div class="d-flex align-items-center mb-4">
<h3 class="me-auto m-0 p-0"><i class="bi bi-image"></i><?php $L->p('File Manager'); ?></h3> <h3 class="me-auto m-0 p-0"><i class="bi bi-image"></i><?php $L->p('File Manager'); ?></h3>
<label id="btnUploadFile" class="btn btn-primary"><i class="bi bi-upload"></i><?php $L->p('Upload file'); ?><input type="file" id="filesToUpload" name="filesToUpload[]" multiple hidden></label> <label id="btnUploadFile" class="btn btn-primary"><i class="bi bi-upload"></i><?php $L->p('Upload file'); ?><input type="file" id="filesToUpload" name="filesToUpload[]" multiple hidden></label>
<div id="progressUploadFile" class="progress w-25 d-none"> <div id="progressUploadFile" class="progress w-25 d-none">
<div class="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div> <div class="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div> </div>
</div> </div>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th scope="col">Preview</th> <th scope="col">Preview</th>
<th scope="col">Filename</th> <th scope="col">Filename</th>
<th scope="col">Type</th> <th scope="col">Type</th>
<th scope="col">Size</th> <th scope="col">Size</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
<tbody id="fmFiles"> <tbody id="fmFiles">
<!-- <tr> <!-- <tr>
<td class="align-middle"> <td class="align-middle">
<img style="width: 32px" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" /> <img style="width: 32px" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />
</td> </td>
<td class="align-middle">photo.jpg</td> <td class="align-middle">photo.jpg</td>
<td class="align-middle">image/jpeg</td> <td class="align-middle">image/jpeg</td>
<td class="align-middle">300Kb</td> <td class="align-middle">300Kb</td>
<td class="align-middle"> <td class="align-middle">
<div class="dropdown"> <div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false"> <button class="btn btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false">
Options Options
</button> </button>
<ul class="dropdown-menu" aria-labelledby="fileOptions"> <ul class="dropdown-menu" aria-labelledby="fileOptions">
<li><a class="dropdown-item" href="#">Insert</a></li> <li><a class="dropdown-item" href="#">Insert</a></li>
<li><a class="dropdown-item" href="#">Set as cover image</a></li> <li><a class="dropdown-item" href="#">Set as cover image</a></li>
<li> <li>
<hr class="dropdown-divider"> <hr class="dropdown-divider">
</li> </li>
<li><a class="dropdown-item" href="#"><?php $L->p('Delete') ?></a></li> <li><a class="dropdown-item" href="#"><?php $L->p('Delete') ?></a></li>
</ul> </ul>
</div> </div>
</td> </td>
</tr> --> </tr> -->
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
// Open File Manager modal // Open File Manager modal
function fmOpen() { function fmOpen() {
$('#modal-fileManager').modal('show'); $('#modal-fileManager').modal('show');
} }
// Close File Manager modal // Close File Manager modal
function fmClose() { function fmClose() {
$('#modal-fileManager').modal('hide'); $('#modal-fileManager').modal('hide');
} }
// Insert HTML code in the Editor content // Insert HTML code in the Editor content
function fmInsertFile(filename, absoluteURL, mime) { function fmInsertFile(filename, absoluteURL, mime) {
if (mime == 'image/jpeg' || mime == 'image/png') { if (mime == 'image/jpeg' || mime == 'image/png') {
editorInsertContent(absoluteURL, 'image'); editorInsertContent(absoluteURL, 'image');
} else { } else {
editorInsertContent('<a href="' + absoluteURL + '">' + filename + '</a>'); editorInsertContent('<a href="' + absoluteURL + '">' + filename + '</a>');
} }
} }
// Get the files for the current page and show them // Get the files for the current page and show them
function fmGetFiles() { function fmGetFiles() {
logs('File Manager. Getting files for the current page: ' + _pageKey); logs('File Manager. Getting files for the current page: ' + _pageKey);
api.getPageFiles({ api.getPageFiles({
'pageKey': _pageKey 'pageKey': _pageKey
}).then(function(response) { }).then(function(response) {
if (response.status == 0) { if (response.status == 0) {
fmDisplayFiles(response.data); fmDisplayFiles(response.data);
} else { } else {
logs("File Manager. An error occurred while trying to get the files for the current page."); logs("File Manager. An error occurred while trying to get the files for the current page.");
showAlertError(response.message); showAlertError(response.message);
} }
}); });
} }
// Displays the files in the table function setCoverImage(filename) {
function fmDisplayFiles(files) { var image = DOMAIN_UPLOADS_PAGES+_pageKey+'/'+filename;
$('#fmFiles').empty(); $("#coverImage").val(filename);
$("#coverImagePreview").attr("src", image);
}
if (files.length == 0) { // Displays the files in the table
logs('File Manager. There are not files for the current page.'); function fmDisplayFiles(files) {
return false; $('#fmFiles').empty();
}
$.each(files, function(key, file) { if (files.length == 0) {
console.log(file); logs('File Manager. There are not files for the current page.');
var row = '<tr>' + return false;
'<td class="align-middle">' + }
' <img style="width: 32px" src="'+ file.thumbnailSmall +'" />' +
'</td>' +
'<td class="align-middle">' + file.filename + '</td>' +
'<td class="align-middle">' + file.mime + '</td>' +
'<td class="align-middle">' + formatBytes(file.size) + '</td>' +
'<td class="align-middle text-center">' +
'<div class="dropdown">' +
' <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-gear"></i>Options</button>' +
' <ul class="dropdown-menu" aria-labelledby="fileOptions">' +
' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.absoluteURL + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert') ?></a></li>' +
' <li><a class="dropdown-item" href="#"><i class="bi bi-image"></i>Set as cover image</a></li>' +
' <li><hr class="dropdown-divider"></li>' +
' <li><a class="dropdown-item" href="#"><i class="bi bi-trash"></i><?php $L->p('Delete') ?></a></li>' +
' </ul>' +
'</div>' +
'</td>' +
'</tr>';
$('#fmFiles').append(row);
});
return true; $.each(files, function(key, file) {
} console.log(file);
var row = '<tr>' +
'<td class="align-middle">' +
' <img style="width: 32px" src="' + file.thumbnailSmall + '" />' +
'</td>' +
'<td class="align-middle">' + file.filename + '</td>' +
'<td class="align-middle">' + file.mime + '</td>' +
'<td class="align-middle">' + formatBytes(file.size) + '</td>' +
'<td class="align-middle text-center">' +
'<div class="dropdown">' +
' <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-gear"></i>Options</button>' +
' <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="fileOptions">' +
' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.absoluteURL + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert original') ?></a></li>' +
' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.thumbnailSmall + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert small') ?></a></li>' +
' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.thumbnailMedium + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert medium') ?></a></li>' +
' <li><hr class="dropdown-divider"></li>' +
' <li><a class="dropdown-item" href="#" onClick="setCoverImage(\'' + file.filename + '\')"><i class="bi bi-image"></i>Set as cover image</a></li>' +
' <li><hr class="dropdown-divider"></li>' +
' <li><a class="dropdown-item" href="#"><i class="bi bi-trash"></i><?php $L->p('Delete') ?></a></li>' +
' </ul>' +
'</div>' +
'</td>' +
'</tr>';
$('#fmFiles').append(row);
});
// Upload a file for the current page return true;
function fmUploadFile(file) { }
logs('File Manager. Uploading file.');
// Check file type/extension // Upload a file for the current page
const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml', 'application/pdf']; function fmUploadFile(file) {
if (!validImageTypes.includes(file.type)) { logs('File Manager. Uploading file.');
logs("File Manager. File type is not supported.");
showAlertError("<?php echo $L->g('File type is not supported. Allowed types:') . ' ' . implode(', ', $GLOBALS['ALLOWED_IMG_EXTENSIONS']) ?>");
return false;
}
// Check file size and compare with PHP upload_max_filesize // Check file type/extension
if (file.size > UPLOAD_MAX_FILESIZE) { const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml', 'application/pdf'];
logs("File Manager. File size is to big for PHP configuration."); if (!validImageTypes.includes(file.type)) {
showAlertError("<?php echo $L->g('Maximum load file size allowed:') . ' ' . ini_get('upload_max_filesize') ?>"); logs("File Manager. File type is not supported.");
return false; showAlertError("<?php echo $L->g('File type is not supported. Allowed types:') . ' ' . implode(', ', $GLOBALS['ALLOWED_IMG_EXTENSIONS']) ?>");
} return false;
}
// Start progress bar // Check file size and compare with PHP upload_max_filesize
$('#btnUploadFile').addClass('d-none'); if (file.size > UPLOAD_MAX_FILESIZE) {
$('#progressUploadFile').removeClass('d-none'); logs("File Manager. File size is to big for PHP configuration.");
$('#progressUploadFile').children('.progress-bar').width('0'); showAlertError("<?php echo $L->g('Maximum load file size allowed:') . ' ' . ini_get('upload_max_filesize') ?>");
return false;
}
// Data to send via AJAX // Start progress bar
var formData = new FormData(); $('#btnUploadFile').addClass('d-none');
formData.append("file", file); $('#progressUploadFile').removeClass('d-none');
formData.append("token", api.body.token); $('#progressUploadFile').children('.progress-bar').width('0');
formData.append("authentication", api.body.authentication);
$.ajax({ // Data to send via AJAX
url: api.apiURL + 'pages/files/' + _pageKey, var formData = new FormData();
type: "POST", formData.append("file", file);
data: formData, formData.append("token", api.body.token);
cache: false, formData.append("authentication", api.body.authentication);
contentType: false,
processData: false,
xhr: function() {
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener("progress", function(e) {
if (e.lengthComputable) {
var percentComplete = (e.loaded / e.total) * 100;
$('#progressUploadFile').children('.progress-bar').width(percentComplete + '%');
}
}, false);
}
return xhr;
}
}).done(function(response) {
if (response.status == 0) {
logs("File Manager. File uploaded.");
// Progress bar
$('#progressUploadFile').addClass('d-none');
$('#btnUploadFile').removeClass('d-none');
// Get current files
fmGetFiles();
} else {
logs("File Manager. An error occurred while trying to upload the file.");
// Progress bar
$('#progressUploadFile').children('.progress-bar').addClass('bg-danger');
// Alert the user about the error
showAlertError('File Manager. ' + response.message);
}
});
}
// Initlization and events for the File Manager $.ajax({
$(document).ready(function() { url: api.apiURL + 'pages/files/' + _pageKey,
// Input file change event type: "POST",
$('#filesToUpload').on("change", function(e) { data: formData,
var filesToUpload = $('#filesToUpload')[0].files; cache: false,
for (var i = 0; i < filesToUpload.length; i++) { contentType: false,
fmUploadFile(filesToUpload[i]); processData: false,
} xhr: function() {
}); var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener("progress", function(e) {
if (e.lengthComputable) {
var percentComplete = (e.loaded / e.total) * 100;
$('#progressUploadFile').children('.progress-bar').width(percentComplete + '%');
}
}, false);
}
return xhr;
}
}).done(function(response) {
if (response.status == 0) {
logs("File Manager. File uploaded.");
// Progress bar
$('#progressUploadFile').addClass('d-none');
$('#btnUploadFile').removeClass('d-none');
// Get current files
fmGetFiles();
} else {
logs("File Manager. An error occurred while trying to upload the file.");
// Progress bar
$('#progressUploadFile').children('.progress-bar').addClass('bg-danger');
// Alert the user about the error
showAlertError('File Manager. ' + response.message);
}
});
}
// Drag and drop files to upload them // Initlization and events for the File Manager
$(window).on("dragover dragenter", function(e) { $(document).ready(function() {
e.preventDefault(); // Input file change event
e.stopPropagation(); $('#filesToUpload').on("change", function(e) {
fmOpen(); var filesToUpload = $('#filesToUpload')[0].files;
}); for (var i = 0; i < filesToUpload.length; i++) {
$(window).on("drop", function(e) { fmUploadFile(filesToUpload[i]);
e.preventDefault(); }
e.stopPropagation(); });
$('#filesToUpload').prop('files', e.originalEvent.dataTransfer.files);
$('#filesToUpload').trigger('change');
});
}); // Drag and drop files to upload them
$(window).on("dragover dragenter", function(e) {
e.preventDefault();
e.stopPropagation();
fmOpen();
});
$(window).on("drop", function(e) {
e.preventDefault();
e.stopPropagation();
$('#filesToUpload').prop('files', e.originalEvent.dataTransfer.files);
$('#filesToUpload').trigger('change');
});
});
</script> </script>

View file

@ -1,89 +1,89 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?> <?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<script> <script>
// ============================================================================ // ============================================================================
// Variables for the view // Variables for the view
// ============================================================================ // ============================================================================
// ============================================================================ // ============================================================================
// Functions for the view // Functions for the view
// ============================================================================ // ============================================================================
function activatePlugin(className) { function activatePlugin(className) {
var args = { var args = {
className: className className: className
}; };
api.activatePlugin(args).then(function(response) { api.activatePlugin(args).then(function(response) {
if (response.status == 0) { if (response.status == 0) {
logs('Plugin activated: ' + response.data.key); logs('Plugin activated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-settings/' ?>'+response.data.key); window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-settings/' ?>' + response.data.key);
} else { } else {
logs('An error occurred while trying to activate the plugin.'); logs('An error occurred while trying to activate the plugin.');
showAlertError(response.message); showAlertError(response.message);
} }
}); });
} }
function deactivatePlugin(className) { function deactivatePlugin(className) {
var args = { var args = {
className: className className: className
}; };
api.deactivatePlugin(args).then(function(response) { api.deactivatePlugin(args).then(function(response) {
if (response.status == 0) { if (response.status == 0) {
logs('Plugin deactivated: ' + response.data.key); logs('Plugin deactivated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins' ?>'); window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins' ?>');
} else { } else {
logs('An error occurred while trying to deactivate the plugin.'); logs('An error occurred while trying to deactivate the plugin.');
showAlertError(response.message); showAlertError(response.message);
} }
}); });
} }
// ============================================================================ // ============================================================================
// Events for the view // Events for the view
// ============================================================================ // ============================================================================
$(document).ready(function() { $(document).ready(function() {
$("#search").on("keyup", function() { $("#search").on("keyup", function() {
var textToSearch = $(this).val().toLowerCase(); var textToSearch = $(this).val().toLowerCase();
$(".searchItem").each(function() { $(".searchItem").each(function() {
var item = $(this); var item = $(this);
item.hide(); item.hide();
item.find(".searchText").each(function() { item.find(".searchText").each(function() {
var element = $(this).text().toLowerCase(); var element = $(this).text().toLowerCase();
if (element.indexOf(textToSearch) != -1) { if (element.indexOf(textToSearch) != -1) {
item.show(); item.show();
} }
}); });
}); });
}); });
$('.activatePlugin').on('click', function() { $('.activatePlugin').on('click', function() {
var className = $(this).data('class-name'); var className = $(this).data('class-name');
activatePlugin(className); activatePlugin(className);
}); });
$('.deactivatePlugin').on('click', function() { $('.deactivatePlugin').on('click', function() {
var className = $(this).data('class-name'); var className = $(this).data('class-name');
deactivatePlugin(className); deactivatePlugin(className);
}); });
}); });
// ============================================================================ // ============================================================================
// Initialization for the view // Initialization for the view
// ============================================================================ // ============================================================================
$(document).ready(function() { $(document).ready(function() {
// nothing here yet // nothing here yet
// how do you hang your toilet paper ? over or under ? // how do you hang your toilet paper ? over or under ?
}); });
</script> </script>
<div class="d-flex align-items-center mb-4"> <div class="d-flex align-items-center mb-4">
<h2 class="m-0"><i class="bi bi-node-plus"></i><?php $L->p('Plugins') ?></h2> <h2 class="m-0"><i class="bi bi-node-plus"></i><?php $L->p('Plugins') ?></h2>
<div class="ms-auto"> <div class="ms-auto">
<a id="btnNew" class="btn btn-primary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-position' ?>" role="button"><i class="bi bi-plus-circle"></i><?php $L->p('Change plugins position') ?></a> <a id="btnNew" class="btn btn-primary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-position' ?>" role="button"><i class="bi bi-plus-circle"></i><?php $L->p('Change plugins position') ?></a>
</div> </div>
</div> </div>
<?php echo Bootstrap::formTitle(array('icon' => 'search', 'title' => $L->g('Search plugins'))); ?> <?php echo Bootstrap::formTitle(array('icon' => 'search', 'title' => $L->g('Search plugins'))); ?>
@ -92,85 +92,74 @@
<?php <?php
// Plugins installed
echo Bootstrap::formTitle(array('icon' => 'check-square', 'title' => $L->g('Enabled plugins'))); echo Bootstrap::formTitle(array('icon' => 'check-square', 'title' => $L->g('Enabled plugins')));
echo '<table class="table table-striped"><tbody>';
echo '
<table class="table table-striped">
<tbody>
';
// Show installed plugins
foreach ($pluginsInstalled as $plugin) { foreach ($pluginsInstalled as $plugin) {
echo '<tr id="' . $plugin->className() . '" class="searchItem">'; echo '<tr id="' . $plugin->className() . '" class="searchItem">';
echo '<td class="align-middle pt-3 pb-3 w-25"> echo '<td class="align-middle pt-3 pb-3 w-25">';
<div class="searchText">' . $plugin->name() . '</div> echo '<div class="searchText">' . $plugin->name().'</div>';
<div class="mt-1">'; echo '<div class="mt-1">';
if (method_exists($plugin, 'form')) { if (method_exists($plugin, 'form')) {
echo '<a class="me-3" href="' . HTML_PATH_ADMIN_ROOT . 'plugins-settings/' . $plugin->className() . '">' . $L->g('Settings') . '</a>'; echo '<a class="me-3" href="' . HTML_PATH_ADMIN_ROOT . 'plugins-settings/' . $plugin->className() . '">' . $L->g('Settings') . '</a>';
} }
// You can not disable a plugin for an activated theme // You can not disable a plugin for theme which is active
if ($plugin->type()!='theme') { if ($plugin->type() != 'theme') {
echo '<span class="link deactivatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>'; echo '<span class="link deactivatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>';
} }
echo '</div>'; echo '</div>';
echo '</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo '<div>' . $plugin->description() . '</div>';
if (in_array($plugin->type(), array('dashboard','theme','editor'))) {
echo '<div class="badge bg-primary">'.$L->g($plugin->type()).'</div>';
}
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">';
echo '<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a>';
echo '</td>'; echo '</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">'; echo '</tr>';
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>';
echo '
</tbody>
</table>
';
echo Bootstrap::formTitle(array('icon' => 'dash-square', 'title' => $L->g('Disabled plugins')));
echo '
<table class="table table-striped">
<tbody>
';
// Plugins not installed // Plugins not installed
echo Bootstrap::formTitle(array('icon' => 'dash-square', 'title' => $L->g('Disabled plugins')));
echo '<table class="table table-striped"><tbody>';
$pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled); $pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled);
foreach ($pluginsNotInstalled as $plugin) { foreach ($pluginsNotInstalled as $plugin) {
echo '<tr id="' . $plugin->className() . '" class="searchItem">'; echo '<tr id="' . $plugin->className() . '" class="searchItem">';
echo '<td class="align-middle pt-3 pb-3 w-25"> echo '<td class="align-middle pt-3 pb-3 w-25">';
<div class="searchText">' . $plugin->name() . '</div> echo '<div class="searchText">' . $plugin->name() . '</div>';
<div class="mt-1"> echo '<div class="mt-1"><span class="link activatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Activate') . '</a></div>';
<span class="link activatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Activate') . '</a> echo '</td>';
</div>
</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">'; echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo $plugin->description(); echo '<div>' . $plugin->description() . '</div>';
if (in_array($plugin->type(), array('dashboard','theme','editor'))) {
echo '<div class="badge bg-primary">'.$L->g($plugin->type()).'</div>';
}
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">';
echo '<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a>';
echo '</td>'; echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">'; echo '</tr>';
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 ' echo '</tbody></table>';
</tbody>
</table>
';

View file

@ -42,6 +42,12 @@
args[key] = value; args[key] = value;
}); });
$('textarea[data-save="true"]').each(function() {
var key = $(this).attr('name');
var value = $(this).val();
args[key] = value;
});
api.saveSettings(args).then(function(response) { api.saveSettings(args).then(function(response) {
if (response.status == 0) { if (response.status == 0) {
logs('Settings saved.'); logs('Settings saved.');