<?php
/**
  @package lossim <www http://www.lossim.org>
  @date  14/03/10 14:27
  @author oscim - <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @class lang

  Construit la definition de la langue d'affichage
*/
class lang {

  function __construct($_PX_config){
    global $lang;
    $lang=appel_lang($_PX_config);
    $this->choose_lang();

  }


  /**
    @date  14/03/10, 14:28
    @author oscim <mail oscim@oscss.org> <www http://www.oscim.fr>
    @param
      @a string lang code (fr/en/...)
  */
  private function set_lang($lang){
    define('LANG_POST',$lang);
    $_SESSION['lang']=$lang;
    tep_setcookie('lang', $lang);
  }

  /**
    @date  14/03/10, 14:28
    @author oscim <mail oscim@oscss.org> <www http://www.oscim.fr>
    @param
      @a string $_POST[lang ]code (fr/en/...)
  */
  private function choose_lang(){
    if (isset($_POST['lang']))
      $this->set_lang($_POST['lang']);
    elseif (isset($_SESSION['lang']))
      $this->set_lang($_SESSION['lang']);
    elseif (isset($_COOKIE['lang']))
       $this->set_lang($_COOKIE['lang']);
    else{
      if( ($c=NewFct('extract_nom')) && isset($c['lang']) )
	 $this->set_lang($c['lang']);
      else
	$this->set_lang(LANG);
    }
  }
}

?>