protected function outputHTML() { ?> <div class="container"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Friend Requests</h3> </div> <div class="panel-body"> <?php $counter = 0; foreach ($this->requests as $request) { $counter++; $userid = $request['fromid']; $user = UserRepository::getUserByID($userid); echo "<p><a href='" . \route\Route::get("userProfile")->generate(array("id" => $userid)) . "'>" . $user['username'] . "</a></p>"; } if ($counter == 0) { echo "<p>There are no new friend requests.</p>"; } ?> </div> </div> </div> <?php }
protected function outputHTML() { $user = UserRepository::getUserByID($this->message['senderid']); ?> <div class="container"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Message</h3> </div> <div class="panel-body"> <p>From: <?php echo $user['username']; ?> </p> <p>Content: <?php echo parseText($this->message['content']); ?> </p> <p><a href="<?php echo \route\Route::get("sendMessage")->generate(array("id" => $user['userid'])); ?> " class="btn btn-info">Reply</a></p> </div> </div> </div> <?php }
public function unfriend() { $profileID = getIdFromURL(); $user = UserRepository::getUserByID($profileID); checkRequestURL($profileID, $user); $myID = UserRepository::getIdByUsername($_SESSION['username']); FriendRepository::unfriend($myID, $profileID); redirect(Route::get("userProfile")->generate(array("id" => $profileID))); }
public function action() { $id = getIdFromURL(); $user = UserRepository::getUserByID($id); checkRequestURL($id, $user); $tweets = TweetRepository::getMyTweets($id); $userGalleries = GalleryRepository::getUserGalleries($id); $userPhotos = array(); foreach ($userGalleries as $gallery) { $photos = PhotoRepository::getPhotosByGalleryID($gallery['galleryid']); foreach ($photos as $photo) { array_push($userPhotos, $photo); } } $main = new Main(); $body = new \templates\TwitterWall(); $body->setTweets($tweets)->setUserPhotos($userPhotos); echo $main->setPageTitle("TwitterApp")->setBody($body); }
protected function outputHTML() { ?> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="<?php echo \route\Route::get("twitterWall")->generate(array("id" => $this->userid)); ?> "><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Home</a> </div> <script> $(function () { $('#input').keyup(function () { var search = $('#input').val(); $.post("<?php echo \route\Route::get("searchBar")->generate(); ?> ", {"search": search}, function (data) { $('.entry').html(data); }); }); }); </script> <div class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Menu <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li> <a href="<?php echo \route\Route::get("listGalleries")->generate(); ?> ">Galleries</a> </li> <li><a href="<?php echo \route\Route::get("listUsers")->generate(); ?> ">Users</a></li> <li><a href="<?php echo \route\Route::get("showFriends")->generate(); ?> ">Friends</a></li> </ul> <li> <?php $color = newRequestNotification(); ?> <a style="color: <?php echo $color; ?> " href="<?php echo \route\Route::get("showRequests")->generate(); ?> ">Requests</a> </li> <li> <?php $color = newMessageNotification(); ?> <a style="color: <?php echo $color; ?> " href="<?php echo \route\Route::get("showMessages")->generate(); ?> ">Messages</a> </li> <li> <form class="navbar-form navbar-left" role="search"> <div class="form-group"> <input type="text" name="search" id="input" class="form-control" placeholder="Search"> </div> </form> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li> <ul> <?php $image = UserRepository::getProfilePicture($_SESSION['username']); if ($image == "") { echo "<img width='50' height='50' src='/TwitterApp/assets/images/profile/default.jpg' alt='Default Profile Pic'>"; } else { echo "<img width='50' height='50' src='/TwitterApp/assets/images/profile/" . $image . "' alt='Default Profile Pic'>"; } ?> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span> Settings <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="<?php echo \route\Route::get("changeProfilePicture")->generate(); ?> ">Upload profile picture</a></li> <li><a href="<?php echo \route\Route::get("changeUsername")->generate(); ?> ">Change username</a></li> <li><a href="<?php echo \route\Route::get("changePassword")->generate(); ?> ">Change password</a></li> <?php $user = UserRepository::getUserByID($this->userid); if ($user['visibility'] == 1) { ?> <li><a href="<?php echo \route\Route::get("changeVisibility")->generate(); ?> ">Hide from users list</a></li> <?php } else { ?> <li><a href="<?php echo \route\Route::get("changeVisibility")->generate(); ?> ">Show in users list</a></li> <?php } ?> <li class="divider"></li> <li><a href="<?php echo \route\Route::get("logout")->generate(); ?> ">Log Out</a></li> </ul> </li> </ul> </div> </div> </nav> <?php }
protected function outputHTML() { ?> <div class="container"> <?php //provjera da li su prijatelji ili da li je to sam korisnik if (checkPermissionToTweet()) { //forma za dodavanje novih tweetova ?> <script src="/TwitterApp/assets/js/postTweetForm.js"></script> <div class="col-md-4 col-md-offset-4"> <button id="open" class="btn btn-success btn-block">Post tweet</button> </div> <form class="form-horizontal" id="tweet-form" role="form" method="post" action="<?php echo \route\Route::get("postTweet")->generate(array("id" => getIdFromURL())); ?> "> <br><br> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <textarea class="form-control" rows="3" name="content" id="content" placeholder="What's happening?" required></textarea> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <input type="text" class="form-control" name="tag" id="tag" placeholder="Enter tweet tag (optional)"> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <select name="selectPhoto" id="sel1" class="form-control"> <option value="">Select photo...</option> <?php foreach ($this->userPhotos as $photo) { ?> <option value="<?php echo $photo['path']; ?> "><?php echo $photo['image']; ?> </option> <?php } ?> </select> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <div style="color: green" id="success"></div> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <input type="submit" class="btn btn-info btn-block" name="tweet" id="tweet" value="Tweet"> </div> </div> </form> <br><br> <?php } else { ?> <div class="col-md-4 col-md-offset-1"> <p>To post tweet on this wall you need to become friends.</p> <hr> </div> <?php } $counter = 0; //prikaži sve tweetove na korisnikovom zidu foreach ($this->tweets as $tweet) { $counter++; $user = UserRepository::getUserByID($tweet['fromid']); $numberOfComments = TweetRepository::getNumberOfComments($tweet['tweetid']); $value = "Comments"; if ($numberOfComments == 1) { $value = "Comment"; } ?> <div class="col-md-10 col-md-offset-1"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Posted by: <?php echo $user['username']; ?> </h3> </div> <div class="panel-body"> <div> <?php echo parseText($tweet['content']); ?> </div> </div> <div class="panel-footer"> <div> <a href="<?php echo \route\Route::get("viewTweet")->generate(array("id" => $tweet['tweetid'])); ?> "><?php echo $numberOfComments . ' ' . $value; ?> </a> </div> </div> </div> </div> <?php } //ako nema tweetova, obavijeti korisnika if ($counter == 0) { ?> <div class="col-md-10 col-md-offset-1"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Tweets</h3> </div> <div class="panel-body"> There are no tweets to show. </div> </div> </div> <?php } ?> </div> <?php }
protected function outputHTML() { ?> <script src="/TwitterApp/assets/js/viewPhoto.js"></script> <div class="container"> <ul class="nav nav-pills"> <li class="dropdown"> <button class="btn btn-success dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> Set As... <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> <li><a href="<?php echo \route\Route::get("setGalleryIcon")->generate(array("id" => $this->photo['photoid'])); ?> ">Set As Gallery Icon</a></li> <li><a href="<?php echo \route\Route::get("setUserBackground")->generate(array("id" => $this->photo['photoid'])); ?> ">Set As Background</a></li> </ul> </li> <li> <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> Filters <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu2"> <li><a href="<?php echo \route\Route::get("imageFilter")->generate(array("id" => $this->photo['photoid'], "filter" => "blackwhite")); ?> ">Black and white</a></li> <li><a href="<?php echo \route\Route::get("imageFilter")->generate(array("id" => $this->photo['photoid'], "filter" => "sepia")); ?> ">Sepia</a></li> <li><a href="<?php echo \route\Route::get("imageFilter")->generate(array("id" => $this->photo['photoid'], "filter" => "blur")); ?> ">Blur</a></li> </ul> </li> <li> <form class="form-inline" role="form" method="post" action="<?php echo \route\Route::get("imageFilter")->generate(array("id" => $this->photo['photoid'], "filter" => "brightness")); ?> " id="brightnessForm"> <div class="form-group"> <input placeholder="Brightness strength" type="number" class="form-control" id="number" name="number"> <button type="submit" name="setBrightness" id="setBrightness" class="btn btn-default">Set brightness</button> </div> </form> </li> </ul> <br> <p><?php echo "<img width='1024' height='768' src='" . $this->photo['path'] . "' alt='image'>"; ?> </p> <p><button class="btn btn-danger" id="editTags">Edit tags</button> <button class="btn btn-danger" id="commentPhoto">Comment photo</button> <a href="<?php echo Route::get("photoRssFeed")->generate(array("id" => $this->photo['photoid'])); ?> " class="btn btn-info">RSS Feed</a> <button class="btn btn-default" id="closeEdit">Close</button></p> <div><h3>Photo tags</h3><p><?php echo $this->photo['tags']; ?> </p></div> <form class="form-horizontal" id="editPhotoTags" role="form" method="post" action="<?php echo \route\Route::get("editPhotoTags")->generate(array("id" => $this->photo['photoid'])); ?> "> <?php if (checkPermissionToCommentPhotoAndEditTags()) { ?> <div class="form-group"> <div class="col-md-4"> <input type="text" class="form-control" name="tags" id="tags" value="<?php echo $this->photo['tags']; ?> " required> </div> </div> <div class="form-group"> <div class="col-md-4"> <input type="submit" class="btn btn-info btn-block" name="postTags" id="postTags" value="Submit changes"> </div> </div> <?php } else { echo "<p style='color: red'>You must be friends with user who created gallery to edit tags.</p>"; } ?> </form> <div id="displayComments"> <h3>Photo comments</h3> <?php if (count($this->comments) == 0) { echo "There are no comments for this photo."; } else { foreach ($this->comments as $comment) { $user = UserRepository::getUserByID($comment['userid']); echo "<p>" . $user['username'] . ": " . parseText($comment['content']) . "</p>"; } } ?> </div> <form class="form-horizontal" id="comment-form" role="form" method="post" action="<?php echo \route\Route::get("postPhotoComment")->generate(array("id" => $this->photo['photoid'])); ?> "> <?php if (checkPermissionToCommentPhotoAndEditTags()) { ?> <div class="form-group"> <div class="col-md-4"> <textarea class="form-control" rows="3" name="comment" id="comment" placeholder="Enter comment..." required></textarea> </div> </div> <div class="form-group"> <div class="col-md-4"> <div style="color: green" id="success"></div> </div> </div> <div class="form-group"> <div class="col-md-4"> <input type="submit" class="btn btn-info btn-block" name="postComment" id="postComment" value="Post Comment"> </div> </div> <?php } else { echo "<p style='color: red'>You must be friends with user who created gallery to post comments.</p>"; } ?> </form> </div> <script type="text/javascript" > $(document).ready(function() { $('#postComment').on('click', function(e) { e.preventDefault(); var comm = $('#comment').val(); var url = "<?php echo Route::get('postPhotoComment')->generate(array("id" => $this->photo['photoid'])); ?> "; $.post(url, {'comment' : comm}, function(data) { a = JSON.parse(data); $('#displayComments').append('<p>' + a.user + ': ' + a.comment + '</p>'); $('#comment').val(''); }) }); }); </script> <?php }
protected function outputHTML() { ?> <div class="container"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Messages</h3> <div class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Sort By <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> <li> <a href="<?php echo \route\Route::get("sortMessages")->generate(array("order" => "newest")); ?> ">Newest</a> </li> <li><a href="<?php echo \route\Route::get("sortMessages")->generate(array("order" => "oldest")); ?> ">Oldest</a></li> <li><a href="<?php echo \route\Route::get("sortMessages")->generate(array("order" => "unread")); ?> ">Unread</a></li> <li><a href="<?php echo \route\Route::get("sortMessages")->generate(array("order" => "read")); ?> ">Read</a></li> </ul> </div> </div> <div class="panel-body"> <?php foreach ($this->messages as $message) { $user = UserRepository::getUserByID($message['senderid']); ?> <p><a href="<?php echo \route\Route::get("readMessage")->generate(array("id" => $message['id'])); ?> ">From: <?php echo $user['username']; ?> </a> | Sent: <?php echo $message['created']; ?> | <l style="color: red"><?php if ($message['readflag'] == 0) { echo " Unread"; } ?> </l></p> <?php } ?> </div> </div> </div> <?php }
protected function outputHTML() { ?> <div class="container"> <div class="col-md-10 col-md-offset-1"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Tweet <a href="<?php echo Route::get("tweetRssFeed")->generate(array("id" => $this->tweet['tweetid'])); ?> " class="btn btn-info">RSS Feed</a></h3> </div> <div class="panel-body"> <label>Content</label> <p><?php echo parseText($this->tweet['content']); ?> </p> <?php if ($this->tweet['image'] != null) { ?> <hr> <label>Image</label> <p><img src="<?php echo $this->tweet['image']; ?> " width="20%" height="20%"></p> <?php } if ($this->tweet['tag'] != null) { ?> <hr> <label>Tag</label> <p><?php echo $this->tweet['tag']; ?> </p> <?php } ?> </div> </div> </div> <div class="col-md-10 col-md-offset-1"> <div class="panel panel-info" id="comments"> <div class="panel-heading"> <h3 class="panel-title">Tweet Comments</h3> </div> <div class="panel-body"> <div id="displayComments"> <?php if (count($this->comments) == 0) { echo "There are no comments for this tweet."; } else { foreach ($this->comments as $comment) { $user = UserRepository::getUserByID($comment['userid']); echo "<p>" . $user['username'] . ": " . parseText($comment['content']) . "</p>"; } } ?> </div> </div> </div> </div> </div> <?php if (checkPermissionToCommentTweet()) { ?> <form class="form-horizontal" id="comment-form" role="form" method="post" action="<?php echo \route\Route::get("postTweetComment")->generate(array("id" => $this->tweet['tweetid'])); ?> "> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <textarea class="form-control" rows="3" name="comment" id="comment" placeholder="Enter comment..." required></textarea> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <div style="color: green" id="success"></div> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-4"> <input type="submit" class="btn btn-info btn-block" name="postComment" id="postComment" value="Post Comment"> </div> </div> </form> <?php } else { ?> <div class="col-md-4 col-md-offset-2"> <p style='color: red'>To comment this tweet you must be friends with user who created it.</p> </div> <?php } ?> <script type="text/javascript" > $(document).ready(function() { $('#postComment').on('click', function(e) { e.preventDefault(); var comm = $('#comment').val(); var url = "<?php echo Route::get('postTweetComment')->generate(array("id" => $this->tweet['tweetid'])); ?> "; $.post(url, {'comment' : comm}, function(data) { a = JSON.parse(data); $('#displayComments').append('<p>' + a.user + ': ' + a.comment + '</p>'); $('#comment').val(''); }) }); }); </script> <?php }
/** * Changes visibility of a user. */ public function changeVisibility() { checkUnauthorizedAccess(); $userid = UserRepository::getIdByUsername($_SESSION['username']); $user = UserRepository::getUserByID($userid); if ($user['visibility'] == 1) { UserRepository::hideFromUsersList($userid); redirect(Route::get("listUsers")->generate()); } else { UserRepository::showInUsersList($userid); redirect(Route::get("listUsers")->generate()); } }