Update.
[mediawiki.git] / includes / api / ApiQuerySiteinfo.php
blob29315358772f13bfadb06633da254dddca90ed0f
1 <?php
3 /*
4 * Created on Sep 25, 2006
6 * API for MediaWiki 1.8+
8 * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@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');
31 /**
32 * A query action to return meta information about the wiki site.
34 * @addtogroup API
36 class ApiQuerySiteinfo extends ApiQueryBase {
38 public function __construct($query, $moduleName) {
39 parent :: __construct($query, $moduleName, 'si');
42 public function execute() {
43 $prop = null;
44 extract($this->extractRequestParams());
46 foreach ($prop as $p) {
47 switch ($p) {
49 case 'general' :
51 global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText;
52 $data = array ();
53 $mainPage = Title :: newFromText(wfMsgForContent('mainpage'));
54 $data['mainpage'] = $mainPage->getText();
55 $data['base'] = $mainPage->getFullUrl();
56 $data['sitename'] = $wgSitename;
57 $data['generator'] = "MediaWiki $wgVersion";
58 $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future
59 if (isset($wgRightsCode))
60 $data['rightscode'] = $wgRightsCode;
61 $data['rights'] = $wgRightsText;
62 $this->getResult()->addValue('query', $p, $data);
63 break;
65 case 'namespaces' :
67 global $wgContLang;
68 $data = array ();
69 foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
70 $data[$ns] = array (
71 'id' => $ns
73 ApiResult :: setContent($data[$ns], $title);
75 $this->getResult()->setIndexedTagName($data, 'ns');
76 $this->getResult()->addValue('query', $p, $data);
77 break;
79 default :
80 ApiBase :: dieDebug(__METHOD__, "Unknown prop=$p");
85 protected function getAllowedParams() {
86 return array (
87 'prop' => array (
88 ApiBase :: PARAM_DFLT => 'general',
89 ApiBase :: PARAM_ISMULTI => true,
90 ApiBase :: PARAM_TYPE => array (
91 'general',
92 'namespaces'
98 protected function getParamDescription() {
99 return array (
100 'prop' => array (
101 'Which sysinfo properties to get:',
102 ' "general" - Overall system information',
103 ' "namespaces" - List of registered namespaces (localized)'
108 protected function getDescription() {
109 return 'Return general information about the site.';
112 protected function getExamples() {
113 return 'api.php?action=query&meta=siteinfo&siprop=general|namespaces';
116 public function getVersion() {
117 return __CLASS__ . ': $Id$';