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 $static;
global $sticky;
global $unlisted;
if ($type == 'published') {
$list = $published;
@ -113,6 +114,14 @@ function table($type)
echo '</p>';
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') {
$list = $sticky;
if (empty($list)) {
@ -234,6 +243,9 @@ function table($type)
} ?>
</a>
</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">
<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>
@ -295,6 +307,11 @@ function table($type)
<?php table('scheduled'); ?>
</div>
<!-- TABS UNLISTED -->
<div class="tab-pane" id="unlisted" role="tabpanel">
<?php table('unlisted'); ?>
</div>
<!-- TABS DRAFT -->
<div class="tab-pane" id="draft" role="tabpanel">
<?php table('draft'); ?>

View file

@ -134,8 +134,11 @@
var args = {
title: $('#title').val(),
content: editorGetContent(),
coverImage: $('#coverImage').val(),
category: $('#category option:selected').val(),
tags: $('#tags').val()
tags: $("#tags option:selected").map(function() {
return this.value
}).get().join(",")
}
savePage(args);
disableBtnSave();
@ -177,6 +180,7 @@
var args = {
title: $('#title').val(),
content: editorGetContent(),
coverImage: $('#coverImage').val(),
category: $('#category option:selected').val(),
tags: $("#tags option:selected").map(function() {
return this.value
@ -288,7 +292,9 @@
// ------------------------------------------------------------------------
$('#btnSaveSeo').on('click', function() {
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);
disableBtnSave();
@ -594,7 +600,8 @@
<!-- Cover Image -->
<h6 class="text-uppercase"><?php $L->p('Cover Image') ?></h6>
<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>
<!-- End Cover Image -->

View file

@ -1,224 +1,233 @@
<div class="modal" id="modal-fileManager" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col">
<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>
<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 class="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<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>
<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 class="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">Preview</th>
<th scope="col">Filename</th>
<th scope="col">Type</th>
<th scope="col">Size</th>
<th scope="col"></th>
</tr>
</thead>
<tbody id="fmFiles">
<!-- <tr>
<td class="align-middle">
<img style="width: 32px" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />
</td>
<td class="align-middle">photo.jpg</td>
<td class="align-middle">image/jpeg</td>
<td class="align-middle">300Kb</td>
<td class="align-middle">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false">
Options
</button>
<ul class="dropdown-menu" aria-labelledby="fileOptions">
<li><a class="dropdown-item" href="#">Insert</a></li>
<li><a class="dropdown-item" href="#">Set as cover image</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#"><?php $L->p('Delete') ?></a></li>
</ul>
</div>
</td>
</tr> -->
</tbody>
</table>
<table class="table">
<thead>
<tr>
<th scope="col">Preview</th>
<th scope="col">Filename</th>
<th scope="col">Type</th>
<th scope="col">Size</th>
<th scope="col"></th>
</tr>
</thead>
<tbody id="fmFiles">
<!-- <tr>
<td class="align-middle">
<img style="width: 32px" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />
</td>
<td class="align-middle">photo.jpg</td>
<td class="align-middle">image/jpeg</td>
<td class="align-middle">300Kb</td>
<td class="align-middle">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false">
Options
</button>
<ul class="dropdown-menu" aria-labelledby="fileOptions">
<li><a class="dropdown-item" href="#">Insert</a></li>
<li><a class="dropdown-item" href="#">Set as cover image</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#"><?php $L->p('Delete') ?></a></li>
</ul>
</div>
</td>
</tr> -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Open File Manager modal
function fmOpen() {
$('#modal-fileManager').modal('show');
}
// Open File Manager modal
function fmOpen() {
$('#modal-fileManager').modal('show');
}
// Close File Manager modal
function fmClose() {
$('#modal-fileManager').modal('hide');
}
// Close File Manager modal
function fmClose() {
$('#modal-fileManager').modal('hide');
}
// Insert HTML code in the Editor content
function fmInsertFile(filename, absoluteURL, mime) {
if (mime == 'image/jpeg' || mime == 'image/png') {
editorInsertContent(absoluteURL, 'image');
} else {
editorInsertContent('<a href="' + absoluteURL + '">' + filename + '</a>');
}
}
// Insert HTML code in the Editor content
function fmInsertFile(filename, absoluteURL, mime) {
if (mime == 'image/jpeg' || mime == 'image/png') {
editorInsertContent(absoluteURL, 'image');
} else {
editorInsertContent('<a href="' + absoluteURL + '">' + filename + '</a>');
}
}
// Get the files for the current page and show them
function fmGetFiles() {
logs('File Manager. Getting files for the current page: ' + _pageKey);
api.getPageFiles({
'pageKey': _pageKey
}).then(function(response) {
if (response.status == 0) {
fmDisplayFiles(response.data);
} else {
logs("File Manager. An error occurred while trying to get the files for the current page.");
showAlertError(response.message);
}
});
}
// Get the files for the current page and show them
function fmGetFiles() {
logs('File Manager. Getting files for the current page: ' + _pageKey);
api.getPageFiles({
'pageKey': _pageKey
}).then(function(response) {
if (response.status == 0) {
fmDisplayFiles(response.data);
} else {
logs("File Manager. An error occurred while trying to get the files for the current page.");
showAlertError(response.message);
}
});
}
// Displays the files in the table
function fmDisplayFiles(files) {
$('#fmFiles').empty();
function setCoverImage(filename) {
var image = DOMAIN_UPLOADS_PAGES+_pageKey+'/'+filename;
$("#coverImage").val(filename);
$("#coverImagePreview").attr("src", image);
}
if (files.length == 0) {
logs('File Manager. There are not files for the current page.');
return false;
}
// Displays the files in the table
function fmDisplayFiles(files) {
$('#fmFiles').empty();
$.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" 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);
});
if (files.length == 0) {
logs('File Manager. There are not files for the current page.');
return false;
}
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
function fmUploadFile(file) {
logs('File Manager. Uploading file.');
return true;
}
// Check file type/extension
const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml', 'application/pdf'];
if (!validImageTypes.includes(file.type)) {
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;
}
// Upload a file for the current page
function fmUploadFile(file) {
logs('File Manager. Uploading file.');
// Check file size and compare with PHP upload_max_filesize
if (file.size > UPLOAD_MAX_FILESIZE) {
logs("File Manager. File size is to big for PHP configuration.");
showAlertError("<?php echo $L->g('Maximum load file size allowed:') . ' ' . ini_get('upload_max_filesize') ?>");
return false;
}
// Check file type/extension
const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml', 'application/pdf'];
if (!validImageTypes.includes(file.type)) {
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;
}
// Start progress bar
$('#btnUploadFile').addClass('d-none');
$('#progressUploadFile').removeClass('d-none');
$('#progressUploadFile').children('.progress-bar').width('0');
// Check file size and compare with PHP upload_max_filesize
if (file.size > UPLOAD_MAX_FILESIZE) {
logs("File Manager. File size is to big for PHP configuration.");
showAlertError("<?php echo $L->g('Maximum load file size allowed:') . ' ' . ini_get('upload_max_filesize') ?>");
return false;
}
// Data to send via AJAX
var formData = new FormData();
formData.append("file", file);
formData.append("token", api.body.token);
formData.append("authentication", api.body.authentication);
// Start progress bar
$('#btnUploadFile').addClass('d-none');
$('#progressUploadFile').removeClass('d-none');
$('#progressUploadFile').children('.progress-bar').width('0');
$.ajax({
url: api.apiURL + 'pages/files/' + _pageKey,
type: "POST",
data: formData,
cache: false,
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);
}
});
}
// Data to send via AJAX
var formData = new FormData();
formData.append("file", file);
formData.append("token", api.body.token);
formData.append("authentication", api.body.authentication);
// Initlization and events for the File Manager
$(document).ready(function() {
// Input file change event
$('#filesToUpload').on("change", function(e) {
var filesToUpload = $('#filesToUpload')[0].files;
for (var i = 0; i < filesToUpload.length; i++) {
fmUploadFile(filesToUpload[i]);
}
});
$.ajax({
url: api.apiURL + 'pages/files/' + _pageKey,
type: "POST",
data: formData,
cache: false,
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);
}
});
}
// 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');
});
// Initlization and events for the File Manager
$(document).ready(function() {
// Input file change event
$('#filesToUpload').on("change", function(e) {
var filesToUpload = $('#filesToUpload')[0].files;
for (var i = 0; i < filesToUpload.length; i++) {
fmUploadFile(filesToUpload[i]);
}
});
});
// 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>

View file

@ -1,89 +1,89 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<script>
// ============================================================================
// Variables for the view
// ============================================================================
// ============================================================================
// Variables for the view
// ============================================================================
// ============================================================================
// Functions for the view
// ============================================================================
// ============================================================================
// Functions for the view
// ============================================================================
function activatePlugin(className) {
var args = {
className: className
};
api.activatePlugin(args).then(function(response) {
if (response.status == 0) {
logs('Plugin activated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-settings/' ?>'+response.data.key);
} else {
logs('An error occurred while trying to activate the plugin.');
showAlertError(response.message);
}
});
}
function activatePlugin(className) {
var args = {
className: className
};
api.activatePlugin(args).then(function(response) {
if (response.status == 0) {
logs('Plugin activated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-settings/' ?>' + response.data.key);
} else {
logs('An error occurred while trying to activate the plugin.');
showAlertError(response.message);
}
});
}
function deactivatePlugin(className) {
var args = {
className: className
};
api.deactivatePlugin(args).then(function(response) {
if (response.status == 0) {
logs('Plugin deactivated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins' ?>');
} else {
logs('An error occurred while trying to deactivate the plugin.');
showAlertError(response.message);
}
});
}
function deactivatePlugin(className) {
var args = {
className: className
};
api.deactivatePlugin(args).then(function(response) {
if (response.status == 0) {
logs('Plugin deactivated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins' ?>');
} else {
logs('An error occurred while trying to deactivate the plugin.');
showAlertError(response.message);
}
});
}
// ============================================================================
// Events for the view
// ============================================================================
$(document).ready(function() {
// ============================================================================
// Events for the view
// ============================================================================
$(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();
}
});
});
});
$("#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();
}
});
});
});
$('.activatePlugin').on('click', function() {
var className = $(this).data('class-name');
activatePlugin(className);
});
$('.activatePlugin').on('click', function() {
var className = $(this).data('class-name');
activatePlugin(className);
});
$('.deactivatePlugin').on('click', function() {
var className = $(this).data('class-name');
deactivatePlugin(className);
});
$('.deactivatePlugin').on('click', function() {
var className = $(this).data('class-name');
deactivatePlugin(className);
});
});
});
// ============================================================================
// Initialization for the view
// ============================================================================
$(document).ready(function() {
// nothing here yet
// how do you hang your toilet paper ? over or under ?
});
// ============================================================================
// Initialization for the view
// ============================================================================
$(document).ready(function() {
// nothing here yet
// how do you hang your toilet paper ? over or under ?
});
</script>
<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>
<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>
</div>
<h2 class="m-0"><i class="bi bi-node-plus"></i><?php $L->p('Plugins') ?></h2>
<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>
</div>
</div>
<?php echo Bootstrap::formTitle(array('icon' => 'search', 'title' => $L->g('Search plugins'))); ?>
@ -92,85 +92,74 @@
<?php
// Plugins installed
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) {
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">
<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 . 'plugins-settings/' . $plugin->className() . '">' . $L->g('Settings') . '</a>';
}
// You can not disable a plugin for an activated theme
if ($plugin->type()!='theme') {
echo '<span class="link deactivatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>';
}
echo '</div>';
echo '<td class="align-middle pt-3 pb-3 w-25">';
echo '<div class="searchText">' . $plugin->name().'</div>';
echo '<div class="mt-1">';
if (method_exists($plugin, 'form')) {
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 theme which is active
if ($plugin->type() != 'theme') {
echo '<span class="link deactivatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>';
}
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 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 '</tr>';
}
echo '
</tbody>
</table>
';
echo Bootstrap::formTitle(array('icon' => 'dash-square', 'title' => $L->g('Disabled plugins')));
echo '
<table class="table table-striped">
<tbody>
';
echo '</tbody></table>';
// 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);
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">
<div class="searchText">' . $plugin->name() . '</div>
<div class="mt-1">
<span class="link activatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Activate') . '</a>
</div>
</td>';
echo '<td class="align-middle pt-3 pb-3 w-25">';
echo '<div class="searchText">' . $plugin->name() . '</div>';
echo '<div class="mt-1"><span class="link activatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Activate') . '</a></div>';
echo '</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo $plugin->description();
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 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 '</tr>';
}
echo '
</tbody>
</table>
';
echo '</tbody></table>';

View file

@ -42,6 +42,12 @@
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) {
if (response.status == 0) {
logs('Settings saved.');