public function PostsAction() { try { $from = $this->getUrlVar('from', 'string'); $to = $this->getUrlVar('to', 'string'); $author = $this->getUrlVar('author', 'string'); if (is_array($this->_pathParams) && isset($this->_pathParams[0])) { $postId = (int) $this->_pathParams[0]; if ($postId === 0) { throw new Exception('ERROR: post id is not valid'); } } $postDao = new PostDao($from, $to); $posts = array(); if ($from != '' || $to != '' || $author != '') { $posts = $postDao->getPost($from, $to, $author); $count = count($posts); $result = array('posts' => $posts, 'count' => $count); } elseif (isset($postId) && $postId > 0) { $result = $postDao->getPostById($postId); } else { $result = $postDao->getPost(); } echo json_encode($result); } catch (Exception $e) { echo $e->getMessage(); } }
/** * Returns class instance * * @return PostDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Aggiunge un Post ad una Collection. * * @param post: il post da aggiungere. * @param collection: la collezione in cui aggiungere il post. * @return: la collezione aggiornata. */ static function addPostToCollection($post, $collection) { $collection->addPost($post); $postdao = new PostDao(); return $postdao->update($post, Session::getUser()); }
private function __construct() { $this->dao = PostDao::getInstance(); $this->config['allowedMPElements'] = array(); }
<?php /** * collect function abandoned in v2.1.4 +; */ require '../dao/PostDao.php'; date_default_timezone_set('PRC'); $userId = $_REQUEST['userId']; $postTime = empty($_REQUEST['postTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['postTime']; $postDao = new PostDao(); echo $postDao->getCollectList($userId, $postTime);
<?php require '../dao/PostDao.php'; date_default_timezone_set('PRC'); $userId = $_REQUEST['userId']; $postTime = empty($_REQUEST['postTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['postTime']; $postDao = new PostDao(); echo $postDao->getPostList($userId, $postTime);
<?php require '../dao/PostDao.php'; /** * @Note 根据频道(标签)分类查找帖子,分页查询,一次取出15条 */ date_default_timezone_set('PRC'); $userId = $_REQUEST['userId']; $postTag = $_REQUEST['postTag']; $postTime = empty($_REQUEST['postTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['postTime']; $postDao = new PostDao(); echo $postDao->searchByTag($userId, $postTag, $postTime);
<?php require '../dao/PostDao.php'; date_default_timezone_set('PRC'); $userId = $_REQUEST['userId']; $visitUser = $_REQUEST['visitUser']; $postTime = empty($_REQUEST['postTime']) ? Date("Y-m-d H:i:s") : $_REQUEST['postTime']; /** * @Note 获得用户所发的帖子列表,分页,一次15条,访客不能看到用户所发的匿名帖,本人可以看到全部 */ $postDao = new PostDao(); $obj = json_decode($postDao->userPostList($userId, $visitUser, $postTime)); $obj->postCount = $postDao->userPostCount($userId, $visitUser == $userId); echo json_encode($obj);
static function getPostResource($id_post) { $postdao = new PostDao(); return $postdao->loadResource($id_post); }
static function showPost($post, $options = null) { if (isset($options[self::SHORTEST]) && $options[self::SHORTEST]) { self::showShortPost($post); return; } else { if (isset($options[self::FLASH]) && $options[self::FLASH]) { self::showFlashPost($post, $options); return; } else { if (isset($options[self::VIDEO]) && $options[self::VIDEO]) { self::showVideoPost($post); return; } else { if (isset($options[self::MOST_RECENT_MENU]) && $options[self::MOST_RECENT_MENU]) { self::showMostRecentMenu($post, $options); return; } else { if (isset($options[self::MOST_RECENT_CONTENT]) && $options[self::MOST_RECENT_CONTENT]) { self::showMostRecentContent($post, $options); return; } } } } } ?> <div class="post <?php echo $post->getType(); ?> " id="post<?php echo $post->getID(); ?> "> <div class="pb_header"><?php if (!isset($options[self::NO_DATE]) || !$options[self::NO_DATE]) { ?> <div class="post_creationDate"><?php echo format_datetime($post->getCreationDate()); ?> </div><?php } if (!isset($options[self::NO_CATEGORIES]) || !$options[self::NO_CATEGORIES]) { ?> <div class="post_categories"><?php $first = true; $cats = explode(",", $post->getCategories()); foreach ($cats as $cat) { if ($first) { $first = false; } else { echo ", "; } echo '<a href="' . FileManager::appendToRootPath('Category/' . trim(Filter::decodeFilteredText($cat))) . '">' . trim(Filter::decodeFilteredText($cat)) . '</a>'; } ?> </div><?php } ?> <div class="clear"></div> </div> <div class="post_header"> <div class="post_headline clear"><?php echo Filter::decodeFilteredText($post->getHeadline()); ?> </div><?php $title_class = "post_title"; if (isset($options[self::SMALL_TITLE]) && $options[self::SMALL_TITLE]) { $title_class .= " small_title"; } ?> <div class="<?php echo $title_class; ?> "><a href="<?php echo FileManager::appendToRootPath($post->getPermalink()); ?> "><?php echo Filter::decodeFilteredText($post->getTitle()); ?> </a></div> <div class="post_subtitle"><?php echo Filter::decodeFilteredText($post->getSubtitle()); ?> </div> </div> <div class="post_content clear"> <span id="post_place_<?php echo $post->getID(); ?> " class="post_place"></span><?php if (is_array($post->getContent())) { $first = true; foreach ($post->getContent() as $rsID) { if ($first) { $first = false; } else { echo " "; } //echo Filter::decodeFilteredText($cont); $cont = ResourceManager::loadResource($rsID); $path = FileManager::appendToRootPath($cont->getPath()); $description = Filter::decodeFilteredText($cont->getDescription()); echo "<a href='{$path}'><img src='" . $path . "' width='100' height='50' alt='" . $description . "' title='" . $description . "'></a>"; } } else { if ($post->getType() == "videoreportage") { echo youtubeManager::getVideoPlayer($post->getContent()); } else { //type=news echo Filter::decodeFilteredText($post->getContent()); $rs_id = PostManager::getPostResource($post->getID()); if ($rs_id) { $photo = ResourceManager::loadResource($rs_id); echo "<img src='" . FileManager::appendToRootPath($photo->getPath()) . "' />"; } } } if (!is_null($post->getPlace())) { require_once "manager/MapManager.php"; MapManager::printInfoInElement($post->getPlace(), "post_place_" . $post->getID()); } $postdao = new PostDao(); ?> <div class="post_authorname"><a href="<?php echo FileManager::appendToRootPath("User/" . $postdao->getAuthorName($post)); ?> "><?php echo $postdao->getAuthorName($post); ?> </a></div> </div> <div class="post_footer clear"> <div class="post_vote"> <div class="vote_image"><a href="<?php echo FileManager::appendToRootPath($post->getPermalink() . "/Vote?vote=yes"); ?> ">sì</a></div> <div class="vote_image"><a href="<?php echo FileManager::appendToRootPath($post->getPermalink() . "/Vote?vote=no"); ?> ">no</a></div> Voto: <?php echo $post->getVote(); ?> </div> <?php if (!isset($options[self::NO_TAGS]) || !$options[self::NO_TAGS]) { if (!is_null($post->getTags()) && trim($post->getTags()) != "") { ?> <div class="post_tags">Tag: <?php $first = true; $tags = explode(",", $post->getTags()); foreach ($tags as $tag) { if ($first) { $first = false; } else { echo ", "; } echo '<a href="' . FileManager::appendToRootPath('Tag/' . trim(Filter::decodeFilteredText($tag))) . '">' . trim(Filter::decodeFilteredText($tag)) . '</a>'; } ?> </div><?php } } if (!isset($options[self::NO_MODIF_DATE]) || !$options[self::NO_MODIF_DATE]) { ?> <div class="post_modificationDate">Ultima modifica: <?php echo format_datetime($post->getModificationDate()); ?> </div><?php } ?> </div><?php if (!isset($options[self::NO_COMMENTS]) || !$options[self::NO_COMMENTS]) { self::showComments($post); } ?> </div> <?php }
private function loadWinners() { parent::load($contest); if (!is_subclass_of($contest, self::OBJECT_CLASS)) { throw new Exception("Attenzione! Il parametro di ricerca non è un contest."); } $s = "SELECT * FROM " . $this->table_cs->getName() . " WHERE " . DB::CONTEST_SUBSCRIBER_PLACEMENT . " IS NOT NULL ORDER BY " . DB::CONTEST_SUBSCRIBER_PLACEMENT . " ASC"; $rs = $this->db->execute($s, $this->table_cs->getName(), $contest); $subscribers = array(); while ($row = $this->db->fetch_result()) { require_once 'dao/PostDao.php'; $postdao = new PostDao(); $subscribers[] = $postdao->quickLoad(intval($row[CONTEST_SUBSCRIBER_POST])); } return $contest->setSubscribers($subscribers); }
<?php require '../dao/PostDao.php'; require '../dao/MessageDao.php'; require 'ImageUpload.php'; $imageUpload = new ImageUpload(); $postUser = $_REQUEST['postUser']; $postImage = $imageUpload->getImageUrl(); $postTopic = $_REQUEST['postTopic']; $postContent = $_REQUEST['postContent']; $postTag = $_REQUEST['postTag']; $isAnonymity = (int) $_REQUEST['isAnonymity']; //boolean $achieveId = 0; if (!empty($_REQUEST['achieveId'])) { $achieveId = $_REQUEST['achieveId']; } $postDao = new PostDao(); $id = $postDao->postWrite($postUser, $postImage, $postTopic, $postContent, $postTag, $isAnonymity); if ($id == null || $id == 0) { echo json_encode(array('mesg' => 'fail', 'result' => false)); } else { if ($achieveId != 0) { $messageDao = new MessageDao(); $messageDao->setMessage($postUser, $achieveId, null, $isAnonymity, $id); } echo json_encode(array('mesg' => 'success', 'result' => true)); }
private static function searchPostsBy($keys, $options, $echo_query = false) { require_once "query.php"; require_once "strings/strings.php"; $table = Query::getDBSchema()->getTable(DB::TABLE_POST); $loadComments = true; $wheres = array(); foreach ($keys as $key => $value) { if ($key == "name" || $key == "title") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_TITLE), Operator::LIKE, "%" . Filter::filterText($value) . "%"); } if ($key == "permalink") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_PERMALINK), Operator::EQUAL, intval($value)); } if ($key == "id") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_ID), Operator::EQUAL, intval($value)); } if ($key == "tag") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_TAGS), Operator::LIKE, "%" . Filter::filterText($value) . "%"); } if ($key == "day") { if (!is_numeric($value)) { $value = date_timestamp_get(date_create_from_format("Y-m-d", $value)); } $daystart = date("Y-m-d", $value); $dayend = date("Y-m-d", $value + 24 * 60 * 60); //echo "<br />" . $daystart . "-" . $dayend; //DEBUG $wheres[] = new WhereConstraint($table->getColumn(DB::POST_CREATION_DATE), Operator::GREATEROREQUAL, $daystart); $wheres[] = new WhereConstraint($table->getColumn(DB::POST_CREATION_DATE), Operator::LESSER, $dayend); } if ($key == "category") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_CATEGORIES), Operator::LIKE, "%" . Filter::filterText($value) . "%"); } if ($key == "title") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_TITLE), Operator::LIKE, "%" . Filter::filterText($value) . "%"); } if ($key == "content") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_CONTENT), Operator::LIKE, "%" . Filter::filterText($value) . "%"); } if ($key == "author") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_AUTHOR), Operator::EQUAL, intval($value)); } if ($key == "no_id") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_ID), Operator::NOTEQUAL, intval($value)); } if ($key == "type") { $wheres[] = new WhereConstraint($table->getColumn(DB::POST_TYPE), Operator::LIKE, "%" . Filter::filterText($value) . "%"); } if ($key == "loadComments") { $loadComments = $value == true; } } $newopt = array(); foreach ($options as $key => $value) { if ($key == "by") { if (!is_array($value)) { $value = array($value); } $newvalue = array(); foreach ($value as $column) { if (!is_a($column, "Column")) { $column = $table->getColumn($column); } if (!is_null($column)) { $newvalue[] = $column; } } $value = $newvalue; } $newopt[$key] = $value; } $db = new DBManager(); $db->execute($s = Query::generateSelectStm(array($table), array(), $wheres, $newopt)); if ($echo_query) { echo "<font color='red'>" . $s . "</font>"; } //DEBUG $posts = array(); while ($row = $db->fetch_result()) { require_once "dao/PostDao.php"; $postdao = new PostDao(); $postdao->setLoadComments($loadComments); $posts[] = $postdao->createFromDBRow($row); } return $posts; }
<?php require '../dao/CommentDao.php'; require '../dao/PostDao.php'; $userId = $_REQUEST['userId']; $postId = $_REQUEST['postId']; $commentDao = new CommentDao(); $postDao = new PostDao(); $obj = json_decode($commentDao->postCommentList($postId)); $obj->post = json_decode($postDao->getPostById($userId, $postId))->resultArray[0]; echo json_encode($obj);
<?php require '../dao/PostDao.php'; /** * this action is abandoned in v2.1.15+ */ $postDao = new PostDao(); echo $postDao->getAllTags();