<?php
/**@license setplus: a lightweight HTML editor
 * @author  Levente Hunyadi
 * @version 0.2.0
 * @remarks Copyright (C) 2010-2011 Levente Hunyadi
 * @remarks Licensed under GNU/GPLv3, see http://www.gnu.org/licenses/gpl-3.0.html
 * @see     http://hunyadi.info.hu/projects/setplus
 **/

/*
* setplus: a lightweight HTML editor
* Copyright 2010-2011 Levente Hunyadi
*
* setplus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* setplus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with setplus.  If not, see <http://www.gnu.org/licenses/>.
*/

if (!defined('DS')) {
	define('DS', DIRECTORY_SEPARATOR);
}

ini_set('zlib.output_compression', true);

$path = dirname(__FILE__);
$min = isset($_GET['min']) && !$_GET['min'] ? '' : '.min';

// import core file
readfile($path.DS.'setplus'.$min.'.js');

// import dialog files
$files = scandir($path);
if ($files !== false) {
	foreach ($files as $file) {
		// use minified sources for production mode and regular sources for debug mode
		if ($min && preg_match('#^setplus\..+\.min\.js$#', $file) || !$min && preg_match('#^setplus\..+(?<!\.min)\.js$#', $file)) {
			readfile($path.DS.$file);
		}
	}
}

// import language
$languagepath = $path.DS.'language';
if (isset($_GET['lang']) && ctype_alpha($_GET['lang']) && file_exists($languagepath.DS.$_GET['lang'].$min.'.js')) {
	readfile($languagepath.DS.$_GET['lang'].$min.'.js');
}

exit;