Yet more doc tweaks:
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
1 <?php
2
3 /*
4 * Created on Sep 25, 2006
5 *
6 * API for MediaWiki 1.8+
7 *
8 * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 */
25
26 if (!defined('MEDIAWIKI')) {
27 // Eclipse helper - will be ignored in production
28 require_once ('ApiQueryBase.php');
29 }
30
31 /**
32 * @addtogroup API
33 */
34 class ApiQuerySiteinfo extends ApiQueryBase {
35
36 public function __construct($query, $moduleName) {
37 parent :: __construct($query, $moduleName, 'si');
38 }
39
40 public function execute() {
41 $prop = null;
42 extract($this->extractRequestParams());
43
44 foreach ($prop as $p) {
45 switch ($p) {
46
47 case 'general' :
48
49 global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText;
50 $data = array ();
51 $mainPage = Title :: newFromText(wfMsgForContent('mainpage'));
52 $data['mainpage'] = $mainPage->getText();
53 $data['base'] = $mainPage->getFullUrl();
54 $data['sitename'] = $wgSitename;
55 $data['generator'] = "MediaWiki $wgVersion";
56 $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future
57 if (isset($wgRightsCode))
58 $data['rightscode'] = $wgRightsCode;
59 $data['rights'] = $wgRightsText;
60 $this->getResult()->addValue('query', $p, $data);
61 break;
62
63 case 'namespaces' :
64
65 global $wgContLang;
66 $data = array ();
67 foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
68 $data[$ns] = array (
69 'id' => $ns
70 );
71 ApiResult :: setContent($data[$ns], $title);
72 }
73 $this->getResult()->setIndexedTagName($data, 'ns');
74 $this->getResult()->addValue('query', $p, $data);
75 break;
76
77 default :
78 ApiBase :: dieDebug(__METHOD__, "Unknown prop=$p");
79 }
80 }
81 }
82
83 protected function getAllowedParams() {
84 return array (
85 'prop' => array (
86 ApiBase :: PARAM_DFLT => 'general',
87 ApiBase :: PARAM_ISMULTI => true,
88 ApiBase :: PARAM_TYPE => array (
89 'general',
90 'namespaces'
91 )
92 )
93 );
94 }
95
96 protected function getParamDescription() {
97 return array (
98 'prop' => array (
99 'Which sysinfo properties to get:',
100 ' "general" - Overall system information',
101 ' "namespaces" - List of registered namespaces (localized)'
102 )
103 );
104 }
105
106 protected function getDescription() {
107 return 'Return general information about the site.';
108 }
109
110 protected function getExamples() {
111 return 'api.php?action=query&meta=siteinfo&siprop=general|namespaces';
112 }
113
114 public function getVersion() {
115 return __CLASS__ . ': $Id$';
116 }
117 }
118 ?>