Extension:AutoExtensionLoader

From MediaWiki.org
Jump to: navigation, search

Other languages:
English • ‎日本語 • ‎русский
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
AutoExtensionLoader

Release status:Extension status beta

ImplementationTemplate:Extension#type MyWiki
DescriptionTemplate:Extension#description Automatically loads extensions
Author(s)Template:Extension#username Thomas Candrian (Thomascandriantalk)
Latest versionTemplate:Extension#version 0.1 (2009-06-09)
MediaWikiTemplate:Extension#mediawiki 1.15+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#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";
    
  • YesY 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);
}