<?php
/*
	Stempora web framework
	copyright (c) 2002-2013 Stempora
		web:  www.stempora.com
		mail: support@stempora.com
*/


/**
* description
*
* @library	
* @author	
* @since	
*/
class CXMLFormLanguage {
	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function Init($langs) {

		$this->langs = $langs;
		
	}

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	function Process($form) {

		global $site;

/*
		if (!$site->vars->data["set_multilanguage"]) {
			return $form;
		}
*/		

		
		if (count($form["languages"]) < 2) {
			return $form;
		}
		
		if (is_array($form["box"])) {
		} else {
	
			if (is_array($form["fields"])) {
				foreach ($form["fields"] as $key => $val) {

				}								
			}
		}

		//debug($form,1);

		return $form;
		
	}

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	static function LanguageButtons() {

		global $site;

		//get all languages

		$languages = $site->db->QFetchRowArray(
			"SELECT * FROM {$site->tables['core:languages']} ORDER BY lang_order ASC"
		);

		if (is_array($languages)) {
			foreach ($languages as $key => $lang) {
				$langs[$lang["lang_code"]]	= array(
					"code"		=> $lang["lang_code"],
					"id"		=> $lang["lang_id"],
					"dir"		=> $lang["lang_dir"],
					"default"	=> $lang["lang_default"],
					"title"		=> $lang["lang_title"],
				);
			}			
		}
		


		return $langs;
	
		
		//prepare the html for the forms



	}
	

	/**
	* description
	*
	* @param
	*
	* @return
	*
	* @access
	*/
	static function GetLanguage($id) {
		global $site;

		$lang = $site->db->QFetchArray(
			"SELECT * FROM {$site->tables['core:languages']} WHERE lang_id={$id}"
		);

		return array(
			"code"		=> $lang["lang_code"],
			"id"		=> $lang["lang_id"],
			"dir"		=> $lang["lang_dir"],
			"default"	=> $lang["lang_default"],
			"title"		=> $lang["lang_title"],
		);
	}
	
	
}

?>
