Difference between revisions of "Extension:Javascript"

From Organic Design wiki
({{legacy}})
m (Nad moved page Extension:Javascript.php to Extension:Javascript without leaving a redirect)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{legacy}}
 
{{legacy}}
<php><?php
 
# Extension:Javascript
 
# - 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.');
+
{{info|JavaScript loading and dependency management is all handled by the [[MW:Manual:Resource loader|Resource loader]] now.}}
  
define('JAVASCRIPT_VERSION','1.0.2, 2007-06-27');
+
{{svn|extensions|MediaWiki-Legacy/JavaScript/JavaScript.php}}
  
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 .= "<li>[$wgServer$file ".basename($file)."]</li>\n";
 
 
$wgExtensionCredits['other'][] = array(
 
'name'        => 'Javascript',
 
'author'      => '[http://www.organicdesign.co.nz/nad User:Nad]',
 
'description' => "Loaded Javascript files:<ul>$list</ul>",
 
'url'        => 'http://www.mediawiki.org/wiki/Extension:Javascript',
 
'version'    => JAVASCRIPT_VERSION
 
);
 
 
# Notes:
 
# Load all dirs/files in $wgJavascriptPaths into $wgJavascriptScripts using filename as key
 
# Other extensions can add to the list if they need to
 
# After all extenions are loaded and $wgOut is established, add all the js scripts
 
# defined from the LocalSettings.php global variable $wgJavascriptPaths
 
 
function wfSetupJavascript() {
 
global $wgOut,$wgServer,$wgJavascriptFiles;
 
foreach (array_keys($wgJavascriptFiles) as $file)
 
$wgOut->addScript("<script type=\"text/javascript\" src=\"$wgServer$file\"></script>\n");
 
}
 
 
?>
 
</php>
 
 
[[Category:Legacy Extensions|Javascript]]
 
[[Category:Legacy Extensions|Javascript]]

Latest revision as of 18:17, 30 April 2015

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.


Info.svg JavaScript loading and dependency management is all handled by the Resource loader now.


Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.