From 7e80f9617c0f1718256028e04eb56f4fd8a66ecb Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 16 Dec 2012 20:35:39 +0100 Subject: [PATCH] Reorganize classes --- .../{class.controller.php => controller.php} | 0 .../{class.iprange.php => iprange.php} | 0 frontend/classes/{class.node.php => node.php} | 0 ...lass.sshconnector.php => sshconnector.php} | 0 .../{class.template.php => template.php} | 0 frontend/classes/{class.user.php => user.php} | 0 .../classes/{class.container.php => vps.php} | 0 frontend/includes/include.base.php | 24 ++++++++++++------- 8 files changed, 15 insertions(+), 9 deletions(-) rename frontend/classes/{class.controller.php => controller.php} (100%) rename frontend/classes/{class.iprange.php => iprange.php} (100%) rename frontend/classes/{class.node.php => node.php} (100%) rename frontend/classes/{class.sshconnector.php => sshconnector.php} (100%) rename frontend/classes/{class.template.php => template.php} (100%) rename frontend/classes/{class.user.php => user.php} (100%) rename frontend/classes/{class.container.php => vps.php} (100%) diff --git a/frontend/classes/class.controller.php b/frontend/classes/controller.php similarity index 100% rename from frontend/classes/class.controller.php rename to frontend/classes/controller.php diff --git a/frontend/classes/class.iprange.php b/frontend/classes/iprange.php similarity index 100% rename from frontend/classes/class.iprange.php rename to frontend/classes/iprange.php diff --git a/frontend/classes/class.node.php b/frontend/classes/node.php similarity index 100% rename from frontend/classes/class.node.php rename to frontend/classes/node.php diff --git a/frontend/classes/class.sshconnector.php b/frontend/classes/sshconnector.php similarity index 100% rename from frontend/classes/class.sshconnector.php rename to frontend/classes/sshconnector.php diff --git a/frontend/classes/class.template.php b/frontend/classes/template.php similarity index 100% rename from frontend/classes/class.template.php rename to frontend/classes/template.php diff --git a/frontend/classes/class.user.php b/frontend/classes/user.php similarity index 100% rename from frontend/classes/class.user.php rename to frontend/classes/user.php diff --git a/frontend/classes/class.container.php b/frontend/classes/vps.php similarity index 100% rename from frontend/classes/class.container.php rename to frontend/classes/vps.php diff --git a/frontend/includes/include.base.php b/frontend/includes/include.base.php index 0721097..6fc6e15 100644 --- a/frontend/includes/include.base.php +++ b/frontend/includes/include.base.php @@ -22,12 +22,18 @@ require("include.constants.php"); require("include.parsing.php"); require("include.misc.php"); -/* TODO: Reorganize and autoloading. */ -require("classes/class.user.php"); -require("classes/class.controller.php"); -require("classes/class.container.php"); -require("classes/class.node.php"); -require("classes/class.template.php"); -require("classes/class.sshconnector.php"); -require("classes/class.iprange.php"); -?> +function __autoload($class_name) +{ + global $_CVM; + + if(strpos($class_name, "\\") !== false) + { + $class_name = str_replace("\\", "/", strtolower($class_name)); + require_once("classes/{$class_name}.php"); + } + else + { + $class_name = strtolower($class_name); + require_once("classes/{$class_name}.php"); + } +}