news avec paramétrages des couleurs

This commit is contained in:
Deltacms 2024-01-06 09:06:47 +01:00
parent 510c315a85
commit 7b4c780a49
17 changed files with 110 additions and 61 deletions

View File

@ -1,36 +0,0 @@
<?php
session_start();
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');
function random($tab) {
return $tab[array_rand($tab)];
}
$chars = '0123456789';
$char1 = mt_rand( 0, strlen($chars) - 1 );
$char2 = mt_rand( 0, strlen($chars) - 1 );
$_SESSION['captcha'] = md5((int)$char1 + (int)$char2);
// polices utilisées
$fonts = glob('polices/*.ttf');
// création de l'image captcha
$image = imagecreatefrompng('captcha.png');
// couleurs des caractères
$colors = array ( imagecolorallocate($image, 238, 238, 238),
imagecolorallocate($image, 51, 51, 51),
imagecolorallocate($image, 0, 102, 153),
imagecolorallocate($image, 204, 0, 51),
imagecolorallocate($image, 255, 51, 51),
imagecolorallocate($image, 51, 255, 51),
imagecolorallocate($image, 255, 255, 51) );
// positions, polices, caractères et couleurs randomisées
imagettftext($image, 28, -10, 7, 50, random($colors), ABSPATH .'/'. random($fonts), $char1);
imagettftext($image, 28, 0, 50, 50, random($colors), ABSPATH .'/'. 'polices/Eskiula.ttf', '+');
imagettftext($image, 28, -35, 75, 50, random($colors), ABSPATH .'/'. random($fonts), $char2);
imagettftext($image, 28, 0, 125, 50, random($colors), ABSPATH .'/'. 'polices/Eskiula.ttf', '=');
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -17,6 +17,16 @@ if ( typeof(lang_admin) == 'undefined') {
if ( typeof(initSnipcart) == 'undefined') {
var initSnipcart = false;
};
// Adaptations pour la saisie des news
if ( typeof(newsAddEdit) == 'undefined') {
var newsAddEdit = false;
};
if(newsAddEdit){
var content_css = [ baseUrl + "core/layout/common.css",baseUrl + "core/layout/mediaqueries.css",baseUrl + "core/vendor/tinymce/content.css",baseUrl + "site/data/theme.css",baseUrl + "site/data/news/themeNews.css",baseUrl + "site/data/custom.css"];
} else {
var content_css = [baseUrl + "core/layout/common.css",baseUrl + "core/layout/mediaqueries.css",baseUrl + "core/vendor/tinymce/content.css",baseUrl + "site/data/theme.css",baseUrl + "site/data/custom.css"];
}
newAddEdit = false;
var pluginsList = "advlist anchor autolink autoresize autosave codemirror colorpicker contextmenu fullscreen hr image imagetools link lists media paste searchreplace stickytoolbar tabfocus table template textcolor nonbreaking";
var toolbarList = "restoredraft | undo redo | formatselect bold italic underline forecolor backcolor | fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist | table template | image media link | code fullscreen";
var templatesList = [
@ -225,13 +235,7 @@ tinymce.init({
// Contenu du menu contextuel
contextmenu: "selectall searchreplace | hr | media image link anchor nonbreaking | insertable cell row column deletetable",
// Fichiers CSS à intégrer à l'éditeur
content_css: [
baseUrl + "core/layout/common.css",
baseUrl + "core/layout/mediaqueries.css",
baseUrl + "core/vendor/tinymce/content.css",
baseUrl + "site/data/theme.css",
baseUrl + "site/data/custom.css"
],
content_css,
// Classe à ajouter à la balise body dans l'iframe
body_class: "editorWysiwyg",
// Cache les menus

View File

@ -12,7 +12,7 @@ $text['news_view']['config'][8] = 'Articles per page';
$text['news_view']['config'][9] = 'Article abstract';
$text['news_view']['config'][10] = 'Module theme';
$text['news_view']['config'][12] = 'Thickness';
$text['news_view']['config'][13] = 'Colour visible in the absence of an image. The horizontal slider sets the level of transparency';
$text['news_view']['config'][13] = 'The colors are initialized to those of the site.';
$text['news_view']['config'][14] = 'Border colour';
$text['news_view']['config'][15] = 'Background colour';
$text['news_view']['config'][16] = 'Title';
@ -35,6 +35,10 @@ $text['news_view']['config'][32] = 'Help';
$text['news_view']['config'][33] = 'module/news/view/config/config.help_en.html';
$text['news_view']['config'][34] = 'Hidden media';
$text['news_view']['config'][35] = 'This option hides the media in the preview';
$text['news_view']['config'][36] = 'Text color';
$text['news_view']['config'][37] = 'Heading color';
$text['news_view']['config'][38] = 'Link color';
$text['news_view']['config'][39] = 'Date and signature color';
$text['news_view']['index'][0] = 'read more';
$text['news_view']['index'][1] = 'No news.';
$text['news_view']['index'][2] = ' Edit';

View File

@ -12,7 +12,7 @@ $text['news_view']['config'][8] = 'Artículos por página';
$text['news_view']['config'][9] = 'Artículo abstracto';
$text['news_view']['config'][10] = 'Tema del módulo';
$text['news_view']['config'][12] = 'Grosor';
$text['news_view']['config'][13] = 'Color visible en ausencia de una imagen.<br />El control deslizante horizontal ajusta el nivel de transparencia.';
$text['news_view']['config'][13] = 'Los colores se inicializan con los del sitio.';
$text['news_view']['config'][14] = 'Color del borde';
$text['news_view']['config'][15] = 'Color de fondo';
$text['news_view']['config'][16] = 'Título';
@ -35,6 +35,10 @@ $text['news_view']['config'][32] = 'Ayuda';
$text['news_view']['config'][33] = 'module/news/view/config/config.help_en.html';
$text['news_view']['config'][34] = 'Medios ocultos';
$text['news_view']['config'][35] = 'Esta opción oculta los medios en la vista previa.';
$text['news_view']['config'][36] = 'Color del texto';
$text['news_view']['config'][37] = 'Color del encabezado';
$text['news_view']['config'][38] = 'Color del enlace';
$text['news_view']['config'][39] = 'Color de firma y fecha';
$text['news_view']['index'][0] = 'leer más';
$text['news_view']['index'][1] = 'Sin noticias.';
$text['news_view']['index'][2] = 'Editar';

View File

@ -12,7 +12,7 @@ $text['news_view']['config'][8] = 'Articles par page';
$text['news_view']['config'][9] = 'Abrégé de l\'article';
$text['news_view']['config'][10] = 'Thème du module';
$text['news_view']['config'][12] = 'Epaisseur';
$text['news_view']['config'][13] = 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.';
$text['news_view']['config'][13] = 'Les couleurs sont initialisées à celles du site.';
$text['news_view']['config'][14] = 'Couleur de la bordure';
$text['news_view']['config'][15] = 'Couleur du fond';
$text['news_view']['config'][16] = 'Titre';
@ -35,6 +35,10 @@ $text['news_view']['config'][32] = 'Aide';
$text['news_view']['config'][33] = 'module/news/view/config/config.help.html';
$text['news_view']['config'][34] = 'Médias cachés';
$text['news_view']['config'][35] = 'Cette option cache les médias dans l\'aperçu.';
$text['news_view']['config'][36] = 'Couleur du texte';
$text['news_view']['config'][37] = 'Couleur des titres';
$text['news_view']['config'][38] = 'Couleur des liens';
$text['news_view']['config'][39] = 'Couleur de la date et de la siganture';
$text['news_view']['index'][0] = 'lire la suite';
$text['news_view']['index'][1] = 'Aucune news.';
$text['news_view']['index'][2] = ' Editer';

View File

@ -18,7 +18,7 @@
class news extends common {
const VERSION = '4.7';
const VERSION = '4.8';
const REALNAME = 'News';
const DELETE = true;
const UPDATE = '0.0';
@ -140,6 +140,15 @@ class news extends common {
'state' => true
]);
}
// Mise à jour ou création du fichier site/data/news/themeNews.css
$style = '.editorWysiwyg{';
$style .= 'background-color:' . $this->getData(['module', $this->getUrl(0), 'theme', 'backgroundColor']) . ';';
$style .= '}';
$style .= '.editorWysiwyg a{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'linkColor']) .'}';
$style .= 'p{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'textColor']) .'}';
$style .= 'h1, h2, h3, h4, h5, h6{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'titleColor']) .'}';
file_put_contents(self::DATADIRECTORY . 'themeNews.css', $style );
// Liste des utilisateurs
self::$users = helper::arrayCollumn($this->getData(['user']), 'firstname');
ksort(self::$users);
@ -186,7 +195,11 @@ class news extends common {
$style .= 'border-radius:' . $this->getInput('newsBorderRadius',helper::FILTER_STRING_SHORT).';';
$style .= 'box-shadow:' . $this->getInput('newsBorderShadows',helper::FILTER_STRING_SHORT).';';
$style .= 'background-color:' . $this->getInput('newsThemeBackgroundColor') . ';';
$style .= 'color:' . $this->getInput('newsThemeTextColor') . ';';
$style .= '}';
$style .= '.newsFrame a{ color:'. $this->getInput('newsThemeLinkColor') .'}';
$style .= '.newsFrame h1,.newsFrame h2,.newsFrame h3,.newsFrame h4,.newsFrame h5,.newsFrame h6{ color:'. $this->getInput('newsThemeTitleColor') .'}';
$style .= '.newsSignature { color:' . $this->getInput('newsThemeSignatureColor') . ';';
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0))) {
@ -202,6 +215,10 @@ class news extends common {
'borderColor' => $this->getInput('newsThemeBorderColor'),
'borderWidth' => $this->getInput('newsThemeBorderWidth',helper::FILTER_STRING_SHORT),
'backgroundColor' => $this->getInput('newsThemeBackgroundColor'),
'textColor' => $this->getInput('newsThemeTextColor'),
'titleColor' => $this->getInput('newsThemeTitleColor'),
'linkColor' => $this->getInput('newsThemeLinkColor'),
'signatureColor' => $this->getInput('newsThemeSignatureColor'),
'borderRadius' => $this->getInput('newsBorderRadius',helper::FILTER_STRING_SHORT),
'borderShadows' => $this->getInput('newsBorderShadows',helper::FILTER_STRING_SHORT)
]]);
@ -405,6 +422,14 @@ class news extends common {
'state' => true
]);
}
// Mise à jour ou création du fichier site/data/news/themeNews.css
$style = '.editorWysiwyg{';
$style .= 'background-color:' . $this->getData(['module', $this->getUrl(0), 'theme', 'backgroundColor']) . ';';
$style .= '}';
$style .= '.editorWysiwyg a{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'linkColor']) .'}';
$style .= 'p{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'textColor']) .'}';
$style .= 'h1, h2, h3, h4, h5, h6{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'titleColor']) .'}';
file_put_contents(self::DATADIRECTORY . 'themeNews.css', $style );
// Liste des utilisateurs
self::$users = helper::arrayCollumn($this->getData(['user']), 'firstname');
ksort(self::$users);
@ -634,10 +659,15 @@ class news extends common {
$this->setData(['module',$this->getUrl(0),'config', 'hideMedia', false ]);
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '4.5' ]);
}
// Mise à jour 4.7
if (version_compare($versionData, '4.7', '<') ) {
// Mise à jour 4.8
if (version_compare($versionData, '4.8', '<') ) {
// Nouvelles couleurs par défaut en configuration
$this->setData(['module', $this->getUrl(0), 'theme','textColor', $this->getData(['theme', 'text', 'textColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme','linkColor', $this->getData(['theme', 'text', 'linkColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme','titleColor', $this->getData(['theme', 'title', 'textColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme','signatureColor', $this->getData(['theme', 'text', 'textColor' ]) ]);
// Mettre à jour la version
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '4.7' ]);
$this->setData(['module',$this->getUrl(0),'config', 'versionData', '4.8' ]);
}
}
@ -658,6 +688,13 @@ class news extends common {
$this->setData(['module', $this->getUrl(0), 'theme', init::$defaultTheme]);
$this->setData(['module', $this->getUrl(0), 'theme', 'style', self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' ]);
}
// Couleurs initialisées à celles du site
$this->setData(['module', $this->getUrl(0), 'theme', 'backgroundColor', $this->getData(['theme', 'site', 'backgroundColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme', 'textColor', $this->getData(['theme', 'text', 'textColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme', 'linkColor', $this->getData(['theme', 'text', 'linkColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme', 'titleColor', $this->getData(['theme', 'title', 'textColor' ]) ]);
$this->setData(['module', $this->getUrl(0), 'theme', 'signatureColor', $this->getData(['theme', 'text', 'textColor' ]) ]);
// Dossier de l'instance
if (!is_dir(self::DATADIRECTORY . $this->getUrl(0) )) {
@ -670,7 +707,11 @@ class news extends common {
$style = '.newsFrame {';
$style .= 'border:' . $this->getData(['module', $this->getUrl(0), 'theme', 'borderStyle' ]) . ' ' .$this->getData(['module', $this->getUrl(0), 'theme', 'borderColor' ]) . ' ' . $this->getData(['module', $this->getUrl(0), 'theme', 'borderWidth' ]) . ';';
$style .= 'background-color:' . $this->getData(['module', $this->getUrl(0), 'theme', 'backgroundColor' ]) . ';';
$style .= 'color:' . $this->getData(['module', $this->getUrl(0), 'theme','textColor']) . ';';
$style .= '}';
$style .= '.newsFrame a{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'linkColor' ]) .'}';
$style .= '.newsFrame h1,.newsFrame h2,.newsFrame h3,.newsFrame h4,.newsFrame h5,.newsFrame h6{ color:'. $this->getData(['module', $this->getUrl(0), 'theme', 'titleColor' ]) .'}';
$style .= '.newsSignature { color:' . $this->getData(['module', $this->getUrl(0), 'theme', 'signatureColor' ]) . ';';
// Sauver la feuille de style
file_put_contents(self::DATADIRECTORY . $this->getUrl(0) . '/theme.css' , $style );

View File

@ -12,12 +12,11 @@ class init extends news {
'sameHeight' => false,
'noMargin' => true
];
public static $defaultTheme = [
'style' => '',
'borderColor' => 'rgba(33, 34, 35, 1)',
'backgroundColor' => 'rgba(255, 255, 255, 1)',
'borderWidth' => '0',
'style' => '',
'borderColor' => 'rgba(33, 34, 35, 1)',
'borderWidth' => '0',
'borderRadius' => '0px',
'borderShadows' => '0px 0px 0px'
];

View File

@ -8,4 +8,4 @@
$("#newsAddDraft").on("click", function() {
$("#newsAddState").val(0);
$("#newsAddForm").trigger("submit");
});
});

View File

@ -5,7 +5,7 @@ include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) .
// Passage de la langue d'administration à Tinymce et flatpickr
$lang_admin = $text['news_view']['add'][12];
$lang_flatpickr = $text['news_view']['add'][13];
?><script> var lang_admin = "<?php echo $lang_admin; ?>"; var lang_flatpickr = "<?php echo $lang_flatpickr; ?>";</script>
?><script> var lang_admin = "<?php echo $lang_admin; ?>"; var lang_flatpickr = "<?php echo $lang_flatpickr; ?>";var newsAddEdit = true;</script>
<?php echo template::formOpen('newsAddForm'); ?>
<div class="row">

View File

@ -117,22 +117,51 @@ echo template::formOpen('newsConfig'); ?>
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'backgroundColor'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('newsThemeTextColor', [
'class' => 'colorPicker',
'label' => $text['news_view']['config'][36],
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'textColor'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('newsThemeTitleColor', [
'class' => 'colorPicker',
'label' => $text['news_view']['config'][37],
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'titleColor'])
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::text('newsThemeLinkColor', [
'class' => 'colorPicker',
'label' => $text['news_view']['config'][38],
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'linkColor'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('newsThemeSignatureColor', [
'class' => 'colorPicker',
'label' => $text['news_view']['config'][39],
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'signatureColor'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('newsThemeBorderColor', [
'class' => 'colorPicker',
'help' => $text['news_view']['config'][13],
'label' => $text['news_view']['config'][14],
'value' => $this->getData(['module', $this->getUrl(0),'theme', 'borderColor'])
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::select('newsThemeBorderWidth', $borderWidth, [
'label' => $text['news_view']['config'][12],
'selected' => $this->getData(['module', $this->getUrl(0),'theme', 'borderWidth'])
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::select('newsBorderRadius', $newsRadius, [
'label' => $text['news_view']['config'][22],

View File

@ -5,7 +5,7 @@ include('./module/news/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) .
// Passage de la langue d'administration à Tinymce et flatpickr
$lang_admin = $text['news_view']['edit'][12];
$lang_flatpickr = $text['news_view']['edit'][13];
?><script> var lang_admin = "<?php echo $lang_admin; ?>"; var lang_flatpickr = "<?php echo $lang_flatpickr; ?>";</script>
?><script> var lang_admin = "<?php echo $lang_admin; ?>"; var lang_flatpickr = "<?php echo $lang_flatpickr; ?>";var newsAddEdit = true;</script>
<?php echo template::formOpen('newsEditForm'); ?>
<div class="row">