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 = Comment::getByPublished("0");
     // on récupère les commentaires non validés
     // récupération des données des commentaires
     $coms = array();
     for ($i = 0; $i < count($liste); $i++) {
         $c = Comment::getById($liste[$i]->id);
         $c = $c[0];
         /*$coms[$i] = array('date'=>"Le ".$c->getDate()." à ".$c->getHour(),
         		 'author'=>$c->getAuthor(),
         		 'content'=>$c->getBody(),
         			 'postitle'=>''.$c->getPost()->getTitle()
         		);*/
         $coms[$i] = array("contenu" => "De : " . $c->getAuthor() . ", contenu : \"" . $c->getBody() . "\", sur l'article : " . $c->getPost()->getTitle(), "id" => $c->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 CommentAdminView();
     $v->display($login, $alltags, $allyears, $coms);
 }
 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);
 }
 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);
 }
Example #6
0
<?php

session_start();
if (isset($_SESSION["us"])) {
    include_once 'definition.php';
    $Tag = new Tag();
    $TagBySnippet = new TagBySnippet();
    $jsondata = array();
    if (isset($_GET['all'])) {
        $jsondata = $Tag->getAll();
    }
    if (isset($_GET['tbs'])) {
        $jsondata = $TagBySnippet->getAll();
    }
    header('Content-type: application/json; charset=utf-8');
    echo json_encode($jsondata);
    //echo $jsondata[1][2];
    exit;
} else {
    echo 'logout';
}
Example #7
0
<?php

// se sono già nella pagina di ricerca rimango nella pagina di ricerca
$stayHere = yii_route() == 'product/list';
$stats = array();
foreach (Tag::getAll() as $tag) {
    $cnt = $tag->productsCount;
    if ($cnt > 0) {
        $statItem = array('weight' => $cnt, 'url' => url('product/list', array('tag' => $tag->name)));
        if ($stayHere) {
            $statItem['htmlOptions'] = array('target' => '_self');
        }
        $stats[$tag->name] = $statItem;
    }
}
if (count($stats) > 0) {
    $this->widget('application.extensions.yii-tagcloud.YiiTagCloud', array('beginColor' => '00089A', 'endColor' => 'A3AEFF', 'minFontSize' => 8, 'maxFontSize' => 20, 'arrTags' => $stats));
}