mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-29 10:49:22 +02:00
More changes to news admin
This commit is contained in:
parent
dac59d3133
commit
d03989481b
@ -56,12 +56,12 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
$icons_a = array(
|
$icons_a = array(
|
||||||
'dashboard', 'envelope',
|
'dashboard','newspaper-o', 'envelope',
|
||||||
'book', 'list',
|
'book', 'list',
|
||||||
'plug', 'user',
|
'plug', 'user',
|
||||||
'edit', 'gavel',
|
'edit', 'gavel',
|
||||||
'wrench', 'edit', 'book', 'book',
|
'wrench', 'edit', 'book', 'book',
|
||||||
);
|
);
|
||||||
|
|
||||||
$menus = array(
|
$menus = array(
|
||||||
'Dashboard' => 'dashboard',
|
'Dashboard' => 'dashboard',
|
||||||
|
@ -84,7 +84,8 @@ if(!empty($action))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($action == 'hide') {
|
else if($action == 'hide') {
|
||||||
News::toggleHidden($id, $errors);
|
News::toggleHidden($id, $errors, $status);
|
||||||
|
success(($status == 1 ? 'Show' : 'Hide') . " successful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($errors))
|
if(!empty($errors))
|
||||||
@ -100,32 +101,34 @@ foreach($db->query('SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'new
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action == 'edit') {
|
if($action == 'edit' || $action == 'new') {
|
||||||
$player = new OTS_Player();
|
if($action == 'edit') {
|
||||||
$player->load($player_id);
|
$player = new OTS_Player();
|
||||||
}
|
$player->load($player_id);
|
||||||
|
}
|
||||||
|
|
||||||
$account_players = $account_logged->getPlayersList();
|
$account_players = $account_logged->getPlayersList();
|
||||||
$account_players->orderBy('group_id', POT::ORDER_DESC);
|
$account_players->orderBy('group_id', POT::ORDER_DESC);
|
||||||
$twig->display('admin.news.form.html.twig', array(
|
$twig->display('admin.news.form.html.twig', array(
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'news_link' => getLink(PAGE),
|
'news_link' => getLink(PAGE),
|
||||||
'news_link_form' => '?p=news&action=' . ($action == 'edit' ? 'edit' : 'add'),
|
'news_link_form' => '?p=news&action=' . ($action == 'edit' ? 'edit' : 'add'),
|
||||||
'news_id' => isset($id) ? $id : null,
|
'news_id' => isset($id) ? $id : null,
|
||||||
'title' => isset($p_title) ? $p_title : '',
|
'title' => isset($p_title) ? $p_title : '',
|
||||||
'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '',
|
'body' => isset($body) ? htmlentities($body, ENT_COMPAT, 'UTF-8') : '',
|
||||||
'type' => isset($type) ? $type : null,
|
'type' => isset($type) ? $type : null,
|
||||||
'player' => isset($player) && $player->isLoaded() ? $player : null,
|
'player' => isset($player) && $player->isLoaded() ? $player : null,
|
||||||
'player_id' => isset($player_id) ? $player_id : null,
|
'player_id' => isset($player_id) ? $player_id : null,
|
||||||
'account_players' => $account_players,
|
'account_players' => $account_players,
|
||||||
'category' => isset($category) ? $category : 0,
|
'category' => isset($category) ? $category : 0,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'forum_boards' => getForumBoards(),
|
'forum_boards' => getForumBoards(),
|
||||||
'forum_section' => isset($forum_section) ? $forum_section : null,
|
'forum_section' => isset($forum_section) ? $forum_section : null,
|
||||||
'comments' => isset($comments) ? $comments : null,
|
'comments' => isset($comments) ? $comments : null,
|
||||||
'article_text' => isset($article_text) ? $article_text : null,
|
'article_text' => isset($article_text) ? $article_text : null,
|
||||||
'article_image' => isset($article_image) ? $article_image : null
|
'article_image' => isset($article_image) ? $article_image : null
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news'));
|
$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news'));
|
||||||
$newses = $tickers = $articles = array();
|
$newses = $tickers = $articles = array();
|
||||||
@ -136,30 +139,33 @@ foreach ($query as $_news) {
|
|||||||
if($_news['type'] == constant('NEWS')){
|
if($_news['type'] == constant('NEWS')){
|
||||||
$newses[] = array(
|
$newses[] = array(
|
||||||
'id' => $_news['id'],
|
'id' => $_news['id'],
|
||||||
|
'hidden' => $_news['hidden'],
|
||||||
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
||||||
'title' => $_news['title'],
|
'title' => $_news['title'],
|
||||||
'date' => $_news['date'],
|
'date' => $_news['date'],
|
||||||
'player_name' => $_player->getName(),
|
'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
||||||
'player_link' => getPlayerLink($_player->getName(), false),
|
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
||||||
);
|
);
|
||||||
} else if ($_news['type'] == constant('TICKER')) {
|
} else if ($_news['type'] == constant('TICKER')) {
|
||||||
|
|
||||||
$tickers[] = array(
|
$tickers[] = array(
|
||||||
'id' => $_news['id'],
|
'id' => $_news['id'],
|
||||||
|
'hidden' => $_news['hidden'],
|
||||||
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
||||||
'title' => $_news['title'],
|
'title' => $_news['title'],
|
||||||
'date' => $_news['date'],
|
'date' => $_news['date'],
|
||||||
'player_name' => $_player->getName(),
|
'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
||||||
'player_link' => getPlayerLink($_player->getName(), false),
|
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
||||||
);
|
);
|
||||||
} else if ($_news['type'] == constant('ARTICLE')) {
|
} else if ($_news['type'] == constant('ARTICLE')) {
|
||||||
$articles[] = array(
|
$articles[] = array(
|
||||||
'id' => $_news['id'],
|
'id' => $_news['id'],
|
||||||
|
'hidden' => $_news['hidden'],
|
||||||
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
||||||
'title' => $_news['title'],
|
'title' => $_news['title'],
|
||||||
'date' => $_news['date'],
|
'date' => $_news['date'],
|
||||||
'player_name' => $_player->getName(),
|
'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
||||||
'player_link' => getPlayerLink($_player->getName(), false),
|
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,14 +244,17 @@ class News
|
|||||||
return !count($errors);
|
return !count($errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function toggleHidden($id, &$errors)
|
static public function toggleHidden($id, &$errors, &$status)
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
if(isset($id))
|
if(isset($id))
|
||||||
{
|
{
|
||||||
$query = $db->select(TABLE_PREFIX . 'news', array('id' => $id));
|
$query = $db->select(TABLE_PREFIX . 'news', array('id' => $id));
|
||||||
if($query !== false)
|
if($query !== false)
|
||||||
|
{
|
||||||
$db->update(TABLE_PREFIX . 'news', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
$db->update(TABLE_PREFIX . 'news', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||||
|
$status = $query['hidden'];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$errors[] = 'News with id ' . $id . ' does not exists.';
|
$errors[] = 'News with id ' . $id . ' does not exists.';
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="content" class="col-sm-2 control-label">Content</label>
|
<label for="body" class="col-sm-2 control-label">Content</label>
|
||||||
|
|
||||||
<div class="col-sm-10" id="body-parent">
|
<div class="col-sm-10" id="body-parent">
|
||||||
<textarea class="form-control" id="body" name="body" maxlength="65000" cols="50" rows="5">{{ body|raw }}</textarea>
|
<textarea class="form-control" id="body" name="body" maxlength="65000" cols="50" rows="5">{{ body|raw }}</textarea>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="type" class="col-sm-2 control-label">Type</label>
|
<label for="select-type" class="col-sm-2 control-label">Type</label>
|
||||||
|
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<select class="form-control" name="type" id="select-type">
|
<select class="form-control" name="type" id="select-type">
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<label for="author" class="col-sm-2 control-label">Author</label>
|
<label for="author" class="col-sm-2 control-label">Author</label>
|
||||||
|
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<select class="form-control" name="original_id" disabled="disabled">
|
<select class="form-control" id="author" name="original_id" disabled="disabled">
|
||||||
<option value="{{ player.getId() }}">{{ player.getName() }}</option>
|
<option value="{{ player.getId() }}">{{ player.getName() }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="modifiedby" class="col-sm-2 control-label">{% if action == 'edit' %}Modified by{% else %}Author{% endif %}</label>
|
<label for="player_id" class="col-sm-2 control-label">{% if action == 'edit' %}Modified by{% else %}Author{% endif %}</label>
|
||||||
|
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<select class="form-control" name="player_id" id="player_id">
|
<select class="form-control" name="player_id" id="player_id">
|
||||||
@ -84,6 +84,7 @@
|
|||||||
{% if action != 'edit' %}
|
{% if action != 'edit' %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="forum_section" class="col-sm-2 control-label">Create forum thread in section:</label>
|
<label for="forum_section" class="col-sm-2 control-label">Create forum thread in section:</label>
|
||||||
|
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<select class="form-control" name="forum_section" id="forum_section">
|
<select class="form-control" name="forum_section" id="forum_section">
|
||||||
<option value="-1">None</option>
|
<option value="-1">None</option>
|
||||||
@ -99,9 +100,10 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="category" class="col-sm-2 control-label">Category</label>
|
<label for="category" class="col-sm-2 control-label">Category</label>
|
||||||
|
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
{% for id, cat in categories %}
|
{% for id, cat in categories %}
|
||||||
<input type="radio" name="category" value="{{ id }}" {% if (category == 0 and id == 1) or (category == id) %}checked="yes"{% endif %}/>
|
<input type="radio" name="category" id="category" value="{{ id }}" {% if (category == 0 and id == 1) or (category == id) %}checked="yes"{% endif %}/>
|
||||||
<img src="{{ constant('BASE_URL') }}/images/news/icon_{{ cat.icon_id }}_small.gif" />
|
<img src="{{ constant('BASE_URL') }}/images/news/icon_{{ cat.icon_id }}_small.gif" />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<td>{{ news.id|raw }}</td>
|
<td>{{ news.id|raw }}</td>
|
||||||
<td><i><a href="?p=news&action=edit&id={{ news.id }}">{{ news.title }}</a></i></td>
|
<td><i><a href="?p=news&action=edit&id={{ news.id }}">{{ news.title }}</a></i></td>
|
||||||
<td>{{ news.date|date(config.news_date_format) }}</td>
|
<td>{{ news.date|date(config.news_date_format) }}</td>
|
||||||
<td><a href="{{ news.player_link }}">{{ news.player_name }}</a></td>
|
<td><a target="_blank" rel="noopener noreferrer" href="{{ news.player_link }}">{{ news.player_name }}</a></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="?p=news&action=edit&id={{ news.id }}" class="ico" title="Edit">
|
<a href="?p=news&action=edit&id={{ news.id }}" class="ico" title="Edit">
|
||||||
<span class="btn btn-success btn-sm edit btn-flat">
|
<span class="btn btn-success btn-sm edit btn-flat">
|
||||||
@ -85,7 +85,7 @@
|
|||||||
<td>{{ ticker.id|raw }}</td>
|
<td>{{ ticker.id|raw }}</td>
|
||||||
<td><i><a href="?p=news&action=edit&id={{ ticker.id }}">{{ ticker.title }}</a></i></td>
|
<td><i><a href="?p=news&action=edit&id={{ ticker.id }}">{{ ticker.title }}</a></i></td>
|
||||||
<td>{{ ticker.date|date(config.news_date_format) }}</td>
|
<td>{{ ticker.date|date(config.news_date_format) }}</td>
|
||||||
<td><a href="{{ ticker.player_link }}">{{ ticker.player_name }}</a></td>
|
<td><a target="_blank" rel="noopener noreferrer" href="{{ ticker.player_link }}">{{ ticker.player_name }}</a></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="?p=news&action=edit&id={{ ticker.id }}" class="ico" title="Edit">
|
<a href="?p=news&action=edit&id={{ ticker.id }}" class="ico" title="Edit">
|
||||||
<span class="btn btn-success btn-sm edit btn-flat">
|
<span class="btn btn-success btn-sm edit btn-flat">
|
||||||
@ -146,7 +146,7 @@
|
|||||||
<td>{{ article.id|raw }}</td>
|
<td>{{ article.id|raw }}</td>
|
||||||
<td><i><a href="?p=news&action=edit&id={{ article.id }}">{{ article.title }}</a></i></td>
|
<td><i><a href="?p=news&action=edit&id={{ article.id }}">{{ article.title }}</a></i></td>
|
||||||
<td>{{ article.date|date(config.news_date_format) }}</td>
|
<td>{{ article.date|date(config.news_date_format) }}</td>
|
||||||
<td><a href="{{ article.player_link }}">{{ article.player_name }}</a></td>
|
<td><a target="_blank" rel="noopener noreferrer" href="{{ article.player_link }}">{{ article.player_name }}</a></td>
|
||||||
<td>
|
<td>
|
||||||
<a href="?p=news&action=edit&id={{ article.id }}" class="ico" title="Edit">
|
<a href="?p=news&action=edit&id={{ article.id }}" class="ico" title="Edit">
|
||||||
<span class="btn btn-success btn-sm edit btn-flat">
|
<span class="btn btn-success btn-sm edit btn-flat">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user