<?php
/**
 * Open Source - Content Managment System
 * Next Generation v2
 * @Coder:  Mutzii
 * @copyright  Copyright (c) 2012-2013 by Mutzii
 * File: api.class.php
 * @Description:  
 
      APILoader ist nicht im CMS System intigriert mit set get Methoden. 
	  Das müsst ihr Manuell machen.
	  Ein Example sieht Ihr in der boot.inc.php
      die function getAuktionAPI().

      Class API ist dafür gedacht, damit Ihr eure API mit den CMS Methoden
      verknüpfen könnt. So änhlich funktioniert auch das Modul System.	  
 */ 


interface API_Interface
{
  public function Init();
}


abstract class API implements API_Interface
{
   protected $instance = null;
 
    public function setInstance($instance) 
    {
     $this->instance = $instance;
    }
     
    public function getInstance()
    {
     return $this->instance;
    }
   
    public function getErrorList()
   {
     return $this->getInstance()->getErrorList();
   }

}




class APILoader
{
   protected $_klasse       = null;
   protected $_instance     = null;
   protected $_class_ini    = null;
   protected $_cms_instance = null;

      public function getCMSInstance()
	  {
	    return $this->_cms_instance;
	  }
	  
	  public function setCMSInstance($instance)
	  {
	    $this->_cms_instance = $instance;
	  }

	   public function ClassLoad($Class)
	  {
		   $this->_klasse   = $Class;  
		   require_once(ROOT.'/api/'.$Class.'.api.php');	   	 
	  }
	  
	  
	  public function getClassInstance()
	  {
	      if(null != $this->_klasse)
		  { 
		       if($this->_class_ini == null){
		            $this->_class_ini = new $this->_klasse();
		            return $this->_class_ini;
			   }else{
			        return $this->_class_ini;
			   }
		  }
	  }

	  
	  public function Activ()
	  {
	      $this->getClassInstance()->setInstance($this->getCMSInstance()); 
		  $this->getClassInstance()->Init();  
	  }

}








?>