FML Update

This commit is contained in:
Steffen Schröder
2014-06-21 03:18:21 +02:00
parent 816ff486ef
commit c8d599189c
107 changed files with 2484 additions and 3099 deletions

View File

@ -4,7 +4,7 @@
* FancyManiaLinks - Automatic ManiaLink Generator Framework
*
* @author steeffeen <mail@steeffeen.com>
* @version 1.2
* @version 1.3
* @link http://github.com/steeffeen/FancyManiaLinks
* @copyright FancyManiaLinks Copyright © 2014 Steffen Schröder
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
@ -13,12 +13,11 @@ if (!defined('FML_PATH')) {
define('FML_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
}
if (!defined('FML_VERSION')) {
define('FML_VERSION', '1.2');
define('FML_VERSION', '1.3');
}
//define('FML_SIMPLE_CLASSES', true);
/*
* Autoload Function that loads FML Class Files on Demand
* Autoload function that loads FML class files on demand
*/
if (!defined('FML_AUTOLOAD_DEFINED')) {
define('FML_AUTOLOAD_DEFINED', true);
@ -26,57 +25,7 @@ if (!defined('FML_AUTOLOAD_DEFINED')) {
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, $className);
$filePath = FML_PATH . $classPath . '.php';
if (file_exists($filePath)) {
// Load with FML namespace
require_once $filePath;
} else if (defined('FML_SIMPLE_CLASSES') && FML_SIMPLE_CLASSES) {
// Load as simple class name
if (!function_exists('loadSimpleClass')) {
/**
* Load FML Class Files from the given Directory
*
* @param string $className Class to load
* @param string $directory Directory to open
* @param array $excludes File Names to ignore
* @param string $baseNamespace Base Namespace
* @return bool
*/
function loadSimpleClass($className, $directory, $excludes, $baseNamespace) {
if ($dirHandle = opendir($directory)) {
$classParts = explode('\\', $className);
$simpleClassName = end($classParts);
$classFileName = $simpleClassName . '.php';
while ($fileName = readdir($dirHandle)) {
if (in_array($fileName, $excludes)) {
continue;
}
$filePath = $directory . $fileName;
if (is_dir($filePath)) {
$subDirectory = $filePath . DIRECTORY_SEPARATOR;
$namespace = $baseNamespace . $fileName . '\\';
$success = loadSimpleClass($className, $subDirectory, $excludes, $namespace);
if ($success) {
return true;
}
continue;
}
if (is_file($filePath)) {
if ($fileName == $classFileName) {
require_once $filePath;
class_alias($baseNamespace . $simpleClassName, $className, false);
return true;
}
continue;
}
}
closedir($dirHandle);
}
return false;
}
}
$excludes = array('.', '..');
$baseNamespace = 'FML\\';
loadSimpleClass($className, FML_PATH . 'FML' . DIRECTORY_SEPARATOR, $excludes, $baseNamespace);
}
});
}