<?php
/**
 * Open Source - Content Managment System
 * Next Generation v2
 * @Coder:  Mutzii
 * @copyright  Copyright (c) 2012-2013 by Mutzii
 * File: includes.inc.php
 * @Description:  
      Lädt alle Klassen im ordner includes.
 */ 


class ClassLoader
{
  protected static $_klasse    = null;
  protected static $_instance  = null;
  protected static $_class_ini = null;

    public static function IncLoader($file,$ordner)
    {
      require_once($ordner.$file.'.class.php');	 
    }	
  
    public static function ClassLoad($Class)
	{
		 if( null == self::$_instance)
		 {
		   self::$_instance = new self();
		   self::$_klasse   = $Class;
		   
		   require_once($Class.'.class.php');	   
		   return self::$_instance;
		 }
	 }


	public static function getClassInstance()
	{
	      if(null != self::$_klasse)
		  { 
		       if(self::$_class_ini == null){
		            self::$_class_ini = new self::$_klasse();
		            return self::$_class_ini;
			   }else{
			        return self::$_class_ini;
			   }
		  }
	 }

}


class Includes extends ClassLoader
{
    public function Includes()
	{
	    $ordner = ROOT.'/includes/';
	    $handle = $this->openDir($ordner);

		if($handle != false){

		   while ($file = readdir ($handle)) {
		     if($file != "." && $file != ".." && $file != "includes.inc.php" && $file != "boot.inc.php") {
		           //echo $file.' <= is Loading <br>';
				   $file = str_replace(".class.php", "", $file);
		           ClassLoader::IncLoader($file,$ordner);
			 }
		   }
		}

   }
		
	public function openDir($ordner)
	{
	   $handle = opendir($ordner);
	   return $handle;
	}

}

?>