Extension:AutoExtensionLoader

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
AutoExtensionLoader

Release status: beta

Implementation MyWiki
Description Automatic Extension Loader
Author(s) Thomas Candrian (Thomascandriantalk)
Latest version 0.1 (2009-06-09)
MediaWiki 1.15+
Database changes No
License GPL V2
Download see below
Added rights

GPL v2

Translate the AutoExtensionLoader extension if possible

Check usage and version matrix; code metrics

Introduction[edit | edit source]

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

/extensions/EXTENSIONNAME/EXTENSIONNAME.php

or as

/extensions/EXTENSIONNAME.php

Requirements[edit | edit source]

This extension has no requirements.

Usage[edit | edit source]

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 | edit source]

1. Store the file below in your extensions/AutoExtensionLoader/

<?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( 
	'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);
}

2. Add a call to it at the end of LocalSettings.php:

require_once("$IP/extensions/AutoExtensionLoader/AutoExtensionLoader.php");