function PostByThisUserPanel($UID, $dbAdapter) { $gateTravelPost = new TravelPostTableGateway($dbAdapter); $resultTravelPost = $gateTravelPost->findForPosts($UID); echo '<hr> <p><i>Posts By This User</i></p>'; foreach ($resultTravelPost as $row) { echo '<p><a href="single-post.php?id=' . $row->PostID . '">' . $row->Title . '</a></p>'; } echo '</div> </div>'; }
function outputPostRows($dbAdapter) { $gateTravelPost = new TravelPostTableGateway($dbAdapter); $gateTravelImage = new TravelImageTableGateway($dbAdapter); $gateTravelUserDetails = new TravelUserDetailsTableGateway($dbAdapter); $gateTravelPostImage = new TravelPostImagesTableGateway($dbAdapter); $result = $gateTravelPost->findAll(); foreach ($result as $row) { $postId = $row->PostID; $userId = $row->UID; $imageId = $gateTravelPostImage->findById($postId)->ImageID; $thumb = $gateTravelImage->findById($imageId)->Path; $title = $row->Title; $firstName = $gateTravelUserDetails->findById($userId)->FirstName; $lastName = $gateTravelUserDetails->findById($userId)->LastName; $userName = utf8_encode($firstName . $lastName); $excerpt = substr($row->Message, 0, 200) . "..."; $date = substr($row->PostTime, 0, 10); echo utf8_encode('<div class="row"> <div class="col-md-2"> <a href="single-image.php?id=' . $imageId . '" class=""> <img src="travel-images/square-medium/' . $thumb . '" alt="' . $title . '" class="img-thumbnail"/> </a> </div> <div class="col-md-10"> <h2>' . $title . '</h2> <div class="details"> Posted by <a href="single-user.php?id=' . $userId . '" class="">' . $userName . '</a> <span class="pull-right">' . $date . '</span> </div> <p class="excerpt">' . $excerpt . '</p> <p><a href="single-post.php?id=' . $postId . '" class="btn btn-primary btn-sm">Read more</a></p> </div> </div> <hr/>'); } }
//function addFavorite(){ if (isset($_GET['favorite_image_id']) && is_numeric($_GET['favorite_image_id']) && $_GET['favorite_image_id'] >= 0) { $gateTravelImageDetails = new TravelImageDetailsTableGateway($dbAdapter); $gateTravelImage = new TravelImageTableGateway($dbAdapter); $imageID = $_GET['favorite_image_id']; $path = $gateTravelImage->findById($imageID)->Path; $title = $gateTravelImageDetails->findById($imageID)->Title; $favoriteImage = new FavoriteImage(FavoriteImage::getFieldNames(), false); $favoriteImage->imageID = $imageID; $favoriteImage->path = $path; $favoriteImage->title = $title; $favoriteImageList[] = $favoriteImage; $_SESSION['favoriteImageList'] = $favoriteImageList; header('Location: single-image.php?id=' . $_GET['favorite_image_id']); } elseif (isset($_GET['favorite_post_id']) && is_numeric($_GET['favorite_post_id']) && $_GET['favorite_post_id'] >= 0) { $gateTravelPost = new TravelPostTableGateway($dbAdapter); $gateTravelPostImage = new TravelPostImagesTableGateway($dbAdapter); $gateTravelImage = new TravelImageTableGateway($dbAdapter); $postID = $_GET['favorite_post_id']; $imageID = $gateTravelPostImage->findById($postID)->ImageID; $path = $gateTravelImage->findById($imageID)->Path; $title = $gateTravelPost->findById($postID)->Title; $favoritePost = new FavoritePost(FavoritePost::getFieldNames(), false); $favoritePost->postID = $postID; $favoritePost->path = $path; $favoritePost->title = $title; $favoritePostList[] = $favoritePost; $_SESSION['favoritePostList'] = $favoritePostList; header('Location: single-post.php?id=' . $_GET['favorite_post_id']); } else { header("Location: error.php");