Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.php 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. $Results = $db->select_raw('ricehalla', "INNER JOIN votes ON ricehalla.id=votes.row_id WHERE votes.table_name=? GROUP BY votes.row_id ORDER BY TotalRank DESC, TotalVotes DESC, TotalPoints DESC", array("ricehalla"), 'ricehalla.url, ricehalla.user_id, ricehalla.id, ricehalla.tags, votes.points, sum(votes.points) as TotalPoints, COUNT(votes.id) as TotalVotes, (sum(votes.points) / COUNT(votes.id)) * abs(sum(votes.points)) as TotalRank, ricehalla.date_added');
  3. $result_list = array();
  4. foreach ($Results as $result)
  5. {
  6. if (!is_array($result))
  7. {
  8. $result_list = array($Results);
  9. break;
  10. }
  11. array_push($result_list, $result);
  12. }
  13. ?>
  14. <div class="container">
  15. <?php
  16. if ($logged_in)
  17. {
  18. ?>
  19. <div class="row">
  20. <center>
  21. <button type="button" class="btn btn-primary" id="uploader">Add Image</button>
  22. </center>
  23. </div>
  24. <?php
  25. }
  26. if ($Results)
  27. {
  28. ?>
  29. <div class="panel panel-primary filterable">
  30. <div class="panel-heading">
  31. <div class="row filters">
  32. <div class="col-sm-1 filter-title"><input type="text" class="form-control text-center" placeholder="Rank" disabled></div>
  33. <div class="col-sm-<?php if ($logged_in) { echo '2'; } else { echo '1'; } ?> filter-title"><input type="text" class="form-control" placeholder="Points" disabled></div>
  34. <div class="col-sm-2 filter-title"><input type="text" class="form-control" placeholder="Owner" disabled></div>
  35. <div class="col-sm-2 filter-title"><input type="text" class="form-control" placeholder="Date Posted" disabled></div>
  36. <div class="col-sm-<?php if ($logged_in) { echo '3'; } else { echo '4'; } ?> filter-title"><input type="text" class="form-control" placeholder="Tags" disabled></div>
  37. <div class="col-sm-2 filter-title text-right"><button class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button></div>
  38. </div>
  39. </div>
  40. <div class="panel-body">
  41. <?php
  42. $rank = 1;
  43. foreach ($result_list as $result)
  44. {
  45. $username = $userTools->get($result['user_id'])->username;
  46. $thumbnail_src = "../uploads/thumbnails/150_150_" . $result['url'];
  47. $image_src = get_page_url("u", $CONF).'/' . $result['url'];
  48. $user_vote = $db->select('votes', 'table_name=? AND row_id=? AND user_id=? ORDER BY id DESC LIMIT 1', array('ricehalla', $result['id'], $user->id));
  49. $thumb_up = "btn-hover";
  50. $thumb_down = "btn-hover";
  51. if ($user_vote)
  52. {
  53. if ($user_vote['points'] > 0)
  54. {
  55. $thumb_up = "";
  56. }
  57. if ($user_vote['points'] < 0)
  58. {
  59. $thumb_down = "";
  60. }
  61. }
  62. ?>
  63. <div class="row desktop_row">
  64. <div class="col-sm-1 filter-col text-center">
  65. <?php echo $rank++; ?>
  66. </div>
  67. <div class="col-sm-<?php if ($logged_in) { echo '2'; } else { echo '1'; } ?>">
  68. <div class="col-sm-2 filter-col" id="points_<?php echo $result['id']; ?>">
  69. (<?php echo $result['TotalPoints']; ?>)
  70. </div>
  71. <div class="col-sm-3">
  72. <a href="<?php echo get_page_url("ricehalla", $CONF).'/'.$result['id']; ?>" target="_blank" class="btn btn-sm btn-hover btn-primary"><span class="glyphicon glyphicon-link"></span></a>
  73. </div>
  74. <?php
  75. if ($logged_in)
  76. {
  77. ?>
  78. <div class="col-sm-3">
  79. <a href="#" class="btn btn-sm <?php echo $thumb_up; ?> btn-success vote_up" id="vote_up_<?php echo $result['id']; ?>" value="<?php echo $result['id']; ?>"><span class="glyphicon glyphicon-thumbs-up"></span></a>
  80. </div>
  81. <div class="col-sm-3">
  82. <a href="#" class="btn btn-sm <?php echo $thumb_down; ?> btn-danger vote_down" id="vote_down_<?php echo $result['id']; ?>" value="<?php echo $result['id']; ?>"><span class="glyphicon glyphicon-thumbs-down"></span></a>
  83. </div>
  84. <?php
  85. if ($result['user_id'] == $user->id)
  86. {
  87. ?>
  88. <div class="col-sm-3">
  89. <button class="btn btn-sm btn-danger delete_image" id="<?php echo $result['id']; ?>"><span class="glyphicon glyphicon-remove"></span></button>
  90. </div>
  91. <?php
  92. }
  93. }
  94. ?>
  95. </div>
  96. <div class="col-sm-2 filter-col">
  97. <a href="<?php echo get_page_url("home", $CONF); ?>/<?php echo $username; ?>"><?php echo $username; ?></a>
  98. </div>
  99. <div class="col-sm-2 filter-col">
  100. <?php echo $result['date_added']; ?>
  101. </div>
  102. <div class="col-sm-<?php if ($logged_in) { echo '3'; } else { echo '4'; } ?> filter-col">
  103. <div id="taglist-<?php echo $result['id']; ?>" class="tag-list"></div>
  104. </div>
  105. <script>
  106. $(function() {
  107. var tag_str = "<?php echo $result['tags']; ?>";
  108. if (tag_str != "")
  109. {
  110. var tag_list = tag_str.split(",");
  111. var tags = new Array();
  112. for (var i = 0; i < tag_list.length; i++)
  113. {
  114. tags.push(tag_list[i]);
  115. }
  116. }
  117. $('#taglist-<?php echo $result['id']; ?>').tags({
  118. suggestions:["Windows", "Linux", "Rice"],
  119. <?php
  120. if (!$logged_in || $result['user_id'] != $user->id)
  121. {
  122. ?>
  123. readOnly: true,
  124. <?php
  125. }
  126. ?>
  127. tagData: tags,
  128. tagSize: "sm",
  129. tagClass: "btn-primary",
  130. afterAddingTag: function(tag){
  131. var current_tags = $('#taglist-<?php echo $result['id']; ?>').tags().getTags();
  132. var url = "../edit_tags.php";
  133. var data = "id="+encodeURIComponent(<?php echo $result['id']; ?>)+"&tags="+encodeURIComponent(current_tags);
  134. $.ajax({
  135. type: "POST",
  136. url: url,
  137. data: data
  138. });
  139. },
  140. afterDeletingTag: function(tag){
  141. var current_tags = $('#taglist-<?php echo $result['id']; ?>').tags().getTags();
  142. var url = "../edit_tags.php";
  143. var data = "id="+encodeURIComponent(<?php echo $result['id']; ?>)+"&tags="+encodeURIComponent(current_tags);
  144. $.ajax({
  145. type: "POST",
  146. url: url,
  147. data: data
  148. });
  149. }
  150. });
  151. });
  152. </script>
  153. <div class="col-sm-2 filter-col">
  154. <a href="#" class="modalButton" data-toggle="modal" data-img="<?php echo $image_src; ?>" data-url="<?php echo get_page_url("u", $CONF).'/'.$result['url']; ?>" data-user="<?php echo $username; ?>" data-target="#viewCreation">
  155. <img src="<?php echo $thumbnail_src; ?>" width="150" class="img-responsive img-rounded" alt="">
  156. </a>
  157. </div>
  158. </div>
  159. <?php
  160. }
  161. ?>
  162. </div>
  163. </div>
  164. <div class="modal modal-wide fade" id="viewCreation" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  165. <div class="modal-dialog">
  166. <div class="modal-content">
  167. <div class="modal-header text-center">
  168. <button type="button" class="close modalClose" data-dismiss="modal" aria-hidden="true">&times;</button>
  169. <h4 class="modal-title" id="myModalLabel">Creation</h4>
  170. </div>
  171. <div class="modal-body">
  172. <center>
  173. <a href="" target="_blank">
  174. <img src="" class="img-responsive" alt="">
  175. </a>
  176. </center>
  177. </div>
  178. </div><!-- /.modal-content -->
  179. </div><!-- /.modal-dialog -->
  180. </div>
  181. <?php
  182. }
  183. else
  184. {
  185. ?>
  186. <div class="row text-center">
  187. <p>No Creations Available</p>
  188. </div>
  189. <?php
  190. }
  191. ?>
  192. </div>