<commit_before><?php
namespace scv;

abstract class Singleton {
	abstract public static function getInstance();

	abstract protected function init();
}

include_once 'configuration.php';
include_once 'database.php';
include_once 'module.php';
include_once 'htmlparser.php';
include_once 'rightmanagement.php';
include_once 'user.php';
include_once 'css.php';
include_once 'operation.php';
include_once 'template.php';
include_once 'site.php';

session_start();

class Core extends Singleton implements IModule{
	private static $instance = null;
	
	public static function getInstance(){
		if (Core::$instance==null){
			Core::$instance = new Core();
			Core::$instance->init();
		}
		return Core::$instance;
	}
	
	private $config = null;
	private $database = null;
	private $htmlparser = null;
	private $rights = null;
	private $users = null;
	private $css = null;
	private $operations = null;
	private $templates = null;
	private $composite = null;
	
	public function getName(){
		return 'de.masterprogs.scoville.core';
	}
	
	protected function init(){
		$this->debugGrindlog("====== New Session! Time: ".time());
		$this->config = new Config();
		$this->database = new Database();
		$this->config->initFromDb($this->database);
		$this->rights = RightsManager::getInstance();
		$this->modules = ModuleManager::getInstance();
		$this->users = UserManager::getInstance();
		$this->css = CssManager::getInstance();
		$this->operations = OperationManager::getInstance();
		$this->templates = TemplateManager::getInstance();
		$this->composite = CompositeManager::getInstance(); 
	}
	
	public function getDB(){
		return $this->database;
	}
	
	public function getConfig(){
		return $this->config;
	}
	
	public function getRightsManager(){
		return $this->rights;
	}
	
	public function getModuleManager(){
		return $this->modules;
	}
	
	public function getUserManager(){
		return $this->users;
	}
	
	public function getCssManager(){
		return $this->css;
	}
	
	public function getOperationManager(){
		return $this->operations;
	}
	
	public function getTemplateManager(){
		return $this->templates;
	}
	
	public function getCompositeManager(){
		return $this->composite;
	}
	
	public function renderModule($modulename, $moduleInstanceId){
		$module = new Module($modulename);
		return $module->render($moduleInstanceId);
	}
	
	public function getHtmlParser() {
	  if($this->htmlparser == null) {
	    $this->htmlparser = new HtmlParser();
	  }
	  return $this->htmlparser;
	}
	
	public function renderHTML($moduleInstanceId){
		return false;
	}
	public function renderJavascript($moduleInstanceId){
		return false;
	}
	
	//EIGENER LOG FUER DEBUGGING
	// ACHTUNG!!1!! ESCAPESHELLARG ENTFERNT ANFUEHRuNGSZEICHEN! 
	public function debugGrindlog($message){
		system("echo '[LEN ".strlen($message)."] ".escapeshellarg($message)."' >> /tmp/Grindlog.log");
		//system("echo '[LEN ".strlen($message)."] ".$message."' >> /tmp/Grindlog.log");<commit_msg>Core effizienzoptimiert: Einzelne Corebereiche werden nur effektiv geladen, wenn sie gebraucht werden.<commit_after><?php
namespace scv;

abstract class Singleton {
	abstract public static function getInstance();

	abstract protected function init();
}

include_once 'configuration.php';
include_once 'database.php';
include_once 'htmlparser.php';

session_start();

class Core extends Singleton implements IModule{
	private static $instance = null;
	
	public static function getInstance(){
		if (Core::$instance==null){
			Core::$instance = new Core();
			Core::$instance->init();
		}
		return Core::$instance;
	}
	
	private $config = null;
	private $database = null;
	private $htmlparser = null;
	private $modules = null;
	private $rights = null;
	private $users = null;
	private $css = null;
	private $operations = null;
	private $templates = null;
	private $composite = null;
	
	public function getName(){
		return 'de.masterprogs.scoville.core';
	}
	
	protected function init(){
		$this->debugGrindlog("====== New Session! Time: ".time());
		$this->config = new Config();
		$this->database = new Database();
		$this->config->initFromDb($this->database);
	}
	
	public function getDB(){
		return $this->database;
	}
	
	public function getConfig(){
		return $this->config;
	}
	
	public function getRightsManager(){
		if (!isset($this->rights)){
			include_once "rightmanagement.php";
			$this->rights = RightsManager::getInstance();
		}
		return $this->rights;
	}
	
	public function getModuleManager(){
		if (!isset($this->modules)){
			include_once "module.php";
			$this->modules = ModuleManager::getInstance();
		}
		return $this->modules;
	}
	
	public function getUserManager(){
		if (!isset($this->users)){
			include_once "user.php";
			$this->users = UserManager::getInstance();
		}
		return $this->users;
	}
	
	public function getCssManager(){
		if (!isset($this->css)){
			include_once "css.php";
			$this->css = CssManager::getInstance();
		}
		return $this->css;
	}
	
	public function getOperationManager(){
		if (!isset($this->operations)){
			include_once "operation.php";
			$this->operations = OperationManager::getInstance();
		}
		return $this->operations;
	}
	
	public function getTemplateManager(){
		if (!isset($this->templates)){
			include_once "template.php";
			$this->templates = TemplateManager::getInstance();
		}
		return $this->templates;
	}
	
	public function getCompositeManager(){
		if (!isset($this->composite)){
			include_once "site.php";
			$this->composite = CompositeManager::getInstance();
		}
		return $this->composite;
	}
	
	public function renderModule($modulename, $moduleInstanceId){
		$module = new Module($modulename);
		return $module->render($moduleInstanceId);
	}
	
	public function getHtmlParser() {
	  if($this->htmlparser == null) {
	    $this->htmlparser = new HtmlParser();
	  }
	  return $this->htmlparser;
	}
	
	public function renderHTML($moduleInstanceId){
		return false;
	}
	public function renderJavascript($moduleInstanceId){
		return false;
	}
	
	//EIGENER LOG FUER DEBUGGING
	// ACHTUNG!!1!! ESCAPESHELLARG ENTFERNT ANFUEHRuNGSZEICHEN! 
	public function debugGrindlog($message){
		system("echo '[LEN ".strlen($message)."] ".escapeshellarg($message)."' >> /tmp/Grindlog.log");
		//system("echo '[LEN ".strlen($message)."] ".$message."' >> /tmp/Grindlog.log");
{'fraction_non_alphanumeric': 0.15205238779747643, 'fraction_numerical': 0.00031943778949049674, 'mean_word_length': 4.792784458834412, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5240565', 'n_tokens_mistral': 2098, 'n_tokens_neox': 1906, 'n_words': 455}