<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/* SVN FILE: $Id$ */
/**
 * Languages
 *
 * This controller handles the language switches.
 *
 */
class Languages extends Controller
{
    /**
     * constructor
     */
    function Languages()
    {
        parent::Controller();
		// load url helper
		//$this->load->helper('url');
        //log_message('debug', "Languages controller initialized");
    }

    /**
     * change the language of the current webpage and of all following ones.
     *
     * @param string $lang the language code, e.g. en
     */
    function change($lang = null)
    {
	//	$this->load->model('MLanguage','',TRUE);
        //log_message('debug', "Languages.change($lang)");
        // change the language
        $this->lang_detect->changeLang($lang);
		if($lang=='gr'){
			$lang_id=1;
			$this->session->set_userdata('lang_id','1');
		};
		if($lang=='en'){
			$lang_id=2;
			$this->session->set_userdata('lang_id','2');
		};
		
		// get page URL where we were called from.
		$url = $this->session->flashdata('uri');
		//log_message('debug', "Redirect to $url (flashdata)");
		redirect($url, '');
		//redirect("home",'refresh');

    }
	function changelg($lang = null)
    {
	//	$this->load->model('MLanguage','',TRUE);
        //log_message('debug', "Languages.change($lang)");
        // change the language
        $this->lang_detect->changeLang($lang);
		if($lang=='gr'){
			$lang_id=1;
			$this->session->set_userdata('lang_id','1');
		};
		if($lang=='en'){
			$lang_id=2;
			$this->session->set_userdata('lang_id','2');
		};
		
		// get page URL where we were called from.
		$url = $this->session->flashdata('uri');
		//log_message('debug', "Redirect to $url (flashdata)");
		redirect("home",'refresh');
    }

}
?>