* improved script loader language support
[lhc/web/wiklou.git] / mwScriptLoader.php
1 <?php
2 /**
3 * mwScriptLoader.php
4 * Script Loading Library for MediaWiki
5 *
6 * @file
7 * @author Michael Dale mdale@wikimedia.org
8 * @date feb, 2009
9 * @link http://www.mediawiki.org/wiki/ScriptLoader Documentation
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * http://www.gnu.org/copyleft/gpl.html
25 */
26
27 //first do a quick static check for the cached file
28 define('MW_CACHE_SCRIPT_CHECK', true);
29 require_once( dirname(__FILE__) . '/js2/mwEmbed/jsScriptLoader.php');
30 $myScriptLoader = new jsScriptLoader();
31 if( $myScriptLoader->outputFromCache() ){
32 exit();
33 }
34
35 //Else load up mediaWiki stuff and continue scriptloader processing:
36
37 // include WebStart.php
38 ob_start();
39 require_once('includes/WebStart.php');
40 $webstartwhitespace = ob_end_clean();
41
42 wfProfileIn( 'mwScriptLoader.php' );
43
44 if( $wgRequest->isPathInfoBad() ){
45 wfHttpError( 403, 'Forbidden',
46 'Invalid file extension found in PATH_INFO. ' .
47 'mwScriptLoader must be accessed through the primary script entry point.' );
48 return;
49 }
50 // Verify the script loader is on:
51 if ( !$wgEnableScriptLoader ) {
52 echo '/*ScriptLoader is not enabled for this site. To enable add the following line to your LocalSettings.php';
53 echo '<pre><b>$wgEnableScriptLoader=true;</b></pre>*/';
54 echo 'alert(\'Script loader is disabled\');';
55 die( 1 );
56 }
57
58 //load the language file and
59 // Run jsScriptLoader action:
60 $myScriptLoader->doScriptLoader();
61
62
63 wfProfileOut( 'mwScriptLoader.php' );