<?php 
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."CRM/class/class.checkString.php");
 class LanguagePack {
 
 	function __construct($db,$aLang) { 
 		$this->db = $db; 
		$this->aLang = $aLang;
 		$sql = "SELECT area,langKey,".$aLang." as language 
 					FROM `".WARPIT_CRM."`.`_TranslationTabel`";
			
 		$res = $this->db->SQLexecute($sql);
 		while ($zad = $this->db->fetchAssoc($res)) $this->Labels[$zad['area']][$zad['langKey']] = $zad['language'];
 	}

 	function GetLabel($aArea,$aKey,$aDefault) {
 		if ($this->Labels[$aArea][$aKey]) return $this->Labels[$aArea][$aKey];
 		else {
 			$sql = "INSERT IGNORE INTO `".WARPIT_CRM."`.`_TranslationTabel`
 						SET 
 							area = '".StringChecker::Check($aArea)."', 
 							langKey = '".StringChecker::Check($aKey)."',
 				".$this->aLang."	= '".StringChecker::Check($aDefault)."'";
 			$this->db->SQLexecute($sql);
 			return $aDefault;
 		}
 	}
 
 } 