Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
sites.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 Sites class for the Joomla Platform.
14  *
15  * @package Joomla.Platform
16  * @subpackage MediaWiki
17  * @since 12.3
18  */
20 {
21  /**
22  * Method to get site information.
23  *
24  * @param array $siprop The sysinfo properties to get.
25  * @param string $sifilteriw Only local or only non local entries to return.
26  * @param boolean $sishowalldb List all database servers.
27  * @param boolean $sinumberingroup List the number of users in usergroups.
28  * @param array $siinlanguagecode Language code for localized languages.
29  *
30  * @return object
31  *
32  * @since 12.3
33  */
34  public function getSiteInfo(array $siprop = null, $sifilteriw = null, $sishowalldb = false, $sinumberingroup = false, array $siinlanguagecode = null)
35  {
36  // Build the request.
37  $path = '?action=query&meta=siteinfo';
38 
39  if (isset($siprop))
40  {
41  $path .= '&siprop=' . $this->buildParameter($siprop);
42  }
43 
44  if (isset($sifilteriw))
45  {
46  $path .= '&sifilteriw=' . $sifilteriw;
47  }
48 
49  if ($sishowalldb)
50  {
51  $path .= '&sishowalldb=';
52  }
53 
54  if ($sinumberingroup)
55  {
56  $path .= '&sinumberingroup=';
57  }
58 
59  if (isset($siinlanguagecode))
60  {
61  $path .= '&siinlanguagecode=' . $this->buildParameter($siinlanguagecode);
62  }
63 
64  // Send the request.
65  $response = $this->client->get($this->fetchUrl($path));
66 
67  return $this->validateResponse($response);
68  }
69 
70  /**
71  * Method to get events from logs.
72  *
73  * @param array $leprop List of properties to get.
74  * @param string $letype Filter log actions to only this type.
75  * @param string $leaction Filter log actions to only this type.
76  * @param string $letitle Filter entries to those related to a page.
77  * @param string $leprefix Filter entries that start with this prefix.
78  * @param string $letag Filter entries with tag.
79  * @param string $leuser Filter entries made by the given user.
80  * @param string $lestart Starting timestamp.
81  * @param string $leend Ending timestamp.
82  * @param string $ledir Direction of enumeration.
83  * @param integer $lelimit Event limit to return.
84  *
85  * @return object
86  *
87  * @since 12.3
88  */
89  public function getEvents(array $leprop = null, $letype = null, $leaction = null, $letitle = null, $leprefix = null, $letag = null,
90  $leuser = null, $lestart = null, $leend = null, $ledir = null, $lelimit = null)
91  {
92  // Build the request
93  $path = '?action=query&list=logevents';
94 
95  if (isset($leprop))
96  {
97  $path .= '&leprop=' . $this->buildParameter($leprop);
98  }
99 
100  if (isset($letype))
101  {
102  $path .= '&letype=' . $letype;
103  }
104 
105  if (isset($leaction))
106  {
107  $path .= '&leaction=' . $leaction;
108  }
109 
110  if (isset($letitle))
111  {
112  $path .= '&letitle=' . $letitle;
113  }
114 
115  if (isset($leprefix))
116  {
117  $path .= '&leprefix=' . $leprefix;
118  }
119 
120  if (isset($letag))
121  {
122  $path .= '&letag=' . $letag;
123  }
124 
125  if (isset($leuser))
126  {
127  $path .= '&leuser=' . $leuser;
128  }
129 
130  if (isset($lestart))
131  {
132  $path .= '&lestart=' . $lestart;
133  }
134 
135  if (isset($leend))
136  {
137  $path .= '&leend=' . $leend;
138  }
139 
140  if (isset($ledir))
141  {
142  $path .= '&ledir=' . $ledir;
143  }
144 
145  if (isset($lelimit))
146  {
147  $path .= '&lelimit=' . $lelimit;
148  }
149 
150  // Send the request.
151  $response = $this->client->get($this->fetchUrl($path));
152 
153  return $this->validateResponse($response);
154  }
155 
156  /**
157  * Method to get recent changes on a site.
158  *
159  * @param string $rcstart Starting timestamp.
160  * @param string $rcend Ending timestamp.
161  * @param string $rcdir Direction of enumeration.
162  * @param array $rcnamespace Filter changes to only this namespace(s).
163  * @param string $rcuser Filter changes by this user.
164  * @param string $rcexcludeuser Filter changes to exclude changes by this user.
165  * @param string $rctag Filter changes by this tag.
166  * @param array $rcprop Filter log actions to only this type.
167  * @param array $rctoken Which token to obtain for each change.
168  * @param array $rcshow Filter changes by this criteria.
169  * @param string $rclimit Changes limit to return.
170  * @param string $rctype Filter event by type of changes.
171  * @param string $rctoponly Filter changes which are latest revision.
172  *
173  * @return object
174  *
175  * @since 12.3
176  */
177  public function getRecentChanges($rcstart = null, $rcend = null, $rcdir = null, array $rcnamespace = null, $rcuser = null, $rcexcludeuser = null,
178  $rctag = null, array $rcprop = null, array $rctoken = null, array $rcshow = null, $rclimit = null, $rctype = null, $rctoponly = null)
179  {
180  // Build the request.
181  $path = '?action=query&list=recentchanges';
182 
183  if (isset($rcstart))
184  {
185  $path .= '&rcstart=' . $rcstart;
186  }
187 
188  if (isset($rcend))
189  {
190  $path .= '&rcend=' . $rcend;
191  }
192 
193  if (isset($rcdir))
194  {
195  $path .= '&rcdir=' . $rcdir;
196  }
197 
198  if (isset($rcnamespace))
199  {
200  $path .= '&rcnamespaces=' . $this->buildParameter($rcnamespace);
201  }
202 
203  if (isset($rcuser))
204  {
205  $path .= '&rcuser=' . $rcuser;
206  }
207 
208  if (isset($rcexcludeuser))
209  {
210  $path .= '&rcexcludeuser=' . $rcexcludeuser;
211  }
212 
213  if (isset($rctag))
214  {
215  $path .= '&rctag=' . $rctag;
216  }
217 
218  if (isset($rcprop))
219  {
220  $path .= '&rcprop=' . $this->buildParameter($rcprop);
221  }
222 
223  if (isset($rctoken))
224  {
225  $path .= '&rctoken=' . $this->buildParameter($rctoken);
226  }
227 
228  if (isset($rcshow))
229  {
230  $path .= '&rcshow=' . $this->buildParameter($rcshow);
231  }
232 
233  if (isset($rclimit))
234  {
235  $path .= '&rclimit=' . $rclimit;
236  }
237 
238  if (isset($rctype))
239  {
240  $path .= '&rctype=' . $rctype;
241  }
242 
243  if (isset($rctoponly))
244  {
245  $path .= '&rctoponly=' . $rctoponly;
246  }
247 
248  // Send the request.
249  $response = $this->client->get($this->fetchUrl($path));
250 
251  return $this->validateResponse($response);
252  }
253 
254  /**
255  * Method to get protected titles on a site.
256  *
257  * @param array $ptnamespace Only list titles in this namespace.
258  * @param array $ptlevel Only list titles with these protection level.
259  * @param integer $ptlimit Limit of pages to return.
260  * @param string $ptdir Direction of enumeration.
261  * @param string $ptstart Starting timestamp.
262  * @param string $ptend Ending timestamp.
263  * @param array $ptprop List of properties to get.
264  *
265  * @return object
266  *
267  * @since 12.3
268  */
269  public function getProtectedTitles(array $ptnamespace = null, array $ptlevel = null, $ptlimit = null, $ptdir = null, $ptstart = null,
270  $ptend = null, array $ptprop = null)
271  {
272  // Build the request.
273  $path = '?action=query&list=protectedtitles';
274 
275  if (isset($ptnamespace))
276  {
277  $path .= '&ptnamespace=' . $this->buildParameter($ptnamespace);
278  }
279 
280  if (isset($ptlevel))
281  {
282  $path .= '&ptlevel=' . $this->buildParameter($ptlevel);
283  }
284 
285  if (isset($ptlimit))
286  {
287  $path .= '&ptlimit=' . $ptlimit;
288  }
289 
290  if (isset($ptdir))
291  {
292  $path .= '&ptdir=' . $ptdir;
293  }
294 
295  if (isset($ptstart))
296  {
297  $path .= '&ptstart=' . $ptstart;
298  }
299 
300  if (isset($ptend))
301  {
302  $path .= '&ptend=' . $ptend;
303  }
304 
305  if (isset($ptprop))
306  {
307  $path .= '&ptprop=' . $this->buildParameter($ptprop);
308  }
309 
310  // Send the request.
311  $response = $this->client->get($this->fetchUrl($path));
312 
313  return $this->validateResponse($response);
314  }
315 }