Merge branch 'bludit:main' into preview

This commit is contained in:
Emanuele 2022-05-04 09:32:11 +02:00 committed by GitHub
commit 825bd5f509
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 184 additions and 71 deletions

View file

@ -135,12 +135,21 @@
// Ctrl+S or Command+S
if ((event.ctrlKey || event.metaKey) && event.which == 83) {
event.preventDefault();
// Parse all custom fields inputs
var customFields = {}
$('input[name^="custom"]').each(function() {
var field = $(this).data('field')
var value = $(this).val()
customFields[field] = value
});
$('select[name^="custom"]').each(function() {
var field = $(this).data('field');
var value = $(this).val();
customFields[field] = value;
});
// Create array with all inputs
var args = {
slug: $('#friendlyURL').val(),
title: $('#title').val(),
@ -190,12 +199,20 @@
});
$('#btnSave').on('click', function() {
// Parse all custom fields inputs
var customFields = {}
$('input[name^="custom"]').each(function() {
var field = $(this).data('field')
var value = $(this).val()
customFields[field] = value
});
$('select[name^="custom"]').each(function() {
var field = $(this).data('field');
var value = $(this).val();
customFields[field] = value;
});
// Create array with all inputs
var args = {
slug: $('#friendlyURL').val(),
title: $('#title').val(),
@ -393,13 +410,20 @@
return false;
}
// Parse all custom fields inputs
var customFields = {}
$('input[name^="custom"]').each(function() {
var field = $(this).data('field')
var value = $(this).val()
customFields[field] = value
});
$('select[name^="custom"]').each(function() {
var field = $(this).data('field');
var value = $(this).val();
customFields[field] = value;
});
// Create array with all inputs
var args = {
slug: $('#friendlyURL').val(),
title: $('#title').val(),
@ -697,12 +721,12 @@
'data' => array('field' => $field)
));
} elseif ($options['type']=="bool") {
echo Bootstrap::formCheckbox(array(
'name'=>'custom['.$field.']',
'label'=>(isset($options['label'])?$options['label']:''),
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
'checked'=>(($pageKey && $page->custom($field))?true:false),
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
echo Bootstrap::formSelectBlock(array(
'name' => 'custom['.$field.']',
'label' => (isset($options['label'])?$options['label']:''),
'options' => array('true' => $L->g('Enabled'), 'false' => $L->g('Disabled')),
'selected' => (($pageKey && $page->custom($field))?'true':'false'),
'tip' => (isset($options['tip'])?$options['tip']:''),
'data' => array('field' => $field)
));
}
@ -732,12 +756,12 @@
'data' => array('field' => $field)
));
} elseif ($options['type']=="bool") {
echo Bootstrap::formCheckbox(array(
'name'=>'custom['.$field.']',
'label'=>(isset($options['label'])?$options['label']:''),
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
'checked'=>(($pageKey && $page->custom($field))?true:false),
'labelForCheckbox'=>(isset($options['tip'])?$options['tip']:''),
echo Bootstrap::formSelectBlock(array(
'name' => 'custom['.$field.']',
'label' => (isset($options['label'])?$options['label']:''),
'options' => array('true' => $L->g('Enabled'), 'false' => $L->g('Disabled')),
'selected' => (($pageKey && $page->custom($field))?'true':'false'),
'tip' => (isset($options['tip'])?$options['tip']:''),
'data' => array('field' => $field)
));
}
@ -810,6 +834,37 @@
</script>
<!-- End Tags -->
<!-- Custom fields menu position -->
<?php
$customFields = $site->customFields();
foreach ($customFields as $field=>$options) {
if ( isset($options['position']) && ($options['position']=='menu') ) {
if ($options['type']=="string") {
echo '<h6 class="text-uppercase mt-4">'.(isset($options['label'])?$options['label']:'').'</h6>';
echo Bootstrap::formInputTextBlock(array(
'name'=>'custom['.$field.']',
'value'=>(($pageKey && $page->custom($field))?$page->custom($field):''),
'tip'=>(isset($options['tip'])?$options['tip']:''),
'placeholder'=>(isset($options['placeholder'])?$options['placeholder']:''),
'class'=>'',
'data' => array('field' => $field)
));
} elseif ($options['type']=="bool") {
echo '<h6 class="text-uppercase mt-4">'.(isset($options['label'])?$options['label']:'').'</h6>';
echo Bootstrap::formSelectBlock(array(
'name' => 'custom['.$field.']',
'label' => '',
'options' => array('true' => $L->g('Enabled'), 'false' => $L->g('Disabled')),
'selected' => (($pageKey && $page->custom($field))?true:false),
'tip' => (isset($options['tip'])?$options['tip']:''),
'data' => array('field' => $field)
));
}
}
}
?>
<h6 class="text-uppercase mt-4"><?php $L->p('More options') ?></h6>
<ul class="list-group">
<li class="list-group-item p-0 pt-3 bg-transparent border-0"><a onclick="fmOpen()" href="#"><i class="bi bi-files"></i><?php $L->p('Files & images') ?></a></li>

View file

@ -24,9 +24,10 @@
});
</script>
<?php
<img class="mx-auto d-block w-25 mb-4" alt="logo" src="<?php echo HTML_PATH_CORE_IMG . 'logo.svg' ?>" />
<h1 class="text-center text-uppercase mb-4"><?php echo $site->title() ?></h1>
echo '<h1 class="text-center fw-normal mb-5">'.$site->title().'</h1>';
<?php
echo Bootstrap::formOpen(array('name'=>'login'));
@ -60,7 +61,7 @@ echo Bootstrap::formOpen(array('name'=>'login'));
</div>
<div class="mt-4">
<button type="submit" class="btn btn-primary btn-lg me-2 w-100" name="save">'.$L->g('Login').'</button>
<button type="submit" class="btn btn-secondary btn-lg me-2 w-100" name="save">'.$L->g('Login').'</button>
</div>
';

View file

@ -48,6 +48,12 @@
args[key] = value;
});
if (!isJson($('#customFields').val())) {
logs('Invalid JSON format for custom fields.');
showAlertError("<?php $L->p('Invalid JSON format for custom fields') ?>");
return false;
}
api.saveSettings(args).then(function(response) {
if (response.status == 0) {
logs('Settings saved.');
@ -685,7 +691,8 @@
'value' => json_encode($site->customFields(), JSON_PRETTY_PRINT),
'tip' => $L->g('define-custom-fields-for-the-content'),
'rows' => 15,
'data' => array('save' => 'true')
'data' => array('save' => 'true'),
'disable-current-value' => false
));
?>
</div>

View file

@ -7,17 +7,16 @@ define('BLUDIT_RELEASE_DATE', '2021-05-23');
define('BLUDIT_BUILD', '20210523');
// Debug mode
// Change to FALSE, for prevent warning or errors on browser
define('DEBUG_MODE', TRUE);
define('DEBUG_TYPE', 'INFO'); // INFO, TRACE
error_reporting(0); // Turn off all error reporting
ini_set("display_errors", 0); // Turn off display errors in browser
ini_set('display_startup_errors', 0);
if (DEBUG_MODE) {
// Turn on all error reporting
ini_set("display_errors", 0);
ini_set('display_startup_errors',0);
// Turn on all error reporting, will be display in log server
ini_set("html_errors", 1);
ini_set('log_errors', 1);
error_reporting(E_ALL | E_STRICT | E_NOTICE);
error_reporting(E_ALL);
}
// PHP paths

View file

@ -8,7 +8,7 @@ class Bootstrap {
$id = isset($args['id'])?$args['id']:$name;
$value = isset($args['value'])?$args['value']:'';
return '<input type="hidden" id="'.$id.'" name="'.$name.'" value="'.$value.'">';
return '<input type="hidden" id="'.$id.'" name="'.$name.'" value="'.$value.'" autocomplete="off">';
}
// Floating Labels
@ -30,7 +30,7 @@ class Bootstrap {
return <<<EOF
<div class="form-floating mb-3">
<input type="$type" class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder">
<input type="$type" class="$class" id="$id" name="$name" value="$value" placeholder="$placeholder" autocomplete="off">
<label for="$id">$label</label>
</div>
EOF;
@ -84,15 +84,30 @@ EOF;
$class = $class.' '.$args['class'];
}
$html = '<div>';
if (!empty($args['label'])) {
$html .= '<label for="'.$id.'">'.$args['label'].'</label>';
$tip = '';
if (!empty($args['tip'])) {
$tip = '<div class="form-text">'.$args['tip'].'</div>';
}
$html .= '<select id="'.$id.'" name="'.$name.'" class="'.$class.'">';
$data = 'data-current-value="'.$args['selected'].'"';
if (isset($args['data'])) {
if (is_array($args['data'])) {
foreach ($args['data'] as $x => $y) {
$data .= 'data-'.$x.' = "'.$y.'"';
}
}
}
$html = '<div class="mb-2">';
if (!empty($args['label'])) {
$html .= '<label class="col-sm-2 col-form-label" for="'.$id.'">'.$args['label'].'</label>';
}
$html .= '<select id="'.$id.'" name="'.$name.'" class="'.$class.'" '.$data.'>';
foreach ($args['options'] as $key=>$value) {
$html .= '<option '.(($key==$args['selected'])?'selected':'').' value="'.$key.'">'.$value.'</option>';
}
$html .= '</select>';
$html .= $tip;
$html .= '</div>';
return $html;
@ -121,14 +136,16 @@ EOF;
$class = $class.' '.$args['class'];
}
$data = 'data-current-value="'.$value.'"';
if (isset($args['data'])) {
if (is_array($args['data'])) {
foreach ($args['data'] as $x => $y) {
$data .= ' data-'.$x.' = "'.$y.'"';
}
}
}
if (!isset($args['disable-current-value'])) {
$data = 'data-current-value="'.$value.'"';
}
if (isset($args['data'])) {
if (is_array($args['data'])) {
foreach ($args['data'] as $x => $y) {
$data .= ' data-'.$x.' = "'.$y.'"';
}
}
}
return <<<EOF
<div class="mb-3 row">
@ -179,7 +196,7 @@ return <<<EOF
<div class="mb-3 row">
$label
<div class="col-sm-10">
<input class="$class" $data id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled $readonly>
<input class="$class" $data id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" autocomplete="off" $disabled $readonly>
$tip
</div>
</div>
@ -263,7 +280,7 @@ EOF;
return <<<EOF
<div class="mb-2">
$label
<input class="$class" $data id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" $disabled $readonly>
<input class="$class" $data id="$id" name="$name" value="$value" placeholder="$placeholder" type="$type" autocomplete="off" $disabled $readonly>
$tip
</div>
EOF;
@ -285,7 +302,7 @@ EOF;
}
$html = '<div class="'.$class.'">';
$html .= '<input type="file" class="custom-file-input" id="'.$id.'">';
$html .= '<input type="file" class="custom-file-input" id="'.$id.'" autocomplete="off">';
$html .= '<label class="custom-file-label" for="'.$id.'">'.$args['label'].'</label>';
$html .= '</div>';
@ -369,7 +386,7 @@ return <<<EOF
<div class="$class">
$label
<div class="form-check">
<input type="hidden" $data name="$name" value="$value"><input id="$id" type="checkbox" class="form-check-input" onclick="this.previousSibling.value=1-this.previousSibling.value" $checked>
<input type="hidden" $data name="$name" value="$value" autocomplete="off"><input id="$id" type="checkbox" class="form-check-input" onclick="this.previousSibling.value=1-this.previousSibling.value" autocomplete="off" $checked>
<label class="form-check-label" for="$id">$labelForCheckbox</label>
$tip
</div>

View file

@ -126,6 +126,13 @@ class Text {
return str_replace(array_keys($replace), array_values($replace), $text);
}
// Remove HTML entities from the string
// HTML entities: &amp; &quot; &#039; &lt; &gt;
public static function removeHTMLEntities($string)
{
return preg_replace("/&#?[a-z0-9]+;/i", "", $string);
}
public static function removeSpecialCharacters($string, $replace='')
{
return preg_replace("/[\/_|+:!@#$%^&*()'\"<>\\\`}{;=,?\[\]~. -]+/", $replace, $string);
@ -156,6 +163,8 @@ class Text {
{
global $L;
$string = self::removeHTMLEntities($string);
if (EXTREME_FRIENDLY_URL && $allowExtremeFriendlyURL) {
$string = self::lowercase($string);
$string = trim($string, $separator);
@ -176,6 +185,7 @@ class Text {
}
}
// Clean
$string = preg_replace("/[^a-zA-Z0-9\/_|+. -]/", '', $string);
$string = self::lowercase($string);
$string = preg_replace("/[\/_|+ -]+/", $separator, $string);

View file

@ -1,5 +1,5 @@
/*
Javascript global functions
Javascript global functions
*/
function sanitizeHTML(text) {
@ -55,4 +55,16 @@ function formatBytes(bytes, decimals = 2) {
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
/*
Returns TRUE if the JSON text is valid, FALSE otherwise
*/
function isJson(text) {
try {
JSON.parse(text);
} catch (e) {
return false;
}
return true;
}

View file

@ -213,7 +213,15 @@ class Pages extends dbJSON {
$html = Sanitize::html($customValue);
// Store the custom field as defined type
if (isset($customFields[$customField])) {
settype($html, $customFields[$customField]['type']);
if ($customFields[$customField]['type']=='bool') {
if ($html==='false' or $html===false) {
$html = false;
} else {
$html = true;
}
} else {
settype($html, $customFields[$customField]['type']);
}
$row['custom'][$customField]['value'] = $html;
}
}
@ -853,12 +861,8 @@ class Pages extends dbJSON {
// The structure for the custom fields need to be a valid JSON format
// The custom fields are incremental, this means the custom fields are never deleted
// The pages only store the value of the custom field, the structure of the custom fields are in the database site.php
public function setCustomFields($fields)
public function setCustomFields($customFields)
{
$customFields = json_decode($fields, true);
if (json_last_error() != JSON_ERROR_NONE) {
return false;
}
foreach ($this->db as $pageKey=>$pageFields) {
foreach ($customFields as $customField=>$customValues) {
if (!isset($pageFields['custom'][$customField])) {
@ -870,7 +874,6 @@ class Pages extends dbJSON {
}
}
}
return $this->save();
}

View file

@ -9,18 +9,18 @@ $examples = array(
'description' => 'A warm welcome to your new website.',
'tags' => array('Welcome', 'Plugins', 'Themes', 'Bludit'),
'content' =>
'<p>Thanks for chose Bludit and welcome to our community, we are growing up everyday and is awesome.</p>
<p>Follow Bludit in different social networks:</p>
'<p>Thank you for choosing Bludit and welcome to our community, we are growing every day and it\'s amazing.</p>
<p>Follow Bludit on different social networks:</p>
<ul>
<li><a href="https://twitter.com/bludit">https://twitter.com/bludit</a></li>
<li><a href="https://www.facebook.com/bluditcms">https://www.facebook.com/bluditcms</a></li>
</ul>
<p>Take a look to the plugins and themes:</p>
<p>Take a look at the plugins and themes:</p>
<ul>
<li><a href="https://plugins.bludit.com">https://plugins.bludit.com</a></li>
<li><a href="https://themes.bludit.com">https://themes.bludit.com</a></li>
</ul>
<p>Do you need support or you want to read about Bludit, check our official documentation or participate in our forum.</p>
<p>Do you need support? or want to read about Bludit, consult our official documentation or participate in our forum</p>
<ul>
<li><a href="https://forum.bludit.org">https://forum.bludit.org</a></li>
<li><a href="https://docs.bludit.com">https://docs.bludit.com</a></li>
@ -36,7 +36,7 @@ $examples = array(
'tags' => array('Language', 'Timezone', 'Markdown', 'Bludit'),
'content' =>
'<h2>Site information</h2>
<p>Improve your site information and metadata. Include a site description to refine your ranking on the search engines, add social networks, include a site logo with your brand.</p>
<p>Improve your site information and metadata. Include a site description to refine your ranking on the search engines, add social networks, and include a site logo with your brand.</p>
<h2>Language and Timezone</h2>
<p>Bludit supports a variety of languages and time zones. Choose the option that best suits you and your visitors.</p>
<h2>Admin panel</h2>
@ -48,7 +48,7 @@ $examples = array(
<p>Bludit supports Markdown, you just need to enable the right editor to work with it.</p>
<ol>
<li>Go to the Admin panel</li>
<li>Go to Plugins section</li>
<li>Go to the plugins section</li>
<li>Disable TinyMCE plugin</li>
<li>Enable EasyMDE plugin</li>
</ol>'

View file

@ -3,7 +3,7 @@
"native": "Italiano (Italia)",
"english-name": "Italian",
"last-update": "2022-04-07",
"locale": "it, it_IT"
"locale": "it, it_IT",
"authors": [
"Daniele La Pira https:\/\/github.com\/danielelapira",
"Giuseppe Pignataro https:\/\/github.com\/fastbyte01",
@ -285,18 +285,6 @@
"there-are-no-sticky-pages-at-this-moment": "Non c'è nessuna pagina sticky in questo momento.",
"there-are-no-scheduled-pages-at-this-moment": "Non c'è nessuna pagina programmata in questo momento.",
"update": "Aggiorna",
"template": "Template",
"nickname": "Nickname",
"disable-user": "Disabilita utente",
@ -308,7 +296,6 @@
"extreme-friendly-url": "URL estremamente friendly",
"title-formats": "Formati titolo",
"delete-content": "Elimina contenuto",
"sticky": "Sticky",
"actions": "Azioni",
"edit": "Modifica",
@ -335,8 +322,6 @@
"allow-unicode": "Permetti Unicode",
"allow-unicode-characters-in-the-url-and-some-part-of-the-system": "Permette i caratteri Unicode nell'URL e in alcune parti del sistema.",
"variables-allowed": "Variabili permesse",
"tag": "Tag",
"drag-and-drop-to-sort-the-plugins": "Sposta e trascina per ordinare i plugin.",
"seo": "SEO",
@ -393,7 +378,7 @@
"custom-fields": "Campi personalizzati",
"define-custom-fields-for-the-content": "Definisci campi personalizzati per il contenuto. Scopri di più sui campi personalizzati nella <a href='https:\/\/docs.bludit.com\/en\/content\/custom-fields'>documentazione<\/a>.",
"start-typing-to-see-a-list-of-suggestions": "Inizia a scrivere per vedere un elenco di suggerimenti.",
"view": "Visualizza"
"view": "Visualizza",
"confirm": "Conferma",
"current-password": "Password attuale",
"are-you-sure-you-want-to-disable-this-user": "Sei sicuro di voler disabilitare questo utente?",

View file

@ -44,6 +44,31 @@ if ($modulesRequiredExit) {
// Bludit constanst, variables, language and locale settings
// ============================================================================
// Bludit version
define('BLUDIT_VERSION', '4.0.0');
define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', '2021-05-23');
define('BLUDIT_BUILD', '20210523');
// Log
define('LOG_SEP', ' | ');
define('LOG_TYPE_INFO', '[INFO]');
define('LOG_TYPE_WARN', '[WARN]');
define('LOG_TYPE_ERROR', '[ERROR]');
// Debug mode
define('DEBUG_MODE', TRUE);
define('DEBUG_TYPE', 'INFO'); // INFO, TRACE
error_reporting(0); // Turn off all error reporting
ini_set("display_errors", 0); // Turn off display errors in browser
ini_set('display_startup_errors', 0);
if (DEBUG_MODE) {
// Turn on all error reporting, will be display in log server
ini_set("html_errors", 1);
ini_set('log_errors', 1);
error_reporting(E_ALL);
}
// Security constant
define('BLUDIT', true);
@ -70,7 +95,6 @@ define('PATH_ABSTRACT', PATH_KERNEL . 'abstract' . DS);
// Protecting against Symlink attacks
define('CHECK_SYMBOLIC_LINKS', TRUE);
define('FILENAME', 'index.txt');
define('LOG_SEP', ' | ');
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
define('CHARSET', 'UTF-8');
define('DEFAULT_LANGUAGE_FILE', 'en.json');