Extension:AutoExtensionLoader

From MediaWiki.org
Jump to navigation Jump to search

Other languages:
English • ‎русский • ‎日本語
MediaWiki extensions manual
Crystal Clear action run.svg
AutoExtensionLoader
Release status: beta
Implementation MyWiki
Description Automatically loads extensions
Author(s) Thomas Candrian (Thomascandriantalk)
Latest version 0.1 (2009-06-09)
MediaWiki 1.15+
Database changes No
License GNU General Public License 2.0 or later
Download See below
Translate the AutoExtensionLoader extension if it is available at translatewiki.net
Check usage and version matrix.

The AutoExtensionLoader extension loads all extensions in extension folder, which are stored either as

/extensions/EXTENSIONNAME/EXTENSIONNAME.php

or as

/extensions/EXTENSIONNAME.php

Thus it simplifies installation of extensions. From now on it's enough to put them into the extension folder. AutoExtensionLoader will then load it!

Installation[edit]

  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/AutoExtensionLoader/AutoExtensionLoader.php";
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Code[edit]

AutoExtensionLoader.php
<?php

/**
 * Extension which loads all Extensions in extension folder
 *
 * @addtogroup Extensions
 * @author Thomas Candrian, dm-informatik.com
 * @copyright © 2009 Thomas Candrian
 * @license GNU General Public Licence 2.0 or later
 */

if (!defined('MEDIAWIKI')) {
	echo ( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
	die(1);
}

$wgExtensionCredits['other'][] = array(
	'path' => __FILE__, 
	'name'   => 'AutoExtensionLoader',
	'version'=> '0.1',
	'url'    => 'https://www.mediawiki.org/wiki/Extension:AutoExtensionLoader',
	'author' => 'Thomas Candrian',
	'description' => 'Loads all extensions in the extension folder automatically'
);

if ($handle = opendir("$IP/extensions/")) {
	while (false !== ($file = readdir($handle))) {
		if ($file != "AutoExtensionLoader" and $file != "AutoExtensionLoader.php" and $file != "." and $file != "..") {
			if (is_file("$IP/extensions/" . $file . "/" . $file . ".php")) {
				include_once ("$IP/extensions/" . $file . "/" . $file . ".php");
			}
			if (is_file("$IP/extensions/" . $file . ".php")) {
				include_once ("$IP/extensions/" . $file . ".php");
			}
		}
	}
	closedir($handle);
}