public function controlerJob($maincont) { // récupération des données if (!$maincont->isLoggued()) { $maincont->goModule("home", "display"); } // récupération de tous les tags pour le nuage $at = Tag::getAll(); $alltags = array(); foreach ($at as $ta) { $alltags[] = $ta->getTag(); } // récupération des années $ay = Post::getAll(); $allyears = array(); foreach ($ay as $ye) { $couranty = explode("-", $ye->getDate()); $couranty = $couranty[0]; if (!in_array($couranty, $allyears)) { $allyears[] = $couranty; } } // login if ($maincont->isLoggued()) { $login = $_SESSION["login"]; } else { $login = "******"; } // edition d'un article existant if (isset($_GET['id']) && $_GET['id'] >= 0) { $id = $_GET['id']; $mode = "update"; $title = "Edition d'un article"; $post = Post::getById($id); $post = $post[0]; // récupération des tags $tags = array(); if ($mode == "update") { $listTag = $post->getTags(); for ($i = 0; $i < count($post->getTags()); $i++) { $t = Tag::getById($listTag[$i]->id); $tags[$i] = $t[0]->getTag(); } } $posttitle = $post->getTitle(); $postbody = $post->getBody(); } else { $id = "-1"; $mode = "create"; $title = "Création d'un article"; $tags = array("tag1", "tag2", "tag3"); $posttitle = "Votre titre"; $postbody = "Votre contenu"; } // affichage de la vue édition include_once "view.php"; $v = new PostEditorView(); $v->display($login, $alltags, $allyears, $posttitle, $postbody, $tags, $mode, $title, $id); }
public function controlerJob($maincont) { // récupération des données if (isset($_GET['id']) && $_GET['id'] >= 0) { $id = $_GET['id']; } else { $maincont->goModule('home', 'display'); return; } $post = Post::getById($id); $post = $post[0]; $tags = array(); $listTag = $post->getTags(); for ($i = 0; $i < count($post->getTags()); $i++) { $t = Tag::getById($listTag[$i]->id); $tags[$i] = $t[0]->getTag(); } $comments = $post->getComments(); $coms = array(); $i = 0; foreach ($comments as $c) { if ($c->getPublished() != 0) { $coms[$i] = array('author' => $c->getAuthor(), 'date' => $c->getDate() . " " . $c->getHour(), 'content' => $c->getBody()); $i++; } } // récupération de tous les tags pour le nuage $at = Tag::getAll(); $alltags = array(); foreach ($at as $ta) { $alltags[] = $ta->getTag(); } // récupération des années $ay = Post::getAll(); $allyears = array(); foreach ($ay as $ye) { $couranty = explode("-", $ye->getDate()); $couranty = $couranty[0]; if (!in_array($couranty, $allyears)) { $allyears[] = $couranty; } } // login if ($maincont->isLoggued()) { $login = $_SESSION["login"]; } else { $login = "******"; } // affichage de la vue include_once "view.php"; $v = new PostViewView(); $v->display($login, $alltags, $allyears, $post->getTitle(), $post->getDate(), $post->getBody(), $tags, $coms, $_GET["id"]); }
public function controlerJob($maincont) { // récupération des données if (!$maincont->isLoggued()) { $maincont->goModule("home", "display"); } $liste = Post::getAll(); // on récupère les posts // récupération des données des articles $articles = array(); for ($i = 0; $i < count($liste); $i++) { $p = Post::getById($liste[$i]->id); $p = $p[0]; $articles[$i] = array("contenu" => $p->getTitle() . ", publié le " . $p->getDate() . " à " . $p->getHour(), "id" => $p->id); } // récupération de tous les tags pour le nuage $at = Tag::getAll(); $alltags = array(); foreach ($at as $ta) { $alltags[] = $ta->getTag(); } // récupération des années $ay = Post::getAll(); $allyears = array(); foreach ($ay as $ye) { $couranty = explode("-", $ye->getDate()); $couranty = $couranty[0]; if (!in_array($couranty, $allyears)) { $allyears[] = $couranty; } } // login if ($maincont->isLoggued()) { $login = $_SESSION["login"]; } else { $login = "******"; } // affichage de la vue include_once "view.php"; $v = new PostAdminView(); $v->display($login, $alltags, $allyears, $articles); }
<?php require_once "auth.php"; require "header.php"; require_once "classes/post.php"; $post = new Post($link); $post->updateView(); $post->getById(); ?> <br xmlns="http://www.w3.org/1999/html"><br><br><br> <div class="container"> <div class="blog-header"> <h2><?php echo $post->getName(); ?> </h2> <p style="font-size: 14px"><?php echo $post->getDate(); ?> </p> <br> <img src="Images/<?php echo $post->getImageName(); ?> " align="top" width=66% height=66%> </div> <br><br><br>
public function testTransactionRollback() { $PDO = \Uzulla\CFEDb2::getPDO(); $post = Post::getById(1, $PDO); $beforeTransaction = $post->val('text'); //echo $beforeTransaction; $post->transactionBegin(); $post->val('text', "トランザクション中保存"); $post->saveItem(); $_post = Post::getById(1, $PDO); $beforeRollbackText = $_post->val('text'); //echo $beforeRollbackText; $post->transactionRollback(); $_post = Post::getById(1, $PDO); $aftertRollbackText = $_post->val('text'); //echo $aftertRollbackText; $this->assertEquals($beforeTransaction, $aftertRollbackText); $this->assertNotEquals($aftertRollbackText, $beforeRollbackText); }
public function getPost() { $res = Post::getById($this->getPostid()); return $res[0]; }
public function controlerJob($maincont) { // récupération des données // par tags if (isset($_GET["tag"])) { $t = $_GET["tag"]; // récupération de l'objet tag $thetag = Tag::getByTag("{$t}"); $thetag = $thetag[0]; $title = "Liste des posts avec le tag {$t}"; // récupération de la liste des posts ayant ce tag $liste = $thetag->getPosts(); } else { if (isset($_GET["datem"]) && isset($_GET["datey"])) { $y = $_GET["datey"]; $mo = $_GET["datem"]; // titre if ($mo != "-1") { $moenlettre = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); $moenlettre = $moenlettre[intval($mo) - 1]; $title = "Liste des posts de {$moenlettre} {$y}"; } else { $title = "Liste des posts de {$y}"; } $liste = array(); $po = Post::getAll(); foreach ($po as $lol) { $date = $lol->getDate(); if ($mo != "-1") { if (substr($date, 0, 7) == "{$y}-{$mo}") { // vérifie que l'article correspond au mois/année $liste[] = $lol; } } else { if (substr($date, 0, 4) == "{$y}") { // vérifie que l'article correspond au mois/année $liste[] = $lol; } } } } else { $title = "Liste des derniers posts"; $liste = Post::getAllOrderBy("id DESC"); } } // récupération des données des articles $articles = array(); for ($i = 0; $i < count($liste); $i++) { $p = Post::getById($liste[$i]->id); $p = $p[0]; $articles[$i] = array('date' => "Le " . $p->getDate() . " à " . $p->getHour(), 'title' => $p->getTitle(), 'content' => $p->getBody(), 'nbComments' => $p->getNbComments(), 'link' => 'index.php?module=post&action=view&id=' . $p->id); } // récupération de tous les tags pour le nuage $at = Tag::getAll(); $alltags = array(); foreach ($at as $ta) { $alltags[] = $ta->getTag(); } // récupération des années $ay = Post::getAll(); $allyears = array(); foreach ($ay as $ye) { $couranty = explode("-", $ye->getDate()); $couranty = $couranty[0]; if (!in_array($couranty, $allyears)) { $allyears[] = $couranty; } } // login if ($maincont->isLoggued()) { $login = $_SESSION["login"]; } else { $login = "******"; } // affichage de la vue include_once "view.php"; $v = new HomeDisplayView(); $v->display($login, $alltags, $allyears, $title, $articles); }
/** * @return Post */ public function getLastPost() { if ($this->lastPost == null) { $this->lastPost = Post::getById($this->lastPostId); } return $this->lastPost; }