c96c6470c2d82fe793042cb302b8afd4a8c3ad41
5 * API for MediaWiki 1.8+
7 * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * http://www.gnu.org/copyleft/gpl.html
25 $wgApiStartTime = microtime(true);
28 * When no format parameter is given, this format will be used
30 define('API_DEFAULT_FORMAT', 'xmlfm');
33 * List of classes and containing files.
35 $wgApiAutoloadClasses = array (
37 'ApiMain' => 'ApiMain.php',
40 'ApiBase' => 'ApiBase.php',
41 'ApiQueryBase' => 'ApiQueryBase.php',
42 'ApiResult' => 'ApiResult.php',
43 'ApiPageSet' => 'ApiPageSet.php',
46 'ApiFormatBase' => 'ApiFormatBase.php',
47 'ApiFormatYaml' => 'ApiFormatYaml.php',
48 'ApiFormatXml' => 'ApiFormatXml.php',
49 'ApiFormatJson' => 'ApiFormatJson.php',
51 // Modules (action=...) - should match the $apiModules list
52 'ApiHelp' => 'ApiHelp.php',
53 'ApiLogin' => 'ApiLogin.php',
54 'ApiQuery' => 'ApiQuery.php',
56 // Query items (meta/prop/list=...)
57 'ApiQuerySiteinfo' => 'ApiQuerySiteinfo.php',
58 'ApiQueryInfo' => 'ApiQueryInfo.php',
59 'ApiQueryRevisions' => 'ApiQueryRevisions.php',
60 'ApiQueryAllpages' => 'ApiQueryAllpages.php'
64 * List of available modules: action name => module class
65 * The class must also be listed in the $wgApiAutoloadClasses array.
67 $wgApiModules = array (
69 'login' => 'ApiLogin',
74 * List of available formats: format name => format class
75 * The class must also be listed in the $wgApiAutoloadClasses array.
77 $wgApiFormats = array (
78 'json' => 'ApiFormatJson',
79 'jsonfm' => 'ApiFormatJson',
80 'xml' => 'ApiFormatXml',
81 'xmlfm' => 'ApiFormatXml',
82 'yaml' => 'ApiFormatYaml',
83 'yamlfm' => 'ApiFormatYaml'
86 // Initialise common code
87 require (dirname(__FILE__
) . '/includes/WebStart.php');
88 wfProfileIn('api.php');
90 // Verify that the API has not been disabled
91 // The next line should be
92 // if (isset ($wgEnableAPI) && !$wgEnableAPI) {
93 // but will be in a safe mode until api is stabler
94 if (!isset ($wgEnableAPI) ||
!$wgEnableAPI) {
95 echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
96 echo '<pre><b>$wgEnableAPI=true;</b></pre>';
100 apiInitAutoloadClasses($wgApiAutoloadClasses, "$IP/includes/api/");
101 $processor = new ApiMain($wgApiStartTime, $wgApiModules, $wgApiFormats);
102 $processor->execute();
104 wfProfileOut('api.php');
105 wfLogProfilingData();
108 function apiInitAutoloadClasses($apiAutoloadClasses, $apiDirectory) {
110 // Prefix each api class with the proper prefix,
111 // and append them to $wgAutoloadClasses
112 global $wgAutoloadClasses;
114 foreach ($apiAutoloadClasses as $className => $classFile)
115 $wgAutoloadClasses[$className] = $apiDirectory . $classFile;