mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 09:19:22 +02:00
238 lines
8.4 KiB
Twig
238 lines
8.4 KiB
Twig
<div id="news_preview"></div>
|
|
{% if action != 'edit' %}
|
|
<a id="news-button" href="#">Add news</a>
|
|
{% endif %}
|
|
<form method="post" action="{{ news_link_form }}" id="news-edit-form">
|
|
{% if action == 'edit' %}
|
|
<input type="hidden" name="id" value="{{ news_id }}" />
|
|
{% endif %}
|
|
<table id="news-edit" width="100%" border="0" cellspacing="1" cellpadding="4">
|
|
<tr>
|
|
<td colspan="2" bgcolor="{{ config.vdarkborder }}" class="white"><b>{% if action == 'edit'%}Edit{% else %}Add{% endif %} news</b></td>
|
|
</tr>
|
|
|
|
{% set rows = 1 %}
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td><b>Title:</b></td>
|
|
<td><input name="title" id="title" value="{{ title }}" size="50" maxlength="100"/></td>
|
|
</tr>
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<!--td>Description:</td-->
|
|
<td colspan="2"><textarea name="body" id="body" maxlength="{{ constant('BODY_LIMIT') }}" class="tinymce">{{ body }}</textarea></td>
|
|
<tr/>
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td><b>Type:</b></td>
|
|
<td>
|
|
<select name="type" id="select-type">
|
|
<option value="{{ constant('NEWS') }}" {% if type is defined and type == constant('NEWS') %}selected="yes"{% endif %}{% if action == 'edit' and type != constant('NEWS') %} disabled{% endif %}>News</option>
|
|
<option value="{{ constant('TICKER') }}" {% if type is defined and type == constant('TICKER') %}selected="yes"{% endif %}{% if action == 'edit' and type != constant('TICKER') %} disabled{% endif %}>Ticket</option>
|
|
<option value="{{ constant('ARTICLE') }}" {% if type is defined and type == constant('ARTICLE') %}selected="yes"{% endif %}{% if action == 'edit' and type != constant('ARTICLE') %} disabled{% endif %}>Article</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr id="article-text" bgcolor="{{ getStyle(rows) }}"{% if type is not defined or type != constant('ARTICLE') %} style="display: none;"{% endif %}>
|
|
<td><b>Article short text:<br/>This will be displayed on news page.<br/>Rest will be available on "read more" page.</b></td>
|
|
<td>
|
|
<textarea name="article_text" id="article_text">{% if article_text is not empty %}{{ article_text }}{% endif %}</textarea>
|
|
</td>
|
|
</tr>
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr id="article-image" bgcolor="{{ getStyle(rows) }}"{% if type is not defined or type != constant('ARTICLE') %} style="display: none;"{% endif %}>
|
|
<td><b>Article image:</b></td>
|
|
<td>
|
|
<input type="text" name="article_image" id="article_image" value="{% if article_image is not empty %}{{ article_image }}{% else %}images/news/announcement.jpg{% endif %}" />
|
|
</td>
|
|
</tr>
|
|
|
|
{% if action == 'edit' %}
|
|
{% set rows = rows + 1 %}
|
|
{% if player is defined %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td width="180"><b>Author:</b></td>
|
|
<td>
|
|
<select name="original_id" disabled="disabled">
|
|
<option value="{{ player.getId() }}">{{ player.getName() }}</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td width="180"><b>{% if action == 'edit' %}Modified by{% else %}Author{% endif %}:</b></td>
|
|
<td>
|
|
<select name="player_id" id="player_id">
|
|
{% for player in account_players %}
|
|
<option value="{{ player.getId() }}"{% if player_id is defined and player.getId() == player_id %} selected="selected"{% endif %}>{{ player.getName() }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td><b>Category:</b></td>
|
|
<td>
|
|
{% for id, cat in categories %}
|
|
<input type="radio" name="category" value="{{ id }}" {% if (category == 0 and id == 1) or (category == id) %}checked="yes"{% endif %}/> <img src="images/news/icon_{{ cat.icon_id }}_small.gif" />
|
|
{% endfor %}
|
|
</td>
|
|
</tr>
|
|
|
|
{% if action == '' %}
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td><b>Create forum thread in section:</b></td>
|
|
<td>
|
|
<select name="forum_section" id="forum_section">
|
|
<option value="-1">None</option>
|
|
{% for section in forum_boards %}
|
|
<option value="{{ section.id }}" {% if forum_section is defined and forum_section == section.id %}checked="yes"{% endif %}/>{{ section.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
{% elseif comments is not null%}
|
|
<input type="hidden" name="forum_section" id="forum_section" value="{{ comments }}" />
|
|
{% endif %}
|
|
|
|
{% set rows = rows + 1 %}
|
|
<tr bgcolor="{{ getStyle(rows) }}">
|
|
<td align="right">
|
|
<a id="preview" style="cursor: pointer;">Preview</a>
|
|
<input type="submit" value="Submit"/>
|
|
</td>
|
|
<td align="left">
|
|
<input id="cancel" type="button" value="Cancel"/>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
|
|
{% if action != 'edit' %}
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$("#news-edit").hide();
|
|
|
|
$("#news-button").click(function() {
|
|
$("#news-edit").toggle();
|
|
return false;
|
|
});
|
|
|
|
$('#select-type').change(function() {
|
|
var value = $('#select-type').val();
|
|
if(value == {{ constant('ARTICLE') }}) {
|
|
$('#article-text').show();
|
|
$('#article-image').show();
|
|
}
|
|
else {
|
|
$('#article-text').hide();
|
|
$('#article-image').hide();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endif %}
|
|
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/tinymce/tinymce.min.js"></script>
|
|
<script type="text/javascript">
|
|
var unsaved = false;
|
|
var lastContent = '';
|
|
|
|
tinymce.init({
|
|
selector : "#body",
|
|
theme : "modern",
|
|
plugins: '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 code',
|
|
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat code',
|
|
image_advtab: true,
|
|
setup: function(ed){
|
|
ed.on('NodeChange', function(e) {
|
|
if(ed.getContent() != lastContent) {
|
|
unsaved = true;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$(document).ready(function() {
|
|
$(":input").change(function(){ //trigers change in all input fields including text type
|
|
unsaved = true;
|
|
});
|
|
|
|
$("#cancel").click(function( event ) {
|
|
unsaved = false;
|
|
window.location = '{{ news_link }}';
|
|
});
|
|
|
|
$("#news-edit-form").submit(function( event ) {
|
|
unsaved = false;
|
|
});
|
|
|
|
if($("#news.Box").length > 0) {
|
|
$('<div id="article_preview"></div>').insertBefore("#news.Box");
|
|
$('<div id="ticker_preview"></div>').insertBefore("#news.Box");
|
|
}
|
|
else {
|
|
$('<div id="article_preview"></div>').insertBefore("#news-edit");
|
|
$('<div id="ticker_preview"></div>').insertBefore("#news-edit");
|
|
}
|
|
|
|
$("#preview").click(function(e) {
|
|
var title = document.getElementById("title").value;
|
|
var body = tinyMCE.activeEditor.getContent();
|
|
var player_id = document.getElementById("player_id").value;
|
|
var category = $('input[name=category]:checked').val();
|
|
var forum_section = document.getElementById("forum_section").value;
|
|
var type = document.getElementById("select-type").value;
|
|
|
|
var params = { title: title, body: body, player_id: player_id, category: category, forum_section: forum_section, template_path: '{{ template_path }}', type: type, uid: Math.random() }
|
|
|
|
if(type == 3) {
|
|
params.article_text = document.getElementById("article_text").value;
|
|
params.article_image = document.getElementById("article_image").value;
|
|
}
|
|
|
|
$.getJSON("tools/news_preview.php", params, function(data){
|
|
if(data.hasOwnProperty('success')) {
|
|
if(type == 3) { // ARTICLE
|
|
$('#news_preview').html('');
|
|
$('#ticker_preview').html('');
|
|
$('#article_preview').html(data.success);
|
|
}
|
|
else if(type == 2) { // TICKER
|
|
$('#news_preview').html('');
|
|
$('#ticker_preview').html(data.success);
|
|
$('#article_preview').html('');
|
|
}
|
|
else { // NEWS
|
|
$('#news_preview').html(data.success);
|
|
$('#ticker_preview').html('');
|
|
$('#article_preview').html('');
|
|
}
|
|
}
|
|
else if(data.hasOwnProperty('error')) {
|
|
$('#news_preview').html(data.error);
|
|
}
|
|
});
|
|
});
|
|
|
|
lastContent = $("#body").val();
|
|
});
|
|
|
|
function unloadPage(){
|
|
if(unsaved){
|
|
return "You have unsaved changes on this page. Do you want to leave this page and discard your changes or stay on this page?";
|
|
}
|
|
}
|
|
|
|
window.onbeforeunload = unloadPage;
|
|
</script> |