-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopics.php
156 lines (142 loc) · 5.2 KB
/
topics.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php include('conn_db.php');?>
<div class="container-fluid">
<style>
input[type=checkbox]
{
/* Double-sized Checkboxes */
-ms-transform: scale(1.5); /* IE */
-moz-transform: scale(1.5); /* FF */
-webkit-transform: scale(1.5); /* Safari and Chrome */
-o-transform: scale(1.5); /* Opera */
transform: scale(1.5);
padding: 10px;
}
.list-group-item + .list-group-item {
border-top-width: 1px !important;
}
</style>
<div class="col-lg-12">
<div class="row mb-4 mt-4">
<div class="col-md-12">
</div>
</div>
<div class="row">
<!-- FORM Panel -->
<!-- Table Panel -->
<div class="col-md-12">
<div class="card">
<div class="card-header">
<b>Topic List</b>
<span class="">
<button class="btn btn_pink btn-block btn-sm col-sm-2 float-right" type="button" id="new_topic">
<i class="fa fa-plus"></i> Create Topic</button>
</span>
</div>
<div class="card-body">
<ul class="w-100 list-group" id="topic-list">
<?php
$tag = $conn->query("SELECT * FROM categories order by name asc");
while($row= $tag->fetch_assoc()):
$tags[$row['id']] = $row['name'];
endwhile;
$topic = $conn->query("SELECT t.*,m.name FROM topics t inner join member m on m.id = t.user_id order by unix_timestamp(date_created) desc");
while($row= $topic->fetch_assoc()):
$trans = get_html_translation_table(HTML_ENTITIES,ENT_QUOTES);
unset($trans["\""], $trans["<"], $trans[">"], $trans["<h2"]);
$desc = strtr(html_entity_decode($row['content']),$trans);
$desc=str_replace(array("<li>","</li>"), array("",","), $desc);
$view = $conn->query("SELECT * FROM forum_views where topic_id=".$row['id'])->num_rows;
$comments = $conn->query("SELECT * FROM comments where topic_id=".$row['id'])->num_rows;
$replies = $conn->query("SELECT * FROM replies where comment_id in (SELECT id FROM comments where topic_id=".$row['id'].")")->num_rows;
?>
<li class="list-group-item mb-4">
<div>
<?php if($_SESSION['id'] == $row['user_id'] || $_SESSION['type'] == 1): ?>
<div class="dropleft float-right mr-4">
<a class="text-dark" href="javascript:void(0)" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="fa fa-ellipsis-v"></span>
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item edit_topic" data-id="<?php echo $row['id'] ?>" href="javascript:void(0)">Edit</a>
<a class="dropdown-item delete_topic" data-id="<?php echo $row['id'] ?>" href="javascript:void(0)">Delete</a>
</div>
</div>
<?php endif; ?>
<span class="float-right mr-4"><small><i>Created: <?php echo date('M d, Y h:i A',strtotime($row['date_created'])) ?></i></small></span>
<a href="forum.php?page=view_forum&id=<?php echo $row['id'] ?>"
class=" filter-text"><?php echo $row['title'] ?></a>
</div>
<hr>
<p class="truncate filter-text"><?php echo strip_tags($desc) ?></p>
<p class="row justify-content-left"><span class="badge badge-success btn_purple"><i>Posted By:
<?php
echo $row['name']
?>
</i></span></p>
<hr>
<span class="float-left badge badge-secondary text-white"><?php echo number_format($view) ?> view/s</span>
<span class="float-left badge btn_pink text-white ml-2"><i class="fa fa-comments"></i> <?php echo number_format($view) ?> comment/s <?php echo $replies > 0 ? " and ".number_format($replies).' replies':'' ?> </span>
<span class="float-right">
<span>Tags: </span>
<?php
foreach(explode(",",$row['category_ids']) as $cat):
?>
<span class="badge badge-info text-white ml-2"><?php echo $tags[$cat] ?></span>
<?php endforeach; ?>
</span>
</li>
<?php endwhile; ?>
</ul>
</div>
</div>
</div>
<!-- Table Panel -->
</div>
</div>
</div>
<style>
td{
vertical-align: middle !important;
}
td p{
margin: unset
}
img{
max-width:100px;
max-height: 150px;
}
</style>
<script>
$(document).ready(function(){
$('table').dataTable()
})
$('#topic-list').JPaging({
pageSize: 15,
visiblePageSize: 10
});
$('#new_topic').click(function(){
uni_modal("New Entry","manage_topic.php",'mid-large')
})
$('.edit_topic').click(function(){
uni_modal("Edit Topic","manage_topic.php?id="+$(this).attr('data-id'),'mid-large')
})
$('.delete_topic').click(function(){
_conf("Are you sure to delete this topic?","delete_topic",[$(this).attr('data-id')],'mid-large')
})
function delete_topic($id){
start_load()
$.ajax({
url:'ajax.php?action=delete_topic',
method:'POST',
data:{id:$id},
success:function(resp){
if(resp==1){
alert_toast("Data successfully deleted",'success')
setTimeout(function(){
location.reload()
},1500)
}
}
})
}
</script>