-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
251 lines (192 loc) · 7.75 KB
/
index.php
File metadata and controls
251 lines (192 loc) · 7.75 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
/**
* Fancy Image Gallery for Wolf CMS- Create gallery and display images with few clicks
* Gallery is free for non-profit and commercial usage.
* @package wolf
* @subpackage plugin.fancy_image_gallery
*
* @author Sanja Andjelkovic <sanja@medio.com.hr>
* @author Dejan Andjelkovic <dejan@medio.com.hr>
* @version 1.0.0
* @for Wolf version 0.7.0 and above
* @license http://www.gnu.org/licenses/gpl.html GPL License
* @copyright medio.com.hr & project79.net, 2009-2012
*/
//security measure
if (!defined('IN_CMS')) { exit(); }
Plugin::setInfos(array(
'id' => 'fancy_image_gallery',
'title' => 'Fancy Image Gallery',
'description' => __('Provides easy to use image gallery with fancybox effect.'),
'version' => '1.0.0',
'license' => 'GPL',
'author' => 'Sanja Andjelkovic',
'website' => 'http://project79.net/projects/fancy-image-gallery',
'update_url' => 'http://www.project79.net/plugin-versions.xml',
'require_wolf_version' => '0.7.3'
));
Plugin::addController('fancy_image_gallery', 'Fancy Image Gallery', 'admin_view');
// funkcija koja izbacuje samo jednu sliku iz direktorija i pravi link na odabranu galeriju - 0.9.0
/*
* Call to action: <?php fancy_list(); ?>
*/
function fancy_list(){
$main_dir = CMS_ROOT . '/public/images/';
$open_main = opendir ($main_dir);
if ($open_main) {
while (false !== ($folder = readdir($open_main)))
{
if ($folder != '.' && $folder != '..')
{
$folders[] = $folder;
}
}
closedir($open_main);
}
// drugi korak - propusti kroz petlju i ispisi putanje
$number = count($folders);
$counter=1;
if(count($folders)){
while ($counter<=$number) {
foreach($folders as $folder) {
$counter++;
$image_dir = CMS_ROOT . '/public/images/' . $folder . '/';
$handle = opendir($image_dir);
$files = array();
if ($handle) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
if(strstr($file,'-thumb'))
{
$files = $file;
}
}
}
closedir($handle);
}
$images = $files;
/*
* $gallername serves as your main gallery page
* In order it to work, you have to replace current 'gallery' with the
* slug of your main gallery page e.g. 'my-gallery'
*/
$galleryname = 'gallery';
$path = str_replace(dirname($folder), '', $folder);
$fullpath = str_replace ('?', '',BASE_URL) . 'public/images/' . $path . '/';
if($files) {
echo '<a class="link" href="',BASE_URL . $galleryname . '/' . $path . '/','" title="',str_replace('/','',$path),'"><img src="',$fullpath, $images,'" alt="',str_replace('/','',$path),'" /></a>',"\n";
}
else {
echo __('There are no images in this gallery.');
}
}
}
}
}
// funkcija koja izbacuje samo jednu sliku iz direktorija i pravi link na odabranu galeriju
/*
* Call to action: <?php fancy_parent('my-first.gallery/', '/gallery/my-first-gallery'); ?>
*/
function fancy_parent($path, $child){
$fullpath = str_replace ('?', '',BASE_URL) . 'public/images/' . $path;
$image_dir = CMS_ROOT . '/public/images/' . $path;
$handle = opendir($image_dir);
if ($handle) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
if(strstr($file,'-thumb'))
{
$files[] = $file;
}
}
}
closedir($handle);
}
// propusti kroz petlju i ispisi linkove, te ih vezi za galeriju
// za title ispisi samo krajnji direktorij u kojem se nalaze slike
$images = $files[0];
$path = str_replace(dirname($path), '', $path);
if($files) {
echo '<a class="link" href="',BASE_URL . $child,'" title="',str_replace('/','',$path),'"><img src="',$fullpath,$images,'" alt="',str_replace('/','',$path),'" /></a>',"\n";
}
else {
echo __('There are no images in this gallery.');
}
}
/*
* Call to action: <?php fancy('my-first.gallery/'); ?>
*/
function fancy($path){
$fullpath = str_replace ('?', '',BASE_URL) . 'public/images/' . $path;
$image_dir = CMS_ROOT . '/public/images/' . $path;
$handle = opendir($image_dir);
// prvi korak: citaj direktorij i napravi polje
if ($handle) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
if(strstr($file,'-thumb'))
{
$files[] = $file;
}
}
}
closedir($handle);
}
// drugi korak - propusti kroz petlju i ispisi slike
$images = count($files);
$counter=1;
if(count($files))
{
natsort($files); //sortiranje; dodano u 0.8.1
while ($counter<=$images)
{
foreach($files as $file)
{
$counter++;
$str=str_replace('_',' ',$file); // ciscenje naslova; 0.8.6
echo '<a class="photo" data-lightbox="fancygallery" href="',$fullpath,str_replace('-thumb','',$file),'" title="',preg_replace('/\-thumb..*$/i', '',$str),'"><img src="',$fullpath,$file,'" alt="',preg_replace('/\-thumb..*$/i', '',$str),'" /></a>';
}
}
}
else
{
echo __('There are no images in this gallery.');
}
}
/*
* Call to action: <?php fancy_slider($path, $page, 400, 200, $title); ?>
*/
function fancy_slider($path, $child, $width=false, $height=false, $title=false){
$fullpath = str_replace ('?', '',BASE_URL) . 'public/images/' . $path;
$image_dir = CMS_ROOT . '/public/images/' . $path;
$handle = opendir($image_dir);
if ($handle) {
while (false !== ($file = readdir($handle)))
{
if ($file != '.' && $file != '..')
{
$files[] = $file;
}
}
closedir($handle);
}
// propusti kroz petlju i ispisi linkove, te ih vezi za galeriju
// za title ispisi samo krajnji direktorij u kojem se nalaze slike
sort($files);
$images = $files[1];
$path = str_replace(dirname($path), '', $path);
if($files)
{
echo '<a href="',BASE_URL . $child,'" title="',str_replace('/','',$path),'"><img src="',$fullpath,$images,'" width="',$width,'" height="',$height,'" title="',$title,'" alt="',$title,'" /></a>',"\n";
}
else
{
echo __('There are no images in this gallery.');
}
}