<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/src/init.php'; //Allow access only via ajax requests if (empty($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { Redirect::redirectTo('404'); } if (isset($_POST['action'])) { $action = $_POST['action']; unset($_POST['action']); } elseif (isset($_GET['action'])) { $action = $_GET['action']; unset($_GET['action']); } else { die("Error! bad request."); } switch ($action) { // get user profile card case 'profile_card': $uid = $_POST['id']; die(View::userCard($uid)); break; case 'renderComment': $id = $_GET['id']; die(View::renderComment($id)); break; default: break; }
public static function renderComment($oComment) { $sOutput = ""; $oCommenter = new User(); $oCommenter->load($oComment->userID); $sOutput .= '<div class="commentFeed">' . "\n"; $sOutput .= '<span class="colour3A floatLeft">' . htmlentities($oCommenter->firstName) . ' ' . htmlentities($oCommenter->lastName) . '</span>' . "\n"; $sOutput .= '<span class="floatRight dayStamp colourPink">' . $oComment->createdAt . '</span>' . "\n"; $sOutput .= '<p class="clearBoth paddingTop20">' . htmlentities($oComment->comment) . '</p>' . "\n"; $sOutput .= '<span class="replyCTA"><a class="commentReply" href="#" data-commentid="' . $oComment->commentID . '">Reply</a></span>' . "\n"; $sOutput .= '</div>' . "\n"; $sOutput .= '<div class="marginLeft30">'; $aReplies = $oComment->replies; foreach ($aReplies as $oReply) { $sOutput .= View::renderComment($oReply); } $sOutput .= '</div>'; return $sOutput; }