suite commentaires de page

This commit is contained in:
Deltacms 2024-02-06 07:53:14 +01:00
parent 29d198c307
commit 497dc4297c
7 changed files with 61 additions and 34 deletions

View File

@ -269,11 +269,16 @@ class template {
/**
* Ouvre un formulaire protégé par CSRF
* @param string $id Id du formulaire
* @param string $action action du formulaire
* @return string
*/
public static function formOpen($id) {
public static function formOpen($id, $action = '') {
// Ouverture formulaire
$html = '<form id="' . $id . '" method="post">';
if($action === ''){
$html = '<form id="' . $id . '" method="post">';
} else {
$html = '<form id="' . $id . '" method="post" action="'.$action.'">';
}
// Stock le token CSRF
$html .= self::hidden('csrf', [
'value' => $_SESSION['csrf']
@ -285,11 +290,16 @@ class template {
/**
* Ouvre un formulaire avec pièce jointe protégé par CSRF
* @param string $id Id du formulaire
* @param string $action action du formulaire
* @return string
*/
public static function formOpenFile($id) {
public static function formOpenFile($id, $action = '') {
// Ouverture formulaire
$html = '<form id="' . $id . '" enctype="multipart/form-data" method="post">';
if($action === ''){
$html = '<form id="' . $id . '" enctype="multipart/form-data" method="post">';
} else {
$html = '<form id="' . $id . '" enctype="multipart/form-data" method="post" action="'.$action.'">';
}
// Stock le token CSRF
$html .= self::hidden('csrf', [
'value' => $_SESSION['csrf']

View File

@ -1299,7 +1299,7 @@ class common {
*/
echo '<div class="'. $content . '" id="contentSite">';
$this->showContent();
if( $this->getData(['page', $this->getUrl(0), 'commentEnable']) === true ) $this->showComment();
if( $this->getData(['page', $this->getUrl(0), 'commentEnable']) === true && strlen($this->getUrl(1)) < 3 ) $this->showComment();
if (file_exists(self::DATA_DIR . 'body.inc.php')) {
include(self::DATA_DIR . 'body.inc.php');
}
@ -1358,7 +1358,15 @@ class common {
*
*/
public function showComment() {
include('./core/include/comment.inc.php');
// Si la page est accessible
if( $this->getData(['page', $this->getUrl(0), 'group']) === self::GROUP_VISITOR
OR (
$this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')
AND $this->getUser('group') >= $this->getData(['page', $this->getUrl(0), 'group'])
)
) {
include('./core/include/comment.inc.php');
}
}
/**

View File

@ -170,7 +170,7 @@ $nbPage =0;
if ( !isset($_SESSION[$commentNumPage] )) $_SESSION[$commentNumPage] = 1;
$dataPage = $this->getData(['comment', $this->getUrl(0), 'data']);
if ( NULL !== $dataPage && is_array($dataPage) && $dataPage !== [] ) {
$nbPage = round(count( $dataPage) / self::ITEMSPAGE, 0, PHP_ROUND_HALF_UP);
$nbPage = ceil(count( $dataPage) / self::ITEMSPAGE);
if( $_SESSION[$commentNumPage] > $nbPage ) $_SESSION[$commentNumPage] = $nbPage;
if( $_SESSION[$commentNumPage] <= 0 ) $_SESSION[$commentNumPage] = 1;
$paramPage = $this->getUrl() .'/'. $_SESSION[$commentNumPage];
@ -237,7 +237,9 @@ echo '<script> var lang_admin = "'.$lang_page.'"; </script>';
<div id="formCommentVisible" style="display: none;">
<?php // Formulaire
echo template::formOpenFile('commentPageFormForm'); ?>
$action = helper::baseUrl().$this->getUrl().'#commentAnchor';
echo template::formOpenFile('commentPageFormForm', $action);
?>
<div class="humanBot">
<?php echo template::text('commentPageFormInput[0]', [
'id' => 'commentPageFormInput_0',
@ -290,7 +292,7 @@ echo template::formOpenFile('commentPageFormForm'); ?>
<?php
// Affichage des messages
echo '<div class="block msgs">';
echo '<div id="commentAnchor" class="block msgs">';
if($data):
foreach( $data as $key1=>$value1){
if( is_array($value1)){
@ -304,12 +306,11 @@ if($data):
endif;
echo '</div>';
if($pagesComment && $nbPage > 1){ ?>
<div class="row" >
<?php $disabledNext = false;
$disabledPrev = false;
if($_SESSION[$commentNumPage] <= 1) $disabledPrev = true;
if($_SESSION[$commentNumPage] >= $nbPage) $disabledNext = true; ?>
<div class="col4 offset4">
<div class="textAlignCenter" style="margin-top: 20px;">
<?php echo template::submit('commentPageFormPrev', [
'class' => 'commentPageButtonPrevNext',
'value' => '<',
@ -328,7 +329,7 @@ if($pagesComment && $nbPage > 1){ ?>
'ico' =>''
]); ?>
</div>
</div> <?php
<?php
}
echo template::formClose();
?>

View File

@ -81,9 +81,11 @@
}
.commentPageButtonPrevNext{
width: 25%;
border-radius: 10%;
width: 60px;
font-size: 1.2em;
}
.commentPageButtonPageNb{
width: 40%;
width: 120px;
font-size: 1em;
}

View File

@ -54,4 +54,5 @@
.delta-ico-instagram:before { content: '\f16d'; } /* '' */
.delta-ico-brush:before { content: '\f1fc'; } /* '' */
.delta-ico-pinterest:before { content: '\f231'; } /* '' */
.delta-ico-left-open:before { content: '\e832'; } /* '' */
.delta-ico-right-open:before { content: '\e833'; } /* '' */

View File

@ -96,4 +96,5 @@
.delta-ico-instagram:before { content: '\f16d'; } /* '' */
.delta-ico-brush:before { content: '\f1fc'; } /* '' */
.delta-ico-pinterest:before { content: '\f231'; } /* '' */
.delta-ico-left-open:before { content: '\e832'; } /* '' */
.delta-ico-right-open:before { content: '\e833'; } /* '' */

View File

@ -175,6 +175,8 @@ tinymce.init({
});
},
// Hauteur en pixels de la zone d'édition
height: 500,
// Langue
language: lang_admin,
// Plugins
@ -337,6 +339,8 @@ tinymce.init({
}
});
},
// Hauteur en pixels de la zone d'édition
height: 300,
// Langue
language: lang_admin,
// Plugins