Esempio n. 1
0
 public function getNbPost($id)
 {
     $postManager = new PostManager($this->db);
     $postList = $postManager->findByIdAuthor($id);
     if ($postList) {
         if (is_string($postList)) {
             $errors[] = $postList;
             return $errors;
         } else {
             $postNb = count($postList);
             if ($postNb == NULL) {
                 $postNb = 0;
                 return $postNb;
             } else {
                 return $postNb;
             }
         }
     } else {
         return "Pas de messages postés";
     }
 }
Esempio n. 2
0
if (isset($_GET['page'])) {
    $action = $_GET['page'];
    if ($action == 'addTopic') {
        if (isset($_POST['title'], $_POST['content'])) {
            $manager = new SCategoryManager($db);
            $sCategory = $manager->findById($_GET['id']);
            $idSCategory = $sCategory->getId();
            if (isset($idSCategory)) {
                $managerTopic = new TopicManager($db);
                $idAuthor = $_SESSION['id'];
                try {
                    $retour = $managerTopic->create($_POST['title'], $idAuthor, $sCategory);
                } catch (Exception $e) {
                    $errors = $e->getMessage();
                }
                $managerPost = new PostManager($db);
                $lastTopic = $managerTopic->getLast();
                $lastTopicIdSCategory = $lastTopic->getIdSCategory();
                $manager = new SCategoryManager($db);
                $sCategory = $manager->findById($lastTopicIdSCategory);
                try {
                    $retour = $managerPost->create($_POST['content'], $idAuthor, $lastTopic, $sCategory);
                } catch (Exception $e) {
                    $errors = $e->getMessage();
                }
                $managerUser = new UserManager($db);
                try {
                    $retour = $managerUser->addTopicUser($lastTopic);
                    header('Location: index.php?page=XtopicX&id=' . $lastTopic->getId() . '');
                    exit;
                } catch (Exception $e) {
Esempio n. 3
0
/* NE PAS OUBLIER L ID TOPIC*/
$title = '';
$content = '';
if (isset($_GET['action']) && $_GET['action'] == 'create') {
    if (isset($_POST['title'], $_POST['content'], $_SESSION['id'], $_GET['id'])) {
        $SousRubriqueManager = new SousRubriqueManager($db);
        $currentSousRubrique = $SousRubriqueManager->findById($_GET['id']);
        $title = $_POST['title'];
        $manager = new TopicManager($db);
        $topic = $manager->create($currentSousRubrique, $currentUser, $title);
        if (is_string($topic)) {
            $errors[] = $topic;
        } else {
            $content = $_POST['content'];
            $idTopic = $topic->getId();
            $PostManager = new PostManager($db);
            $post = $PostManager->create($idTopic, $content);
            if (is_string($post)) {
                var_dump($post);
                exit;
                $errors[] = $post;
            } else {
                header('Location: ?page=create_topic&id=1');
                exit;
            }
        }
    } else {
        header('Location : ?page=error_404');
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'edit') {
Esempio n. 4
0
<?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++;
    }*/
Esempio n. 5
0
            $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);
        if (is_string($back)) {
            $errors[] = $back;
        } else {
            $back = $manager->getTopic($idPost);
            if (is_string($back)) {
                $errors[] = $back;
            } else {
                $idTopic = $back->getId();
                header('Location: index.php?page=topic&id=' . $idTopic . '');
                exit;
            }
        }
    }
}
Esempio n. 6
0
<?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++;
}
Esempio n. 7
0
<?php

if (isset($_GET['page'])) {
    $action = $_GET['page'];
    if ($action == 'addPost') {
        if (isset($_POST['content'])) {
            $manager = new TopicManager($db);
            $topic = $manager->findById($_GET['id']);
            $idTopic = $topic->getId();
            $idScategoryTopic = $topic->getIdSCategory();
            $manager = new SCategoryManager($db);
            $sCategory = $manager->findById($idScategoryTopic);
            if (isset($idTopic)) {
                $manager = new PostManager($db);
                $userManager = new UserManager($db);
                $idAuthor = $_SESSION['id'];
                try {
                    $retour = $manager->create($_POST['content'], $idAuthor, $topic, $sCategory);
                    $retour = $userManager->addTopicUser($topic);
                    header('Location: index.php?page=XtopicX&id=' . $topic->getId() . '');
                    exit;
                } catch (Exception $e) {
                    $errors = $e->getMessage();
                }
            } else {
                throw new Exception("Categorie inéxistance");
            }
        }
    } else {
        if ($action == 'updateSCategory') {
            if (isset($_POST['title'], $_POST['content'])) {
Esempio n. 8
0
<?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';
}
Esempio n. 9
0
 /**
  * Aggiunge un commento ad una Collection.
  * 
  * @param author: l'autore del commento.
  * @param collection: la collezione in cui aggiungere il voto.
  * @param comment: il testo del commento.
  * @return: la collezione aggiornata.
  */
 static function commentCollection($author, $collection, $comment)
 {
     require_once "post/PostManager.php";
     return PostManager::commentPost($collection, $author, $comment);
 }
Esempio n. 10
0
 private static function PCWho($data)
 {
     //		echo "Chi Siamo";
     require_once 'post/PostManager.php';
     $p = PostManager::loadPost(self::$WHO_POST, false);
     if ($p !== false) {
         require_once 'post/PostPage.php';
         self::$post_options[PostPage::SHORT] = true;
         self::$post_options[PostPage::NO_COMMENTS] = true;
         self::$post_options[PostPage::NO_CATEGORIES] = true;
         self::$post_options[PostPage::NO_TAGS] = true;
         self::$post_options[PostPage::NO_MODIF_DATE] = true;
         PostPage::showPost($p, self::$post_options);
         self::$post_options[PostPage::SHORT] = false;
         self::$post_options[PostPage::NO_COMMENTS] = false;
         self::$post_options[PostPage::NO_TAGS] = false;
         self::$post_options[PostPage::NO_MODIF_DATE] = false;
     }
 }
Esempio n. 11
0
<?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 {
Esempio n. 12
0
    static function showEditPostForm($post, $data = null, $error = null)
    {
        $user = Session::getUser();
        if ($user->getID() != $post->getAuthor()) {
            return;
        }
        //TODO controlla sessione
        if (is_null($error) && count($_POST) > 0) {
            $data = array();
            if (isset($_POST["title"]) && trim($_POST["title"]) != "") {
                $data["title"] = $_POST["title"];
            } else {
                $error = array("Inserire un titolo.");
            }
            if (isset($_POST["type"])) {
                $data["type"] = $_POST["type"];
            } else {
                $error[] = "Scegliere il tipo di post da pubblicare.";
            }
            if (isset($_POST["content"]) && trim($_POST["content"]) != "") {
                $data["content"] = $_POST["content"];
            } else {
                $error[] = "Inserire un contenuto.";
            }
            if (isset($_POST["cat"]) && is_array($_POST["cat"]) && count($_POST["cat"]) > 0) {
                $cat = "";
                $first = true;
                foreach ($_POST["cat"] as $k => $c) {
                    if ($first) {
                        $first = false;
                    } else {
                        $cat .= ", ";
                    }
                    $cat .= $c;
                }
                $data["categories"] = $cat;
            }
            if (isset($_POST["place"]) && trim($_POST["place"]) != "") {
                $data["place"] = $_POST["place"];
            }
            if (isset($_POST["headline"]) && trim($_POST["headline"]) != "") {
                $data["headline"] = $_POST["headline"];
            }
            if (isset($_POST["subtitle"]) && trim($_POST["subtitle"]) != "") {
                $data["subtitle"] = $_POST["subtitle"];
            }
            if (isset($_POST["tags"]) && trim($_POST["tags"]) != "") {
                $data["tags"] = $_POST["tags"];
            }
            if (is_null($error) || is_array($error) && count($error) == 0) {
                $data["author"] = $user->getID();
                $post = PostManager::createPost($data);
                /*DEBUG*/
                echo $post;
                if ($post !== false) {
                    echo '
			<div class="message">
				Notizia salvata: <a href="' . $post->getFullPermalink() . '">Visualizza</a>
			</div>';
                }
            } else {
                self::showNewPostForm($data, $error);
                return;
            }
        }
        //echo serialize(isset($_GET["type"])) . "<br/>"; //DEBUG
        if (isset($_GET["type"])) {
            switch ($_GET["type"]) {
                case "Collection":
                case "photoreportage":
                case "videoreportage":
                case "Album":
                case "Magazine":
                case "Playlist":
                    call_user_func(array("PostPage", "showEdit" . $_GET["type"] . "Form"), $data, $error);
                    break;
                case "News":
                default:
                    self::showEditNewsForm($data, $error);
            }
        } else {
            self::showEditNewsForm($data, $error);
        }
    }
Esempio n. 13
0
<?php

$sCategoryManager = new SCategoryManager($db);
$sCategorys = $sCategoryManager->getList($category->getId());
$topicManager = new TopicManager($db);
$postManager = new PostManager($db);
$a = 0;
$b = count($sCategorys);
while ($a < $b) {
    $sCategory = $sCategorys[$a];
    $topic = $topicManager->getList($sCategory->getId());
    $nTopic = count($topic);
    $post = $postManager->getListSCat($sCategory->getId());
    $nPost = count($post);
    if ($nPost !== 0) {
        $lastPost = $postManager->getLastBySCat($sCategory->getId());
        $userLastPost = $userManager->findById($lastPost->getIdAuthor());
    }
    require 'views/forum/sCategorys.phtml';
    $a++;
}
Esempio n. 14
0
<?php

if (isset($_GET['id'])) {
    if (isset($_SESSION['id'])) {
        $manager = new PostManager($db);
        $post = $manager->findById(intval($_GET['id']));
        if ($currentUser->getId() == $manager->getAuthor($post)->getId()) {
            require 'views/edit_post.phtml';
        } else {
            header('Location: index.php?page=home');
            exit;
        }
    } else {
        header('Location: index.php?page=login');
        exit;
    }
} else {
    header('Location: index.php?page=error_404');
    exit;
}
Esempio n. 15
0
    private static function showEditNewsForm($post, $error, $new = false)
    {
        $name = "Edit";
        $caption = "Modifica";
        if ($new) {
            $post = new Post($post);
            $name = "New";
            $caption = "Nuova";
        }
        ?>
		<div class="title"><?php 
        echo $caption;
        ?>
 Notizia</div>
		<?php 
        if (is_array($error)) {
            ?>
		<div class="error"><?php 
            foreach ($error as $err) {
                ?>
			<p><?php 
                echo $err;
                ?>
</p>
			<?php 
            }
            ?>
</div>
		<?php 
        }
        ?>
		<form name="<?php 
        echo $name;
        ?>
Post" action="?type=news" method="post" enctype="multipart/form-data">
			<!--<p class="post_headline"><label>Occhiello:</label><br />
				<input class="post_headline" name="headline" value="<?php 
        echo Filter::decodeFilteredText($post->getHeadline());
        ?>
"/></p>-->
			<p class="title"><label>Titolo:</label><br/>
				<input class="post_title" name="title" value="<?php 
        echo Filter::decodeFilteredText($post->getTitle());
        ?>
"/></p>
			<p class="post_subtitle"><label>Sottotilolo:</label><br />
				<input class="post_subtitle" name="subtitle" value="<?php 
        echo Filter::decodeFilteredText($post->getSubtitle());
        ?>
"/></p>
			<p class="content"><label>Contenuto:</label><br/>
				<textarea name="content" id="post_content"><?php 
        echo Filter::decodeFilteredText($post->getContent());
        ?>
</textarea>
				<!-- sostituisco textarea standard con ckeditor -->
				<script type="text/javascript">
					CKEDITOR.replace( 'post_content', { toolbar : 'edited'});
				</script>
				<fieldset><legend>upload immagine</legend><?php 
        //se è presente la foto la visualizzo
        if ($post->getID() != "") {
            $rs_id = PostManager::getPostResource($post->getID());
            if ($rs_id) {
                $articlePhoto = ResourceManager::loadResource($rs_id);
                echo "<img src='" . FileManager::appendToRootPath($articlePhoto->getPath()) . "' /></br>";
            }
        }
        ?>
					<input type='file' name='upfile' />
				</fieldset>
			</p>
			<p class="tags"><label>Tags:</label> 
				<input class="tags" id="post_tags_input" name="tags" value="<?php 
        echo Filter::decodeFilteredText($post->getTags());
        ?>
"/></p>
			<p class="categories"><label>Categorie:</label><br/><?php 
        $cat = array();
        if (trim($post->getCategories()) != "") {
            $cat = explode(", ", Filter::decodeFilteredText($post->getCategories()));
        }
        self::showCategoryTree($cat);
        ?>
			</p>
            <p class="<?php 
        echo trim($post->getPlace()) == "" ? "hidden" : "";
        ?>
"><label id="place_label">Posizione: <?php 
        echo $post->getPlace();
        ?>
</label></p>
            	<input id="post_place" name="place" type="hidden" value="<?php 
        echo $post->getPlace();
        ?>
" />
            <input name="visible" type="hidden" value="true" />
            <input name="type" type="hidden" value="news" />
           	<p class="submit"><input type="submit" value="Pubblica" /> 
            	<input type="button" onclick="javascript:save();" value="Salva come bozza"/></p>
             <script type="text/javascript">
            	function save() {
					document.<?php 
        echo $name;
        ?>
Post.visible.value = false;
					document.<?php 
        echo $name;
        ?>
Post.submit();
            	}
            </script>
		<?php 
        require_once 'manager/MapManager.php';
        MapManager::setCenterToMap($post->getPlace(), "map_canvas");
        ?>
        </form>
        <?php 
    }
Esempio n. 16
0
 /**
  * @deprecated
  * Enter description here ...
  * @param unknown_type $type
  * @param unknown_type $id
  */
 static function getAccessCount($type, $id)
 {
     if ($type == null || $type == "" || $id == null) {
         return 0;
     }
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineLogColumns();
         $table = Query::getDBSchema()->getTable("AccessLog");
         $exists = false;
         if ($type == "Post") {
             require_once 'post/PostManager.php';
             return 0;
             $exists = PostManager::postExists($id);
         } else {
             if ($type == "User") {
                 require_once 'user/UserManager.php';
                 return 0;
                 $exists = UserManager::userExists($id);
             } elseif ($type == "Partner") {
                 //TODO: implementa Partner
                 //				require_once 'post/PartnerManager.php';
                 //				$exists = PartnerManager::partnerExists($id);
             }
         }
         if ($exists) {
             $wheres = array(new WhereConstraint($table->getColumn("alog_type"), Operator::EQUAL, $type), new WhereConstraint($table->getColumn("alog_id"), Operator::EQUAL, $id));
             $db->execute($s = Query::generateSelectStm(array($table), array(), $wheres, array()));
             if ($db->num_rows() == 1) {
                 $row = $db->fetch_result();
                 $data = array("alog_count" => ++$row["alog_count"]);
                 $db->execute($s = Query::generateUpdateStm($table, $data, $wheres), null, LOGMANAGER);
                 if ($db->affected_rows() == 1) {
                     return $row["alog_count"];
                 }
             } else {
                 $data = array("alog_type" => $type, "alog_id" => $id);
                 $db->execute($s = Query::generateInsertStm($table, $data));
                 if ($db->affected_rows() == 1) {
                 }
                 return 1;
             }
         }
         return 0;
     }
 }
Esempio n. 17
0
<?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++;
}
Esempio n. 18
0
 static function loadCollectionByPermalink($permalink)
 {
     return PostManager::loadPostByPermalink($permalink);
 }
Esempio n. 19
0
 function insertFirstNews()
 {
     $p = PostManager::createPost($this->post_serious);
     echo $p->getFullPermalink();
 }