if (!empty($_GET['a'])) { ?> <p><a href="commentaires_online.php?a=<?php echo $_GET['a']; ?> ">« Retour à la liste des commentaires de cet article</a></p> <?php } else { ?> <p><a href="commentaires_online.php">« Retour à la liste des commentaires</a></p> <?php } ?> <h2>Rédiger un commentaire (article «<?php echo plxUtils::strCheck(plxUtils::strCut($aArt['title'], 80)); ?> »)</h2> <ul> <li>Auteur : <strong><?php echo plxUtils::strCheck($plxAdmin->aUsers[$_SESSION['user']]['name']); ?> </strong></li> <li>Type de commentaire : <strong>admin</strong></li> <li>Site : <?php echo '<a href="' . $plxAdmin->racine . '">' . $plxAdmin->racine . '</a>'; ?> </li> <li>Article attaché : <?php echo $article;
unset($catsName[0]); if (sizeof($catsName) > 0) { $libCats .= ', ... <a class="help" title="' . implode(',', $catsName) . '"> </a>'; } } else { $libCats = 'Non classé'; } } # Commentaires $nbComsToValidate = $plxAdmin->getNbCommentaires('/^_' . $plxAdmin->plxRecord_arts->f('numero') . '.(.*).xml$/'); $nbComsValidated = $plxAdmin->getNbCommentaires('/^' . $plxAdmin->plxRecord_arts->f('numero') . '.(.*).xml$/'); # On affiche la ligne echo '<tr class="line-' . $plxAdmin->plxRecord_arts->i % 2 . '">'; echo '<td><input type="checkbox" name="idArt[]" value="' . $plxAdmin->plxRecord_arts->f('numero') . '" /></td>'; echo '<td class="tc1"> ' . $day . '/' . $month . '/' . $year . '</td>'; echo '<td class="tc4"> <a href="article.php?a=' . $plxAdmin->plxRecord_arts->f('numero') . '" title="Éditer cet article">' . plxUtils::strCheck(plxUtils::strCut($plxAdmin->plxRecord_arts->f('title'), 60)) . '</a>' . $draft . '</td>'; echo '<td class="tc1"> ' . $libCats . '</td>'; echo '<td class="tc1" style="text-align:center"> <a title="Commentaires en attente de validation" href="commentaires_offline.php?a=' . $plxAdmin->plxRecord_arts->f('numero') . '&page=1">' . $nbComsToValidate . '</a> / <a title="Commentaires publiés" href="commentaires_online.php?a=' . $plxAdmin->plxRecord_arts->f('numero') . '&page=1">' . $nbComsValidated . '</a></td>'; echo '<td class="tc4"> ' . plxUtils::strCheck($author) . '</td>'; echo '<td class="tc4" style="text-align:center"> '; if ($publi and $draft == '') { # Si l'article est publié echo '<a href="' . PLX_ROOT . '?article' . intval($plxAdmin->plxRecord_arts->f('numero')) . '/' . $plxAdmin->plxRecord_arts->f('url') . '" title="Visualiser cet article sur le site">Visualiser</a> - '; } echo '<a href="article.php?a=' . $plxAdmin->plxRecord_arts->f('numero') . '" title="Editer cet article">Éditer</a>'; echo "</td>"; echo "</tr>"; } ?> <tr> <td colspan="7">
$month = substr($plxAdmin->plxRecord_coms->f('date'), 5, 2); $day = substr($plxAdmin->plxRecord_coms->f('date'), 8, 2); $time = substr($plxAdmin->plxRecord_coms->f('date'), 11, 8); $artId = $plxAdmin->plxRecord_coms->f('article'); $id = '_' . $artId . '.' . $plxAdmin->plxRecord_coms->f('numero'); # On coupe le commentaire mais attention aux entités HTML if ($plxAdmin->plxRecord_coms->f('type') == 'admin') { $content = plxUtils::strCut(strip_tags($plxAdmin->plxRecord_coms->f('content')), 70); } else { $content = plxUtils::strCheck(plxUtils::strCut(plxUtils::strRevCheck($plxAdmin->plxRecord_coms->f('content')), 70)); } # On génère notre ligne echo '<tr class="line-' . $plxAdmin->plxRecord_coms->i % 2 . '">'; echo '<td><input type="checkbox" name="idCom[]" value="' . $id . '" /></td>'; echo '<td> ' . $day . '/' . $month . '/' . $year . ' ' . $time . '</td>'; echo '<td> ' . plxUtils::strCut($plxAdmin->plxRecord_coms->f('author'), 15) . '</td>'; echo '<td> <a href="commentaire.php?c=' . $id . (!empty($_GET['a']) ? '&a=' . $_GET['a'] : '') . '" title="Éditer ce commentaire">' . $content . '</a></td>'; echo '<td style="text-align:center"> '; echo '<a href="commentaire.php?c=' . $id . (!empty($_GET['a']) ? '&a=' . $_GET['a'] : '') . '" title="Éditer ce commentaire">Éditer</a> - '; echo '<a href="article.php?a=' . $artId . '" title="Article attaché à ce commentaire">Article</a>'; echo '</td></tr>'; } ?> <tr> <td colspan="5"> <?php plxUtils::printSelect('selection', array('' => 'Pour la sélection...', 'delete' => 'Supprimer', 'online' => 'Valider'), ''); ?> <input class="button" type="submit" name="submit" value="Ok" /> </td> </tr>
/** * Méthode qui affiche les documents du dossier en cours * * @return stdout * @author Stephane F. **/ function displayDocuments($dir, $plxMedias, $view) { if (!empty($plxMedias->aContent['files'])) { echo '<table class="table">'; echo '<thead>'; echo '<tr>'; echo '<th style="width:75%">Nom du fichier</th>'; echo '<th style="width:25%">Action</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; # Initialisation variable de boucles $i = 1; foreach ($plxMedias->aContent['files'] as $k => $v) { $i++; echo '<tr class="line-' . $i % 2 . '">'; echo '<td class="tc1"> ' . plxUtils::strCut($v['name'], 100) . '</td>'; echo '<td class="tc1"> '; if ($view != '') { # Icone pour lien crypté echo '<a href="javascript:void(0)" title="Ajouter le lien pour télécharger le fichier" onclick="opener.insDoc(\'' . $view . '\', \'' . str_replace('../', '', plxEncrypt::encryptId($plxMedias->path . $dir . $v['name'])) . '\', \'' . $v['name'] . '\', \'1\')">'; echo '<img src="img/lock_go.png" alt="Ajouter fichier" /></a> '; # Icone pour lien en clair echo '<a href="javascript:void(0)" title="Ajouter le lien du fichier" onclick="opener.insDoc(\'' . $view . '\', \'' . str_replace('../', '', $plxMedias->path . $dir . $v['name']) . '\', \'' . $v['name'] . '\', \'0\')">'; echo '<img src="img/square.png" alt="Ajouter fichier" /></a> '; } echo "\n" . '<select name="files[' . $dir . $v['name'] . ']">' . $plxMedias->getDirs($dir) . '</select> '; echo '<a href="medias.php?delfile=' . $dir . $v['name'] . '&dir=' . urlencode($dir) . '&hash=' . $_SESSION['hash'] . ($view != '' ? '&v=' . $view : '') . '" title="Supprimer le fichier" onclick="Check=confirm(\'Supprimer ce fichier ?\');if(Check==false) return false;"><img src="img/delete.gif" alt="Supprimer" /></a>'; echo '</td>'; echo '</tr>'; } echo '</tbody>'; echo '</table>'; } else { echo '<p style="padding:10px;">Aucun fichier</p>'; } }
/** * Méthode qui affiche la liste des $max derniers commentaires. * Si la variable $art_id est renseignée, seuls les commentaires de cet article sont retournés. * * @param format format du texte pour chaque commentaire * @param max nombre de commentaires maximum * @param art_id id de l'article cible (24,3) * @param cat_ids liste des categories pour filtrer les derniers commentaires (sous la forme 001|002) * @return stdout * @scope global * @author Florent MONTHEL, Stephane F **/ public function lastComList($format = '<li><a href="#com_url">#com_author L_SAID :</a><br/>#com_content(50)</li>', $max = 5, $art_id = '', $cat_ids = '') { # Hook Plugins if (eval($this->plxMotor->plxPlugins->callHook('plxShowLastComList'))) { return; } # Génération de notre motif if (empty($art_id)) { $motif = '/^[0-9]{4}.[0-9]{10}-[0-9]+.xml$/'; } else { $motif = '/^' . str_pad($art_id, 4, '0', STR_PAD_LEFT) . '.[0-9]{10}-[0-9]+.xml$/'; } $count = 1; $datetime = date('YmdHi'); # Nouvel objet plxGlob et récupération des fichiers $plxGlob_coms = clone $this->plxMotor->plxGlob_coms; if ($aFiles = $plxGlob_coms->query($motif, 'com', 'rsort', 0, false, 'before')) { $aComArtTitles = array(); # tableau contenant les titres des articles $isComArtTitle = strpos($format, '#com_art_title') != FALSE ? true : false; # On parcourt les fichiers des commentaires foreach ($aFiles as $v) { # On filtre si le commentaire appartient à un article d'une catégorie inactive if (isset($this->plxMotor->activeArts[substr($v, 0, 4)])) { $com = $this->plxMotor->parseCommentaire(PLX_ROOT . $this->plxMotor->aConf['racine_commentaires'] . $v); $artInfo = $this->plxMotor->artInfoFromFilename($this->plxMotor->plxGlob_arts->aFiles[$com['article']]); if ($artInfo['artDate'] <= $datetime) { # on ne prends que les commentaires pour les articles publiés if (empty($cat_ids) or preg_match('/(' . $cat_ids . ')/', $artInfo['catId'])) { $url = '?article' . intval($com['article']) . '/' . $artInfo['artUrl'] . '#c' . $com['article'] . '-' . $com['index']; $date = $com['date']; $content = strip_tags($com['content']); # On modifie nos motifs $row = str_replace('L_SAID', L_SAID, $format); $row = str_replace('#com_id', $com['index'], $row); $row = str_replace('#com_url', $this->plxMotor->urlRewrite($url), $row); $row = str_replace('#com_author', $com['author'], $row); while (preg_match('/#com_content\\(([0-9]+)\\)/', $row, $capture)) { if ($com['author'] == 'admin') { $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCut($content, $capture[1]), $row); } else { $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCheck(plxUtils::strCut(plxUtils::strRevCheck($content), $capture[1])), $row); } } $row = str_replace('#com_content', $content, $row); $row = str_replace('#com_date', plxDate::formatDate($date, '#num_day/#num_month/#num_year(4)'), $row); $row = str_replace('#com_hour', plxDate::formatDate($date, '#time'), $row); $row = plxDate::formatDate($date, $row); # récupération du titre de l'article if ($isComArtTitle) { if (isset($aComArtTitles[$com['article']])) { $row = str_replace('#com_art_title', $aComArtTitles[$com['article']], $row); } else { if ($file = $this->plxMotor->plxGlob_arts->query('/^' . $com['article'] . '.(.*).xml$/')) { $art = $this->plxMotor->parseArticle(PLX_ROOT . $this->plxMotor->aConf['racine_articles'] . $file[0]); $aComArtTitles[$com['article']] = $art_title = $art['title']; $row = str_replace('#com_art_title', $art_title, $row); } } } # On genère notre ligne echo $row; $count++; } } } if ($count > $max) { break; } } } }
$num = 0; while ($plxAdmin->plxRecord_coms->loop()) { # On boucle $artId = $plxAdmin->plxRecord_coms->f('article'); $status = $plxAdmin->plxRecord_coms->f('status'); $id = $status . $artId . '.' . $plxAdmin->plxRecord_coms->f('numero'); $content = nl2br($plxAdmin->plxRecord_coms->f('content')); if ($_SESSION['selCom'] == 'all') { $content = '<strong>' . ($status == '' ? L_COMMENT_ONLINE : L_COMMENT_OFFLINE) . '</strong> - ' . $content; } # On génère notre ligne echo '<tr class="line-' . ++$num % 2 . ' top type-' . $plxAdmin->plxRecord_coms->f('type') . '">'; echo '<td><input type="checkbox" name="idCom[]" value="' . $id . '" /></td>'; echo '<td class="datetime">' . plxDate::formatDate($plxAdmin->plxRecord_coms->f('date')) . ' </td>'; echo '<td class="wrap">' . $content . ' </td>'; echo '<td>' . plxUtils::strCut($plxAdmin->plxRecord_coms->f('author'), 30) . ' </td>'; echo '<td class="action">'; echo '<a href="comment_new.php?c=' . $id . (!empty($_GET['a']) ? '&a=' . $_GET['a'] : '') . '" title="' . L_COMMENT_ANSWER . '">' . L_COMMENT_ANSWER . '</a> '; echo '<a href="comment.php?c=' . $id . (!empty($_GET['a']) ? '&a=' . $_GET['a'] : '') . '" title="' . L_COMMENT_EDIT_TITLE . '">' . L_COMMENT_EDIT . '</a> '; echo '<a href="article.php?a=' . $artId . '" title="' . L_COMMENT_ARTICLE_LINKED_TITLE . '">' . L_COMMENT_ARTICLE_LINKED . '</a>'; echo '</td></tr>'; } } else { # Pas de commentaires echo '<tr><td colspan="5" class="center">' . L_NO_COMMENT . '</td></tr>'; } ?> </tbody> </table> </div>
/** * M�thode qui affiche la liste des $max derniers commentaires. * Si la variable $art_id est renseign�e, seulement les commentaires de cet article seront retourn�s. * * @param format format du texte pour chaque commentaire (variable: #com_id, #com_url, #com_author, #com_content(num), #com_content, #com_date, #com_hour) * @param max nombre de commentaires maximum * @param art_id id de l'article cible (24,3) * @return stdout * @scope global * @author Florent MONTHEL, Stephane F **/ public function lastComList($format = '<li><a href="#com_url">#com_author a dit :</a><br/>#com_content(50)</li>', $max = 5, $art_id = '') { # G�n�ration de notre motif if (empty($art_id)) { $motif = '/^[0-9]{4}.[0-9]{10}-[0-9]+.xml$/'; } else { $motif = '/^' . str_pad($art_id, 4, '0', STR_PAD_LEFT) . '.[0-9]{10}-[0-9]+.xml$/'; } # Nouvel objet plxGlob et r�cup�ration des fichiers $plxGlob_coms = plxGlob::getInstance(PLX_ROOT . $this->plxMotor->aConf['racine_commentaires']); $aFiles = $plxGlob_coms->query($motif, 'com', 'rsort', 0, $max); # On parse les fichiers if (is_array($aFiles)) { # On a des fichiers foreach ($aFiles as $v) { # On parcourt tous les fichiers $com = $this->plxMotor->parseCommentaire(PLX_ROOT . $this->plxMotor->aConf['racine_commentaires'] . $v); $url = '?article' . intval($com['article']) . '/#c' . $com['numero']; $date = $com['date']; $content = strip_tags($com['content']); # On modifie nos motifs $row = str_replace('#com_id', $com['numero'], $format); $row = str_replace('#com_url', $this->plxMotor->urlRewrite($url), $row); $row = str_replace('#com_author', $com['author'], $row); while (preg_match('/#com_content\\(([0-9]+)\\)/', $row, $capture)) { if ($com['author'] == 'admin') { $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCut($content, $capture[1]), $row); } else { $row = str_replace('#com_content(' . $capture[1] . ')', plxUtils::strCheck(plxUtils::strCut(plxUtils::strRevCheck($content), $capture[1])), $row); } } $row = str_replace('#com_content', $content, $row); $row = str_replace('#com_date', plxDate::dateIsoToHum($date, '#num_day/#num_month/#num_year(4)'), $row); $row = str_replace('#com_hour', plxDate::dateIsoToHum($date, '#hour:#minute'), $row); # On gen�re notre ligne echo $row; } } }