<?php $manager = new PostManager($db); $userManager = new UserManager($db); $post = $manager->getList($_GET['id'], $min, $max); if (!empty($post)) { for ($i = 0; $i < count($post); $i++) { $postC = $post[$i]; $author = $manager->getAuthor($postC); require 'views/posts.phtml'; } } else { require 'views/error_404.phtml'; }
<?php $manager = new PostManager($db); $postCount = count($manager->getList($_GET['id'])); if (isset($_GET['id'])) { $postPerPage = 10; $manager = new TopicManager($db); $topic = $manager->findById($_GET['id']); if (isset($_GET['p'])) { $pN = intval($_GET['p']); } else { $pN = 1; } $p = $pN - 1; $min = $p * $postPerPage; $max = $min + $postPerPage; require 'views/topic.phtml'; } else { require 'views/home.phtml'; } ?> <?php /* $i = 0; while (isset($listTopic[$i])) { $topic = $listTopic[$i]; require('views/topic.phtml'); $i++; }*/
<?php $postManager = new PostManager($db); $posts = $postManager->getList($_GET['id']); $userManager = new UserManager($db); $i = 0; $c = count($posts); while ($i < $c) { $post = $posts[$i]; $postUser = $postManager->getListUser($post->getIdAuthor()); $NpostUser = count($postUser); $userPost = $userManager->findById($post->getIdAuthor()); require 'views/forum/posts.phtml'; $i++; }
<?php $topicManager = new TopicManager($db); $topics = $topicManager->getList($_GET['id']); $userManager = new UserManager($db); $postManager = new PostManager($db); $i = 0; $c = count($topics); while ($i < $c) { $topic = $topics[$i]; $link = $userManager->findLink($_SESSION['id'], $topic->getId()); $userTopic = $userManager->findById($topic->getIdAuthor()); $lastPost = $postManager->getLastByTopic($topic->getId()); if ($lastPost == TRUE) { $userLastPost = $userManager->findById($lastPost->getIdAuthor()); $posts = $postManager->getList($topic->getId()); $Nrep = count($posts) - 1; } require 'views/forum/topics.phtml'; $i++; }
<?php $manager = new TopicManager($db); $topicList = $manager->getByIdSousRubrique($sousRubrique->getId()); if (!empty($topicList)) { $topic = $topicList[0]; if (is_object($topic)) { $manager = new PostManager($db); $postCount = count($manager->getList($topic->getId())); $postList = $manager->getList($topic->getId(), $postCount - 1, $postCount); $lastPage = ceil($postCount / 10); if (!empty($postList)) { for ($k = 0; $k < count($postList); $k++) { if (isset($postList[$k])) { $lastPost = $postList[$k]; if (is_string($lastPost)) { require 'views/no_last_post.phtml'; } else { $author = $manager->getAuthor($lastPost); $date = date('d M à H:i', strtotime($lastPost->getDate())); require 'views/last_post.phtml'; } } } } else { require 'views/no_last_post.phtml'; } } else { require 'views/no_last_post.phtml'; } } else {
<?php $content = ''; // ________ CREATE POST ________ if (isset($_GET['action']) && $_GET['action'] == 'create') { if (isset($_POST['content'], $_GET['id'])) { $idTopic = $_GET['id']; $content = $_POST['content']; $manager = new PostManager($db); $back = $manager->create($idTopic, $content); if (is_string($back)) { $errors[] = $back; } else { $topic = $manager->getTopic($back->getId()); $postCount = count($manager->getList($topic->getId())); $lastPage = ceil($postCount / 10); $idTopic = $topic->getId(); $idPost = $back->getId(); header('Location: index.php?page=topic&id=' . $idTopic . '&p=' . $lastPage . '#' . $idPost . ''); exit; } } } // ________________ // ________ EDIT POST ________ if (isset($_GET['action']) && $_GET['action'] == 'edit') { if (isset($_POST['content'], $_GET['id'])) { $content = $_POST['content']; $idPost = $_GET['id']; $manager = new PostManager($db); $back = $manager->edit($idPost, $content);