* (bug 6164) Avoid smashing Cite state if message transformation triggers
[lhc/web/wiklou.git] / api.php
1 <?php
2
3
4 /**
5 * API for MediaWiki 1.8+
6 *
7 * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
8 *
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.
13 *
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.
18 *
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
23 */
24
25 // Initialise common code
26 require (dirname(__FILE__) . '/includes/WebStart.php');
27
28 /**
29 * When no format parameter is given, this format will be used
30 */
31 define('API_DEFAULT_FORMAT', 'xmlfm');
32
33 /**
34 * Location of all api-related files (must end with a slash '/')
35 */
36 define('API_DIR', 'includes/api/');
37
38 /**
39 * List of classes and containing files.
40 */
41 $wgApiAutoloadClasses = array (
42
43 'ApiMain' => API_DIR . 'ApiMain.php',
44
45 // Utility classes
46 'ApiBase' => API_DIR . 'ApiBase.php',
47 'ApiQueryBase' => API_DIR . 'ApiQueryBase.php',
48 'ApiResult' => API_DIR . 'ApiResult.php',
49 'ApiPageSet' => API_DIR . 'ApiPageSet.php',
50
51 // Formats
52 'ApiFormatBase' => API_DIR . 'ApiFormatBase.php',
53 'ApiFormatYaml' => API_DIR . 'ApiFormatYaml.php',
54 'ApiFormatXml' => API_DIR . 'ApiFormatXml.php',
55 'ApiFormatJson' => API_DIR . 'ApiFormatJson.php',
56
57 // Modules (action=...) - should match the $apiModules list
58 'ApiHelp' => API_DIR . 'ApiHelp.php',
59 'ApiLogin' => API_DIR . 'ApiLogin.php',
60 'ApiQuery' => API_DIR . 'ApiQuery.php',
61
62 // Query items (meta/prop/list=...)
63 'ApiQuerySiteinfo' => API_DIR . 'ApiQuerySiteinfo.php',
64 'ApiQueryInfo' => API_DIR . 'ApiQueryInfo.php',
65 'ApiQueryRevisions' => API_DIR . 'ApiQueryRevisions.php',
66 'ApiQueryAllpages' => API_DIR . 'ApiQueryAllpages.php'
67 );
68
69 /**
70 * List of available modules: action name => module class
71 * The class must also be listed in the $wgApiAutoloadClasses array.
72 */
73 $wgApiModules = array (
74 'help' => 'ApiHelp',
75 'login' => 'ApiLogin',
76 'query' => 'ApiQuery'
77 );
78
79 /**
80 * List of available formats: format name => format class
81 * The class must also be listed in the $wgApiAutoloadClasses array.
82 */
83 $wgApiFormats = array (
84 'json' => 'ApiFormatJson',
85 'jsonfm' => 'ApiFormatJson',
86 'xml' => 'ApiFormatXml',
87 'xmlfm' => 'ApiFormatXml',
88 'yaml' => 'ApiFormatYaml',
89 'yamlfm' => 'ApiFormatYaml'
90 );
91
92 wfProfileIn('api.php');
93
94 // Verify that the API has not been disabled
95 if (!$wgEnableAPI) {
96 echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
97 echo '<pre><b>$wgEnableAPI=true;</b></pre>';
98 die(-1);
99 }
100
101 $wgAutoloadClasses = array_merge($wgAutoloadClasses, $wgApiAutoloadClasses);
102
103 $processor = new ApiMain($wgRequestTime, $wgApiModules, $wgApiFormats, $wgEnableWriteAPI);
104 $processor->execute();
105
106 wfProfileOut('api.php');
107 wfLogProfilingData();
108 ?>