4 * Created on Sep 25, 2006
6 * API for MediaWiki 1.8+
8 * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
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.
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.
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
26 if (!defined('MEDIAWIKI')) {
27 // Eclipse helper - will be ignored in production
28 require_once ('ApiQueryBase.php');
34 class ApiQuerySiteinfo
extends ApiQueryBase
{
36 public function __construct($query, $moduleName) {
37 parent
:: __construct($query, $moduleName, 'si');
40 public function execute() {
42 extract($this->extractRequestParams());
44 foreach ($prop as $p) {
49 global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText;
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);
67 foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
71 ApiResult
:: setContent($data[$ns], $title);
73 $this->getResult()->setIndexedTagName($data, 'ns');
74 $this->getResult()->addValue('query', $p, $data);
78 ApiBase
:: dieDebug(__METHOD__
, "Unknown prop=$p");
83 protected function getAllowedParams() {
86 ApiBase
:: PARAM_DFLT
=> 'general',
87 ApiBase
:: PARAM_ISMULTI
=> true,
88 ApiBase
:: PARAM_TYPE
=> array (
96 protected function getParamDescription() {
99 'Which sysinfo properties to get:',
100 ' "general" - Overall system information',
101 ' "namespaces" - List of registered namespaces (localized)'
106 protected function getDescription() {
107 return 'Return general information about the site.';
110 protected function getExamples() {
111 return 'api.php?action=query&meta=siteinfo&siprop=general|namespaces';
114 public function getVersion() {
115 return __CLASS__
. ': $Id$';