suite commentaires de page
This commit is contained in:
parent
29d198c307
commit
497dc4297c
|
@ -269,11 +269,16 @@ class template {
|
||||||
/**
|
/**
|
||||||
* Ouvre un formulaire protégé par CSRF
|
* Ouvre un formulaire protégé par CSRF
|
||||||
* @param string $id Id du formulaire
|
* @param string $id Id du formulaire
|
||||||
|
* @param string $action action du formulaire
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function formOpen($id) {
|
public static function formOpen($id, $action = '') {
|
||||||
// Ouverture formulaire
|
// 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
|
// Stock le token CSRF
|
||||||
$html .= self::hidden('csrf', [
|
$html .= self::hidden('csrf', [
|
||||||
'value' => $_SESSION['csrf']
|
'value' => $_SESSION['csrf']
|
||||||
|
@ -285,11 +290,16 @@ class template {
|
||||||
/**
|
/**
|
||||||
* Ouvre un formulaire avec pièce jointe protégé par CSRF
|
* Ouvre un formulaire avec pièce jointe protégé par CSRF
|
||||||
* @param string $id Id du formulaire
|
* @param string $id Id du formulaire
|
||||||
|
* @param string $action action du formulaire
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function formOpenFile($id) {
|
public static function formOpenFile($id, $action = '') {
|
||||||
// Ouverture formulaire
|
// 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
|
// Stock le token CSRF
|
||||||
$html .= self::hidden('csrf', [
|
$html .= self::hidden('csrf', [
|
||||||
'value' => $_SESSION['csrf']
|
'value' => $_SESSION['csrf']
|
||||||
|
|
|
@ -1299,7 +1299,7 @@ class common {
|
||||||
*/
|
*/
|
||||||
echo '<div class="'. $content . '" id="contentSite">';
|
echo '<div class="'. $content . '" id="contentSite">';
|
||||||
$this->showContent();
|
$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')) {
|
if (file_exists(self::DATA_DIR . 'body.inc.php')) {
|
||||||
include(self::DATA_DIR . 'body.inc.php');
|
include(self::DATA_DIR . 'body.inc.php');
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1358,15 @@ class common {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function showComment() {
|
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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -24,7 +24,7 @@ if($this->isPost() && isset($_POST['commentPageFormPrev' ])){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Traitement de l'envoi du formualire
|
// Traitement de l'envoi du formualire
|
||||||
if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
||||||
|
|
||||||
|
|
||||||
// $notice concerne la détection d'erreurs
|
// $notice concerne la détection d'erreurs
|
||||||
|
@ -48,15 +48,15 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
||||||
if( $detectBot === 'bot') $_SESSION['humanBot']='bot';
|
if( $detectBot === 'bot') $_SESSION['humanBot']='bot';
|
||||||
}
|
}
|
||||||
// $_SESSION['humanBot']==='bot' ou option 'Pas de Captcha pour un humain' non validée
|
// $_SESSION['humanBot']==='bot' ou option 'Pas de Captcha pour un humain' non validée
|
||||||
elseif( md5($code) !== $_SESSION['captcha'] ) {
|
elseif( md5($code) !== $_SESSION['captcha'] ) {
|
||||||
$notice = $text['core']['showComment'][1];
|
$notice = $text['core']['showComment'][1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lecture des inputs
|
// Lecture des inputs
|
||||||
$valueText = $this->getInput('commentPageFormInput[0]', helper::FILTER_STRING_SHORT, true);
|
$valueText = $this->getInput('commentPageFormInput[0]', helper::FILTER_STRING_SHORT, true);
|
||||||
$valueTextarea = $this->getInput('commentPageFormInput[1]', helper::FILTER_STRING_LONG_NOSTRIP, true);
|
$valueTextarea = $this->getInput('commentPageFormInput[1]', helper::FILTER_STRING_LONG_NOSTRIP, true);
|
||||||
|
|
||||||
// Mise à jour du brouillon
|
// Mise à jour du brouillon
|
||||||
$_SESSION['draftPage']['text'] = $valueText;
|
$_SESSION['draftPage']['text'] = $valueText;
|
||||||
$_SESSION['draftPage']['textarea'] = $valueTextarea;
|
$_SESSION['draftPage']['textarea'] = $valueTextarea;
|
||||||
|
@ -69,7 +69,7 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
||||||
if( $valueText !== '') $content .= '<strong>' . $text['core']['showComment'][9] . ' :</strong> ' . $valueText . '<br>';
|
if( $valueText !== '') $content .= '<strong>' . $text['core']['showComment'][9] . ' :</strong> ' . $valueText . '<br>';
|
||||||
if( $valueTextarea !== '') $content .= '<strong>' . $text['core']['showComment'][10] . ' :</strong> ' . $valueTextarea . '<br>';
|
if( $valueTextarea !== '') $content .= '<strong>' . $text['core']['showComment'][10] . ' :</strong> ' . $valueTextarea . '<br>';
|
||||||
// Données
|
// Données
|
||||||
$data[$text['core']['showComment'][9]] = $valueText;
|
$data[$text['core']['showComment'][9]] = $valueText;
|
||||||
$data[$text['core']['showComment'][10]] = $valueTextarea;
|
$data[$text['core']['showComment'][10]] = $valueTextarea;
|
||||||
|
|
||||||
// Bot présumé, la page sera actualisée avec l'affichage du captcha complet
|
// Bot présumé, la page sera actualisée avec l'affichage du captcha complet
|
||||||
|
@ -106,7 +106,7 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
||||||
$group > 0 ||
|
$group > 0 ||
|
||||||
$singleuser !== '' ||
|
$singleuser !== '' ||
|
||||||
$singlemail !== '' )
|
$singlemail !== '' )
|
||||||
) {
|
) {
|
||||||
// Utilisateurs dans le groupe
|
// Utilisateurs dans le groupe
|
||||||
$to = [];
|
$to = [];
|
||||||
if ($group > 0){
|
if ($group > 0){
|
||||||
|
@ -152,25 +152,25 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$sent = false;
|
$sent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
if( $sent === true) {
|
if( $sent === true) {
|
||||||
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= $text['core']['showComment'][4];
|
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= $text['core']['showComment'][4];
|
||||||
$_SESSION['DELTA_NOTIFICATION_ERROR'] = '';
|
$_SESSION['DELTA_NOTIFICATION_ERROR'] = '';
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= '';
|
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= '';
|
||||||
$_SESSION['DELTA_NOTIFICATION_ERROR'] = $text['core']['showComment'][5];
|
$_SESSION['DELTA_NOTIFICATION_ERROR'] = $text['core']['showComment'][5];
|
||||||
}
|
}
|
||||||
$this->showNotification();
|
$this->showNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Préparation de la liste paginée des commentaires // Initialisation de la pagination
|
// Préparation de la liste paginée des commentaires // Initialisation de la pagination
|
||||||
$nbPage =0;
|
$nbPage =0;
|
||||||
if ( !isset($_SESSION[$commentNumPage] )) $_SESSION[$commentNumPage] = 1;
|
if ( !isset($_SESSION[$commentNumPage] )) $_SESSION[$commentNumPage] = 1;
|
||||||
$dataPage = $this->getData(['comment', $this->getUrl(0), 'data']);
|
$dataPage = $this->getData(['comment', $this->getUrl(0), 'data']);
|
||||||
if ( NULL !== $dataPage && is_array($dataPage) && $dataPage !== [] ) {
|
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] > $nbPage ) $_SESSION[$commentNumPage] = $nbPage;
|
||||||
if( $_SESSION[$commentNumPage] <= 0 ) $_SESSION[$commentNumPage] = 1;
|
if( $_SESSION[$commentNumPage] <= 0 ) $_SESSION[$commentNumPage] = 1;
|
||||||
$paramPage = $this->getUrl() .'/'. $_SESSION[$commentNumPage];
|
$paramPage = $this->getUrl() .'/'. $_SESSION[$commentNumPage];
|
||||||
|
@ -237,7 +237,9 @@ echo '<script> var lang_admin = "'.$lang_page.'"; </script>';
|
||||||
|
|
||||||
<div id="formCommentVisible" style="display: none;">
|
<div id="formCommentVisible" style="display: none;">
|
||||||
<?php // Formulaire
|
<?php // Formulaire
|
||||||
echo template::formOpenFile('commentPageFormForm'); ?>
|
$action = helper::baseUrl().$this->getUrl().'#commentAnchor';
|
||||||
|
echo template::formOpenFile('commentPageFormForm', $action);
|
||||||
|
?>
|
||||||
<div class="humanBot">
|
<div class="humanBot">
|
||||||
<?php echo template::text('commentPageFormInput[0]', [
|
<?php echo template::text('commentPageFormInput[0]', [
|
||||||
'id' => 'commentPageFormInput_0',
|
'id' => 'commentPageFormInput_0',
|
||||||
|
@ -250,7 +252,7 @@ echo template::formOpenFile('commentPageFormForm'); ?>
|
||||||
'value' => $_SESSION['draftPage']['textarea'],
|
'value' => $_SESSION['draftPage']['textarea'],
|
||||||
'class' => 'editorWysiwygComment',
|
'class' => 'editorWysiwygComment',
|
||||||
'noDirty' => true
|
'noDirty' => true
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if( $this->getData(['config', 'social', 'comment', 'captcha']) && ( $_SESSION['humanBot']==='bot') || $this->getData(['config', 'connect', 'captchaBot'])===false ): ?>
|
<?php if( $this->getData(['config', 'social', 'comment', 'captcha']) && ( $_SESSION['humanBot']==='bot') || $this->getData(['config', 'connect', 'captchaBot'])===false ): ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -288,9 +290,9 @@ echo template::formOpenFile('commentPageFormForm'); ?>
|
||||||
<br>
|
<br>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// Affichage des messages
|
// Affichage des messages
|
||||||
echo '<div class="block msgs">';
|
echo '<div id="commentAnchor" class="block msgs">';
|
||||||
if($data):
|
if($data):
|
||||||
foreach( $data as $key1=>$value1){
|
foreach( $data as $key1=>$value1){
|
||||||
if( is_array($value1)){
|
if( is_array($value1)){
|
||||||
|
@ -304,12 +306,11 @@ if($data):
|
||||||
endif;
|
endif;
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
if($pagesComment && $nbPage > 1){ ?>
|
if($pagesComment && $nbPage > 1){ ?>
|
||||||
<div class="row" >
|
|
||||||
<?php $disabledNext = false;
|
<?php $disabledNext = false;
|
||||||
$disabledPrev = false;
|
$disabledPrev = false;
|
||||||
if($_SESSION[$commentNumPage] <= 1) $disabledPrev = true;
|
if($_SESSION[$commentNumPage] <= 1) $disabledPrev = true;
|
||||||
if($_SESSION[$commentNumPage] >= $nbPage) $disabledNext = true; ?>
|
if($_SESSION[$commentNumPage] >= $nbPage) $disabledNext = true; ?>
|
||||||
<div class="col4 offset4">
|
<div class="textAlignCenter" style="margin-top: 20px;">
|
||||||
<?php echo template::submit('commentPageFormPrev', [
|
<?php echo template::submit('commentPageFormPrev', [
|
||||||
'class' => 'commentPageButtonPrevNext',
|
'class' => 'commentPageButtonPrevNext',
|
||||||
'value' => '<',
|
'value' => '<',
|
||||||
|
@ -328,7 +329,7 @@ if($pagesComment && $nbPage > 1){ ?>
|
||||||
'ico' =>''
|
'ico' =>''
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div> <?php
|
<?php
|
||||||
}
|
}
|
||||||
echo template::formClose();
|
echo template::formClose();
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -80,10 +80,12 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.commentPageButtonPrevNext{
|
.commentPageButtonPrevNext{
|
||||||
width: 25%;
|
border-radius: 10%;
|
||||||
|
width: 60px;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
.commentPageButtonPageNb{
|
.commentPageButtonPageNb{
|
||||||
width: 40%;
|
width: 120px;
|
||||||
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,4 +54,5 @@
|
||||||
.delta-ico-instagram:before { content: '\f16d'; } /* '' */
|
.delta-ico-instagram:before { content: '\f16d'; } /* '' */
|
||||||
.delta-ico-brush:before { content: '\f1fc'; } /* '' */
|
.delta-ico-brush:before { content: '\f1fc'; } /* '' */
|
||||||
.delta-ico-pinterest:before { content: '\f231'; } /* '' */
|
.delta-ico-pinterest:before { content: '\f231'; } /* '' */
|
||||||
|
.delta-ico-left-open:before { content: '\e832'; } /* '' */
|
||||||
|
.delta-ico-right-open:before { content: '\e833'; } /* '' */
|
||||||
|
|
|
@ -96,4 +96,5 @@
|
||||||
.delta-ico-instagram:before { content: '\f16d'; } /* '' */
|
.delta-ico-instagram:before { content: '\f16d'; } /* '' */
|
||||||
.delta-ico-brush:before { content: '\f1fc'; } /* '' */
|
.delta-ico-brush:before { content: '\f1fc'; } /* '' */
|
||||||
.delta-ico-pinterest:before { content: '\f231'; } /* '' */
|
.delta-ico-pinterest:before { content: '\f231'; } /* '' */
|
||||||
|
.delta-ico-left-open:before { content: '\e832'; } /* '' */
|
||||||
|
.delta-ico-right-open:before { content: '\e833'; } /* '' */
|
||||||
|
|
|
@ -175,6 +175,8 @@ tinymce.init({
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// Hauteur en pixels de la zone d'édition
|
||||||
|
height: 500,
|
||||||
// Langue
|
// Langue
|
||||||
language: lang_admin,
|
language: lang_admin,
|
||||||
// Plugins
|
// Plugins
|
||||||
|
@ -337,6 +339,8 @@ tinymce.init({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// Hauteur en pixels de la zone d'édition
|
||||||
|
height: 300,
|
||||||
// Langue
|
// Langue
|
||||||
language: lang_admin,
|
language: lang_admin,
|
||||||
// Plugins
|
// Plugins
|
||||||
|
|
Loading…
Reference in New Issue