* API: added watchlist module (incomplete)
[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 'ApiQueryWatchlist' => API_DIR . 'ApiQueryWatchlist.php'
68 );
69
70 /**
71 * List of available modules: action name => module class
72 * The class must also be listed in the $wgApiAutoloadClasses array.
73 */
74 $wgApiModules = array (
75 'help' => 'ApiHelp',
76 'login' => 'ApiLogin',
77 'query' => 'ApiQuery'
78 );
79
80 /**
81 * List of available formats: format name => format class
82 * The class must also be listed in the $wgApiAutoloadClasses array.
83 */
84 $wgApiFormats = array (
85 'json' => 'ApiFormatJson',
86 'jsonfm' => 'ApiFormatJson',
87 'xml' => 'ApiFormatXml',
88 'xmlfm' => 'ApiFormatXml',
89 'yaml' => 'ApiFormatYaml',
90 'yamlfm' => 'ApiFormatYaml'
91 );
92
93 wfProfileIn('api.php');
94
95 // Verify that the API has not been disabled
96 if (!$wgEnableAPI) {
97 echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
98 echo '<pre><b>$wgEnableAPI=true;</b></pre>';
99 die(-1);
100 }
101
102 $wgAutoloadClasses = array_merge($wgAutoloadClasses, $wgApiAutoloadClasses);
103
104 $processor = new ApiMain($wgRequestTime, $wgApiModules, $wgApiFormats, $wgEnableWriteAPI);
105 $processor->execute();
106
107 wfProfileOut('api.php');
108 wfLogProfilingData();
109 ?>