bug fixes

This commit is contained in:
Diego Najar 2021-09-05 16:18:01 +02:00
parent 7a96a8f1af
commit cf4e0cc755
33 changed files with 2681 additions and 2580 deletions

View file

@ -7,10 +7,13 @@ Complete here.
### Bludit version
Complete here.
### Hosting or Webserver name
Complete here.
### PHP version
If you do not know delete this line.
### PHP logs
If you do not know delete this line.
The default settings of the PHP Error Log file varies from OS to OS. The location of the error log file itself can be set manually in the php.ini file. On a Windows server, in IIS, it may be something like `error_log = C:\log_files\php_errors.log` in Linux it may be a value of `/var/log/php_errors.log`.
The default settings for the PHP error log file vary from operating system to system. The location of the error log file itself can be set manually in the php.ini file. On a Windows server, in IIS, it may be something like `error_log = C:\log_files\php_errors.log` in Linux it may be a value of `/var/log/php_errors.log`.

View file

@ -39,5 +39,5 @@ PHPStan
-------
https://phpstan.org/
```
docker run --rm -v $(pwd):/app ghcr.io/phpstan/phpstan:0.12.89 analyse -c /app/phpstan.neon /app
docker run --rm -v $(pwd):/app ghcr.io/phpstan/phpstan:0.12.96 analyse -c /app/phpstan.neon /app
```

View file

@ -6,6 +6,7 @@ class dbJSON {
public $dbBackup;
public $file;
public $firstLine;
protected $dbFields; // These fields are defined in the extended classes
// $file, the JSON file.
// $firstLine, TRUE if you want to remove the first line, FALSE otherwise
@ -101,7 +102,7 @@ class dbJSON {
{
// NULL is returned if the json cannot be decoded
$decode = json_decode($data, true);
if ($decode===NULL) {
if ($decode===null) {
Log::set(__METHOD__.LOG_SEP.'Error trying to read the JSON file: '.$this->file, LOG_TYPE_ERROR);
return false;
}

View file

@ -30,11 +30,6 @@ a.nav-link:hover,
border-color: #dee2e6;
}
.list-group-item {
background-color: inherit;
border: 0 none;
}
.list-group-item a {
text-decoration: none;
}

View file

@ -14,6 +14,7 @@
<?php
echo HTML::cssBootstrap();
echo HTML::cssBootstrapIcons();
echo HTML::cssSelect2();
echo HTML::css(array(
'01-bludit.css',
'02-bootstrap-hacks.css'
@ -22,8 +23,6 @@
echo HTML::css(array(
'jquery.datetimepicker.min.css',
'jquery-ui.min.css',
'select2.min.css',
'select2-bootstrap4.min.css',
'tagsinput-revisited.min.css'
), DOMAIN_CORE_CSS);
@ -44,10 +43,10 @@
echo HTML::jsBootstrap();
echo HTML::jsSortable();
echo HTML::bootbox();
echo HTML::jsSelect2();
echo HTML::js(array(
'jquery.datetimepicker.full.min.js',
'jquery-ui.min.js',
'select2.full.min.js',
'tagsinput-revisited.min.js',
'functions.js',
'api.js'

View file

@ -49,7 +49,7 @@ foreach ($categories->keys() as $key) {
try {
$category = new Category($key);
echo '<tr>';
echo '<td class="pt-4 pb-4"><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$key.'">'.$category->name().'</a></td>';
echo '<td class="pt-4 pb-4"><i class="bi bi-bookmark"></i><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$key.'">'.$category->name().'</a></td>';
echo '<td class="pt-4 pb-4"><span>'.$category->description().'</span></td>';
echo '<td class="pt-4 pb-4"><a href="'.$category->permalink().'">'.$category->permalink().'</a></td>';
echo '</tr>';

View file

@ -134,7 +134,7 @@ function table($type)
echo '<td class="pt-4 pb-4">
<div>
<span>' . ($page->title() ? $page->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ') . '</span>
<i class="bi bi-file-text"></i><span>' . ($page->title() ? $page->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ') . '</span>
</div>
<div class="mt-1">
<a class="me-2" target="_blank" href="' . $page->permalink() . '">' . $L->g('View') . '</a>
@ -160,7 +160,7 @@ function table($type)
echo '<td class="ps-3 pt-4 pb-4">
<div>
<span>' . ($child->title() ? $child->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ') . '</span>
<i class="bi bi-file-text"></i><span>' . ($child->title() ? $child->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ') . '</span>
</div>
<div class="mt-1">
<a class="me-2" target="_blank" href="' . $child->permalink() . '">' . $L->g('View') . '</a>
@ -188,7 +188,7 @@ function table($type)
echo '<td class="pt-4 pb-4">
<div>
' . ($page->title() ? $page->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ') . '
<i class="bi bi-file-text"></i>' . ($page->title() ? $page->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ') . '
</div>
<div class="mt-1">
<a class="me-2" target="_blank" href="' . $page->permalink() . '">' . $L->g('View') . '</a>

View file

@ -1,5 +1,7 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
<?php createPage(array()); ?>
<script>
// ============================================================================
// Variables for the view

View file

@ -28,7 +28,7 @@
echo Bootstrap::pageTitle(array('title'=>$L->g('Developers'), 'icon'=>'gears'));
echo '<h2 class="mb-4 mt-4"><b>PHP version: '.phpversion().'</b></h2>';
echo '<h2 class="mt-4 mb-4"><b>PHP version: '.phpversion().'</b></h2>';
// PHP Ini
$uploadOptions = array(

View file

@ -85,26 +85,38 @@
return true;
}
// Open the modal and store the current value
// The current value is store to recover it if the user click on the button "Cancel"
/*
Open the modal and store the current value
The current value is store to recover it if the user click on the button "Cancel"
*/
function openModal(fieldName) {
var value = $('#' + fieldName).val();
localStorage.setItem(fieldName, value);
$('#modal-' + fieldName).modal('show');
}
// Close the modal when the user click in the button "Cancel"
// The function also recover the old value
function closeModal(fieldName) {
/*
Close the modal
The function also recover the old value
*/
function closeModal(fieldName, revertValue=false) {
if (revertValue) {
var value = localStorage.getItem(fieldName);
$('#' + fieldName).val(value);
}
$('#modal-' + fieldName).modal('hide');
}
/*
Disable the "Save" button
*/
function disableBtnSave() {
$('#btnSave').addClass('btn-primary-disabled').attr('data-current', 'saved').html('<i class="bi bi-check-square"></i><?php $L->p('Saved') ?>');
}
/*
Enable the "Save" button
*/
function enableBtnSave() {
$('#btnSave').removeClass('btn-primary-disabled').attr('data-current', 'unsaved').html('<i class="bi bi-save"></i><?php $L->p('Save') ?>');
}
@ -194,7 +206,7 @@
});
$('#btnCancelDescription').on('click', function() {
closeModal('description');
closeModal('description', true);
});
// Modal date events
@ -209,7 +221,7 @@
});
$('#btnCancelDate').on('click', function() {
closeModal('date');
closeModal('date', true);
});
// Modal friendly-url events
@ -224,7 +236,7 @@
});
$('#btnCancelFriendlyURL').on('click', function() {
closeModal('friendlyURL');
closeModal('friendlyURL', true);
});
$('#btnGenURLFromTitle').on('click', function() {
@ -269,7 +281,7 @@
});
$('#btnCancelType').on('click', function() {
closeModal('type');
closeModal('type', true);
});
// Modal SEO events
@ -284,7 +296,7 @@
});
$('#btnCancelSeo').on('click', function() {
closeModal('seo');
closeModal('seo', true);
});
// Modal parent events
@ -299,7 +311,7 @@
});
$('#btnCancelParent').on('click', function() {
closeModal('parent');
closeModal('parent', true);
});
});
@ -328,6 +340,37 @@
disableBtnSave();
}, 1000 * 60 * AUTOSAVE_INTERVAL);
$("#parent").select2({
placeholder: '',
allowClear: true,
theme: 'bootstrap-5',
minimumInputLength: 2,
dropdownParent: $('#modal-parent'),
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>
@ -487,10 +530,8 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="m-0">
<label for="parent" class="fw-bold mb-2">Parent page</label>
<select id="parent" name="parent" class="custom-select"></select>
<div class="form-text"><?php echo $L->g('Start typing a page title to see a list of suggestions.') ?></div>
<div class="col-sm-10">
<select id="parent" name="parent" class="form-select" data-current-value="" data-save="true"></select>
</div>
</div>
<div class="modal-footer ps-2 pe-2 pt-1 pb-1">
@ -500,44 +541,11 @@
</div>
</div>
</div>
<script>
$(document).ready(function() {
var parent = $("#parent").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>
<!-- End Modal Parent -->
<div class="container-fluid h-100">
<div class="row h-100">
<div class="col-sm-9 d-flex flex-column h-100">
<div class="col-sm-9 d-flex flex-column" style="height: 85%">
<!-- Toolbar > Save, Preview, Type and Options -->
<div id="editorToolbar" class="d-flex align-items-center mb-2">
@ -645,13 +653,13 @@
<h6 class="text-uppercase mt-4">More options</h6>
<ul class="list-group">
<li class="list-group-item p-0 pt-3"><a onclick="fmOpen()" href="#"><i class="bi bi-files"></i>Files & images</a></li>
<li class="list-group-item p-0 pt-3"><a onclick="openModal('description')" href="#"><i class="bi bi-info-square"></i>Description</a></li>
<li class="list-group-item p-0 pt-3"><a onclick="openModal('date')" href="#"><i class="bi bi-calendar"></i>Publish date</a></li>
<li class="list-group-item p-0 pt-3"><a onclick="openModal('friendlyURL')" href="#"><i class="bi bi-link"></i>Change URL</a></li>
<li class="list-group-item p-0 pt-3"><a onclick="openModal('type')" href="#"><i class="bi bi-eye"></i>Type</a></li>
<li class="list-group-item p-0 pt-3"><a onclick="openModal('seo')" href="#"><i class="bi bi-compass"></i>SEO features</a></li>
<li class="list-group-item p-0 pt-3"><a onclick="openModal('parent')" href="#"><i class="bi bi-diagram-2"></i>Parent page</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="fmOpen()" href="#"><i class="bi bi-files"></i>Files & images</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="openModal('description')" href="#"><i class="bi bi-info-square"></i>Description</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="openModal('date')" href="#"><i class="bi bi-calendar"></i>Publish date</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="openModal('friendlyURL')" href="#"><i class="bi bi-link"></i>Change URL</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="openModal('type')" href="#"><i class="bi bi-eye"></i>Type</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="openModal('seo')" href="#"><i class="bi bi-compass"></i>SEO features</a></li>
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="openModal('parent')" href="#"><i class="bi bi-diagram-2"></i>Parent page</a></li>
</ul>

View file

@ -104,9 +104,10 @@
}
$.each(files, function(key, file) {
console.log(file);
var row = '<tr>' +
'<td class="align-middle">' +
' <img style="width: 32px" src="<?php echo HTML_PATH_CORE_IMG ?>default.svg" />' +
' <img style="width: 32px" src="'+ file.thumbnailSmall +'" />' +
'</td>' +
'<td class="align-middle">' + file.filename + '</td>' +
'<td class="align-middle">' + file.mime + '</td>' +

View file

@ -145,8 +145,45 @@
// Initlization for the view
// ============================================================================
$(document).ready(function() {
// nothing here yet
// how do you hang your toilet paper ? over or under ?
$("#homepage").select2({
placeholder: "Search for a page",
allowClear: true,
theme: "bootstrap-5",
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;
}
}
});
$("#pageNotFound").select2({
placeholder: "Search for a page",
allowClear: true,
theme: "bootstrap-5",
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>
@ -288,19 +325,37 @@
echo Bootstrap::formTitle(array('title' => $L->g('Predefined pages')));
try {
$options = array();
if (!empty($site->homepage())) {
$tmp = new Page($site->homepage());
$options = array($site->homepage()=>$tmp->title());
}
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelect(array(
'name' => 'homepage',
'label' => $L->g('Homepage'),
'options' => array(), // Complete via Ajax
'options' => $options, // Complete via Ajax
'selected' => false,
'tip' => $L->g('Returning page for the main page'),
'data' => array('save' => 'true')
));
try {
$options = array();
if (!empty($site->pageNotFound())) {
$tmp = new Page($site->pageNotFound());
$options = array($site->pageNotFound()=>$tmp->title());
}
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelect(array(
'name' => 'pageNotFound',
'label' => $L->g('Page not found'),
'options' => array(), // Complete via Ajax
'options' => $options, // Complete via Ajax
'selected' => false,
'tip' => $L->g('Returning page when the page doesnt exist'),
'data' => array('save' => 'true')
@ -516,28 +571,54 @@
<!-- Images tab -->
<div class="tab-pane" id="images" role="tabpanel" aria-labelledby="images-tab">
<?php
echo Bootstrap::formTitle(array('title' => $L->g('Thumbnails')));
echo Bootstrap::formTitle(array('title' => $L->g('Thumbnail small')));
echo Bootstrap::formInputText(array(
'name' => 'thumbnailWidth',
'name' => 'thumbnailSmallWidth',
'label' => $L->g('Width'),
'value' => $site->thumbnailWidth(),
'value' => $site->thumbnailSmallWidth(),
'tip' => $L->g('Thumbnail width in pixels'),
'data' => array('save' => 'true')
));
echo Bootstrap::formInputText(array(
'name' => 'thumbnailHeight',
'name' => 'thumbnailSmallHeight',
'label' => $L->g('Height'),
'value' => $site->thumbnailHeight(),
'value' => $site->thumbnailSmallHeight(),
'tip' => $L->g('Thumbnail height in pixels'),
'data' => array('save' => 'true')
));
echo Bootstrap::formInputText(array(
'name' => 'thumbnailQuality',
'name' => 'thumbnailSmallQuality',
'label' => $L->g('Quality'),
'value' => $site->thumbnailQuality(),
'value' => $site->thumbnailSmallQuality(),
'tip' => $L->g('Thumbnail quality in percentage'),
'data' => array('save' => 'true')
));
echo Bootstrap::formTitle(array('title' => $L->g('Thumbnail medium')));
echo Bootstrap::formInputText(array(
'name' => 'thumbnailMediumWidth',
'label' => $L->g('Width'),
'value' => $site->thumbnailMediumWidth(),
'tip' => $L->g('Thumbnail width in pixels'),
'data' => array('save' => 'true')
));
echo Bootstrap::formInputText(array(
'name' => 'thumbnailMediumHeight',
'label' => $L->g('Height'),
'value' => $site->thumbnailMediumHeight(),
'tip' => $L->g('Thumbnail height in pixels'),
'data' => array('save' => 'true')
));
echo Bootstrap::formInputText(array(
'name' => 'thumbnailMediumQuality',
'label' => $L->g('Quality'),
'value' => $site->thumbnailMediumQuality(),
'tip' => $L->g('Thumbnail quality in percentage'),
'data' => array('save' => 'true')
));

View file

@ -52,7 +52,7 @@ foreach ($list as $username) {
try {
$user = new User($username);
echo '<tr>';
echo '<td class="pt-4 pb-4"><a href="'.HTML_PATH_ADMIN_ROOT.'edit-user/'.$username.'">'.$username.'</a></td>';
echo '<td class="pt-4 pb-4"><i class="bi bi-person"></i><a href="'.HTML_PATH_ADMIN_ROOT.'edit-user/'.$username.'">'.$username.'</a></td>';
echo '<td class="pt-4 pb-4 d-none d-lg-table-cell">'.$user->nickname().'</td>';
echo '<td class="pt-4 pb-4">'.$user->email().'</td>';
echo '<td class="pt-4 pb-4">'.($user->enabled()?'<b>'.$L->g('Enabled').'</b>':'<b class="text-danger">'.$L->g('Disabled').'</b>').'</td>';

View file

@ -48,5 +48,3 @@ foreach ($pagesKey as $pageKey) {
}
exit (json_encode(array('results'=>$result)));
?>

View file

@ -44,7 +44,6 @@ define('PATH_WORKSPACES', PATH_CONTENT.'workspaces'.DS);
define('PATH_UPLOADS_PAGES', PATH_UPLOADS.'pages'.DS);
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
define('PATH_UPLOADS_THUMBNAILS',PATH_UPLOADS.'thumbnails'.DS);
define('PATH_ADMIN', PATH_KERNEL.'admin'.DS);
define('PATH_ADMIN_THEMES', PATH_ADMIN.'themes'.DS);
@ -172,8 +171,7 @@ define('HTML_PATH_CORE_IMG', HTML_PATH_ROOT.'bl-kernel/img/');
define('HTML_PATH_CONTENT', HTML_PATH_ROOT.'bl-content/');
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'bl-content/uploads/');
define('HTML_PATH_UPLOADS_PAGES', HTML_PATH_UPLOADS.'pages/');
define('HTML_PATH_UPLOADS_PROFILES', HTML_PATH_UPLOADS.'profiles/');
define('HTML_PATH_UPLOADS_THUMBNAILS', HTML_PATH_UPLOADS.'thumbnails/');
define('HTML_PATH_UPLOADS_PROFILES',HTML_PATH_UPLOADS.'profiles/');
define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
// --- Objects with dependency ---
@ -236,7 +234,6 @@ define('DOMAIN_ADMIN_THEME_JS', DOMAIN.HTML_PATH_ADMIN_THEME_JS);
define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS);
define('DOMAIN_UPLOADS_PAGES', DOMAIN.HTML_PATH_UPLOADS_PAGES);
define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES);
define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
define('DOMAIN_PLUGINS', DOMAIN.HTML_PATH_PLUGINS);
define('DOMAIN_CONTENT', DOMAIN.HTML_PATH_CONTENT);

View file

@ -5,42 +5,42 @@
// ============================================================================
$plugins = array(
'siteHead'=>array(),
'siteBodyBegin'=>array(),
'siteBodyEnd'=>array(),
'siteSidebar'=>array(),
'beforeSiteLoad'=>array(),
'afterSiteLoad'=>array(),
'siteHead' => array(),
'siteBodyBegin' => array(),
'siteBodyEnd' => array(),
'siteSidebar' => array(),
'beforeSiteLoad' => array(),
'afterSiteLoad' => array(),
'pageBegin'=>array(),
'pageEnd'=>array(),
'pageBegin' => array(),
'pageEnd' => array(),
'beforeAdminLoad'=>array(),
'afterAdminLoad'=>array(),
'adminHead'=>array(),
'adminBodyBegin'=>array(),
'adminBodyEnd'=>array(),
'adminSidebar'=>array(),
'adminContentSidebar'=>array(),
'dashboard'=>array(),
'beforeAdminLoad' => array(),
'afterAdminLoad' => array(),
'adminHead' => array(),
'adminBodyBegin' => array(),
'adminBodyEnd' => array(),
'adminSidebar' => array(),
'adminContentSidebar' => array(),
'dashboard' => array(),
'beforeAll'=>array(),
'afterAll'=>array(),
'beforeAll' => array(),
'afterAll' => array(),
'paginator'=>array(),
'paginator' => array(),
'beforePageModify'=>array(),
'beforePageDelete'=>array(),
'beforePageModify' => array(),
'beforePageDelete' => array(),
'afterPageCreate'=>array(),
'afterPageModify'=>array(),
'afterPageDelete'=>array(),
'afterPageCreate' => array(),
'afterPageModify' => array(),
'afterPageDelete' => array(),
'loginHead'=>array(),
'loginBodyBegin'=>array(),
'loginBodyEnd'=>array(),
'loginHead' => array(),
'loginBodyBegin' => array(),
'loginBodyEnd' => array(),
'all'=>array() // $plugins['all'] keep installed and not installed plugins
'all' => array() // $plugins['all'] keep installed and not installed plugins
);
// This array has only the installed plugins
@ -69,8 +69,8 @@ function buildPlugins()
// Load plugins clasess
$list = Filesystem::listDirectories(PATH_PLUGINS);
foreach ($list as $pluginPath) {
if (file_exists($pluginPath.DS.'plugin.php')) {
include_once($pluginPath.DS.'plugin.php');
if (file_exists($pluginPath . DS . 'plugin.php')) {
include_once($pluginPath . DS . 'plugin.php');
}
}
@ -81,17 +81,17 @@ function buildPlugins()
$Plugin = new $pluginClass;
// Check if the plugin is translated
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$site->language().'.json';
$languageFilename = PATH_PLUGINS . $Plugin->directoryName() . DS . 'languages' . DS . $site->language() . '.json';
if (!Sanitize::pathFile($languageFilename)) {
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
$languageFilename = PATH_PLUGINS . $Plugin->directoryName() . DS . 'languages' . DS . DEFAULT_LANGUAGE_FILE;
}
$database = file_get_contents($languageFilename);
$database = json_decode($database, true);
// Set name and description from the language file
$Plugin->setMetadata('name',$database['plugin-data']['name']);
$Plugin->setMetadata('description',$database['plugin-data']['description']);
$Plugin->setMetadata('name', $database['plugin-data']['name']);
$Plugin->setMetadata('description', $database['plugin-data']['description']);
// Remove name and description from the language and includes new words to the global language dictionary
unset($database['plugin-data']);
@ -117,7 +117,7 @@ function buildPlugins()
}
// Insert the plugin into the hooks
foreach ($pluginsHooks as $hook=>$value) {
foreach ($pluginsHooks as $hook => $value) {
if (method_exists($Plugin, $hook)) {
array_push($plugins[$hook], $Plugin);
}
@ -125,14 +125,18 @@ function buildPlugins()
}
// Sort the plugins by the position for the site sidebar
uasort($plugins['siteSidebar'], function ($a, $b) {
return $a->position()>$b->position();
uasort(
$plugins['siteSidebar'],
function ($a, $b) {
return $a->position() <=> $b->position();
}
);
// Sort the plugins by the position for the dashboard
uasort($plugins['dashboard'], function ($a, $b) {
return $a->position()>$b->position();
uasort(
$plugins['dashboard'],
function ($a, $b) {
return $a->position() <=> $b->position();
}
);
}

View file

@ -13,7 +13,7 @@
/**
* Create a new page. === bludit v4
* @param array $args All supported keys are defined in the class pages.class.php variable $dbFields
* @param array $args All supported parameters are defined in the class pages.class.php, variable $dbFields
* @return string|bool Returns the page key on successful create, FALSE otherwise
*/
function createPage($args) {
@ -53,7 +53,7 @@ function createPage($args) {
/**
* Edit a page. === Bludit v4
* @param array $args All supported keys are defined in the class pages.class.php variable $dbFields
* @param array $args All supported parameters are defined in the class pages.class.php, variable $dbFields
* @param string $args['key'] The key of the page to be edited
* @return string|bool Returns the page key on successful edit, FALSE otherwise
*/
@ -240,8 +240,8 @@ function deleteCategory($args) {
/**
* Create an user. === Bludit v4
* This function should check everthing, such as empty username, emtpy password, password lenght, etc
* @param array $args All supported keys are defined in the class users.class.php variable $dbFields
* This function should check everthing, such as empty username, empty password, password lenght, etc
* @param array $args All supported parameters are defined in the class users.class.php variable $dbFields
* @return string|bool Returns the username on successful create, FALSE otherwise
*/
function createUser($args) {
@ -277,7 +277,7 @@ function createUser($args) {
/**
* Edit an user. === Bludit v4
* @param array $args All supported keys are defined in the class users.class.php variable $dbFields
* @param array $args All supported parameters are defined in the class users.class.php, variable $dbFields
* @param bool $args['disable'] If you set this variable the user will be disabled
* @param string $args['password'] If you set this variable a new password will be set for the user
* @return string|bool Returns TRUE on successful delete, FALSE otherwise
@ -563,20 +563,27 @@ function uploadPageFile($pageKey) {
}
}
$filename = $_FILES['file']['name'];
$absoluteURL = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename;
$absolutePath = PATH_UPLOADS_PAGES.$pageKey.DS.$filename;
$filename = Filesystem::filename($_FILES['file']['name']);
$absoluteURL = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
$absolutePath = PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
if (Filesystem::mv($_FILES['file']['tmp_name'], $absolutePath)) {
// Create thumbnail if the files is an image
$thumbnail = '';
if (in_array($fileMimeType, $GLOBALS['ALLOWED_IMG_MIMETYPES'])) {
try {
$thumbnail = PATH_UPLOADS_THUMBNAILS.$pageKey.DS.$filename;
$image = new \claviska\SimpleImage();
$thumbnailSmall = PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-s.'.$fileExtension;
$image
->fromFile($absolutePath)
->thumbnail($site->thumbnailWidth(), $site->thumbnailHeight(), 'center')
->toFile($thumbnail, 'image/jpeg');
->thumbnail($site->thumbnailSmallWidth(), $site->thumbnailSmallHeight(), 'center')
->toFile($thumbnailSmall, 'image/jpeg');
$thumbnailMedium = PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-m.'.$fileExtension;
$image
->fromFile($absolutePath)
->thumbnail($site->thumbnailMediumWidth(), $site->thumbnailMediumHeight(), 'center')
->toFile($thumbnailMedium, 'image/jpeg');
} catch(Exception $e) {
Log::set(__FUNCTION__.LOG_SEP.$e->getMessage(), LOG_TYPE_ERROR);
return false;
@ -585,7 +592,7 @@ function uploadPageFile($pageKey) {
Log::set(__FUNCTION__.LOG_SEP.'File uploaded to the page.', LOG_TYPE_INFO);
return array(
'filename'=>$filename,
'filename'=>$filename.'.'.$fileExtension,
'absolutePath'=>$absolutePath,
'absoluteURL'=>$absoluteURL,
'mime'=>Filesystem::mimeType($absolutePath),

View file

@ -149,10 +149,12 @@ class Filesystem {
return true;
}
// Compress a file or directory
// $source = /home/diego/example
// $destionation = /tmp/example.zip
public static function zip($source, $destination)
/**
* Compress a file or directory.
* $source = /home/diego/example
* $destionation = /tmp/example.zip
*/
public static function zip(string $source, string $destination): bool
{
if (!extension_loaded('zip')) {
return false;
@ -217,7 +219,7 @@ class Filesystem {
|
| @return string
*/
public static function nextFilename($path=PATH_UPLOADS, $filename) {
public static function nextFilename($filename, $path=PATH_UPLOADS) {
// Clean filename and get extension
$fileExtension = pathinfo($filename, PATHINFO_EXTENSION);
$fileExtension = Text::lowercase($fileExtension);
@ -238,38 +240,37 @@ class Filesystem {
return $tmpName;
}
/*
| Returns the filename
| Example:
| @file /home/diego/dog.jpg
| @return dog.jpg
|
| @file string Full path of the file
|
| @return string
/**
* Returns the file filename witout the extension. === Bludit v4
* @param string $file Filename with the path
* @return string Extension. Example: /home/diego/dog.jpg -> dog.jpg
*/
public static function filename($file) {
return basename($file);
public static function basename(string $file): string {
return pathinfo($file, PATHINFO_BASENAME);
}
/*
| Returns the file extension
| Example:
| @file /home/diego/dog.jpg
| @return jpg
|
| @file string Full path of the file
|
| @return string
/**
* Returns the file filename witout the extension. === Bludit v4
* @param string $file Filename with the path
* @return string Extension. Example: /home/diego/dog.jpg -> dog
*/
public static function extension($file) {
public static function filename(string $file): string {
return pathinfo($file, PATHINFO_FILENAME);
}
/**
* Returns the file extension. === Bludit v4
* @param string $file Filename with the path
* @return string Extension. Example: /home/diego/dog.jpg -> jpg
*/
public static function extension(string $file): string {
return pathinfo($file, PATHINFO_EXTENSION);
}
/**
* Get Size of file or directory in bytes
* @param [string] $fileOrDirectory
* @return [int|bool] [bytes or false on error]
* Get size of file or directory in bytes
* @param string $fileOrDirectory
* @return int|bool Bytes or false on error
*/
public static function getSize($fileOrDirectory) {
// Files

View file

@ -82,6 +82,18 @@ class HTML {
return '<script '.$attributes.' src="'.DOMAIN_CORE_VENDORS.'bootstrap-html5sortable/jquery.sortable.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
}
public static function jsSelect2($attributes='')
{
return '<script '.$attributes.' src="'.DOMAIN_CORE_VENDORS.'select2/select2.min.js?version='.BLUDIT_VERSION.'"></script>'.PHP_EOL;
}
public static function cssSelect2()
{
$html = '<link rel="stylesheet" type="text/css" href="'.DOMAIN_CORE_VENDORS.'select2/select2.min.css?version='.BLUDIT_VERSION.'">'.PHP_EOL;
$html .= '<link rel="stylesheet" type="text/css" href="'.DOMAIN_CORE_VENDORS.'select2/select2-bootstrap-5-theme.min.css?version='.BLUDIT_VERSION.'">'.PHP_EOL;
return $html;
}
/* Generates a dynamiclly the meta tag title for the themes === Bludit v4
@return string Returns the meta tag title <title>...</title>

View file

@ -218,7 +218,10 @@ class Text {
return mb_stripos($string, $substring, 0, CHARSET);
}
public static function stringContains($string, $substring, $caseSensitive=true)
/**
* Return TRUE if the string contains the substring, FALSE otherwhise. === Bludit v4
*/
public static function stringContains(string $string, string $substring, bool $caseSensitive=true): bool
{
return (self::stringPosition($string, $substring, $caseSensitive) !== false);
}

File diff suppressed because one or more lines are too long

View file

@ -10,7 +10,6 @@ echo 'var HTML_PATH_ADMIN_ROOT = "'.HTML_PATH_ADMIN_ROOT.'";'.PHP_EOL;
echo 'var HTML_PATH_ADMIN_THEME = "'.HTML_PATH_ADMIN_THEME.'";'.PHP_EOL;
echo 'var HTML_PATH_CORE_IMG = "'.HTML_PATH_CORE_IMG.'";'.PHP_EOL;
echo 'var HTML_PATH_UPLOADS = "'.HTML_PATH_UPLOADS.'";'.PHP_EOL;
echo 'var HTML_PATH_UPLOADS_THUMBNAILS = "'.HTML_PATH_UPLOADS_THUMBNAILS.'";'.PHP_EOL;
echo 'var BLUDIT_VERSION = "'.BLUDIT_VERSION.'";'.PHP_EOL;
echo 'var BLUDIT_BUILD = "'.BLUDIT_BUILD.'";'.PHP_EOL;
echo 'var DOMAIN = "'.DOMAIN.'";'.PHP_EOL;

View file

@ -9,7 +9,6 @@ class Page {
global $pages;
$this->vars['key'] = $key;
// If key is FALSE, the page is create with default values, like an empty page
// Useful for Page Not Found
if ($key===false) {
@ -332,25 +331,6 @@ class Page {
return $filename;
}
// Returns the endpoint of the thumbnail cover image, FALSE if the page doesn't have a cover image
public function thumbCoverImage()
{
$filename = $this->coverImage(false);
if ($filename==false) {
return false;
}
// Check is external cover image
if (filter_var($filename, FILTER_VALIDATE_URL)) {
return $filename;
}
if (IMAGE_RESTRICT) {
return DOMAIN_UPLOADS_PAGES.$this->uuid().'/thumbnails/'.$filename;
}
return DOMAIN_UPLOADS_THUMBNAILS.$filename;
}
// Returns TRUE if the content has the text splited
public function readMore()
{

View file

@ -8,7 +8,7 @@ class Pages extends dbJSON {
'description'=>'',
'username'=>'', // Username key
'tags'=>array(),
'type'=>'published', // published, static, draft, sticky, scheduled
'type'=>'draft', // published, static, draft, sticky, scheduled
'date'=>'',
'dateModified'=>'',
'position'=>0,
@ -154,12 +154,6 @@ class Pages extends dbJSON {
return false;
}
// Create the thumbnails directory for the page
if (Filesystem::mkdir(PATH_UPLOADS_THUMBNAILS.$key, true) === false) {
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to create the directory: '.PATH_UPLOADS_THUMBNAILS.$key, LOG_TYPE_ERROR);
return false;
}
// Create the index.txt and save the file
if (file_put_contents(PATH_PAGES.$key.DS.FILENAME, $contentRaw) === false) {
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to create the file: '.FILENAME, LOG_TYPE_ERROR);
@ -274,11 +268,6 @@ class Pages extends dbJSON {
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to move the directory: '.PATH_UPLOADS_PAGES.$newKey, LOG_TYPE_ERROR);
return false;
}
if (Filesystem::mv(PATH_UPLOADS_THUMBNAILS.$key, PATH_UPLOADS_THUMBNAILS.$newKey) === false) {
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to move the directory: '.PATH_UPLOADS_THUMBNAILS.$newKey, LOG_TYPE_ERROR);
return false;
}
}
// If the content was passed via arguments replace the content
@ -340,11 +329,6 @@ class Pages extends dbJSON {
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to delete the directory: '.PATH_UPLOADS_PAGES.$key, LOG_TYPE_ERROR);
}
// Delete thumbnail directory
if (Filesystem::deleteRecursive(PATH_UPLOADS_THUMBNAILS.$key) === false) {
Log::set(__METHOD__.LOG_SEP.'An error occurred while trying to delete the directory: '.PATH_UPLOADS_THUMBNAILS.$key, LOG_TYPE_ERROR);
}
// Remove from database
unset($this->db[$key]);
@ -545,12 +529,13 @@ class Pages extends dbJSON {
return false;
}
// Returns an array with a list of key of pages, FALSE if out of range
// The database is sorted by date or by position
// (int) $pageNumber, the page number
// (int) $numberOfItems, amount of items to return, if -1 returns all the items
// (boolean) $onlyPublished, TRUE to return only published pages
public function getList($pageNumber, $numberOfItems, $published=true, $static=false, $sticky=false, $draft=false, $scheduled=false)
/**
* Get a list of pages' keys. === Bludit v4
* @param int $pageNumber Page number for the paginator
* @param int $numberOfItems Amount of items to return, if -1 returns all the items
* @return array|bool Returns an array with the pages' keys or FALSE if it out of range
*/
public function getList(int $pageNumber, int $numberOfItems, bool $published=true, bool $static=false, bool $sticky=false, bool $draft=false, bool $scheduled=false)
{
$list = array();
foreach ($this->db as $key=>$fields) {
@ -664,11 +649,11 @@ class Pages extends dbJSON {
private function sortByDateLowToHigh($a, $b)
{
return $a['date']>$b['date'];
return $a['date']<=>$b['date'];
}
private function sortByDateHighToLow($a, $b)
{
return $a['date']<$b['date'];
return $b['date']<=>$a['date'];
}
function generateUUID() {

View file

@ -13,7 +13,7 @@
#
#
class Parsedown
final class Parsedown
{
# ~

View file

@ -1,68 +1,68 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
class Site extends dbJSON {
class Site extends dbJSON
{
public $dbFields = array(
'title'=> 'I am Guybrush Threepwood, mighty developer',
'slogan'=> '',
'description'=> '',
'footer'=> 'I wanna be a pirate!',
'itemsPerPage'=> 6,
'language'=> 'en',
'locale'=> 'en, en_US, en_AU, en_CA, en_GB, en_IE, en_NZ',
'timezone'=> 'America/Argentina/Buenos_Aires',
'theme'=> 'alternative',
'adminTheme'=> 'booty',
'homepage'=> '',
'pageNotFound'=> '',
'uriPage'=> '/',
'uriTag'=> '/tag/',
'uriCategory'=> '/category/',
'uriBlog'=> '/blog/',
'url'=> '',
'emailFrom'=> '',
'dateFormat'=> 'F j, Y',
'timeFormat'=> 'g:i a',
'currentBuild'=> 0,
'twitter'=> '',
'facebook'=> '',
'codepen'=> '',
'instagram'=> '',
'github'=> '',
'gitlab'=> '',
'linkedin'=> '',
'xing'=> '',
'mastodon'=> '',
'dribbble'=> '',
'vk'=> '',
'discord'=> '',
'youtube'=> '',
'orderBy'=> 'date', // date or position
'extremeFriendly'=> true,
'autosaveInterval'=> 2, // minutes
'titleFormatHomepage'=> '{{site-slogan}} | {{site-title}}',
'titleFormatPages'=> '{{page-title}} | {{site-title}}',
'titleFormatCategory'=> '{{category-name}} | {{site-title}}',
'titleFormatTag'=> '{{tag-name}} | {{site-title}}',
'imageRestrict'=> true,
'imageRelativeToAbsolute'=> false,
'thumbnailWidth'=> 400, // px
'thumbnailHeight'=> 400, // px
'thumbnailQuality'=> 100,
'logo'=> '',
'markdownParser'=> true,
'customFields'=> '{}',
'darkModeAdmin'=> false
'title' => 'I am Guybrush Threepwood, mighty developer',
'slogan' => '',
'description' => '',
'footer' => 'I wanna be a pirate!',
'itemsPerPage' => 6,
'language' => 'en',
'locale' => 'en, en_US, en_AU, en_CA, en_GB, en_IE, en_NZ',
'timezone' => 'America/Argentina/Buenos_Aires',
'theme' => 'alternative',
'adminTheme' => 'booty',
'homepage' => '',
'pageNotFound' => '',
'uriPage' => '/',
'uriTag' => '/tag/',
'uriCategory' => '/category/',
'uriBlog' => '/blog/',
'url' => '',
'emailFrom' => '',
'dateFormat' => 'F j, Y',
'timeFormat' => 'g:i a',
'currentBuild' => 0,
'twitter' => '',
'facebook' => '',
'codepen' => '',
'instagram' => '',
'github' => '',
'gitlab' => '',
'linkedin' => '',
'xing' => '',
'mastodon' => '',
'dribbble' => '',
'vk' => '',
'discord' => '',
'youtube' => '',
'orderBy' => 'date', // date or position
'extremeFriendly' => true,
'autosaveInterval' => 2, // minutes
'titleFormatHomepage' => '{{site-slogan}} | {{site-title}}',
'titleFormatPages' => '{{page-title}} | {{site-title}}',
'titleFormatCategory' => '{{category-name}} | {{site-title}}',
'titleFormatTag' => '{{tag-name}} | {{site-title}}',
'imageRestrict' => true,
'imageRelativeToAbsolute' => false,
'thumbnailSmallWidth' => 400, // px
'thumbnailSmallHeight' => 400, // px
'thumbnailSmallQuality' => 100, // %
'thumbnailMediumWidth' => 800, // px
'thumbnailMediumHeight' => 600, // px
'thumbnailMediumQuality' => 100, // %
'logo' => '',
'markdownParser' => true,
'customFields' => '{}',
'darkModeAdmin' => false
);
function __construct()
{
parent::__construct(DB_SITE);
// Set timezone
$this->setTimezone( $this->timezone() );
// Set locale
$this->setLocale( $this->locale() );
$this->setTimezone($this->timezone());
$this->setLocale($this->locale());
}
// Returns an array with site configuration.
@ -74,11 +74,14 @@ class Site extends dbJSON {
public function set($args)
{
// Check values on args or set default values
foreach ($this->dbFields as $field=>$value) {
foreach ($this->dbFields as $field => $value) {
if (isset($args[$field])) {
$finalValue = Sanitize::html($args[$field]);
if ($finalValue==='false') { $finalValue = false; }
elseif ($finalValue==='true') { $finalValue = true; }
if ($finalValue === 'false') {
$finalValue = false;
} elseif ($finalValue === 'true') {
$finalValue = true;
}
settype($finalValue, gettype($value));
$this->db[$field] = $finalValue;
}
@ -88,9 +91,9 @@ class Site extends dbJSON {
// Returns an array with the URL filters
// Also, you can get the a particular filter
public function uriFilters($filter='')
public function uriFilters($filter = '')
{
$filters['admin'] = '/'.ADMIN_URI_FILTER.'/';
$filters['admin'] = '/' . ADMIN_URI_FILTER . '/';
$filters['page'] = $this->getField('uriPage');
$filters['tag'] = $this->getField('uriTag');
$filters['category'] = $this->getField('uriCategory');
@ -110,31 +113,34 @@ class Site extends dbJSON {
return false;
}
// DEPRECATED in v3.0, use HTML::rssUrl()
public function rss()
public function thumbnailSmallWidth()
{
return DOMAIN_BASE.'rss.xml';
return $this->getField('thumbnailSmallWidth');
}
// DEPRECATED in v3.0, use HTML::sitemapUrl()
public function sitemap()
public function thumbnailSmallHeight()
{
return DOMAIN_BASE.'sitemap.xml';
return $this->getField('thumbnailSmallHeight');
}
public function thumbnailWidth()
public function thumbnailSmallQuality()
{
return $this->getField('thumbnailWidth');
return $this->getField('thumbnailSmallQuality');
}
public function thumbnailHeight()
public function thumbnailMediumWidth()
{
return $this->getField('thumbnailHeight');
return $this->getField('thumbnailMediumWidth');
}
public function thumbnailQuality()
public function thumbnailMediumHeight()
{
return $this->getField('thumbnailQuality');
return $this->getField('thumbnailMediumHeight');
}
public function thumbnailMediumQuality()
{
return $this->getField('thumbnailMediumQuality');
}
public function autosaveInterval()
@ -310,11 +316,11 @@ class Site extends dbJSON {
// Returns the absolute URL of the site logo
// If you set $absolute=false returns only the filename
public function logo($absolute=true)
public function logo($absolute = true)
{
$logo = $this->getField('logo');
if ($absolute && $logo) {
return DOMAIN_UPLOADS.$logo;
return DOMAIN_UPLOADS . $logo;
}
return $logo;
}
@ -331,25 +337,24 @@ class Site extends dbJSON {
public function domain()
{
// If the URL field is not set, try detect the domain.
if(Text::isEmpty( $this->url() )) {
if(!empty($_SERVER['HTTPS'])) {
if (Text::isEmpty($this->url())) {
if (!empty($_SERVER['HTTPS'])) {
$protocol = 'https://';
}
else {
} else {
$protocol = 'http://';
}
$domain = trim($_SERVER['HTTP_HOST'], '/');
return $protocol.$domain;
return $protocol . $domain;
}
// Parse the domain from the field url (Settings->Advanced)
$parse = parse_url($this->url());
$domain = rtrim($parse['host'], '/');
$port = !empty($parse['port']) ? ':'.$parse['port'] : '';
$scheme = !empty($parse['scheme']) ? $parse['scheme'].'://' : 'http://';
$port = !empty($parse['port']) ? ':' . $parse['port'] : '';
$scheme = !empty($parse['scheme']) ? $parse['scheme'] . '://' : 'http://';
return $scheme.$domain.$port;
return $scheme . $domain . $port;
}
// Returns the timezone.
@ -413,10 +418,9 @@ class Site extends dbJSON {
$localeList = explode(',', $locale);
foreach ($localeList as $locale) {
$locale = trim($locale);
if (setlocale(LC_ALL, $locale.'.UTF-8')!==false) {
if (setlocale(LC_ALL, $locale . '.UTF-8') !== false) {
return true;
}
elseif (setlocale(LC_ALL, $locale)!==false) {
} elseif (setlocale(LC_ALL, $locale) !== false) {
return true;
}
}
@ -437,5 +441,4 @@ class Site extends dbJSON {
$customFields = Sanitize::htmlDecode($this->getField('customFields'));
return json_decode($customFields, true);
}
}

View file

@ -33,7 +33,7 @@ class Users extends dbJSON {
parent::__construct(DB_USERS);
}
public function getDefaultFields()
public function getDefaultFields(): array
{
return $this->dbFields;
}
@ -48,27 +48,25 @@ class Users extends dbJSON {
}
// Return TRUE if the user exists, FALSE otherwise
public function exists($username)
public function exists($username): bool
{
return isset($this->db[$username]);
}
/* Disable an user === Bludit v4
@username string The username to be disabled
@return string Returns the username
/**
* Disable an username
*/
public function disableUser($username)
public function disableUser(string $username): string
{
$this->db[$username]['password'] = '!';
$this->save();
return $username;
}
/* Create a new user === Bludit v4
@args array The array $args supports all the keys from the variable $dbFields. If you don't pass all the keys, the default values are used.
@return string/bool Returns the username if the user is successfully created, FALSE otherwise
/**
* Create a new user. === Bludit v4
* @param array $args All supported parameters are defined in this class, variable $dbFields
* @return string|bool Returns the username on successful create, FALSE otherwise
*/
public function add($args)
{
@ -110,10 +108,10 @@ class Users extends dbJSON {
return $username;
}
/* Edit an user === Bludit v4
@args array The array $args supports all the keys from the variable $dbFields. If you don't pass all the keys, the default values are used.
@return string/bool Returns the username if the user is successfully created, FALSE otherwise
/**
* Edit an user. === Bludit v4
* @param array $args All supported parameters are defined in this class, variable $dbFields
* @return string|bool Returns the username on successful edit, FALSE otherwise
*/
public function edit($args)
{
@ -157,7 +155,11 @@ class Users extends dbJSON {
return $username;
}
// Delete an user
/**
* Delete an user. === Bludit v4
* @param string $username Username to be delete
* @return string|bool Returns true or false
*/
public function delete($username)
{
unset($this->db[$username]);
@ -188,14 +190,14 @@ class Users extends dbJSON {
{
$args['username'] = $username;
$args['tokenRemember'] = $token;
return $this->set($args);
return $this->edit($args);
}
// Change user password
// args => array( username, password )
public function setPassword($args)
{
return $this->set($args);
return $this->edit($args);
}
// Return the username associated to an email, FALSE otherwise

View file

@ -587,7 +587,7 @@ class pluginAPI extends Plugin {
/**
* Edit settings
* @param array $args All supported keys are defined in the class site.class.php variable $dbFields
* @param array $args All supported parameters are defined in the class site.class.php, variable $dbFields
* @return array
*/
private function editSettings($args)
@ -956,24 +956,35 @@ class pluginAPI extends Plugin {
$files = array();
$listFiles = Filesystem::listFiles($path, '*', '*', $sortByDate, $chunk);
foreach ($listFiles as $file) {
$filename = basename($file);
$absoluteURL = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename;
$absolutePath = $file;
if (Text::stringContains($file, '-thumbnail-')) {
continue;
}
$filename = Filesystem::filename($file);
$fileExtension = Filesystem::extension($file);
$absoluteURL = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
$absolutePath = PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'.'.$fileExtension;
$thumbnailSmall = '';
if (Filesystem::fileExists(PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-s.'.$fileExtension)) {
$thumbnailSmall = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-s.'.$fileExtension;
}
$thumbnailMedium = '';
if (Filesystem::fileExists(PATH_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-m.'.$fileExtension)) {
$thumbnailMedium = DOMAIN_UPLOADS_PAGES.$pageKey.DS.$filename.'-thumbnail-m.'.$fileExtension;
}
$data = array(
'filename'=>$filename,
'filename'=>$filename.'.'.$fileExtension,
'absolutePath'=>$absolutePath,
'absoluteURL'=>$absoluteURL,
'mime'=>Filesystem::mimeType($absolutePath),
'size'=>Filesystem::getSize($absolutePath),
'thumbnail'=>''
'thumbnailSmall'=>$thumbnailSmall,
'thumbnailMedium'=>$thumbnailMedium
);
// Check if thumbnail exists for the file
$thumbnail = $path.'thumbnails'.DS.$filename;
if (Filesystem::fileExists($thumbnail)) {
$data['thumbnail'] = $thumbnail;
}
array_push($files, $data);
}

View file

@ -13,7 +13,7 @@ class pluginLatestPages extends Plugin {
$tmp = $pages->getList(1, 5);
foreach ($tmp as $key) {
$page = buildPage($key);
$html .= '<a href="'.$page->permalink().'" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">';
$html .= '<a target="_blank" href="'.$page->permalink().'" class="list-group-item list-group-item-action d-flex gap-3 py-3" aria-current="true">';
$html .= '<div class="d-flex gap-2 w-100 justify-content-between">';
$html .= '<div>';
$html .= '<h6 class="mb-0">'.($page->title() ? $page->title() : '<span class="text-muted">' . $L->g('Empty title') . '</span> ').'</h6>';

View file

@ -205,8 +205,8 @@ class Fuzz
*/
public function getJaroWinkler($first, $second)
{
$shorter;
$longer;
$shorter = '';
$longer = '';
if (mb_strlen($first, CHARSET) > mb_strlen($second, CHARSET)) {
$longer = mb_strtolower($first, CHARSET);

View file

@ -62,7 +62,6 @@ define('PATH_WORKSPACES', PATH_CONTENT . 'workspaces' . DS);
define('PATH_DATABASES', PATH_CONTENT . 'databases' . DS);
define('PATH_PLUGINS_DATABASES', PATH_CONTENT . 'databases' . DS . 'plugins' . DS);
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS . 'profiles' . DS);
define('PATH_UPLOADS_THUMBNAILS', PATH_UPLOADS . 'thumbnails' . DS);
define('PATH_UPLOADS_PAGES', PATH_UPLOADS . 'pages' . DS);
define('PATH_HELPERS', PATH_KERNEL . 'helpers' . DS);
define('PATH_ABSTRACT', PATH_KERNEL . 'abstract' . DS);
@ -275,7 +274,7 @@ function install($adminPassword, $timezone)
}
// Directories for initial plugins
$pluginsToInstall = array('tinymce', 'about', 'welcome', 'api', 'visits-stats', 'robots', 'canonical', 'popeye');
$pluginsToInstall = array('tinymce', 'about', 'welcome', 'api', 'visits-stats', 'robots', 'canonical', 'popeye', 'latest-pages');
foreach ($pluginsToInstall as $plugin) {
if (!mkdir(PATH_PLUGINS_DATABASES . $plugin, DIR_PERMISSIONS, true)) {
$errorText = 'Error when trying to created the directory=>' . PATH_PLUGINS_DATABASES . $plugin;
@ -284,7 +283,7 @@ function install($adminPassword, $timezone)
}
// System directories
$systemDirectories = array(PATH_UPLOADS_PROFILES, PATH_UPLOADS_THUMBNAILS, PATH_TMP, PATH_WORKSPACES, PATH_UPLOADS_PAGES);
$systemDirectories = array(PATH_UPLOADS_PROFILES, PATH_TMP, PATH_WORKSPACES, PATH_UPLOADS_PAGES);
foreach ($systemDirectories as $directory) {
if (!mkdir($directory, DIR_PERMISSIONS, true)) {
$errorText = 'Error when trying to created the directory=>' . $directory;
@ -388,9 +387,9 @@ function install($adminPassword, $timezone)
'titleFormatTag' => '{{tag-name}} | {{site-title}}',
'imageRestrict' => true,
'imageRelativeToAbsolute' => false,
'thumbnailWidth' => 400,
'thumbnailHeight' => 400,
'thumbnailQuality' => 100,
'thumbnailSmallWidth' => 400,
'thumbnailSmallHeight' => 400,
'thumbnailSmallQuality' => 100,
'logo' => '',
'markdownParser' => true,
'customFields' => '{}',
@ -548,12 +547,24 @@ function install($adminPassword, $timezone)
LOCK_EX
);
// File plugins/latest-pages/db.php
file_put_contents(
PATH_PLUGINS_DATABASES . 'latest-pages' . DS . 'db.php',
$dataHead . json_encode(
array(
'position' => 2
),
JSON_PRETTY_PRINT
),
LOCK_EX
);
// File plugins/visits-stats/db.php
file_put_contents(
PATH_PLUGINS_DATABASES . 'visits-stats' . DS . 'db.php',
$dataHead . json_encode(
array(
'position' => 2,
'position' => 3,
'excludeAdmins' => false,
'label' => $L->get('Visits')
),

View file

@ -1,9 +1,9 @@
parameters:
phpVersion: 70100 # PHP 7.1 - https://github.com/phpstan/phpstan/blob/master/playground-api/handler.ts#L38
#phpVersion: 70100 # PHP 7.1 - https://github.com/phpstan/phpstan/blob/master/playground-api/handler.ts#L38
#phpVersion: 70200 # PHP 7.2
#phpVersion: 70300 # PHP 7.3
#phpVersion: 70400 # PHP 7.4
#phpVersion: 80000 # PHP 8.0
phpVersion: 80000 # PHP 8.0
level: 0
excludePaths:
analyse: