-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·175 lines (53 loc) · 2.19 KB
/
index.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php include("includes/header.php"); ?>
<?php
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
$items_per_page = 16;
$items_total_count = Photo::count_all();
$paginate = new Paginate($page, $items_per_page, $items_total_count);
$sql = "SELECT * FROM photos ";
$sql .= "LIMIT {$items_per_page} ";
$sql .= "OFFSET {$paginate->offset()}";
$photos = Photo::find_by_query($sql);
// $photos = Photo::find_all();
?>
<div class="row">
<!-- Blog Entries Column -->
<div class="col-md-12">
<div class="thumbnails row">
<?php foreach ($photos as $photo): ?>
<div class="col-xs-6 col-md-3">
<a class="thumbnail" href="photo.php?id=<?php echo $photo->id; ?>">
<img class="home_page_photo img-responsive " src="admin/<?php echo $photo->picture_path(); ?>" alt="">
</a>
</div>
<?php endforeach; ?>
</div>
<div class="row">
<ul class="pager">
<?php
if($paginate->page_total() > 1) {
if($paginate->has_next()) {
echo "<li class='next'><a href='index.php?page={$paginate->next()}'>Next</a></li>";
}
for ($i=1; $i <= $paginate->page_total(); $i++) {
if($i == $paginate->current_page) {
echo "<li class='active'><a href='index.php?page={$i}'>{$i}</a></li>";
} else {
echo "<li><a href='index.php?page={$i}'>{$i}</a></li>";
}
}
if($paginate->has_previous()) {
echo "<li class='previous'><a href='index.php?page={$paginate->previous()}'>Previous</a></li>";
}
}
?>
</ul>
</div>
</div>
<!-- Blog Sidebar Widgets Column -->
<!-- <div class="col-md-4">
-->
<?php // include("includes/sidebar.php"); ?>
</div>
<!-- /.row -->
<?php include("includes/footer.php"); ?>