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
|
||||
* @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) {
|
||||
// Ouverture formulaire
|
||||
$html = '<form id="' . $id . '" enctype="multipart/form-data" method="post">';
|
||||
public static function formOpenFile($id, $action = '') {
|
||||
// Ouverture formulaire
|
||||
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']
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ if($this->isPost() && isset($_POST['commentPageFormPrev' ])){
|
|||
}
|
||||
|
||||
// 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
|
||||
|
@ -48,15 +48,15 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
|||
if( $detectBot === 'bot') $_SESSION['humanBot']='bot';
|
||||
}
|
||||
// $_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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Lecture des inputs
|
||||
$valueText = $this->getInput('commentPageFormInput[0]', helper::FILTER_STRING_SHORT, true);
|
||||
$valueTextarea = $this->getInput('commentPageFormInput[1]', helper::FILTER_STRING_LONG_NOSTRIP, true);
|
||||
|
||||
|
||||
// Mise à jour du brouillon
|
||||
$_SESSION['draftPage']['text'] = $valueText;
|
||||
$_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( $valueTextarea !== '') $content .= '<strong>' . $text['core']['showComment'][10] . ' :</strong> ' . $valueTextarea . '<br>';
|
||||
// Données
|
||||
$data[$text['core']['showComment'][9]] = $valueText;
|
||||
$data[$text['core']['showComment'][9]] = $valueText;
|
||||
$data[$text['core']['showComment'][10]] = $valueTextarea;
|
||||
|
||||
// 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 ||
|
||||
$singleuser !== '' ||
|
||||
$singlemail !== '' )
|
||||
) {
|
||||
) {
|
||||
// Utilisateurs dans le groupe
|
||||
$to = [];
|
||||
if ($group > 0){
|
||||
|
@ -152,25 +152,25 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) {
|
|||
}
|
||||
} else {
|
||||
$sent = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Notifications
|
||||
if( $sent === true) {
|
||||
$_SESSION['DELTA_NOTIFICATION_SUCCESS']= $text['core']['showComment'][4];
|
||||
$_SESSION['DELTA_NOTIFICATION_ERROR'] = '';
|
||||
} else {
|
||||
$_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
|
||||
$nbPage =0;
|
||||
$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',
|
||||
|
@ -250,7 +252,7 @@ echo template::formOpenFile('commentPageFormForm'); ?>
|
|||
'value' => $_SESSION['draftPage']['textarea'],
|
||||
'class' => 'editorWysiwygComment',
|
||||
'noDirty' => true
|
||||
]); ?>
|
||||
]); ?>
|
||||
</div>
|
||||
<?php if( $this->getData(['config', 'social', 'comment', 'captcha']) && ( $_SESSION['humanBot']==='bot') || $this->getData(['config', 'connect', 'captchaBot'])===false ): ?>
|
||||
<div class="row">
|
||||
|
@ -288,9 +290,9 @@ echo template::formOpenFile('commentPageFormForm'); ?>
|
|||
<br>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
<?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();
|
||||
?>
|
||||
echo template::formClose();
|
||||
?>
|
||||
|
|
|
@ -80,10 +80,12 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
.commentPageButtonPrevNext{
|
||||
width: 25%;
|
||||
.commentPageButtonPrevNext{
|
||||
border-radius: 10%;
|
||||
width: 60px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.commentPageButtonPageNb{
|
||||
width: 40%;
|
||||
width: 120px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
|
|
@ -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'; } /* '' */
|
||||
|
|
|
@ -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'; } /* '' */
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue