<?php
include("../../conf/preferences.php");
session_name(SYS_APP_SESSNAME);
session_start();
include("../../conf/langs/".$langs[$_SESSION['userlang']][0]."/MAIN.php");
include("../../conf/connections.php");
include("../../phplib/auth.php");
require_once("../../phplib/utils.php");
require_once("../../phplib/phpmailer/class.phpmailer.php");
require_once("../../core/plugins.php");



$rootfolder=isset($_GET['rootfolder']) ? $_GET['rootfolder'] : "";
?>
<!DOCTYPE html>
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>elFinder 2.0</title>

	<!-- jQuery and jQuery UI (REQUIRED) -->
	<!--<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css">
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>-->
	<link type="text/css" href="../../jslib/jq/ui/css/Aristo/jquery-ui.custom.css" rel="stylesheet" />
	<script type="text/javascript" src = "../../jslib/jq/jquery-1.7.2.min.js" ></script>
	<script type="text/javascript" src = "../../jslib/jq/ui/js/jquery-ui-1.8.21.custom.min.js" ></script>


	<!-- elFinder CSS (REQUIRED) -->
	<link rel="stylesheet" type="text/css" media="screen" href="css/elfinder.min.css">
	<link rel="stylesheet" type="text/css" media="screen" href="css/theme.css">

	<!-- elFinder JS (REQUIRED) -->
	<script type="text/javascript" src="js/elfinder.min.js"></script>

	<!-- elFinder translation (OPTIONAL) -->
	<script type="text/javascript" src="js/i18n/elfinder.es.js"></script>

	<!-- TinyMCE Popup class (REQUIRED) -->
	<script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce_popup.js"></script>
	<script type="text/javascript">
	var FileBrowserDialogue = {
		init: function() {
		  // Here goes your code for setting your custom things onLoad.
		},
		mySubmit: function (URL) {
			var win = tinyMCEPopup.getWindowArg('window');
			// pass selected file path to TinyMCE
			win.document.getElementById(tinyMCEPopup.getWindowArg('input')).value = URL;
			// are we an image browser?
			if (typeof(win.ImageDialog) != 'undefined') {
				// update image dimensions
				if (win.ImageDialog.getImageData) {
					win.ImageDialog.getImageData();
				}
				// update preview if necessary
				if (win.ImageDialog.showPreviewImage) {
					win.ImageDialog.showPreviewImage(URL);
				}
			}
			// close popup window
			tinyMCEPopup.close();
		}
	}

	tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);

	$().ready(function() {
		// set your elFinder options here
		var elf = $('#elfinder').elfinder({
			lang: 'es',             // language (OPTIONAL)
			url: 'php/connector.php?rootfolder=<? echo $rootfolder ?>',
			getfile : {
				onlyURL : true,
				multiple : false,
				folders : false
			},
			height: document.documentElement.clientHeight,
			getFileCallback: function(url) { // editor callback
				FileBrowserDialogue.mySubmit(url); // pass selected file path to TinyMCE 
			}
		}).elfinder('instance');      
	});
	</script>
	<style type="text/css">
	html, body{
		margin:0; padding:0; overflow:hidden; height:100%;
	}
	#elfinder{height:100%}
	</style>
	</head>
	<body>
		<!-- Element where elFinder will be created (REQUIRED) -->
		<div id="elfinder"></div>
	</body>
</html>
