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