images.php
6.03 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
<?php
/**
* @package Joomla.Platform
* @subpackage MediaWiki
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
/**
* MediaWiki API Images class for the Joomla Platform.
*
* @since 3.1.4
*/
class JMediawikiImages extends JMediawikiObject
{
/**
* Method to get all images contained on the given page(s).
*
* @param array $titles Page titles to retrieve images.
* @param integer $imagelimit How many images to return.
* @param boolean $imagecontinue When more results are available, use this to continue.
* @param integer $imimages Only list these images.
* @param string $imdir The direction in which to list.
*
* @return object
*
* @since 3.1.4
*/
public function getImages(array $titles, $imagelimit = null, $imagecontinue = null, $imimages = null, $imdir = null)
{
// Build the request.
$path = '?action=query&prop=images';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
if (isset($imagelimit))
{
$path .= '&imagelimit=' . $imagelimit;
}
if ($imagecontinue)
{
$path .= '&imagecontinue=';
}
if (isset($imimages))
{
$path .= '&imimages=' . $imimages;
}
if (isset($imdir))
{
$path .= '&imdir=' . $imdir;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all images contained on the given page(s).
*
* @param array $titles Page titles to retrieve links.
*
* @return object
*
* @since 3.1.4
*/
public function getImagesUsed(array $titles)
{
// Build the request.
$path = '?action=query&generator=images&prop=info';
// Append titles to the request.
$path .= '&titles=' . $this->buildParameter($titles);
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to get all image information and upload history.
*
* @param array $liprop What image information to get.
* @param integer $lilimit How many image revisions to return.
* @param string $listart Timestamp to start listing from.
* @param string $liend Timestamp to stop listing at.
* @param integer $liurlwidth URL to an image scaled to this width will be returned..
* @param integer $liurlheight URL to an image scaled to this height will be returned.
* @param string $limetadataversion Version of metadata to use.
* @param string $liurlparam A handler specific parameter string.
* @param boolean $licontinue When more results are available, use this to continue.
*
* @return object
*
* @since 3.1.4
*/
public function getImageInfo(array $liprop = null, $lilimit = null, $listart = null, $liend = null, $liurlwidth = null,
$liurlheight = null, $limetadataversion = null, $liurlparam = null, $licontinue = null)
{
// Build the request.
$path = '?action=query&prop=imageinfo';
if (isset($liprop))
{
$path .= '&liprop=' . $this->buildParameter($liprop);
}
if (isset($lilimit))
{
$path .= '&lilimit=' . $lilimit;
}
if (isset($listart))
{
$path .= '&listart=' . $listart;
}
if (isset($liend))
{
$path .= '&liend=' . $liend;
}
if (isset($liurlwidth))
{
$path .= '&liurlwidth=' . $liurlwidth;
}
if (isset($liurlheight))
{
$path .= '&liurlheight=' . $liurlheight;
}
if (isset($limetadataversion))
{
$path .= '&limetadataversion=' . $limetadataversion;
}
if (isset($liurlparam))
{
$path .= '&liurlparam=' . $liurlparam;
}
if ($licontinue)
{
$path .= '&alcontinue=';
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
/**
* Method to enumerate all images.
*
* @param string $aifrom The image title to start enumerating from.
* @param string $aito The image title to stop enumerating at.
* @param string $aiprefix Search for all image titles that begin with this value.
* @param integer $aiminsize Limit to images with at least this many bytes.
* @param integer $aimaxsize Limit to images with at most this many bytes.
* @param integer $ailimit How many images in total to return.
* @param string $aidir The direction in which to list.
* @param string $aisha1 SHA1 hash of image.
* @param string $aisha1base36 SHA1 hash of image in base 36.
* @param array $aiprop What image information to get.
* @param string $aimime What MIME type to search for.
*
* @return object
*
* @since 3.1.4
*/
public function enumerateImages($aifrom = null, $aito = null, $aiprefix = null, $aiminsize = null, $aimaxsize = null, $ailimit = null,
$aidir = null, $aisha1 = null, $aisha1base36 = null, array $aiprop = null, $aimime = null)
{
// Build the request.
$path = '?action=query&list=allimages';
if (isset($aifrom))
{
$path .= '&aifrom=' . $aifrom;
}
if (isset($aito))
{
$path .= '&aito=' . $aito;
}
if (isset($aiprefix))
{
$path .= '&aiprefix=' . $aiprefix;
}
if (isset($aiminsize))
{
$path .= '&aiminsize=' . $aiminsize;
}
if (isset($aimaxsize))
{
$path .= '&aimaxsize=' . $aimaxsize;
}
if (isset($ailimit))
{
$path .= '&ailimit=' . $ailimit;
}
if (isset($aidir))
{
$path .= '&aidir=' . $aidir;
}
if (isset($aisha1))
{
$path .= '&aisha1=' . $aisha1;
}
if (isset($aisha1base36))
{
$path .= '&$aisha1base36=' . $aisha1base36;
}
if (isset($aiprop))
{
$path .= '&aiprop=' . $this->buildParameter($aiprop);
}
if (isset($aimime))
{
$path .= '&aimime=' . $aimime;
}
// Send the request.
$response = $this->client->get($this->fetchUrl($path));
return $this->validateResponse($response);
}
}