<commit_before><?php if (!defined('CLYDEPHP')) die("Direct access not allowed") ;?>
<?php

	define('MENU_LIST',1);
	define('MENU_SIMPLE',2);

	function getWebRoot() {
		return String::slash(getCmsConfig("WEB_ROOT"));
	}
	
	function getSiteName() {
		return getCmsConfig("SITE_NAME");
	}
	
	function getSiteSlogan() {
		return getCmsConfig("SITE_SLOGAN");
	}
	
	function getCmsConfig($key=null,$context="site") {
		
		$conf = Config::get($context);
		if (is_null($key)) {
			return $conf;
		}
		if (isset($conf[$key])) {
			return $conf[$key];
		} 
		return null;
	}
	
	function getDataDir() {
		return APP_ROOT."data/";
	}
	
	function getLogsDir() {
		return APP_ROOT."logs/"; 
	}
	
	function getConfDir() {

		$env = $_SERVER['HTTP_HOST'];
		
		//if exist and is readable, return specific server configuration dir
		if (is_readable(APP_ROOT."conf_".$env."/")) {				
			return APP_ROOT."conf_".$env."/";
		}		
		//else return standard configuration dir
		return APP_ROOT."conf/";
	}
	
	function getPluginsDir() {
		return DOC_ROOT."plugins/";
	}
	
	function getTemplateDir($tplName=null) {
		if (is_null($tplName)) {
			return DOC_ROOT."templates/";
		}
		
		return DOC_ROOT."templates/".$tplName."/";	
	}	
	
	function getTemplateName() {
		
		$conf = getCmsConfig();
		if (!isset($conf["TEMPLATE"]))
			return null;
			
		return $conf["TEMPLATE"];
	}
	
	function loadTemplate($file,$tplName=null) {
		
		$tFile = findTemplate($file,$tplName);
		if (is_null($tFile)) return null;
				
		return new Template($tFile);
		
	}
	
	function findTemplate($file,$tplName) {
			if ( (is_null($tplName) || $tplName === "") &&
			 (is_null($file) || $file === "")) 
			return null;
			
		//try to load first in the template dir
		if (is_readable(getTemplateDir($tplName).$file)) {
			return getTemplateDir($tplName).$file;
		}
		
		//try to load in the root template dir
		if (is_readable(getTemplateDir().$file)) {
			return getTemplateDir().$file;
		}
		
		return null;	
	}

	function makeLink($id,$locale=null,$type="page") {
				
		$lang="";
		$conf = getCmsConfig();
		if (!is_null($locale) && $locale !== $conf['LANG'])
			$lang="&lang=".$locale;
		
		switch ($type) {
			case 'page':				
				return "index.php?page=".String::slugify($id).$lang;
			case 'download':
				 return "services/download.php?file=".$id;
			default:
				return null;
		}
		
	}
	
	function buildMenu($name,$type= MENU_LIST) {
		
		global $menu_list;
		
		$menu = $menu_list[$name];
		
		$out = "";		
		if ($type == MENU_LIST) $out = "<ul>";
		
		foreach ($menu as $key => $value) {<commit_msg>Initial support for other cms components<commit_after><?php if (!defined('CLYDEPHP')) die("Direct access not allowed") ;?>
<?php

	define('MENU_LIST',1);
	define('MENU_SIMPLE',2);

	function getWebRoot() {
		return String::slash(getCmsConfig("WEB_ROOT"));
	}
	
	function getSiteName() {
		return getCmsConfig("SITE_NAME");
	}
	
	function getSiteSlogan() {
		return getCmsConfig("SITE_SLOGAN");
	}
	
	function getCmsConfig($key=null,$context="site") {
		
		$conf = Config::get($context);
		if (is_null($key)) {
			return $conf;
		}
		if (isset($conf[$key])) {
			return $conf[$key];
		} 
		return null;
	}
	
	function getDataDir() {
		return APP_ROOT."data/";
	}
	
	function getLogsDir() {
		return APP_ROOT."logs/"; 
	}
	
	function getConfDir() {

		$env = $_SERVER['HTTP_HOST'];
		
		//if exist and is readable, return specific server configuration dir
		if (is_readable(APP_ROOT."conf_".$env."/")) {				
			return APP_ROOT."conf_".$env."/";
		}		
		//else return standard configuration dir
		return APP_ROOT."conf/";
	}
	
	function getPluginsDir() {
		return DOC_ROOT."plugins/";
	}
	
	function getTemplateDir($tplName=null) {
		if (is_null($tplName)) {
			return DOC_ROOT."templates/";
		}
		
		return DOC_ROOT."templates/".$tplName."/";	
	}	
	
	function getTemplateName() {
		
		$conf = getCmsConfig();
		if (!isset($conf["TEMPLATE"]))
			return null;
			
		return $conf["TEMPLATE"];
	}
	
	function loadTemplate($file,$tplName=null) {
		
		$tFile = findTemplate($file,$tplName);
		if (is_null($tFile)) return null;
				
		return new Template($tFile);
		
	}
	
	function findTemplate($file,$tplName) {
			if ( (is_null($tplName) || $tplName === "") &&
			 (is_null($file) || $file === "")) 
			return null;
			
		//try to load first in the template dir
		if (is_readable(getTemplateDir($tplName).$file)) {
			return getTemplateDir($tplName).$file;
		}
		
		//try to load in the root template dir
		if (is_readable(getTemplateDir().$file)) {
			return getTemplateDir().$file;
		}
		
		return null;	
	}

	function makeLink($id,$locale=null,$type="page") {
				
		$lang="";
		$conf = getCmsConfig();
		if (!is_null($locale) && $locale !== $conf['LANG'])
			$lang="&lang=".$locale;
		
		switch ($type) {
			case 'page':				
				return "page.php?page=".String::slugify($id).$lang;
			case 'download':
				 return "services/download.php?file=".$id;
			default:
				return null;
		}
		
	}
	
	function buildMenu($name,$type= MENU_LIST) {
		
		global $menu_list;
		
		$menu = $menu_list[$name];
		
		$out = "";		
		if ($type == MENU_LIST) $out = "<ul>";
		
		foreach ($menu as $key => $value) {
{'fraction_non_alphanumeric': 0.18026418026418026, 'fraction_numerical': 0.000777000777000777, 'mean_word_length': 3.556637168141593, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2174316', 'n_tokens_mistral': 2170, 'n_tokens_neox': 1810, 'n_words': 361}