Deactivate plugin via API
This commit is contained in:
parent
cd0446e080
commit
0f71046b92
10 changed files with 106 additions and 1384 deletions
|
@ -1,39 +0,0 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Check role
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
checkRole(array('admin'));
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Functions
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main before POST
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// POST Method
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main after POST
|
|
||||||
// ============================================================================
|
|
||||||
$pluginClassName = $layout['parameters'];
|
|
||||||
if (!activatePlugin($pluginClassName)) {
|
|
||||||
Log::set('Fail when try to activate the plugin.', LOG_TYPE_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($plugins['all'][$pluginClassName])) {
|
|
||||||
$plugin = $plugins['all'][$pluginClassName];
|
|
||||||
} else {
|
|
||||||
Redirect::page('plugins');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (method_exists($plugin, 'form')) {
|
|
||||||
Redirect::page('configure-plugin/'.$pluginClassName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Redirect::page('plugins#'.$pluginClassName);
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Check role
|
// Authorization
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
checkRole(array('admin'));
|
checkRole(array('admin'));
|
||||||
|
@ -11,8 +11,9 @@ checkRole(array('admin'));
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Main before POST
|
// Main
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
$plugin = false;
|
$plugin = false;
|
||||||
$pluginClassName = $layout['parameters'];
|
$pluginClassName = $layout['parameters'];
|
||||||
|
|
||||||
|
@ -28,26 +29,5 @@ if (!method_exists($plugin, 'form')) {
|
||||||
Redirect::page('plugins');
|
Redirect::page('plugins');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// HTML <title>
|
||||||
// POST Method
|
$layout['title'] = $L->g('Plugin'). ' [ ' .$plugin->name(). ' ] ' . ' - ' . $layout['title'];
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
||||||
// Add to syslog
|
|
||||||
$syslog->add(array(
|
|
||||||
'dictionaryKey'=>'plugin-configured',
|
|
||||||
'notes'=>$plugin->name()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Call the method post of the plugin
|
|
||||||
$plugin->post();
|
|
||||||
Alert::set( $L->g('The changes have been saved') );
|
|
||||||
Redirect::page('configure-plugin/'.$plugin->className());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main after POST
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// Title of the page
|
|
||||||
$layout['title'] = $L->g('Plugin').' - '.$plugin->name().' - '.$layout['title'];
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Check role
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
checkRole(array('admin'));
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Functions
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main before POST
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// POST Method
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main after POST
|
|
||||||
// ============================================================================
|
|
||||||
$pluginClassName = $layout['parameters'];
|
|
||||||
deactivatePlugin($pluginClassName);
|
|
||||||
Redirect::page('plugins');
|
|
|
@ -1,51 +0,0 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Functions
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main before POST
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// POST Method
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
||||||
// Prevent non-administrators to change other users
|
|
||||||
$username = $_POST['username'];
|
|
||||||
if ($login->role()!=='admin') {
|
|
||||||
$username = $login->username();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeUserPassword(array(
|
|
||||||
'username'=>$username,
|
|
||||||
'newPassword'=>$_POST['newPassword'],
|
|
||||||
'confirmPassword'=>$_POST['confirmPassword']
|
|
||||||
))) {
|
|
||||||
if ($login->role()==='admin') {
|
|
||||||
Redirect::page('users');
|
|
||||||
}
|
|
||||||
Redirect::page('edit-user/'.$login->username());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Main after POST
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// Prevent non-administrators to change other users
|
|
||||||
if ($login->role()!=='admin') {
|
|
||||||
$layout['parameters'] = $login->username();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$username = $layout['parameters'];
|
|
||||||
$user = new User($username);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Redirect::page('users');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Title of the page
|
|
||||||
$layout['title'] = $L->g('Change password').' - '.$layout['title'];
|
|
|
@ -1,644 +0,0 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
|
||||||
|
|
||||||
<div class="container-fluid h-100">
|
|
||||||
<div class="row h-100">
|
|
||||||
<div class="col-sm-9 h-100">
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
// Start form
|
|
||||||
echo Bootstrap::formOpen(array(
|
|
||||||
'id'=>'jsform',
|
|
||||||
'class'=>'d-flex flex-column h-100'
|
|
||||||
));
|
|
||||||
|
|
||||||
// Token CSRF
|
|
||||||
echo Bootstrap::formInputHidden(array(
|
|
||||||
'name'=>'tokenCSRF',
|
|
||||||
'value'=>$security->getTokenCSRF()
|
|
||||||
));
|
|
||||||
|
|
||||||
// UUID
|
|
||||||
// The UUID is generated in the controller
|
|
||||||
echo Bootstrap::formInputHidden(array(
|
|
||||||
'name'=>'uuid',
|
|
||||||
'value'=>$uuid
|
|
||||||
));
|
|
||||||
|
|
||||||
// Type = published, draft, sticky, static
|
|
||||||
echo Bootstrap::formInputHidden(array(
|
|
||||||
'name'=>'type',
|
|
||||||
'value'=>'published'
|
|
||||||
));
|
|
||||||
|
|
||||||
// Cover image
|
|
||||||
echo Bootstrap::formInputHidden(array(
|
|
||||||
'name'=>'coverImage',
|
|
||||||
'value'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
// Content
|
|
||||||
echo Bootstrap::formInputHidden(array(
|
|
||||||
'name'=>'content',
|
|
||||||
'value'=>''
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- TOOLBAR -->
|
|
||||||
<div id="editorToolbar" class="mb-1">
|
|
||||||
<div id="editorToolbarRight" class="btn-group btn-group-sm float-end" role="group" aria-label="Toolbar right">
|
|
||||||
<button type="button" class="btn btn-light" id="jsmediaManagerOpenModal" data-toggle="modal" data-target="#jsmediaManagerModal"><span class="bi-image"></span> <?php $L->p('Images') ?></button>
|
|
||||||
<button type="button" class="btn btn-light" id="jsoptionsSidebar" style="z-index:30"><span class="bi-cog"></span> <?php $L->p('Options') ?></button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="jseditorToolbarLeft">
|
|
||||||
<button id="jsbuttonSave" type="button" class="btn btn-sm btn-primary" ><?php $L->p('Save') ?></button>
|
|
||||||
<button id="jsbuttonPreview" type="button" class="btn btn-sm btn-secondary"><?php $L->p('Preview') ?></button>
|
|
||||||
<span id="jsbuttonSwitch" data-switch="publish" class="ms-2 text-secondary switch-button"><i class="bi-square switch-icon-publish"></i> <?php $L->p('Publish') ?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$("#jsoptionsSidebar").on("click", function() {
|
|
||||||
$("#jseditorSidebar").toggle();
|
|
||||||
$("#jsshadow").toggle();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsshadow").on("click", function() {
|
|
||||||
$("#jseditorSidebar").toggle();
|
|
||||||
$("#jsshadow").toggle();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- SIDEBAR OPTIONS -->
|
|
||||||
<div id="jseditorSidebar">
|
|
||||||
<nav>
|
|
||||||
<div class="nav nav-tabs" id="nav-tab" role="tablist">
|
|
||||||
<a class="nav-link active show" id="nav-general-tab" data-toggle="tab" href="#nav-general" role="tab" aria-controls="general"><?php $L->p('General') ?></a>
|
|
||||||
<a class="nav-link" id="nav-advanced-tab" data-toggle="tab" href="#nav-advanced" role="tab" aria-controls="advanced"><?php $L->p('Advanced') ?></a>
|
|
||||||
<?php if (!empty($site->customFields())): ?>
|
|
||||||
<a class="nav-link" id="nav-custom-tab" data-toggle="tab" href="#nav-custom" role="tab" aria-controls="custom"><?php $L->p('Custom') ?></a>
|
|
||||||
<?php endif ?>
|
|
||||||
<a class="nav-link" id="nav-seo-tab" data-toggle="tab" href="#nav-seo" role="tab" aria-controls="seo"><?php $L->p('SEO') ?></a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div class="tab-content pe-3 ps-3 pb-3">
|
|
||||||
<div id="nav-general" class="tab-pane fade show active" role="tabpanel" aria-labelledby="general-tab">
|
|
||||||
<?php
|
|
||||||
// Category
|
|
||||||
echo Bootstrap::formSelectBlock(array(
|
|
||||||
'name'=>'category',
|
|
||||||
'label'=>$L->g('Category'),
|
|
||||||
'selected'=>'',
|
|
||||||
'class'=>'',
|
|
||||||
'emptyOption'=>'- '.$L->g('Uncategorized').' -',
|
|
||||||
'options'=>$categories->getKeyNameArray()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Description
|
|
||||||
echo Bootstrap::formTextareaBlock(array(
|
|
||||||
'name'=>'description',
|
|
||||||
'label'=>$L->g('Description'),
|
|
||||||
'selected'=>'',
|
|
||||||
'class'=>'',
|
|
||||||
'value'=>'',
|
|
||||||
'rows'=>5,
|
|
||||||
'placeholder'=>$L->get('this-field-can-help-describe-the-content')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Cover Image -->
|
|
||||||
<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100"><?php $L->p('Cover Image') ?></label>
|
|
||||||
<div>
|
|
||||||
<img id="jscoverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />
|
|
||||||
</div>
|
|
||||||
<div class="mt-2 text-center">
|
|
||||||
<button type="button" id="jsbuttonSelectCoverImage" class="btn btn-primary btn-sm"><?php echo $L->g('Select cover image') ?></button>
|
|
||||||
<button type="button" id="jsbuttonRemoveCoverImage" class="btn btn-secondary btn-sm"><?php echo $L->g('Remove cover image') ?></button>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$("#jscoverImagePreview").on("click", function() {
|
|
||||||
openMediaManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsbuttonSelectCoverImage").on("click", function() {
|
|
||||||
openMediaManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsbuttonRemoveCoverImage").on("click", function() {
|
|
||||||
$("#jscoverImage").val('');
|
|
||||||
$("#jscoverImagePreview").attr('src', HTML_PATH_CORE_IMG+'default.svg');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
<div id="nav-advanced" class="tab-pane fade" role="tabpanel" aria-labelledby="advanced-tab">
|
|
||||||
<?php
|
|
||||||
// Date
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'date',
|
|
||||||
'label'=>$L->g('Date'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'value'=>Date::current(DB_DATE_FORMAT),
|
|
||||||
'tip'=>$L->g('date-format-format')
|
|
||||||
));
|
|
||||||
|
|
||||||
// Type
|
|
||||||
echo Bootstrap::formSelectBlock(array(
|
|
||||||
'name'=>'typeSelector',
|
|
||||||
'label'=>$L->g('Type'),
|
|
||||||
'selected'=>'',
|
|
||||||
'options'=>array(
|
|
||||||
'published'=>'- '.$L->g('Default').' -',
|
|
||||||
'sticky'=>$L->g('Sticky'),
|
|
||||||
'static'=>$L->g('Static')
|
|
||||||
),
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
// Position
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'position',
|
|
||||||
'label'=>$L->g('Position'),
|
|
||||||
'tip'=>$L->g('Field used when ordering content by position'),
|
|
||||||
'value'=>$pages->nextPositionNumber()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Tags
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'tags',
|
|
||||||
'label'=>$L->g('Tags'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Write the tags separated by comma')
|
|
||||||
));
|
|
||||||
|
|
||||||
// Parent
|
|
||||||
echo Bootstrap::formSelectBlock(array(
|
|
||||||
'name'=>'parent',
|
|
||||||
'label'=>$L->g('Parent'),
|
|
||||||
'options'=>array(),
|
|
||||||
'selected'=>false,
|
|
||||||
'class'=>'',
|
|
||||||
'tip'=>$L->g('Start typing a page title to see a list of suggestions.'),
|
|
||||||
));
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
var parent = $("#jsparent").select2({
|
|
||||||
placeholder: "",
|
|
||||||
allowClear: true,
|
|
||||||
theme: "bootstrap4",
|
|
||||||
minimumInputLength: 2,
|
|
||||||
ajax: {
|
|
||||||
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
|
|
||||||
data: function (params) {
|
|
||||||
var query = {
|
|
||||||
checkIsParent: true,
|
|
||||||
query: params.term
|
|
||||||
}
|
|
||||||
return query;
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
escapeMarkup: function(markup) {
|
|
||||||
return markup;
|
|
||||||
},
|
|
||||||
templateResult: function(data) {
|
|
||||||
var html = data.text;
|
|
||||||
if (data.type=="static") {
|
|
||||||
html += '<span class="badge badge-pill badge-light">'+data.type+'</span>';
|
|
||||||
}
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// Template
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'template',
|
|
||||||
'label'=>$L->g('Template'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'value'=>'',
|
|
||||||
'tip'=>$L->g('Write a template name to filter the page in the theme and change the style of the page.')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'externalCoverImage',
|
|
||||||
'label'=>$L->g('External cover image'),
|
|
||||||
'placeholder'=>"https://",
|
|
||||||
'value'=>'',
|
|
||||||
'tip'=>$L->g('Set a cover image from external URL, such as a CDN or some server dedicated for images.')
|
|
||||||
));
|
|
||||||
|
|
||||||
// Username
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'',
|
|
||||||
'label'=>$L->g('Author'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'value'=>$login->username(),
|
|
||||||
'tip'=>'',
|
|
||||||
'disabled'=>true
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
// Changes in External cover image input
|
|
||||||
$("#jsexternalCoverImage").change(function() {
|
|
||||||
$("#jscoverImage").val( $(this).val() );
|
|
||||||
});
|
|
||||||
|
|
||||||
// Generate slug when the user type the title
|
|
||||||
$("#jstitle").keyup(function() {
|
|
||||||
var text = $(this).val();
|
|
||||||
var parent = $("#jsparent").val();
|
|
||||||
var currentKey = "";
|
|
||||||
var ajax = new bluditAjax();
|
|
||||||
var callBack = $("#jsslug");
|
|
||||||
ajax.generateSlug(text, parent, currentKey, callBack);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Datepicker
|
|
||||||
$("#jsdate").datetimepicker({format:DB_DATE_FORMAT});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
<?php if (!empty($site->customFields())): ?>
|
|
||||||
<div id="nav-custom" class="tab-pane fade" role="tabpanel" aria-labelledby="custom-tab">
|
|
||||||
<?php
|
|
||||||
$customFields = $site->customFields();
|
|
||||||
foreach ($customFields as $field=>$options) {
|
|
||||||
if ( !isset($options['position']) ) {
|
|
||||||
if ($options['type']=="string") {
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'custom['.$field.']',
|
|
||||||
'label'=>(isset($options['label'])?$options['label']:''),
|
|
||||||
'value'=>(isset($options['default'])?$options['default']:''),
|
|
||||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
|
||||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:'')
|
|
||||||
));
|
|
||||||
} elseif ($options['type']=="bool") {
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
|
||||||
'name'=>'custom['.$field.']',
|
|
||||||
'label'=>(isset($options['label'])?$options['label']:''),
|
|
||||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
|
||||||
'checked'=>(isset($options['checked'])?true:false),
|
|
||||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:'')
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<?php endif ?>
|
|
||||||
<div id="nav-seo" class="tab-pane fade" role="tabpanel" aria-labelledby="seo-tab">
|
|
||||||
<?php
|
|
||||||
// Friendly URL
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'slug',
|
|
||||||
'tip'=>$L->g('URL associated with the content'),
|
|
||||||
'label'=>$L->g('Friendly URL'),
|
|
||||||
'placeholder'=>$L->g('Leave empty for autocomplete by Bludit.')
|
|
||||||
));
|
|
||||||
|
|
||||||
// Robots
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
|
||||||
'name'=>'noindex',
|
|
||||||
'label'=>'Robots',
|
|
||||||
'labelForCheckbox'=>$L->g('apply-code-noindex-code-to-this-page'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'checked'=>false,
|
|
||||||
'tip'=>$L->g('This tells search engines not to show this page in their search results.')
|
|
||||||
));
|
|
||||||
|
|
||||||
// Robots
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
|
||||||
'name'=>'nofollow',
|
|
||||||
'label'=>'',
|
|
||||||
'labelForCheckbox'=>$L->g('apply-code-nofollow-code-to-this-page'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'checked'=>false,
|
|
||||||
'tip'=>$L->g('This tells search engines not to follow links on this page.')
|
|
||||||
));
|
|
||||||
|
|
||||||
// Robots
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
|
||||||
'name'=>'noarchive',
|
|
||||||
'label'=>'',
|
|
||||||
'labelForCheckbox'=>$L->g('apply-code-noarchive-code-to-this-page'),
|
|
||||||
'placeholder'=>'',
|
|
||||||
'checked'=>false,
|
|
||||||
'tip'=>$L->g('This tells search engines not to save a cached copy of this page.')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Custom fields: TOP -->
|
|
||||||
<?php
|
|
||||||
$customFields = $site->customFields();
|
|
||||||
foreach ($customFields as $field=>$options) {
|
|
||||||
if ( isset($options['position']) && ($options['position']=='top') ) {
|
|
||||||
if ($options['type']=="string") {
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'custom['.$field.']',
|
|
||||||
'label'=>(isset($options['label'])?$options['label']:''),
|
|
||||||
'value'=>(isset($options['default'])?$options['default']:''),
|
|
||||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
|
||||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
|
||||||
'class'=>'mb-2',
|
|
||||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
|
||||||
|
|
||||||
));
|
|
||||||
} elseif ($options['type']=="bool") {
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
|
||||||
'name'=>'custom['.$field.']',
|
|
||||||
'label'=>(isset($options['label'])?$options['label']:''),
|
|
||||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
|
||||||
'checked'=>(isset($options['checked'])?true:false),
|
|
||||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
|
|
||||||
'class'=>'mb-2',
|
|
||||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Title -->
|
|
||||||
<div id="jseditorTitle" class="form-group mb-1">
|
|
||||||
<input id="jstitle" name="title" type="text" class="form-control form-control-lg rounded-0" value="" placeholder="<?php $L->p('Enter title') ?>">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Editor -->
|
|
||||||
<textarea id="jseditor" class="editable h-100 mb-1"></textarea>
|
|
||||||
|
|
||||||
<!-- Custom fields: BOTTOM -->
|
|
||||||
<?php
|
|
||||||
$customFields = $site->customFields();
|
|
||||||
foreach ($customFields as $field=>$options) {
|
|
||||||
if ( isset($options['position']) && ($options['position']=='bottom') ) {
|
|
||||||
if ($options['type']=="string") {
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
|
||||||
'name'=>'custom['.$field.']',
|
|
||||||
'label'=>(isset($options['label'])?$options['label']:''),
|
|
||||||
'value'=>(isset($options['default'])?$options['default']:''),
|
|
||||||
'tip'=>(isset($options['tip'])?$options['tip']:''),
|
|
||||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
|
||||||
'class'=>'mt-2',
|
|
||||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
|
||||||
|
|
||||||
));
|
|
||||||
} elseif ($options['type']=="bool") {
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
|
||||||
'name'=>'custom['.$field.']',
|
|
||||||
'label'=>(isset($options['label'])?$options['label']:''),
|
|
||||||
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
|
|
||||||
'checked'=>(isset($options['checked'])?true:false),
|
|
||||||
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
|
|
||||||
'class'=>'mt-2',
|
|
||||||
'labelClass'=>'mb-2 pb-2 border-bottom text-uppercase w-100'
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-sm-3 h-100 p-0">
|
|
||||||
|
|
||||||
<!-- Options -->
|
|
||||||
<div class="accordion" id="sidebarOptions">
|
|
||||||
|
|
||||||
<!-- Options > General -->
|
|
||||||
<div class="general card">
|
|
||||||
<div class="card-header m-0 p-2" id="headingOne">
|
|
||||||
<a href="#optionsGeneral" class="w-100 text-start text-uppercase fw-bold" data-toggle="collapse" data-target="#optionsGeneral" aria-expanded="true" aria-controls="optionsGeneral">
|
|
||||||
General <span class="float-end bi-angle-down"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="optionsGeneral" class="collapse" aria-labelledby="headingOne" data-parent="#sidebarOptions">
|
|
||||||
<div class="card-body m-0 p-0">
|
|
||||||
|
|
||||||
<!-- Options > General > Cover Image -->
|
|
||||||
<label class="mt-4 mb-2 pb-2 text-uppercase w-100 fw-bold"><?php $L->p('Cover Image') ?></label>
|
|
||||||
<div>
|
|
||||||
<img id="jscoverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$("#jscoverImagePreview").on("click", function() {
|
|
||||||
openMediaManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsbuttonSelectCoverImage").on("click", function() {
|
|
||||||
openMediaManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsbuttonRemoveCoverImage").on("click", function() {
|
|
||||||
$("#jscoverImage").val('');
|
|
||||||
$("#jscoverImagePreview").attr('src', HTML_PATH_CORE_IMG+'default.svg');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<!-- End Options > General > Cover Image -->
|
|
||||||
|
|
||||||
<!-- Options > General > Category and Description -->
|
|
||||||
<?php
|
|
||||||
// Category
|
|
||||||
echo Bootstrap::formSelectBlock(array(
|
|
||||||
'name'=>'category',
|
|
||||||
'label'=>$L->g('Category'),
|
|
||||||
'selected'=>'',
|
|
||||||
'class'=>'',
|
|
||||||
'emptyOption'=>'- '.$L->g('Uncategorized').' -',
|
|
||||||
'options'=>$categories->getKeyNameArray()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Description
|
|
||||||
echo Bootstrap::formTextareaBlock(array(
|
|
||||||
'name'=>'description',
|
|
||||||
'label'=>$L->g('Description'),
|
|
||||||
'selected'=>'',
|
|
||||||
'class'=>'',
|
|
||||||
'value'=>'',
|
|
||||||
'rows'=>5,
|
|
||||||
'placeholder'=>$L->get('this-field-can-help-describe-the-content')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
<!-- End Options > General > Category and Description -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- End Options > General -->
|
|
||||||
|
|
||||||
<!-- Options > Advanced -->
|
|
||||||
<div class="advanced card">
|
|
||||||
<div class="card-header m-0 p-2" id="headingOne">
|
|
||||||
<a href="#optionsAdvanced" class="w-100 text-start text-uppercase fw-bold" data-toggle="collapse" data-target="#optionsAdvanced" aria-expanded="true" aria-controls="optionsAdvanced">
|
|
||||||
Advanced <span class="float-end bi-angle-down"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="optionsAdvanced" class="collapse" aria-labelledby="headingOne" data-parent="#sidebarOptions">
|
|
||||||
<div class="card-body m-0 p-0">
|
|
||||||
|
|
||||||
<!-- Options > General > Cover Image -->
|
|
||||||
<label class="mt-4 mb-2 pb-2 border-bottom text-uppercase w-100"><?php $L->p('Cover Image') ?></label>
|
|
||||||
<div>
|
|
||||||
<img id="jscoverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$("#jscoverImagePreview").on("click", function() {
|
|
||||||
openMediaManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsbuttonSelectCoverImage").on("click", function() {
|
|
||||||
openMediaManager();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jsbuttonRemoveCoverImage").on("click", function() {
|
|
||||||
$("#jscoverImage").val('');
|
|
||||||
$("#jscoverImagePreview").attr('src', HTML_PATH_CORE_IMG+'default.svg');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<!-- End Options > General > Cover Image -->
|
|
||||||
|
|
||||||
<!-- Options > General > Category and Description -->
|
|
||||||
<?php
|
|
||||||
// Category
|
|
||||||
echo Bootstrap::formSelectBlock(array(
|
|
||||||
'name'=>'category',
|
|
||||||
'label'=>$L->g('Category'),
|
|
||||||
'selected'=>'',
|
|
||||||
'class'=>'',
|
|
||||||
'emptyOption'=>'- '.$L->g('Uncategorized').' -',
|
|
||||||
'options'=>$categories->getKeyNameArray()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Description
|
|
||||||
echo Bootstrap::formTextareaBlock(array(
|
|
||||||
'name'=>'description',
|
|
||||||
'label'=>$L->g('Description'),
|
|
||||||
'selected'=>'',
|
|
||||||
'class'=>'',
|
|
||||||
'value'=>'',
|
|
||||||
'rows'=>5,
|
|
||||||
'placeholder'=>$L->get('this-field-can-help-describe-the-content')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
<!-- End Options > General > Category and Description -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- End Options > General -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<!-- End Options -->
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Modal for Media Manager -->
|
|
||||||
<?php include(PATH_ADMIN_THEMES.'booty/html/media.php'); ?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
// Define function if they doesn't exist
|
|
||||||
// This helps if the user doesn't activate any plugin as editor
|
|
||||||
if (typeof editorGetContent != "function") {
|
|
||||||
window.editorGetContent = function(){
|
|
||||||
return $("#jseditor").val();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (typeof editorInsertMedia != "function") {
|
|
||||||
window.editorInsertMedia = function(filename){
|
|
||||||
$("#jseditor").val($('#jseditor').val()+'<img src="'+filename+'" alt="">');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Button switch
|
|
||||||
$("#jsbuttonSwitch").on("click", function() {
|
|
||||||
if ($(this).data("switch")=="publish") {
|
|
||||||
$(this).html('<i class="bi-square switch-icon-draft"></i> <?php $L->p('Draft') ?>');
|
|
||||||
$(this).data("switch", "draft");
|
|
||||||
} else {
|
|
||||||
$(this).html('<i class="bi-square switch-icon-publish"></i> <?php $L->p('Publish') ?>');
|
|
||||||
$(this).data("switch", "publish");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Button preview
|
|
||||||
$("#jsbuttonPreview").on("click", function() {
|
|
||||||
var uuid = $("#jsuuid").val();
|
|
||||||
var title = $("#jstitle").val();
|
|
||||||
var content = editorGetContent();
|
|
||||||
bluditAjax.saveAsDraft(uuid, title, content).then(function(data) {
|
|
||||||
var preview = window.open("<?php echo DOMAIN_PAGES.'autosave-'.$uuid.'?preview='.md5('autosave-'.$uuid) ?>", "bludit-preview");
|
|
||||||
preview.focus();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Button Save
|
|
||||||
$("#jsbuttonSave").on("click", function() {
|
|
||||||
// If the switch is setted to "published", get the value from the selector
|
|
||||||
if ($("#jsbuttonSwitch").data("switch")=="publish") {
|
|
||||||
var value = $("#jstypeSelector option:selected").val();
|
|
||||||
$("#jstype").val(value);
|
|
||||||
} else {
|
|
||||||
$("#jstype").val("draft");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the content
|
|
||||||
$("#jscontent").val( editorGetContent() );
|
|
||||||
|
|
||||||
// Submit the form
|
|
||||||
$("#jsform").submit();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Autosave
|
|
||||||
var currentContent = editorGetContent();
|
|
||||||
setInterval(function() {
|
|
||||||
var uuid = $("#jsuuid").val();
|
|
||||||
var title = $("#jstitle").val() + "[<?php $L->p('Autosave') ?>]";
|
|
||||||
var content = editorGetContent();
|
|
||||||
// Autosave when content has at least 100 characters
|
|
||||||
if (content.length<100) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Autosave only when the user change the content
|
|
||||||
if (currentContent!=content) {
|
|
||||||
currentContent = content;
|
|
||||||
bluditAjax.saveAsDraft(uuid, title, content).then(function(data) {
|
|
||||||
if (data.status==0) {
|
|
||||||
showAlert("<?php $L->p('Autosave') ?>");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},1000*60*AUTOSAVE_INTERVAL);
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -24,6 +24,21 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deactivatePlugin(pluginClassName) {
|
||||||
|
var args = {
|
||||||
|
pluginClassName: pluginClassName
|
||||||
|
};
|
||||||
|
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
|
// Events for the view
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -48,6 +63,11 @@
|
||||||
activatePlugin(pluginClassName);
|
activatePlugin(pluginClassName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.deactivatePlugin').on('click', function() {
|
||||||
|
var pluginClassName = $(this).data('class-name');
|
||||||
|
deactivatePlugin(pluginClassName);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -87,9 +107,9 @@ foreach ($pluginsInstalled as $plugin) {
|
||||||
<div class="searchText">' . $plugin->name() . '</div>
|
<div class="searchText">' . $plugin->name() . '</div>
|
||||||
<div class="mt-1">';
|
<div class="mt-1">';
|
||||||
if (method_exists($plugin, 'form')) {
|
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 class="me-3" href="' . HTML_PATH_ADMIN_ROOT . 'plugins-settings/' . $plugin->className() . '">' . $L->g('Settings') . '</a>';
|
||||||
}
|
}
|
||||||
echo '<a href="' . HTML_PATH_ADMIN_ROOT . 'uninstall-plugin/' . $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>';
|
||||||
|
|
||||||
|
|
|
@ -1,568 +0,0 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
|
||||||
|
|
||||||
<div class="align-middle">
|
|
||||||
<div class="float-end mt-1">
|
|
||||||
<button type="submit" class="btn btn-primary btn-sm" name="save"><?php $L->p('Save') ?></button>
|
|
||||||
<a class="btn btn-secondary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>" role="button"><?php $L->p('Cancel') ?></a>
|
|
||||||
</div>
|
|
||||||
<?php echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog')); ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Tabs -->
|
|
||||||
<nav>
|
|
||||||
<div class="nav nav-tabs ps-3" id="nav-tab" role="tablist">
|
|
||||||
<a class="nav-item nav-link active" id="nav-general-tab" data-toggle="tab" href="#general" role="tab" aria-controls="nav-general" aria-selected="false"><?php $L->p('General') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-advanced-tab" data-toggle="tab" href="#advanced" role="tab" aria-controls="nav-advanced" aria-selected="false"><?php $L->p('Advanced') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-seo-tab" data-toggle="tab" href="#seo" role="tab" aria-controls="nav-seo" aria-selected="false"><?php $L->p('SEO') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-social-tab" data-toggle="tab" href="#social" role="tab" aria-controls="nav-social" aria-selected="false"><?php $L->p('Social Networks') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-images-tab" data-toggle="tab" href="#images" role="tab" aria-controls="nav-images" aria-selected="false"><?php $L->p('Images') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-language-tab" data-toggle="tab" href="#language" role="tab" aria-controls="nav-language" aria-selected="false"><?php $L->p('Language') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-custom-fields-tab" data-toggle="tab" href="#custom-fields" role="tab" aria-controls="nav-custom-fields" aria-selected="false"><?php $L->p('Custom fields') ?></a>
|
|
||||||
<a class="nav-item nav-link" id="nav-logo-tab" data-toggle="tab" href="#logo" role="tab" aria-controls="nav-logo" aria-selected="false"><?php $L->p('Logo') ?></a>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<!-- End Tabs -->
|
|
||||||
|
|
||||||
<div class="tab-content" id="myTabContent">
|
|
||||||
|
|
||||||
<!-- General tab -->
|
|
||||||
<div class="tab-pane fade show active pt-1 pb-1 ps-3 pe-3" id="general" role="tabpanel" aria-labelledby="general-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Site')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'title',
|
|
||||||
'label'=>$L->g('Site title'),
|
|
||||||
'value'=>$site->title(),
|
|
||||||
'tip'=>$L->g('use-this-field-to-name-your-site')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'slogan',
|
|
||||||
'label'=>$L->g('Site slogan'),
|
|
||||||
'value'=>$site->slogan(),
|
|
||||||
'tip'=>$L->g('use-this-field-to-add-a-catchy-phrase')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'description',
|
|
||||||
'label'=>$L->g('Site description'),
|
|
||||||
'value'=>$site->description(),
|
|
||||||
'tip'=>$L->g('you-can-add-a-site-description-to-provide')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'footer',
|
|
||||||
'label'=>$L->g('Footer text'),
|
|
||||||
'value'=>$site->footer(),
|
|
||||||
'tip'=>$L->g('you-can-add-a-small-text-on-the-bottom')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Content')));
|
|
||||||
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'itemsPerPage',
|
|
||||||
'label'=>$L->g('Items per page'),
|
|
||||||
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All content')),
|
|
||||||
'selected'=>$site->itemsPerPage(),
|
|
||||||
'tip'=>$L->g('Number of items to show per page')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'orderBy',
|
|
||||||
'label'=>$L->g('Order content by'),
|
|
||||||
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
|
|
||||||
'selected'=>$site->orderBy(),
|
|
||||||
'tip'=>$L->g('order-the-content-by-date-to-build-a-blog')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<!-- End General tab -->
|
|
||||||
|
|
||||||
<!-- Advanced tab -->
|
|
||||||
<div class="tab-pane fade pt-1 pb-1 ps-3 pe-3" id="advanced" role="tabpanel" aria-labelledby="advanced-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Page content')));
|
|
||||||
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'markdownParser',
|
|
||||||
'label'=>$L->g('Markdown parser'),
|
|
||||||
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
|
|
||||||
'selected'=>($site->markdownParser()?'true':'false'),
|
|
||||||
'tip'=>$L->g('Enable the markdown parser for the content of the page.')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Predefined pages')));
|
|
||||||
|
|
||||||
// Homepage
|
|
||||||
try {
|
|
||||||
$options = array();
|
|
||||||
$homeKey = $site->homepage();
|
|
||||||
if (!empty($homeKey)) {
|
|
||||||
$home = new Page($homeKey);
|
|
||||||
$options = array($homeKey=>$home->title());
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'homepage',
|
|
||||||
'label'=>$L->g('Homepage'),
|
|
||||||
'options'=>$options,
|
|
||||||
'selected'=>false,
|
|
||||||
'class'=>'',
|
|
||||||
'tip'=>$L->g('Returning page for the main page')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
var homepage = $("#jshomepage").select2({
|
|
||||||
placeholder: "<?php $L->p('Start typing to see a list of suggestions.') ?>",
|
|
||||||
allowClear: true,
|
|
||||||
theme: "bootstrap4",
|
|
||||||
minimumInputLength: 2,
|
|
||||||
ajax: {
|
|
||||||
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
|
|
||||||
data: function (params) {
|
|
||||||
var query = { query: params.term }
|
|
||||||
return query;
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
escapeMarkup: function(markup) {
|
|
||||||
return markup;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// Page not found 404
|
|
||||||
try {
|
|
||||||
$options = array();
|
|
||||||
$pageNotFoundKey = $site->pageNotFound();
|
|
||||||
if (!empty($pageNotFoundKey)) {
|
|
||||||
$pageNotFound = new Page($pageNotFoundKey);
|
|
||||||
$options = array($pageNotFoundKey=>$pageNotFound->title());
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// continue
|
|
||||||
}
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'pageNotFound',
|
|
||||||
'label'=>$L->g('Page not found'),
|
|
||||||
'options'=>$options,
|
|
||||||
'selected'=>false,
|
|
||||||
'class'=>'',
|
|
||||||
'tip'=>$L->g('Returning page when the page doesnt exist')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
$(document).ready(function() {
|
|
||||||
var homepage = $("#jspageNotFound").select2({
|
|
||||||
placeholder: "<?php $L->p('Start typing to see a list of suggestions.') ?>",
|
|
||||||
allowClear: true,
|
|
||||||
theme: "bootstrap4",
|
|
||||||
minimumInputLength: 2,
|
|
||||||
ajax: {
|
|
||||||
url: HTML_PATH_ADMIN_ROOT+"ajax/get-published",
|
|
||||||
data: function (params) {
|
|
||||||
var query = { query: params.term }
|
|
||||||
return query;
|
|
||||||
},
|
|
||||||
processResults: function (data) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
escapeMarkup: function(markup) {
|
|
||||||
return markup;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Email account settings')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'emailFrom',
|
|
||||||
'label'=>$L->g('Sender email'),
|
|
||||||
'value'=>$site->emailFrom(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Emails will be sent from this address')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Autosave')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'autosaveInterval',
|
|
||||||
'label'=>$L->g('Interval'),
|
|
||||||
'value'=>$site->autosaveInterval(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Number in minutes for every execution of autosave')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Site URL')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'url',
|
|
||||||
'label'=>'URL',
|
|
||||||
'value'=>$site->url(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('full-url-of-your-site'),
|
|
||||||
'placeholder'=>'https://'
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'uriPage',
|
|
||||||
'label'=>$L->g('Pages'),
|
|
||||||
'value'=>$site->uriFilters('page'),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>DOMAIN_PAGES
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'uriTag',
|
|
||||||
'label'=>$L->g('Tags'),
|
|
||||||
'value'=>$site->uriFilters('tag'),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>DOMAIN_TAGS
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'uriCategory',
|
|
||||||
'label'=>$L->g('Category'),
|
|
||||||
'value'=>$site->uriFilters('category'),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>DOMAIN_CATEGORIES
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'uriBlog',
|
|
||||||
'label'=>$L->g('Blog'),
|
|
||||||
'value'=>$site->uriFilters('blog'),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>DOMAIN.$site->uriFilters('blog'),
|
|
||||||
'disabled'=>Text::isEmpty($site->uriFilters('blog'))
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- SEO tab -->
|
|
||||||
<div class="tab-pane fade" id="seo" role="tabpanel" aria-labelledby="seo-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Extreme friendly URL')));
|
|
||||||
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'extremeFriendly',
|
|
||||||
'label'=>$L->g('Allow Unicode'),
|
|
||||||
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
|
|
||||||
'selected'=>($site->extremeFriendly()?'true':'false'),
|
|
||||||
'class'=>'',
|
|
||||||
'tip'=>$L->g('Allow unicode characters in the URL and some part of the system.')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Title formats')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'titleFormatHomepage',
|
|
||||||
'label'=>$L->g('Homepage'),
|
|
||||||
'value'=>$site->titleFormatHomepage(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Variables allowed').' <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
|
||||||
'placeholder'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'titleFormatPages',
|
|
||||||
'label'=>$L->g('Pages'),
|
|
||||||
'value'=>$site->titleFormatPages(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Variables allowed').' <code>{{page-title}}</code> <code>{{page-description}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
|
||||||
'placeholder'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'titleFormatCategory',
|
|
||||||
'label'=>$L->g('Category'),
|
|
||||||
'value'=>$site->titleFormatCategory(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Variables allowed').' <code>{{category-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
|
||||||
'placeholder'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'titleFormatTag',
|
|
||||||
'label'=>$L->g('Tag'),
|
|
||||||
'value'=>$site->titleFormatTag(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Variables allowed').' <code>{{tag-name}}</code> <code>{{site-title}}</code> <code>{{site-slogan}}</code> <code>{{site-description}}</code>',
|
|
||||||
'placeholder'=>''
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Social Network tab -->
|
|
||||||
<div class="tab-pane fade" id="social" role="tabpanel" aria-labelledby="social-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'twitter',
|
|
||||||
'label'=>'Twitter',
|
|
||||||
'value'=>$site->twitter(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'facebook',
|
|
||||||
'label'=>'Facebook',
|
|
||||||
'value'=>$site->facebook(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'codepen',
|
|
||||||
'label'=>'CodePen',
|
|
||||||
'value'=>$site->codepen(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'instagram',
|
|
||||||
'label'=>'Instagram',
|
|
||||||
'value'=>$site->instagram(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'gitlab',
|
|
||||||
'label'=>'GitLab',
|
|
||||||
'value'=>$site->gitlab(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'github',
|
|
||||||
'label'=>'GitHub',
|
|
||||||
'value'=>$site->github(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'linkedin',
|
|
||||||
'label'=>'LinkedIn',
|
|
||||||
'value'=>$site->linkedin(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'xing',
|
|
||||||
'label'=>'Xing',
|
|
||||||
'value'=>$site->xing(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'mastodon',
|
|
||||||
'label'=>'Mastodon',
|
|
||||||
'value'=>$site->mastodon(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'dribbble',
|
|
||||||
'label'=>'Dribbble',
|
|
||||||
'value'=>$site->dribbble(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'vk',
|
|
||||||
'label'=>'VK',
|
|
||||||
'value'=>$site->vk(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Images tab -->
|
|
||||||
<div class="tab-pane fade" id="images" role="tabpanel" aria-labelledby="images-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Thumbnails')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'thumbnailWidth',
|
|
||||||
'label'=>$L->g('Width'),
|
|
||||||
'value'=>$site->thumbnailWidth(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Thumbnail width in pixels')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'thumbnailHeight',
|
|
||||||
'label'=>$L->g('Height'),
|
|
||||||
'value'=>$site->thumbnailHeight(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Thumbnail height in pixels')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'thumbnailQuality',
|
|
||||||
'label'=>$L->g('Quality'),
|
|
||||||
'value'=>$site->thumbnailQuality(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Thumbnail quality in percentage')
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Timezone and language tab -->
|
|
||||||
<div class="tab-pane fade" id="language" role="tabpanel" aria-labelledby="language-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Language and timezone')));
|
|
||||||
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'language',
|
|
||||||
'label'=>$L->g('Language'),
|
|
||||||
'options'=>$L->getLanguageList(),
|
|
||||||
'selected'=>$site->language(),
|
|
||||||
'class'=>'',
|
|
||||||
'tip'=>$L->g('select-your-sites-language')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'timezone',
|
|
||||||
'label'=>$L->g('Timezone'),
|
|
||||||
'options'=>Date::timezoneList(),
|
|
||||||
'selected'=>$site->timezone(),
|
|
||||||
'class'=>'',
|
|
||||||
'tip'=>$L->g('select-a-timezone-for-a-correct')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'locale',
|
|
||||||
'label'=>$L->g('Locale'),
|
|
||||||
'value'=>$site->locale(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('with-the-locales-you-can-set-the-regional-user-interface')
|
|
||||||
));
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Date and time formats')));
|
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'dateFormat',
|
|
||||||
'label'=>$L->g('Date format'),
|
|
||||||
'value'=>$site->dateFormat(),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('Current format').': '.Date::current($site->dateFormat())
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Custom fields -->
|
|
||||||
<div class="tab-pane fade" id="custom-fields" role="tabpanel" aria-labelledby="custom-fields-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Custom fields')));
|
|
||||||
|
|
||||||
echo Bootstrap::formTextarea(array(
|
|
||||||
'name'=>'customFields',
|
|
||||||
'label'=>'JSON Format',
|
|
||||||
'value'=>json_encode($site->customFields(), JSON_PRETTY_PRINT),
|
|
||||||
'class'=>'',
|
|
||||||
'placeholder'=>'',
|
|
||||||
'tip'=>$L->g('define-custom-fields-for-the-content'),
|
|
||||||
'rows'=>15
|
|
||||||
));
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Site logo tab -->
|
|
||||||
<div class="tab-pane fade" id="logo" role="tabpanel" aria-labelledby="logo-tab">
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Site logo')));
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-4 col-sm-12 p-0 pe-2">
|
|
||||||
<div class="custom-file">
|
|
||||||
<input id="jssiteLogoInputFile" class="custom-file-input" type="file" name="inputFile">
|
|
||||||
<label for="jssiteLogoInputFile" class="custom-file-label"><?php $L->p('Upload image'); ?></label>
|
|
||||||
</div>
|
|
||||||
<button id="jsbuttonRemoveLogo" type="button" class="btn btn-primary w-100 mt-4 mb-4"><i class="bi-trash"></i><?php $L->p('Remove logo') ?></button>
|
|
||||||
</div>
|
|
||||||
<div class="col-lg-8 col-sm-12 p-0 text-center">
|
|
||||||
<img id="jssiteLogoPreview" class="img-fluid img-thumbnail" alt="Site logo preview" src="<?php echo ($site->logo()?DOMAIN_UPLOADS.$site->logo(false).'?version='.time():HTML_PATH_CORE_IMG.'default.svg') ?>" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
$("#jsbuttonRemoveLogo").on("click", function() {
|
|
||||||
bluditAjax.removeLogo();
|
|
||||||
$("#jssiteLogoPreview").attr("src", "<?php echo HTML_PATH_CORE_IMG.'default.svg' ?>");
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#jssiteLogoInputFile").on("change", function() {
|
|
||||||
var formData = new FormData();
|
|
||||||
formData.append('tokenCSRF', tokenCSRF);
|
|
||||||
formData.append('inputFile', $(this)[0].files[0]);
|
|
||||||
$.ajax({
|
|
||||||
url: HTML_PATH_ADMIN_ROOT+"ajax/logo-upload",
|
|
||||||
type: "POST",
|
|
||||||
data: formData,
|
|
||||||
cache: false,
|
|
||||||
contentType: false,
|
|
||||||
processData: false
|
|
||||||
}).done(function(data) {
|
|
||||||
if (data.status==0) {
|
|
||||||
$("#jssiteLogoPreview").attr('src',data.absoluteURL+"?time="+Math.random());
|
|
||||||
} else {
|
|
||||||
showAlert(data.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
|
|
|
@ -531,6 +531,34 @@ function activatePlugin($pluginClassName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Uninstall and deactivate a plugin === Bludit v4
|
||||||
|
|
||||||
|
@pluginClassName string The plugin PHP class name
|
||||||
|
@return string/bool Returns TRUE on successful install, FALSE otherwise
|
||||||
|
*/
|
||||||
|
function deactivatePlugin($pluginClassName) {
|
||||||
|
global $plugins;
|
||||||
|
global $syslog;
|
||||||
|
|
||||||
|
if (!isset($plugins['all'][$pluginClassName])) {
|
||||||
|
Log::set(__FUNCTION__.LOG_SEP.'The plugin doesn\'t exist: '.$pluginClassName, LOG_TYPE_ERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$plugin = $plugins['all'][$pluginClassName];
|
||||||
|
if ($plugin->uninstall()) {
|
||||||
|
$syslog->add(array(
|
||||||
|
'dictionaryKey'=>'plugin-deactivated',
|
||||||
|
'notes'=>$plugin->name()
|
||||||
|
));
|
||||||
|
Log::set(__FUNCTION__.LOG_SEP.'Plugin uninstalled.', LOG_TYPE_INFO);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::set(__FUNCTION__.LOG_SEP.'Not was possible uninstall the plugin.', LOG_TYPE_ERROR);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Re-index database of categories
|
// Re-index database of categories
|
||||||
// If you create/edit/remove a page is necessary regenerate the database of categories
|
// If you create/edit/remove a page is necessary regenerate the database of categories
|
||||||
function reindexCategories() {
|
function reindexCategories() {
|
||||||
|
@ -737,33 +765,6 @@ function pluginActivated($pluginClassName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Deactivate / uninstall the plugin
|
|
||||||
// Returns TRUE if the plugin is successfully deactivated, FALSE otherwise
|
|
||||||
function deactivatePlugin($pluginClassName) {
|
|
||||||
global $plugins;
|
|
||||||
global $syslog;
|
|
||||||
global $L;
|
|
||||||
|
|
||||||
// Check if the plugin exists
|
|
||||||
if (isset($plugins['all'][$pluginClassName])) {
|
|
||||||
$plugin = $plugins['all'][$pluginClassName];
|
|
||||||
|
|
||||||
if ($plugin->uninstall()) {
|
|
||||||
// Add to syslog
|
|
||||||
$syslog->add(array(
|
|
||||||
'dictionaryKey'=>'plugin-deactivated',
|
|
||||||
'notes'=>$plugin->name()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Create an alert
|
|
||||||
Alert::set($L->g('plugin-deactivated'));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function deactivateAllPlugin() {
|
function deactivateAllPlugin() {
|
||||||
global $plugins;
|
global $plugins;
|
||||||
global $syslog;
|
global $syslog;
|
||||||
|
|
|
@ -295,8 +295,8 @@ class API {
|
||||||
|
|
||||||
/* Install and activate a plugin === Bludit v4
|
/* Install and activate a plugin === Bludit v4
|
||||||
|
|
||||||
@args array Arguments can be any of the fields from a category
|
@args array
|
||||||
@return string New category key
|
@return string
|
||||||
*/
|
*/
|
||||||
async activatePlugin(args) {
|
async activatePlugin(args) {
|
||||||
var url = this.apiURL + "plugins/" + args['pluginClassName'];
|
var url = this.apiURL + "plugins/" + args['pluginClassName'];
|
||||||
|
@ -318,4 +318,29 @@ class API {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Uninstall and deactivate a plugin === Bludit v4
|
||||||
|
|
||||||
|
@args array
|
||||||
|
@return string
|
||||||
|
*/
|
||||||
|
async deactivatePlugin(args) {
|
||||||
|
var url = this.apiURL + "plugins/" + args['pluginClassName'];
|
||||||
|
var body = Object.assign({}, this.body, args);
|
||||||
|
try {
|
||||||
|
var response = await fetch(url, {
|
||||||
|
credentials: "same-origin",
|
||||||
|
method: "DELETE",
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
headers: new Headers({
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
var json = await response.json();
|
||||||
|
return json;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -270,6 +270,11 @@ class pluginAPI extends Plugin {
|
||||||
$pluginClassName = $parmB;
|
$pluginClassName = $parmB;
|
||||||
$data = $this->activatePlugin($pluginClassName);
|
$data = $this->activatePlugin($pluginClassName);
|
||||||
}
|
}
|
||||||
|
// (DELETE) /api/plugins/:key
|
||||||
|
elseif ( ($method==='DELETE') && ($parmA==='plugins') && !empty($parmB) ) {
|
||||||
|
$pluginClassName = $parmB;
|
||||||
|
$data = $this->deactivatePlugin($pluginClassName);
|
||||||
|
}
|
||||||
// (GET) /api/helper/:name
|
// (GET) /api/helper/:name
|
||||||
elseif ( ($method==='GET') && ($parmA==='helper') && !empty($parmB) ) {
|
elseif ( ($method==='GET') && ($parmA==='helper') && !empty($parmB) ) {
|
||||||
$name = $parmB;
|
$name = $parmB;
|
||||||
|
@ -939,4 +944,23 @@ class pluginAPI extends Plugin {
|
||||||
'message'=>'An error occurred while trying to install the plugin.'
|
'message'=>'An error occurred while trying to install the plugin.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Uninstall and deactivate a plugin === Bludit v4
|
||||||
|
Referer to the function deactivatePlugin() from functions.php
|
||||||
|
*/
|
||||||
|
private function deactivatePlugin($pluginClassName)
|
||||||
|
{
|
||||||
|
if (deactivatePlugin($pluginClassName)) {
|
||||||
|
return array(
|
||||||
|
'status'=>'0',
|
||||||
|
'message'=>'Plugin uninstalled and deactivated.',
|
||||||
|
'data'=>array('key'=>$pluginClassName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'status'=>'1',
|
||||||
|
'message'=>'An error occurred while trying to uninstall the plugin.'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue