-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_gallery2.php
163 lines (156 loc) · 4.92 KB
/
mod_gallery2.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
<?php
# Define your own gallery here, straight to main.php
define(GALLERY, 'http://example.com/gallery2/main.php');
/*******************************************************************
*
* @author Sander Ruitenbeek <[email protected]>
* @version 0.2, Mar 2012
*
* Use at your own risk!
*
* Description:
* This module connects Ariadne to a Gallery 2 to display pictures in an
* external image block, to use on your sites in Ariadne.
*
* Use in Ariadne as follows:
* 1. Define the GALLERY const on line 3 of this file.
* 2. Add something like this in your template:
* <pinp>
* load(mod_gallery.php);
* gallery::ShowRandomImages(10);
* </pinp>
*
* This will display something like this for 10 images:
* <div class="one-image">
* <a href="http://example.com/gallery/IMG.JPG.html" target="_newWindow">
* <img src="http://example.com/gallery/IMG.JPG" width="150"
* height="150" class="giThumbnail" alt="IMG.JPG"/>
* </a>
* </div>
*
* See the respective functions comments for more info
*
* More info on the Gallery2 external image block can be found on the codex:
* http://codex.gallery2.org/Gallery2:Modules:imageblock
*
*
*******************************************************************/
class gallery
{
/**
* Show single image
*
* @param imageId the gallery item id
* @return the image to show
*/
public function ShowSingleImage($imageId)
{
$image = null;
if (is_numeric($imageId))
{
$image = @readfile(GALLERY.'?g2_view=imageblock.External&g2_blocks=specificItem&g2_show=none&g2_itemId='.$imageId.'&g2_linkTarget=_newWindow');
}
return $image;
}
/**
* Show images from a comma separated values list
*
* @param $imageCSV a list of comma separated imageIds (12,34,56)
*/
public function ShowImages($imageCSV)
{
$images = null;
$ids = split(',', $imageCSV);
foreach ($ids as $id)
{
$id = trim($id);
if (is_numeric($id))
{
$images .= @readfile(GALLERY.'?g2_view=imageblock.External&g2_blocks=specificItem&g2_show=none&g2_itemId='.$id.'&g2_linkTarget=_newWindow');
}
}
return $images;
}
/**
* Show random image(s)
*
* number of images to show
* @param integer $number
*/
public function ShowRandomImages($number)
{
if (is_numeric($number))
{
$blocks = 'randomImage';
while ($number > 1)
{
$blocks .= '|randomImage';
$number--;
}
return @readfile(GALLERY.'?g2_view=imageblock.External&g2_blocks='.$blocks.'&g2_show=none&g2_linkTarget=_newWindow');
}
}
/**
* Show recent image(s)
*
* @param integer $number number of images to show
* @return type
*/
public function ShowRecentImages($number)
{
if (is_numeric($number))
{
$blocks = 'recentImage';
while ($number > 1)
{
$blocks .= '|recentImage';
$number--;
}
return @readfile(GALLERY.'?g2_view=imageblock.External&g2_blocks='.$blocks.'&g2_show=none&g2_linkTarget=_newWindow');
}
}
}
class pinp_gallery
{
/**
* Show a single image
*
* @param numeric $imageId Gallery imageId of the image to show
* @return the image to show
*/
function _ShowSingleImage($imageId)
{
return gallery::ShowSingleImage($imageId);
}
/**
* Show multiple images
*
* @param $imageCSV a comma separated list of values of the Gallery imageIds of the images to show
* @return string|null images to show
*/
function _ShowImages($imageCSV)
{
return gallery::ShowImages($imageCSV);
}
/**
* Show random image(s)
*
* @param int $number the number of random images to show
* @return the random images to show
*/
function _ShowRandomImages($number = 1)
{
return gallery::ShowRandomImages($number);
}
/**
* Show recent image(s)
*
* @param int $number the number of recent images to show
* @return the recent image(s) to show
*/
function _ShowRecentImages($number = 1)
{
return gallery::ShowRecentImages($number);
}
}
?>