Difference between revisions of "Extension:Javascript"
(1.0.0 In use on OD) |
m |
||
Line 37: | Line 37: | ||
); | ); | ||
− | # | + | # Add the script-import to the output page |
− | |||
− | |||
− | |||
− | |||
function wfSetupJavascript() { | function wfSetupJavascript() { | ||
global $wgOut,$wgJavascriptFiles; | global $wgOut,$wgJavascriptFiles; |
Revision as of 04:33, 25 June 2007
<?php
- Extension:JavascriptTemplate:Php
- - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
- - Author: http://www.organicdesign.co.nz/nad
- - Started: 2007-06-25, see article history
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('JAVASCRIPT_VERSION','1.0.0, 2007-06-25');
if (!isset($wgJavascriptPaths)) $wgJavascriptPaths = array(); $wgJavascriptFiles = array();
$wgExtensionFunctions[] = 'wfSetupJavascript';
- Build list of files from list, no duplicate names
foreach ($wgJavascriptPaths as $path) { $ipath = $_SERVER['DOCUMENT_ROOT']."/$path"; if (is_file("$ipath")) $wgJavascriptFiles[$path] = true; elseif (is_dir($ipath)) { if ($dir = opendir($ipath)) { while (false !== ($file = readdir($dir))) $wgJavascriptFiles["$path/$file"] = true; closedir($dir); } } } $list = ; foreach (array_keys($wgJavascriptFiles) as $file)
$list .= "
\n";
$wgExtensionCredits['other'][] = array( 'name' => 'Javascript', 'author' => 'User:Nad',
'description' => "Loaded Javascript files:
- $list
",
'url' => 'http://www.mediawiki.org/wiki/Extension:Javascript', 'version' => JAVASCRIPT_VERSION );
- Add the script-import to the output page
function wfSetupJavascript() { global $wgOut,$wgJavascriptFiles; foreach (array_keys($wgJavascriptFiles) as $file) $wgOut->addScript("<script type=\"text/javascript\" src=\"$file\"></script>\n"); }
?>