Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
images.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage MediaWiki
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 /**
13  * MediaWiki API Images class for the Joomla Platform.
14  *
15  * @package Joomla.Platform
16  * @subpackage MediaWiki
17  * @since 12.3
18  */
20 {
21 
22  /**
23  * Method to get all images contained on the given page(s).
24  *
25  * @param array $titles Page titles to retrieve images.
26  * @param integer $imagelimit How many images to return.
27  * @param boolean $imagecontinue When more results are available, use this to continue.
28  * @param integer $imimages Only list these images.
29  * @param string $imdir The direction in which to list.
30  *
31  * @return object
32  *
33  * @since 12.3
34  */
35  public function getImages(array $titles, $imagelimit = null, $imagecontinue = null, $imimages = null, $imdir = null)
36  {
37  // Build the request.
38  $path = '?action=query&prop=images';
39 
40  // Append titles to the request.
41  $path .= '&titles=' . $this->buildParameter($titles);
42 
43  if (isset($imagelimit))
44  {
45  $path .= '&imagelimit=' . $imagelimit;
46  }
47 
48  if ($imagecontinue)
49  {
50  $path .= '&imagecontinue=';
51  }
52 
53  if (isset($imimages))
54  {
55  $path .= '&imimages=' . $imimages;
56  }
57 
58  if (isset($imdir))
59  {
60  $path .= '&imdir=' . $imdir;
61  }
62 
63  // Send the request.
64  $response = $this->client->get($this->fetchUrl($path));
65 
66  return $this->validateResponse($response);
67  }
68 
69  /**
70  * Method to get all images contained on the given page(s).
71  *
72  * @param array $titles Page titles to retrieve links.
73  *
74  * @return object
75  *
76  * @since 12.3
77  */
78  public function getImagesUsed(array $titles)
79  {
80  // Build the request.
81  $path = '?action=query&generator=images&prop=info';
82 
83  // Append titles to the request.
84  $path .= '&titles=' . $this->buildParameter($titles);
85 
86  // Send the request.
87  $response = $this->client->get($this->fetchUrl($path));
88 
89  return $this->validateResponse($response);
90  }
91 
92  /**
93  * Method to get all image information and upload history.
94  *
95  * @param array $liprop What image information to get.
96  * @param integer $lilimit How many image revisions to return.
97  * @param string $listart Timestamp to start listing from.
98  * @param string $liend Timestamp to stop listing at.
99  * @param integer $liurlwidth URL to an image scaled to this width will be returned..
100  * @param integer $liurlheight URL to an image scaled to this height will be returned.
101  * @param string $limetadataversion Version of metadata to use.
102  * @param string $liurlparam A handler specific parameter string.
103  * @param boolean $licontinue When more results are available, use this to continue.
104  *
105  * @return object
106  *
107  * @since 12.3
108  */
109  public function getImageInfo(array $liprop = null, $lilimit = null, $listart = null, $liend = null, $liurlwidth = null,
110  $liurlheight = null, $limetadataversion = null, $liurlparam = null, $licontinue = null)
111  {
112  // Build the request.
113  $path = '?action=query&prop=imageinfo';
114 
115  if (isset($liprop))
116  {
117  $path .= '&liprop=' . $this->buildParameter($liprop);
118  }
119 
120  if (isset($lilimit))
121  {
122  $path .= '&lilimit=' . $lilimit;
123  }
124 
125  if (isset($listart))
126  {
127  $path .= '&listart=' . $listart;
128  }
129 
130  if (isset($liend))
131  {
132  $path .= '&liend=' . $liend;
133  }
134 
135  if (isset($liurlwidth))
136  {
137  $path .= '&liurlwidth=' . $liurlwidth;
138  }
139 
140  if (isset($liurlheight))
141  {
142  $path .= '&liurlheight=' . $liurlheight;
143  }
144 
145  if (isset($limetadataversion))
146  {
147  $path .= '&limetadataversion=' . $limetadataversion;
148  }
149 
150  if (isset($liurlparam))
151  {
152  $path .= '&liurlparam=' . $liurlparam;
153  }
154 
155  if ($licontinue)
156  {
157  $path .= '&alcontinue=';
158  }
159 
160  // Send the request.
161  $response = $this->client->get($this->fetchUrl($path));
162 
163  return $this->validateResponse($response);
164  }
165 
166  /**
167  * Method to enumerate all images.
168  *
169  * @param string $aifrom The image title to start enumerating from.
170  * @param string $aito The image title to stop enumerating at.
171  * @param string $aiprefix Search for all image titles that begin with this value.
172  * @param integer $aiminsize Limit to images with at least this many bytes.
173  * @param integer $aimaxsize Limit to images with at most this many bytes.
174  * @param integer $ailimit How many images in total to return.
175  * @param string $aidir The direction in which to list.
176  * @param string $aisha1 SHA1 hash of image.
177  * @param string $aisha1base36 SHA1 hash of image in base 36.
178  * @param array $aiprop What image information to get.
179  * @param string $aimime What MIME type to search for.
180  *
181  * @return object
182  *
183  * @since 12.3
184  */
185  public function enumerateImages($aifrom = null, $aito = null, $aiprefix = null, $aiminsize = null, $aimaxsize = null, $ailimit = null,
186  $aidir = null, $aisha1 = null, $aisha1base36 = null, array $aiprop = null, $aimime = null)
187  {
188  // Build the request.
189  $path = '?action=query&list=allimages';
190 
191  if (isset($aifrom))
192  {
193  $path .= '&aifrom=' . $aifrom;
194  }
195 
196  if (isset($aito))
197  {
198  $path .= '&aito=' . $aito;
199  }
200 
201  if (isset($aiprefix))
202  {
203  $path .= '&aiprefix=' . $aiprefix;
204  }
205 
206  if (isset($aiminsize))
207  {
208  $path .= '&aiminsize=' . $aiminsize;
209  }
210 
211  if (isset($aimaxsize))
212  {
213  $path .= '&aimaxsize=' . $aimaxsize;
214  }
215 
216  if (isset($ailimit))
217  {
218  $path .= '&ailimit=' . $ailimit;
219  }
220 
221  if (isset($aidir))
222  {
223  $path .= '&aidir=' . $aidir;
224  }
225  if (isset($aisha1))
226  {
227  $path .= '&aisha1=' . $aisha1;
228  }
229 
230  if (isset($aisha1base36))
231  {
232  $path .= '&$aisha1base36=' . $aisha1base36;
233  }
234 
235  if (isset($aiprop))
236  {
237  $path .= '&aiprop=' . $this->buildParameter($aiprop);
238  }
239 
240  if (isset($aimime))
241  {
242  $path .= '&aimime=' . $aimime;
243  }
244 
245  // Send the request.
246  $response = $this->client->get($this->fetchUrl($path));
247 
248  return $this->validateResponse($response);
249  }
250 }