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

if ($_GET["mod"] == "export-settings") {

	$modules = $this->db->QFetchRowArray(
		"SELECT * FROM {$this->tables['core:modules']}"
	);

	foreach ($modules as $__k => $__module) {

		$module = $_MODULES["modules"]->LoadDefaultModule($__module["module_code"]);

		if ($__module["module_code"] == "autoinventorypublic") {
		}
		
		if (is_array($module["settings"])) {
			$settings = array();
			$lang = array();

			foreach ($module["settings"] as $key => $val) {
				if (stristr($key , "set_")) {
					$settings[$key] = $val;
				}
					
				if (stristr($key , "lang_")) {
					$lang[$key] = $val;
				}
			}


			$out = "	<data>\n";

			if (count($settings)) {
				$out .=	"		<settings>\n";
				foreach ($settings as $key => $val) {
					if (stristr($val , "<")) {
						$out .= "			<{$key}><![CDATA[{$val}]]></{$key}>\n";
					} else {
						$out .= "			<{$key}>{$val}</{$key}>\n";
					}
				}			
				$out .=	"		</settings>\n";
			}
			

			if (count($lang)) {
				$out .=	"		<language>\n";
				foreach ($lang as $key => $val) {
					if (stristr($val , "<")) {
						$out .= "			<{$key}><![CDATA[{$val}]]></{$key}>\n";
					} else {
						$out .= "			<{$key}>{$val}</{$key}>\n";
					}
					
				}			
				$out .=	"		</language>\n";
			}
			
			$out .= "	</data>\n";


			savefilecontents("set/{$module[module_code]}.xml" , $out);
		}
		
	}
	



}



?>
