<?php
/*
	Stempora Web Framework
	Copyright (c) 2002-2014 Stempora. 
	All rights reserved.
		web:  www.stempora.com
		mail: support@stempora.com				
*/


	if (is_dir("modules/skineditor/updates/skins/")) {	


		$dir = new CDir("modules/skineditor/updates/skins/" , ".xml" , false);

		if (is_array($dir->_files) && count($dir->_files)) {
			foreach ($dir->_files as $key => $val) {

				$skin = new CConfig($val);

				//insert in database
				$sid = $this->db->QueryInsert(
					$this->tables["core:skins"],
					array(
						"skin_css"	=> $skin->vars["skin"]["content"],
						"skin_name"	=> $skin->vars["skin"]["name"],
						"skin_base"	=> $skin->vars["skin"]["base"],
					)
				);

				//save the files in the skinds folder
				CFile::Save("../upload/skins/{$sid}.css" , $skin->vars["skin"]["content"]);

				if ($skin->vars["skin"]["default"] == "true") {
					$this->vars->SetVars(array(
						"set_skin"	=> $sid
					));
				}				
			}			
		}
	}		
?>