* Non-working API to facilitate dev collaboration. Do not enable this yet in localset...
[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 $apiStartTime = microtime(true);
26
27 /**
28 * List of classes and containing files.
29 */
30 $apiAutoloadClasses = array (
31 'ApiBase' => 'includes/api/ApiBase.php',
32 'ApiMain' => 'includes/api/ApiMain.php',
33 'ApiResult' => 'includes/api/ApiResult.php',
34
35 // Available modules - should match the $apiModules list
36 'ApiHelp' => 'includes/api/ApiHelp.php',
37 'ApiLogin' => 'includes/api/ApiLogin.php',
38 'ApiQuery' => 'includes/api/ApiQuery.php'
39 );
40
41 /**
42 * List of available modules: action name => module class
43 * The class must also be listed in the $apiAutoloadClasses array.
44 */
45 $apiModules = array (
46 'help' => 'ApiHelp',
47 'login' => 'ApiLogin',
48 'query' => 'ApiQuery'
49 );
50
51
52 // Initialise common code
53 require_once ('./includes/WebStart.php');
54 wfProfileIn('api.php');
55
56
57 // Verify that the API has not been disabled
58 // The next line should be
59 // if (isset ($wgEnableAPI) && !$wgEnableAPI) {
60 // but will be in a safe mode until api is stabler
61 if (!isset ($wgEnableAPI) || !$wgEnableAPI) {
62 echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
63 echo '<pre><b>$wgEnableAPI=true;</b></pre>';
64 die(-1);
65 }
66
67
68 ApiInitAutoloadClasses($apiAutoloadClasses);
69 $processor = new ApiMain($apiStartTime, $apiModules);
70 $processor->Execute();
71
72 wfProfileOut('api.php');
73 wfLogProfilingData();
74 exit; // Done!
75
76
77 function ApiInitAutoloadClasses($apiAutoloadClasses) {
78
79 // Append $apiAutoloadClasses to $wgAutoloadClasses
80 global $wgAutoloadClasses;
81 if (isset ($wgAutoloadClasses)) {
82 $wgAutoloadClasses = array_merge($wgAutoloadClasses, $apiAutoloadClasses);
83 } else {
84 $wgAutoloadClasses = $apiAutoloadClasses;
85 }
86 }
87 ?>