623 lines
19 KiB
PHP
623 lines
19 KiB
PHP
<?php
|
|
/*
|
|
Plugin Name: LDC Messages
|
|
Description: Gestion des formulaires de contact
|
|
Version: 1.0
|
|
Author: Vincent BRIDIER
|
|
*/
|
|
|
|
use Dompdf\Dompdf as DOMPDF;
|
|
|
|
// Cron
|
|
require_once 'cron.php';
|
|
require_once 'roles.php';
|
|
|
|
function getPostContactInfo($postID)
|
|
{
|
|
$contactsLists = getContactsList();
|
|
foreach ($contactsLists as $cList) {
|
|
if (in_array($postID, $cList['postsIDS'])) {
|
|
return $cList;
|
|
}
|
|
}
|
|
return [];
|
|
}
|
|
/**
|
|
* Recupere les email de contact pour un post donné
|
|
*
|
|
* @param int $postID
|
|
* @return array
|
|
*/
|
|
function getPostContacts($postID): array
|
|
{
|
|
$contactInfo = getPostContactInfo($postID);
|
|
return $contactInfo['contacts'] ?? [];
|
|
}
|
|
|
|
add_action('admin_menu', 'plugin_menu');
|
|
function plugin_menu()
|
|
{
|
|
add_menu_page('LDC Messages', 'LDC Messages', LDC_MESSAGE_CAP, 'ldc-messages', 'init', 'dashicons-email-alt', 30);
|
|
}
|
|
|
|
function ldc_messages()
|
|
{
|
|
wp_register_style('ldc_messages', plugins_url('style.css', __FILE__));
|
|
wp_enqueue_style('ldc_messages');
|
|
}
|
|
add_action('admin_init', 'ldc_messages');
|
|
|
|
function my_admin_scripts()
|
|
{
|
|
wp_enqueue_style('fancyboxcss', get_template_directory_uri() . '/assets/js/fancybox/jquery.fancybox.min.css', false, '1.1', 'all');
|
|
wp_enqueue_script('fancyboxjs', get_template_directory_uri() . '/assets/js/fancybox/jquery.fancybox.min.js', false, '1.1', 'all');
|
|
|
|
wp_enqueue_script('ldc_messages', plugins_url('script.js', __FILE__), array('jquery'), '1.0.0', false);
|
|
}
|
|
add_action('admin_enqueue_scripts', 'my_admin_scripts');
|
|
|
|
add_action('wp_ajax_getMsg', 'getMsg');
|
|
add_action('wp_ajax_nopriv_getMsg', 'getMsg');
|
|
|
|
function getMsg()
|
|
{
|
|
global $wpdb;
|
|
|
|
$msg_id = $_POST['id'];
|
|
|
|
$msg = $wpdb->get_row("SELECT * FROM wp_messages, wp_messages_types WHERE wp_messages.type_id = wp_messages_types.id AND wp_messages.id = $msg_id LIMIT 1", OBJECT);
|
|
|
|
if ($msg === NULL)
|
|
die('<h1>Message inconnu</h1>');
|
|
|
|
echo renderMessage($msg);
|
|
|
|
die();
|
|
}
|
|
|
|
//Ajax pour ouvrir la page de réponse
|
|
add_action('wp_ajax_getReponseForMsg', 'getReponseForMsg');
|
|
add_action('wp_ajax_nopriv_getReponseForMsg', 'getReponseForMsg');
|
|
|
|
function getReponseForMsg()
|
|
{
|
|
global $wpdb;
|
|
|
|
$msg_id = $_POST['id'];
|
|
|
|
$msg = $wpdb->get_row("SELECT * FROM wp_messages, wp_messages_types WHERE wp_messages.type_id = wp_messages_types.id AND wp_messages.id = $msg_id LIMIT 1", OBJECT);
|
|
|
|
if ($msg === NULL)
|
|
die('<h1>Message inconnu</h1>');
|
|
|
|
echo renderMessage($msg);
|
|
|
|
die();
|
|
}
|
|
|
|
//Ajax d'envoi de la réponse
|
|
add_action('wp_ajax_sendReponse', 'sendReponse');
|
|
add_action('wp_ajax_nopriv_sendReponse', 'sendReponse');
|
|
|
|
function sendReponse()
|
|
{
|
|
global $wpdb;
|
|
|
|
$email = $_POST['email'];
|
|
$message = $_POST['message'];
|
|
$msg_id = $_POST['id'];
|
|
$ref = $_POST['ref'];
|
|
|
|
$message = "REF: $ref <br><br>" . nl2br($message);
|
|
|
|
wp_mail($email, "Réponse à votre message sur le site LDC", $message);
|
|
|
|
$wpdb->update(
|
|
'wp_messages',
|
|
[
|
|
'response' => $message,
|
|
'response_date' => date('Y-m-d H:i:s'),
|
|
'status' => 1,
|
|
],
|
|
['id' => $msg_id],
|
|
[
|
|
'%s',
|
|
'%s',
|
|
'%d',
|
|
]
|
|
);
|
|
|
|
$html = "<h1>Message Envoyé !</h1>";
|
|
|
|
echo ($html);
|
|
|
|
die();
|
|
}
|
|
|
|
add_action('wp_ajax_markMsg', 'markMsg');
|
|
add_action('wp_ajax_nopriv_markMsg', 'markMsg');
|
|
|
|
function markMsg()
|
|
{
|
|
global $wpdb;
|
|
|
|
$msg_id = $_POST['id'];
|
|
|
|
$wpdb->update(
|
|
'wp_messages',
|
|
['status' => 1],
|
|
['id' => $msg_id],
|
|
['%d']
|
|
);
|
|
|
|
die();
|
|
}
|
|
|
|
add_action('wp_ajax_downloadMsg', 'downloadMsg');
|
|
add_action('wp_ajax_nopriv_downloadMsg', 'downloadMsg');
|
|
|
|
function downloadMsg()
|
|
{
|
|
global $wpdb;
|
|
|
|
$msg_id = $_GET['id'];
|
|
|
|
$msg = $wpdb->get_row("SELECT * FROM wp_messages, wp_messages_types WHERE wp_messages.type_id = wp_messages_types.id AND wp_messages.id = $msg_id LIMIT 1", OBJECT);
|
|
|
|
outputMessageToPDF($msg->ref, $msg->date, renderMessage($msg, true));
|
|
exit;
|
|
}
|
|
|
|
function generateRandomString($length = 10)
|
|
{
|
|
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
$charactersLength = strlen($characters);
|
|
$randomString = '';
|
|
for ($i = 0; $i < $length; $i++) {
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
}
|
|
return $randomString;
|
|
}
|
|
|
|
add_action('wp_ajax_ContactAjx', 'ContactAjx');
|
|
add_action('wp_ajax_nopriv_ContactAjx', 'ContactAjx');
|
|
|
|
function ContactAjx()
|
|
{
|
|
global $wpdb;
|
|
|
|
if (!isset($_POST['id']) || empty($_POST['id']) || !isset($_POST['firstname']) || empty($_POST['firstname']) || !isset($_POST['lastname']) || empty($_POST['lastname']) || !isset($_POST['email']) || empty($_POST['email'])) {
|
|
$error = new WP_Error('001', 'Check Failure', 'Required values');
|
|
wp_send_json_error($error, 500);
|
|
die();
|
|
}
|
|
|
|
$postID = sanitize_text_field($_POST['id']);
|
|
$firstname = sanitize_text_field($_POST['firstname']);
|
|
$lastname = sanitize_text_field($_POST['lastname']);
|
|
$email = sanitize_email($_POST['email']);
|
|
|
|
|
|
$gToken = $_POST['token'];
|
|
|
|
$secret = getenv('LDC_MSG_PLUGIN_RECAPTCHA');
|
|
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && $_SERVER["HTTP_X_FORWARDED_FOR"] != "") {
|
|
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')) {
|
|
$explode = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
|
$remoteip = trim($explode[0]);
|
|
} else {
|
|
$remoteip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
}
|
|
} else {
|
|
$remoteip = $_SERVER["REMOTE_ADDR"];
|
|
}
|
|
|
|
$api_url = "https://www.google.com/recaptcha/api/siteverify?secret=" . $secret . "&response=" . $gToken . "&remoteip=" . $remoteip;
|
|
$decode = json_decode(file_get_contents($api_url), true);
|
|
|
|
if ($decode['success'] == true) {
|
|
|
|
$content = "";
|
|
|
|
foreach ($_POST as $key => $item) {
|
|
if ($key === 'firstname' || $key === 'lastname' || $key === 'email' || $key === 'action' || $key === 'id' || $key === 'token')
|
|
continue;
|
|
|
|
if (is_array($item)) {
|
|
$content .= ucfirst($key) . " :\n\r";
|
|
foreach ($item as $v) {
|
|
$content .= "- $v \n\r";
|
|
}
|
|
} else {
|
|
$content .= ucfirst($key) . " : " . $item . "\n\r";
|
|
}
|
|
}
|
|
// ! Freaking sanitize inputs
|
|
$firstname = strip_tags($firstname);
|
|
$lastname = strip_tags($lastname);
|
|
$email = strip_tags($email);
|
|
$content = strip_tags($content);
|
|
|
|
$ref = date('ymd') . '-' . generateRandomString(4);
|
|
|
|
$wpdb->insert(
|
|
'wp_messages',
|
|
[
|
|
'ref' => $ref,
|
|
'firstname' => $firstname,
|
|
'lastname' => $lastname,
|
|
'email' => $email,
|
|
'content' => $content,
|
|
'status' => 0,
|
|
'date' => date('Y-m-d H:i:s'),
|
|
'type_id' => getPostContactInfo($postID)['MessageTypeID']
|
|
],
|
|
[
|
|
'%s',
|
|
'%s',
|
|
'%s',
|
|
'%s',
|
|
'%s',
|
|
'%d',
|
|
'%s',
|
|
'%d'
|
|
]
|
|
);
|
|
|
|
$mInfo = getPostContactInfo($postID);
|
|
|
|
$dest_emails = getPostContacts($postID);
|
|
$title = "Vous avez un message à traiter sur le site LDC";
|
|
$content = genMailString($title, nl2br(sprintf(
|
|
"<p>%s : %s %s \n E-mail : %s \n %s \n %s</p>",
|
|
$ref,
|
|
$firstname,
|
|
$lastname,
|
|
$email,
|
|
$mInfo['MessageLabel'] ?? '',
|
|
$content
|
|
)));
|
|
wp_mail($dest_emails, $title, $content, ['Content-Type: text/html; charset=UTF-8']);
|
|
} else {
|
|
$error = new WP_Error('002', 'Check Failure', 'Recaptcha');
|
|
wp_send_json_error($error, 500);
|
|
}
|
|
die();
|
|
}
|
|
|
|
function genMailString(string $title, string $message)
|
|
{
|
|
return "<!DOCTYPE html><html lang=\"fr\"><head><meta charset=\"UTF-8\"><title>$title</title></head><body>$message</body></html>";
|
|
}
|
|
|
|
// Function to change email address
|
|
function wpb_sender_email($original_email_address)
|
|
{
|
|
return 'nepasrepondre@ldc.fr';
|
|
}
|
|
|
|
// Function to change sender name
|
|
function wpb_sender_name($original_email_from)
|
|
{
|
|
return 'Groupe LDC';
|
|
}
|
|
|
|
// Hooking up our functions to WordPress filters
|
|
add_filter('wp_mail_from', 'wpb_sender_email');
|
|
add_filter('wp_mail_from_name', 'wpb_sender_name');
|
|
|
|
function renderMessage($msg, $isPdf = false)
|
|
{
|
|
$o = '';
|
|
if ($isPdf) {
|
|
$o = "<h1>Message " . $msg->ref . " sur ldc.fr</h1>";
|
|
if ($msg->status) {
|
|
$o .= "<h2>Statut : Traité";
|
|
if ($msg->response_date) {
|
|
$o .= " le " . date('d/m/Y H:i', strtotime($msg->response_date));
|
|
}
|
|
$o .= "</h2>";
|
|
} else {
|
|
$o .= "<h2>À traiter</h2>";
|
|
}
|
|
}
|
|
return $o .
|
|
"<div class='msg-reponse'>" .
|
|
"<h1>Message du consommateur :</h1>" .
|
|
"<p><strong>Nom Prénom : </strong>" . $msg->lastname . " " . $msg->firstname . "</p>" .
|
|
"<p><strong>E-mail : </strong>" . $msg->email . "</p>" .
|
|
"<p>" . renderMessageContent($msg->content) . "</p>" .
|
|
($msg->response ? renderResponse($msg) : (!$isPdf ? renderResponseForm($msg) : '')) .
|
|
"</div>";
|
|
}
|
|
|
|
function renderResponse($msg)
|
|
{
|
|
return
|
|
"<h1>Réponse :</h1>" .
|
|
"<p>le : " . date('d/m/Y H:i', strtotime($msg->response_date)) . "</p>" .
|
|
"<p>" . renderMessageContent($msg->response) . "</p>";
|
|
}
|
|
|
|
function renderResponseForm($msg)
|
|
{
|
|
return
|
|
"<h1>Votre Réponse :</h1>" .
|
|
"<input type='hidden' name='email' id='emailTosend' value='" . $msg->email . "'/>" .
|
|
"<textarea name='answer' id='msgTosend'></textarea>" .
|
|
"<button class='send-answer' id='msgTosend'>Envoyer</button>";
|
|
}
|
|
|
|
function renderMessageContent($textString)
|
|
{
|
|
return nl2br(htmlspecialchars(stripslashes(preg_replace('~\s*<br ?/?>\s*~', "\n", $textString))));
|
|
}
|
|
|
|
function outputMessageToPDF($ref, $date, $htmlMessageString)
|
|
{
|
|
// instantiate and use the dompdf class
|
|
$dompdf = new DOMPDF();
|
|
$dompdf->load_html($htmlMessageString);
|
|
|
|
// (Optional) Setup the paper size and orientation
|
|
$dompdf->setPaper('A4', 'portrait');
|
|
|
|
// Render the HTML as PDF
|
|
$dompdf->render();
|
|
|
|
$dompdf->stream("Message_" . $ref . "_" . date('d-m-Y_H:i', strtotime($date)));
|
|
die();
|
|
}
|
|
|
|
/**
|
|
* Récupère les messages par page
|
|
* en fonction du champ de recherche
|
|
*
|
|
* @param int $page Le numéro de la page
|
|
* @param int $limit LE nombre maximal d'éléments dans une page
|
|
* @param string $search Le texte a rechercher sur un des champs
|
|
* @param int $status Recherche avec un statut, $search ne doit pas être à false
|
|
*
|
|
* @return object
|
|
*/
|
|
function getMessages($page, $limit = 8, $search = false, $status = null)
|
|
{
|
|
global $wpdb;
|
|
|
|
if (!$page or !strlen($page) or $page <= 0) {
|
|
$page = 1;
|
|
}
|
|
|
|
$offset = ($page * $limit) - $limit;
|
|
|
|
$query = 'wp_messages.id AS msg_id' .
|
|
' FROM wp_messages, wp_messages_types' .
|
|
' WHERE wp_messages.type_id = wp_messages_types.id';
|
|
|
|
if ($search !== false and !empty($search)) {
|
|
// * Text search filter
|
|
$search = trim(strip_tags($search));
|
|
|
|
// string search
|
|
$query .=
|
|
" AND (ref = '$search'" .
|
|
" OR ref LIKE '%$search%'" .
|
|
" OR email LIKE '%$search%'" .
|
|
" OR date LIKE '%$search%'" .
|
|
" OR firstname LIKE '%$search%'" .
|
|
" OR lastname LIKE '%$search%'";
|
|
|
|
//type search
|
|
foreach (queryMessagesTypesFromDB() as $type) {
|
|
if (strpos(strtolower($type->name), strtolower($search)) !== false) {
|
|
$query .= " OR type_id = $type->id";
|
|
}
|
|
}
|
|
|
|
// status
|
|
if (strpos(
|
|
strtolower(remove_accents('traité')),
|
|
strtolower(remove_accents($search))
|
|
) !== false) {
|
|
$query .= ' OR status = 1';
|
|
} elseif (strpos(
|
|
strtolower(remove_accents('À traiter')),
|
|
strtolower(remove_accents($search))
|
|
) !== false) {
|
|
$query .= ' OR status = 0';
|
|
}
|
|
|
|
$query .= ')';
|
|
}
|
|
// status
|
|
if ($status !== null) {
|
|
$query .= " AND status = $status";
|
|
}
|
|
|
|
$total = $wpdb->get_results(
|
|
'SELECT count(*) as total,' . $query,
|
|
OBJECT
|
|
)[0]->total;
|
|
|
|
$query .= " ORDER BY status, date LIMIT $offset, $limit";
|
|
$query = 'SELECT *,' . $query;
|
|
$results = $wpdb->get_results($query, OBJECT);
|
|
|
|
return (object)[
|
|
'total' => $total,
|
|
'currentPage' => $page,
|
|
'firstPage' => 1,
|
|
'lastPage' => ceil($total / $limit),
|
|
'data' => $results
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Récupère les types de mesasges dans la base de donnée
|
|
*
|
|
* @return array
|
|
*/
|
|
function queryMessagesTypesFromDB()
|
|
{
|
|
global $wpdb;
|
|
|
|
return $wpdb->get_results("SELECT * FROM wp_messages_types");
|
|
}
|
|
|
|
function start_session_if_needed()
|
|
{
|
|
if (!session_id()) {
|
|
@session_start();
|
|
}
|
|
}
|
|
|
|
// Start session on init hook.
|
|
add_action('init', 'start_session_if_needed');
|
|
|
|
function init()
|
|
{
|
|
/**
|
|
* Nombre de messages par page
|
|
*
|
|
* @var int
|
|
* */
|
|
$messagesByPage = 8;
|
|
$search = isset($_SESSION['LDC_MESSAGE.search']) ? strval($_SESSION['LDC_MESSAGE.search']) : false;
|
|
// * Fetch from search
|
|
$search = ($_SERVER['REQUEST_METHOD'] === 'POST' and isset($_POST['search'])) ?
|
|
sanitize_text_field($_POST['search']) : $search;
|
|
// * Reset if present in search
|
|
$search = ($_SERVER['REQUEST_METHOD'] === 'GET' and isset($_GET['search'])) ? false : $search;
|
|
$_SESSION['LDC_MESSAGE.search'] = $search;
|
|
$searchLabel = $search ? "- Recherche de '{$search}'" : '';
|
|
|
|
$currentPage = isset($_GET['p']) ? intval(sanitize_text_field($_GET['p'])) : 1;
|
|
$status = isset($_GET['s']) ? intval((bool)sanitize_text_field($_GET['s'])) : null;
|
|
$statusLabel = $status == '0' ? 'À traiter' : ($status == '1' ? 'Traité' : 'Tout');
|
|
$messages = getMessages($currentPage, $messagesByPage, $search, $status);
|
|
|
|
$page = '<div class="wrap">';
|
|
$page .= "<h1 class=\"wp-heading-inline\">Gestion des messages - LDC - {$statusLabel} {$searchLabel}</h1>";
|
|
|
|
$page .= "<form class='ldc_messages_search' method='POST' action='/wp-admin/admin.php?page=ldc-messages&s={$status}'>";
|
|
$page .= "<div>";
|
|
$page .= "<a href='/wp-admin/admin.php?page=ldc-messages' class='ldc_messages_btn'>Tout</a>";
|
|
$page .= "<a href='/wp-admin/admin.php?page=ldc-messages&s=0' class='ldc_messages_btn ldc_messages_bg_red'>À traiter</a>";
|
|
$page .= "<a href='/wp-admin/admin.php?page=ldc-messages&s=1' class='ldc_messages_btn ldc_messages_bg_green'>Traité</a>";
|
|
$page .= "</div>";
|
|
$page .= "<input type=\"text\" name=\"search\" style=\"min-width: 28rem;\" placeholder=\"Recherche selon de multiples critères\" value=\"{$search}\" required/>";
|
|
if (!empty($searchLabel)) {
|
|
$page .= " <a href=\"/wp-admin/admin.php?page=ldc-messages&s={$status}&search\">Effacer</a> ";
|
|
}
|
|
$page .= "<button type='submit'>Rechercher</button>";
|
|
$page .= "</form>";
|
|
|
|
// Tableau
|
|
$page .= "<table class='ldc_messages_table'>";
|
|
|
|
$page .= "<tr>";
|
|
|
|
$page .= "<th>#</th>";
|
|
$page .= "<th>Date</th>";
|
|
$page .= "<th>Statut</th>";
|
|
$page .= "<th>Nom</th>";
|
|
$page .= "<th>Prénom</th>";
|
|
$page .= "<th>Email</th>";
|
|
$page .= "<th>Type</th>";
|
|
$page .= "<th>Date de réponse</th>";
|
|
$page .= "<th></th>";
|
|
|
|
$page .= "</tr>";
|
|
|
|
foreach ($messages->data as $message) {
|
|
$page .= "<tr>";
|
|
|
|
$page .= "<td style='font-weight: bold;'>$message->ref</td>";
|
|
|
|
$page .= "<td>" . date('d/m/Y H:i', strtotime($message->date)) . "</td>";
|
|
|
|
if ($message->status === '0') {
|
|
$page .= "<td><p class='ldc_messages_red'>À traiter</p></td>";
|
|
} else {
|
|
$page .= "<td><p class='ldc_messages_green'>Traité</p></td>";
|
|
}
|
|
|
|
$page .= "<td>$message->lastname</td>";
|
|
$page .= "<td>$message->firstname</td>";
|
|
$page .= "<td><a href='mailto:$message->email'>$message->email</a></td>";
|
|
$page .= "<td>$message->name</td>";
|
|
|
|
if ($message->response_date !== NULL) {
|
|
$page .= "<td>" . date('d/m/Y H:i', strtotime($message->response_date)) . "</td>";
|
|
} elseif ($message->status) {
|
|
$page .= "<td>Marqué comme traité</td>";
|
|
} else {
|
|
$page .= "<td>-</td>";
|
|
}
|
|
|
|
if ($message->status === '0') {
|
|
$page .= "<td>";
|
|
$page .= "<a href='#' class='answer-msg' data-id='$message->msg_id' data-ref='$message->ref'>Répondre</a><br>";
|
|
$page .= "<a href='#' class='mark-msg' data-id='$message->msg_id' data-ref='$message->ref'>Marquer comme traité</a><br>";
|
|
$page .= "<a href='" . admin_url('admin-ajax.php') . "?action=downloadMsg&id=$message->msg_id'>Télécharger en PDF</a>";
|
|
$page .= "</td>";
|
|
} else {
|
|
$page .= "<td>";
|
|
$page .= "<a href='#' class='show-msg' data-id='$message->msg_id'>Afficher</a><br>";
|
|
$page .= "<a href='" . admin_url('admin-ajax.php') . "?action=downloadMsg&id=$message->msg_id'>Télécharger en PDF</a>";
|
|
$page .= "</td>";
|
|
}
|
|
|
|
$page .= "</tr>";
|
|
}
|
|
|
|
$page .= "</table>";
|
|
|
|
$genLink = function ($page, $text = null) use ($currentPage, $status) {
|
|
$class = $currentPage === $page ? "class='active'" : "";
|
|
$link = "/wp-admin/admin.php?page=ldc-messages&p=$page";
|
|
if ($status !== null) {
|
|
$link .= "&s=$status";
|
|
}
|
|
return "<a href='$link' $class>" . ($text ?? $page) . "</a>";
|
|
};
|
|
|
|
if ($messages->total and $messages->total > $messagesByPage) {
|
|
$page .= "<div class='ldc_messages_pagination'>";
|
|
|
|
if ($messages->firstPage != $messages->lastPage) {
|
|
$page .= $messages->firstPage !== $messages->currentPage ?
|
|
$genLink(1, 'Début') : '<span>Début</span>';
|
|
}
|
|
$limitPagesIndexShow = 5;
|
|
$iStartPage = ($messages->currentPage - 2) < $messages->firstPage ?
|
|
$messages->firstPage : ($messages->currentPage - 2);
|
|
if ($iStartPage != $messages->firstPage) {
|
|
$page .= "<span>...</span>";
|
|
}
|
|
for ($i = $iStartPage; $i <= $messages->lastPage; $i++) {
|
|
$page .= $i !== $messages->currentPage ?
|
|
$genLink($i) : "<span>$i</span>";
|
|
if ($i >= ($iStartPage + $limitPagesIndexShow)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($messages->currentPage < ($messages->lastPage - 2)) {
|
|
$page .= "<span>...</span>";
|
|
}
|
|
|
|
if ($messages->firstPage != $messages->lastPage) {
|
|
$page .= $messages->lastPage != $messages->currentPage ?
|
|
$genLink($messages->lastPage, 'Fin') : '<span>Fin</span>';
|
|
}
|
|
$page .= " <div>Total messages : $messages->total</div>";
|
|
$page .= "</div>";
|
|
}
|
|
|
|
$page .= "<div id='reponse-msg' style='display:none'></div>";
|
|
|
|
$page .= '</div>';
|
|
|
|
echo $page;
|
|
}
|