<?php
if(!defined('__XE__')) exit();

if($called_position != 'before_display_content') return;

//기본 샘플 설정파일을 불러와서 애드온 설정변수의 값을 대입한 뒤 elfinder 설정파일로 저장함
$addon_url = Context::pathToUrl($addon_path);
$file_open = file_get_contents($addon_path."include/connector_ori.php");
$file_open = str_replace('$elfinder_root_path',"$addon_info->elfinder_root_path",$file_open);
$file_open = str_replace('$elfinder_root_url',"$addon_info->elfinder_root_url",$file_open);
file_put_contents($addon_path."include/connector.php",$file_open) or die("file_put_contents failed");


//애드온 구동에 필요한 파일을 로드;
Context::loadFile($addon_url.'include/elfinder.full.js','','','');
Context::loadFile($addon_url.'/include/css/elfinder.css','','','');
Context::loadFile($addon_url.'include/i18n/elfinder.ko.js','','','');

Context::addHtmlHeader('
<script type="text/javascript" charset="utf-8">
		(function($){
			$(document).ready(function(){
				$("#elfinder").elfinder({
					url : "'.$addon_url.'/include/connector.php",
					lang : "ko"
					'.$addon_info->elfinder_dock_stat.'
				});
				$("#close,#open,#dock,#undock").click(function() {
					$("#elfinder").elfinder($(this).attr("id"));
				});
			})
		})(jQuery);
</script>
');


?>