myaac/system/templates/admin.pages.form.html.twig
slawkens bf988a7f6e * added tinymce editor to 'Pages' in admin panel
* enabled code plugin for tinymce which enabled raw html code editing
2017-10-23 14:59:43 +02:00

92 lines
3.0 KiB
Twig

<form method="post" action="?p=pages&action={% if action == 'edit' %}edit{% else %}add{% endif %}">
{% if action == 'edit' %}
<input type="hidden" name="id" value="{{ id }}" />
{% endif %}
<table class="table" id="page-edit-table" width="100%" border="0" cellspacing="1" cellpadding="4">
<tr>
<th><b>{% if action == 'edit' %}Edit{% else %}Add{% endif %} page</b></th>
</tr>
<tr>
<td>
<table border="0" cellpadding="1">
<tr>
<td>Link/name:</td>
<td><input name="name" value="{{ name }}" size="29" maxlength="29"/></td>
</tr>
<tr>
<td>Title:</td>
<td><input name="title" value="{{ title }}" size="29" maxlength="29"/></td>
</tr>
<tr>
<td>PHP:</td>
<td><input type="checkbox" id="php" name="php" title="Check if page should be executed as PHP" value="1"{% if php %} checked="true"{% endif %}{% if action == 'edit' %} disabled{% endif %}/></td>
</tr>
<tr>
<td>Content:</td>
<td id="body-parent">
<textarea id="body" name="body" maxlength="65000" cols="50" rows="5">{{ body|raw }}</textarea>
</td>
<tr/>
<tr>
<td>Access:</td>
<td>
<select name="access">
{% for id, group in groups %}
<option value="{{ group.getId() }}"{% if access == group.getId() %} selected{% endif %}>{{ group.getName() }}</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<td align="right"><input type="submit" class="button" value="Save"/></td>
<td align="left">
<input type="button" onclick="window.location = '{{ constant('ADMIN_URL') }}?p=pages';" class="button" value="Cancel"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
$(function () {
$('#php').on('change', function(e) {
if (this.checked) {
tinymce.remove('#body');
} else {
if(tinymce.editors.length > 0) {
tinymce.activeEditor.show();
}
else {
init_tinymce();
}
}
});
{% if not php %}
init_tinymce();
{% endif %}
function init_tinymce() {
tinymce.init({
selector : "#body",
theme : "modern",
plugins: 'code print preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount spellchecker imagetools contextmenu colorpicker textpattern help',
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat code',
image_advtab: true,
relative_urls : false,
remove_script_host : false,
document_base_url : "{{ constant('BASE_URL') }}"
});
}
function decodeHtml(html) {
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
}
});
</script>