function printPostCode($user_id, $name, $surname, $description, $post_id, $sharing_date, $like, $likes, $img_url)
{
    if ($img_url == "") {
        $img_url = "img/user.png";
    }
    $data = new MysqlConnector();
    $data->connectMysql();
    #LOAD COMMENTS OF THE CURRENT POST
    $comments = $data->getComments($post_id);
    #CHECK IF THERE ARE COMMENTS AND PRINT THEM
    $num_of_comments = $comments->num_rows;
    if ($like) {
        $class_like = "glyphicon glyphicon-heart";
    } else {
        $class_like = "glyphicon glyphicon-heart-empty";
    }
    echo "\n      <div class='row post-box' id=" . $post_id . ">\n        <div class='col-lg-12 col-xs-12'>\n          <div class='panel'>\n            <div class='panel-heading'>\n              <div class='row'>\n                <div class='col-lg-1 col-xs-2 img-container'>\n                  <img class='img-rounded user-img' \n                       src='" . $img_url . "' >\n                </div>\n                <div class='col-lg-11 col-xs-10'>\n                  <strong class='author'>" . $surname . " " . $name . "</strong>\n                  <br> \n                  <span class='text-muted date'>\n                    posted on: " . $sharing_date . "</span>\n                </div>\n              </div>\n          </div><!-- /panel-heading -->\n          <div class='panel-body text'>\n            <h3 class='text'>" . $description . "</h3>\n          </div><!-- /panel-body -->\n          <div class='panel-footer'>\n            <button class='like'>\n              <span class='" . $class_like . "'></span>\n              <strong>\n                <span class='like-num'>" . $likes . "</span> \n                likes\n              </strong>\n            </button>\n            \n            <button class='comm'>\n              <span class='glyphicon glyphicon-comment'></span>\n              <strong>\n                <span class='comm-num'>" . $num_of_comments . "</span>\n                comments\n              </strong>\n            </button>\n            \n            <button class='reblog pull-right'>\n              <span class='glyphicon glyphicon-plus'></span>\n            </button>\n    ";
    echo " \n      <div class='write-comment'>\n        <div class='panel-body'>\n          <form class='comment-form' action='' method='post'>\n            <textarea class='form-control elastic-box \n                             insert-comment' \n                      style='resize: none;' \n                      rows='2' name='comment'  \n                      placeholder='Insert a comment...'></textarea>\n\n            <button type='button' \n                    class='btn btn-default btn-xs comment-button pull-right' \n            > <span class='glyphicon glyphicon-pencil'></span> Comment </button>\n          </form>\n        </div>\n      </div>\n    ";
    echo "<div class='all-comments'>";
    if ($num_of_comments !== 0) {
        #PRINT COMMENTS OF THE POST
        while ($comment = $comments->fetch_assoc()) {
            printCommentCode($comment['user_id'], $comment['name'], $comment['surname'], $comment['description'], $comment['sharing_date'], $comment['img_url']);
        }
    }
    $data->disconnectMysql();
    echo "</div>";
    #close /all-comments
    echo "\n      </div><!-- /panel-footer -->\n    </div><!-- /panel -->\n    ";
    echo "     \n      </div><!-- col-lg-5 col-xs-12 -->\n    </div><!-- /row -->\n    ";
}
Example #2
0
    printPostCode($post['user_id'], $post['name'], $post['surname'], $post['description'], $post['post_id'], $post['sharing_date'], $like, $likes, $post['img_url']);
}
?>
    </div>
  </div>
  
  <div class='hidden postCodeSample'>
    <?php 
printPostCode("", "", "", "", "", "", false, "", "", "");
?>
  </div>

  <!-- A div for storing a codesample of a general comment --> 
  <div class='hidden commentCodeSample'>
    <?php 
printCommentCode("", "", "", "", "", "");
?>
  </div>
  

  <!--INCLUSIONS -->
  <script src="bower_components/jquery/dist/jquery.min.js"></script>
  <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  <script src=
    'bower_components/jakobmattsson-jquery-elastic/jquery.elastic.source.js'>
  </script>

  <!--Store some js global var -->
  <script>
    /* GLOBAL VARIABLES */
    firstname = "<?php