<?php

class Language extends Model {

  var $data = array();
  var $defdata = array();

  function Language() {
  
    parent::Model();
  
  }
  
  function LoadLang($lang = "sk", $default = "sk") {
    $script = "language_web/$lang/lang.php";
    
    if (file_exists($script))
    {
      include($script);
      $this->data = $lang;
    }
    
    $script = "language_web/$default/lang.php";
    
    if (!file_exists($script))
      Die('Default language data not exists!');
    
    include($script);
    $this->defdata = $lang;
  }
  
  function GetLang($key = "")
  {
    if ($key == "")
    {
      if (isset($this->data))
        return $this->data;
      return $this->defdata;
    }
    else
    {
      if (isset($this->data[$key]))
        return $this->data[$key];
      if (isset($this->defdata[$key]))
        return $this->defdata[$key];
      return "";
    }
  }

}

?>