<?php
/**
 * Created by CS medien- & kommunikationssysteme.
 * @author Christian Steinle
 * @date 09.09.2016
 *
 * @copyright CS medien- & kommunikationssysteme (http://www.steinle-computer.de)
 */

header('Access-Control-Allow-Origin: *');

$includeFile = dirname(__DIR__) . '/lang/lang-' . $_POST['lang'] . '.php';
if (file_exists(dirname(__DIR__) . '/lang/lang-' . $_POST['lang'] . '.php'))
{
	$includeFile = dirname(__DIR__) . '/lang/lang-' . $_POST['lang'] . '.php';
}

include_once($includeFile);

?>
<form id="editor_form" action="" method="post">
	<input type="hidden" name="userId" id="userId" value=""/>
	<input type="hidden" name="prefix" id="prefix" value=""/>
	<input type="hidden" name="dataSet" id="dataSet" value=""/>
	<input type="hidden" name="request" id="request" value="updateData"/>

	<textarea class="ckeditor" name="content" id="content"></textarea>
	<div class="bottom">
		<input type="button" class="submitButton formSubmit" value="<?php echo $lang['button']['save']; ?>">
		<input type="button" class="submitButton formCancel" value="<?php echo $lang['button']['cancel']; ?>">
	</div>
	<script>
		initEditor();

		function initEditor() {
			if (editor.contentData === null) {
				window.setTimeout(initEditor, 50);
				return false;
			}
			CKEDITOR.replace('content', {
				enterMode: CKEDITOR.ENTER_P,
				extraPlugins: 'divarea',
				height: '500px',
				language: '<?php echo $_POST['lang']; ?>',
				toolbarGroups: [
					{name: 'clipboard', groups: ['clipboard', 'undo']},
					{name: 'editing', groups: ['find', 'selection', 'spellchecker']},
					{name: 'basicstyles', groups: ['basicstyles', 'cleanup']},
					{name: 'paragraph', groups: ['list']},
					{name: 'links'},
					{name: 'about'}
				]
			});
		}
	</script>
</form>