mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 01:09:21 +02:00
Merge pull request #71 from whiteblXK/master
Many changes in admin panel and team page
This commit is contained in:
commit
ffebcee48b
@ -56,15 +56,16 @@
|
||||
|
||||
<?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',
|
||||
'News' => 'news',
|
||||
'Mailer' => 'mailer',
|
||||
'Pages' => 'pages',
|
||||
'Menus' => 'menus',
|
||||
|
@ -62,18 +62,6 @@ $query = $db->query('SELECT count(*) as `how_much` FROM `houses`;');
|
||||
$query = $query->fetch();
|
||||
$total_houses = $query['how_much'];
|
||||
|
||||
if ($db->hasColumn('accounts', 'premium_points')) {
|
||||
$points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
|
||||
} else {
|
||||
$points = 0;
|
||||
}
|
||||
|
||||
if ($db->hasColumn('accounts', 'coins')) {
|
||||
$coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;');
|
||||
} else {
|
||||
$coins = 0;
|
||||
}
|
||||
|
||||
$twig->display('admin.statistics.html.twig', array(
|
||||
'total_accounts' => $total_accounts,
|
||||
'total_players' => $total_players,
|
||||
@ -86,9 +74,23 @@ $twig->display('admin.dashboard.html.twig', array(
|
||||
'closed_message' => $closed_message,
|
||||
'status' => $status,
|
||||
'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'),
|
||||
'points' => $points,
|
||||
'coins' => $coins,
|
||||
|
||||
));
|
||||
|
||||
echo '<div class="row">';
|
||||
$config['modules'] = "lastlogin,points,coins";
|
||||
if(isset($config['modules']))
|
||||
$config['modules'] = explode(",", $config['modules']);
|
||||
|
||||
$twig_loader->prependPath(__DIR__ . '/modules/templates');
|
||||
foreach($config['modules'] as $box) {
|
||||
$file = __DIR__ . '/modules/' . $box . '.php';
|
||||
if(file_exists($file)) {
|
||||
include($file);
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
function clearCache()
|
||||
{
|
||||
global $template_name;
|
||||
|
11
system/pages/admin/modules/coins.php
Normal file
11
system/pages/admin/modules/coins.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if ($db->hasColumn('accounts', 'coins')) {
|
||||
$coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;');
|
||||
} else {
|
||||
$coins = 0;
|
||||
}
|
||||
|
||||
$twig->display('coins.html.twig', array(
|
||||
'coins' => $coins
|
||||
));
|
11
system/pages/admin/modules/lastlogin.php
Normal file
11
system/pages/admin/modules/lastlogin.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
if ($db->hasColumn('players', 'lastlogin')) {
|
||||
$players = $db->query('SELECT ' . (USE_ACCOUNT_NAME ? 'name' : 'id') . ' as name, level,lastlogin FROM players ORDER BY lastlogin DESC LIMIT 10;');
|
||||
} else {
|
||||
$players = 0;
|
||||
}
|
||||
|
||||
$twig->display('lastlogin.html.twig', array(
|
||||
'players' => $players,
|
||||
));
|
10
system/pages/admin/modules/points.php
Normal file
10
system/pages/admin/modules/points.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ($db->hasColumn('accounts', 'premium_points')) {
|
||||
$points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;');
|
||||
} else {
|
||||
$points = 0;
|
||||
}
|
||||
|
||||
$twig->display('points.html.twig', array(
|
||||
'points' => $points,
|
||||
));
|
29
system/pages/admin/modules/templates/coins.html.twig
Normal file
29
system/pages/admin/modules/templates/coins.html.twig
Normal file
@ -0,0 +1,29 @@
|
||||
{% if coins is iterable %}
|
||||
<div class="col-md-3">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Top 10 - Most coins</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Account {{ account_type }}</th>
|
||||
<th>Tibia coins</th>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for result in coins %}
|
||||
{% set i = i + 1 %}
|
||||
<tr>
|
||||
<td>{{ i }}</td>
|
||||
<td>{{ result.name }}</td>
|
||||
<td>{{ result.coins }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
29
system/pages/admin/modules/templates/lastlogin.html.twig
Normal file
29
system/pages/admin/modules/templates/lastlogin.html.twig
Normal file
@ -0,0 +1,29 @@
|
||||
{% if players is iterable %}
|
||||
<div class="col-md-3">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Last 10 Logins</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Player</th>
|
||||
<th>Login Date</th>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for result in players %}
|
||||
{% set i = i + 1 %}
|
||||
<tr>
|
||||
<td>{{ i }}</td>
|
||||
<td>{{ result.name }}</td>
|
||||
<td>{{ result.lastlogin|date("M d Y, H:i:s") }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
29
system/pages/admin/modules/templates/points.html.twig
Normal file
29
system/pages/admin/modules/templates/points.html.twig
Normal file
@ -0,0 +1,29 @@
|
||||
{% if points is iterable %}
|
||||
<div class="col-md-3">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Top 10 - Most premium points</h3>
|
||||
</div>
|
||||
<div class="box-body no-padding">
|
||||
<table class="table table-condensed">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Account {{ account_type }}</th>
|
||||
<th>Premium points</th>
|
||||
</tr>
|
||||
{% set i = 0 %}
|
||||
{% for result in points %}
|
||||
{% set i = i + 1 %}
|
||||
<tr>
|
||||
<td>{{ i }}</td>
|
||||
<td>{{ result.name }}</td>
|
||||
<td>{{ result.premium_points }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
242
system/pages/admin/news.php
Normal file
242
system/pages/admin/news.php
Normal file
@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Pages
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
require_once LIBS . 'forum.php';
|
||||
|
||||
$title = 'News Panel';
|
||||
|
||||
if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
|
||||
echo 'Access denied.';
|
||||
return;
|
||||
}
|
||||
|
||||
header('X-XSS-Protection:0');
|
||||
|
||||
// some constants, used mainly by database (cannot by modified without schema changes)
|
||||
define('TITLE_LIMIT', 100);
|
||||
define('BODY_LIMIT', 65535); // maximum news body length
|
||||
define('ARTICLE_TEXT_LIMIT', 300);
|
||||
define('ARTICLE_IMAGE_LIMIT', 100);
|
||||
|
||||
$name = $p_title = '';
|
||||
if(!empty($action))
|
||||
{
|
||||
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
|
||||
$p_title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
|
||||
$body = isset($_REQUEST['body']) ? stripslashes($_REQUEST['body']) : null;
|
||||
$comments = isset($_REQUEST['comments']) ? $_REQUEST['comments'] : null;
|
||||
$type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : null;
|
||||
$category = isset($_REQUEST['category']) ? (int)$_REQUEST['category'] : null;
|
||||
$player_id = isset($_REQUEST['player_id']) ? (int)$_REQUEST['player_id'] : null;
|
||||
$article_text = isset($_REQUEST['article_text']) ? $_REQUEST['article_text'] : null;
|
||||
$article_image = isset($_REQUEST['article_image']) ? $_REQUEST['article_image'] : null;
|
||||
$forum_section = isset($_REQUEST['forum_section']) ? $_REQUEST['forum_section'] : null;
|
||||
$errors = array();
|
||||
|
||||
if($action == 'add') {
|
||||
if(isset($forum_section) && $forum_section != '-1') {
|
||||
$forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors);
|
||||
}
|
||||
|
||||
if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) {
|
||||
$p_title = $body = $comments = $article_text = $article_image = '';
|
||||
$type = $category = $player_id = 0;
|
||||
|
||||
success("Added successful.");
|
||||
}
|
||||
}
|
||||
else if($action == 'delete') {
|
||||
News::delete($id, $errors);
|
||||
success("Deleted successful.");
|
||||
}
|
||||
else if($action == 'edit')
|
||||
{
|
||||
if(isset($id) && !isset($p_title)) {
|
||||
$news = News::get($id);
|
||||
$p_title = $news['title'];
|
||||
$body = $news['body'];
|
||||
$comments = $news['comments'];
|
||||
$type = $news['type'];
|
||||
$category = $news['category'];
|
||||
$player_id = $news['player_id'];
|
||||
$article_text = $news['article_text'];
|
||||
$article_image = $news['article_image'];
|
||||
}
|
||||
else {
|
||||
if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $article_text, $article_image, $errors)) {
|
||||
// update forum thread if exists
|
||||
if(isset($forum_section) && Validator::number($forum_section)) {
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section));
|
||||
}
|
||||
|
||||
$action = $p_title = $body = $comments = $article_text = $article_image = '';
|
||||
$type = $category = $player_id = 0;
|
||||
|
||||
success("Updated successful.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($action == 'hide') {
|
||||
News::toggleHidden($id, $errors, $status);
|
||||
success(($status == 1 ? 'Show' : 'Hide') . " successful.");
|
||||
}
|
||||
|
||||
if(!empty($errors))
|
||||
error(implode(", ", $errors));
|
||||
}
|
||||
|
||||
$categories = array();
|
||||
foreach($db->query('SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat)
|
||||
{
|
||||
$categories[$cat['id']] = array(
|
||||
'name' => $cat['name'],
|
||||
'icon_id' => $cat['icon_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
|
||||
));
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news'));
|
||||
$newses = array();
|
||||
foreach ($query as $_news) {
|
||||
$_player = new OTS_Player();
|
||||
$_player->load($_news['player_id']);
|
||||
|
||||
$newses[$_news['type']][] = array(
|
||||
'id' => $_news['id'],
|
||||
'hidden' => $_news['hidden'],
|
||||
'archive_link' => getLink('news') . '/archive/' . $_news['id'],
|
||||
'title' => $_news['title'],
|
||||
'date' => $_news['date'],
|
||||
'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
||||
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
||||
);
|
||||
}
|
||||
|
||||
$twig->display('admin.news.html.twig', array(
|
||||
'newses' => $newses
|
||||
));
|
||||
|
||||
class News
|
||||
{
|
||||
static public function verify($title, $body, $article_text, $article_image, &$errors)
|
||||
{
|
||||
if(!isset($title[0]) || !isset($body[0])) {
|
||||
$errors[] = 'Please fill all inputs.';
|
||||
return false;
|
||||
}
|
||||
if(strlen($title) > TITLE_LIMIT) {
|
||||
$errors[] = 'News title cannot be longer than ' . TITLE_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
if(strlen($body) > BODY_LIMIT) {
|
||||
$errors[] = 'News content cannot be longer than ' . BODY_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
if(strlen($article_text) > ARTICLE_TEXT_LIMIT) {
|
||||
$errors[] = 'Article text cannot be longer than ' . ARTICLE_TEXT_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
if(strlen($article_image) > ARTICLE_IMAGE_LIMIT) {
|
||||
$errors[] = 'Article image cannot be longer than ' . ARTICLE_IMAGE_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function add($title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||
return false;
|
||||
|
||||
$db->insert(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'date' => time(), 'category' => $category, 'player_id' => isset($player_id) ? $player_id : 0, 'comments' => $comments, 'article_text' => ($type == 3 ? $article_text : ''), 'article_image' => ($type == 3 ? $article_image : '')));
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function get($id) {
|
||||
global $db;
|
||||
return $db->select(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
}
|
||||
|
||||
static public function update($id, $title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||
return false;
|
||||
|
||||
$db->update(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'category' => $category, 'last_modified_by' => isset($player_id) ? $player_id : 0, 'last_modified_date' => time(), 'comments' => $comments, 'article_text' => $article_text, 'article_image' => $article_image), array('id' => $id));
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if($db->select(TABLE_PREFIX . 'news', array('id' => $id)) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
else
|
||||
$errors[] = 'News with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'News id not set.';
|
||||
|
||||
return !count($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.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'News id not set.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
}
|
||||
?>
|
@ -76,7 +76,7 @@ if (!empty($action)) {
|
||||
}
|
||||
|
||||
if (!empty($errors))
|
||||
$twig->display('admin.error.html.twig', array('errors' => $errors));
|
||||
error(implode(", ", $errors));
|
||||
}
|
||||
|
||||
$query =
|
||||
|
@ -17,8 +17,7 @@ if(isset($_GET['archive']))
|
||||
$title = 'News Archive';
|
||||
|
||||
$categories = array();
|
||||
foreach($db->query(
|
||||
'SELECT id, name, icon_id FROM ' . TABLE_PREFIX . 'news_categories WHERE hidden != 1') as $cat)
|
||||
foreach($db->query('SELECT id, name, icon_id FROM ' . TABLE_PREFIX . 'news_categories WHERE hidden != 1') as $cat)
|
||||
{
|
||||
$categories[$cat['id']] = array(
|
||||
'name' => $cat['name'],
|
||||
@ -98,91 +97,16 @@ header('X-XSS-Protection: 0');
|
||||
$title = 'Latest News';
|
||||
|
||||
$cache = Cache::getInstance();
|
||||
$canEdit = hasFlag(FLAG_CONTENT_NEWS) || superAdmin();
|
||||
|
||||
$news_cached = false;
|
||||
// some constants, used mainly by database (cannot by modified without schema changes)
|
||||
define('TITLE_LIMIT', 100);
|
||||
define('BODY_LIMIT', 65535); // maximum news body length
|
||||
define('ARTICLE_TEXT_LIMIT', 300);
|
||||
define('ARTICLE_IMAGE_LIMIT', 100);
|
||||
|
||||
$canEdit = hasFlag(FLAG_CONTENT_NEWS) || superAdmin();
|
||||
if($canEdit)
|
||||
{
|
||||
if(!empty($action))
|
||||
{
|
||||
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
|
||||
$p_title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
|
||||
$body = isset($_REQUEST['body']) ? stripslashes($_REQUEST['body']) : null;
|
||||
$comments = isset($_REQUEST['comments']) ? $_REQUEST['comments'] : null;
|
||||
$type = isset($_REQUEST['type']) ? (int)$_REQUEST['type'] : null;
|
||||
$category = isset($_REQUEST['category']) ? (int)$_REQUEST['category'] : null;
|
||||
$player_id = isset($_REQUEST['player_id']) ? (int)$_REQUEST['player_id'] : null;
|
||||
$article_text = isset($_REQUEST['article_text']) ? $_REQUEST['article_text'] : null;
|
||||
$article_image = isset($_REQUEST['article_image']) ? $_REQUEST['article_image'] : null;
|
||||
$forum_section = isset($_REQUEST['forum_section']) ? $_REQUEST['forum_section'] : null;
|
||||
$errors = array();
|
||||
|
||||
if($action == 'add') {
|
||||
if(isset($forum_section) && $forum_section != '-1') {
|
||||
$forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors);
|
||||
}
|
||||
|
||||
if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $article_text, $article_image, $errors)) {
|
||||
$p_title = $body = $comments = $article_text = $article_image = '';
|
||||
$type = $category = $player_id = 0;
|
||||
}
|
||||
}
|
||||
else if($action == 'delete') {
|
||||
News::delete($id, $errors);
|
||||
}
|
||||
else if($action == 'edit')
|
||||
{
|
||||
if(isset($id) && !isset($p_title)) {
|
||||
$news = News::get($id);
|
||||
$p_title = $news['title'];
|
||||
$body = $news['body'];
|
||||
$comments = $news['comments'];
|
||||
$type = $news['type'];
|
||||
$category = $news['category'];
|
||||
$player_id = $news['player_id'];
|
||||
$article_text = $news['article_text'];
|
||||
$article_image = $news['article_image'];
|
||||
}
|
||||
else {
|
||||
if(News::update($id, $p_title, $body, $type, $category, $player_id, $forum_section, $article_text, $article_image, $errors)) {
|
||||
// update forum thread if exists
|
||||
if(isset($forum_section) && Validator::number($forum_section)) {
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $player_id.", `post_text` = ".$db->quote($body).", `post_topic` = ".$db->quote($p_title).", `edit_date` = " . time() . " WHERE `id` = " . $db->quote($forum_section));
|
||||
}
|
||||
|
||||
$action = $p_title = $body = $comments = $article_text = $article_image = '';
|
||||
$type = $category = $player_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($action == 'hide') {
|
||||
News::toggleHidden($id, $errors);
|
||||
}
|
||||
|
||||
if(!empty($errors))
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
if($cache->enabled())
|
||||
{
|
||||
$cache->set('news_' . $template_name . '_' . NEWS, '', 120);
|
||||
$cache->set('news_' . $template_name . '_' . TICKER, '', 120);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($cache->enabled())
|
||||
if($cache->enabled())
|
||||
$news_cached = News::getCached(NEWS);
|
||||
|
||||
if(!$news_cached)
|
||||
{
|
||||
$categories = array();
|
||||
foreach($db->query(
|
||||
'SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat)
|
||||
foreach($db->query('SELECT `id`, `name`, `icon_id` FROM `' . TABLE_PREFIX . 'news_categories` WHERE `hidden` != 1') as $cat)
|
||||
{
|
||||
$categories[$cat['id']] = array(
|
||||
'name' => $cat['name'],
|
||||
@ -190,12 +114,7 @@ if(!$news_cached)
|
||||
);
|
||||
}
|
||||
|
||||
$tickers_db =
|
||||
$db->query(
|
||||
'SELECT * FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . TICKER .
|
||||
($canEdit ? '' : ' AND `hidden` != 1') .
|
||||
' ORDER BY `date` DESC LIMIT ' . $config['news_ticker_limit']);
|
||||
|
||||
$tickers_db = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . TICKER .($canEdit ? '' : ' AND `hidden` != 1') .' ORDER BY `date` DESC LIMIT ' . $config['news_ticker_limit']);
|
||||
$tickers_content = '';
|
||||
if($tickers_db->rowCount() > 0)
|
||||
{
|
||||
@ -214,12 +133,7 @@ if(!$news_cached)
|
||||
if($cache->enabled() && !$canEdit)
|
||||
$cache->set('news_' . $template_name . '_' . TICKER, $tickers_content, 120);
|
||||
|
||||
$featured_article_db =
|
||||
$db->query(
|
||||
'SELECT `id`, `title`, `article_text`, `article_image`, `hidden` FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . ARTICLE .
|
||||
($canEdit ? '' : ' AND `hidden` != 1') .
|
||||
' ORDER BY `date` DESC LIMIT 1');
|
||||
|
||||
$featured_article_db =$db->query('SELECT `id`, `title`, `article_text`, `article_image`, `hidden` FROM `' . TABLE_PREFIX . 'news` WHERE `type` = ' . ARTICLE . ($canEdit ? '' : ' AND `hidden` != 1') .' ORDER BY `date` DESC LIMIT 1');
|
||||
$article = '';
|
||||
if($featured_article_db->rowCount() > 0) {
|
||||
$article = $featured_article_db->fetch();
|
||||
@ -251,44 +165,7 @@ else {
|
||||
if(!$news_cached)
|
||||
{
|
||||
ob_start();
|
||||
if($canEdit)
|
||||
{
|
||||
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('news.add.html.twig', array(
|
||||
'action' => $action,
|
||||
'news_link' => getLink(PAGE),
|
||||
'news_link_form' => getLink('news/' . ($action == 'edit' ? 'edit' : 'add')),
|
||||
'news_id' => isset($id) ? $id : null,
|
||||
'title' => isset($p_title) ? $p_title : '',
|
||||
'body' => isset($body) ? $body : '',
|
||||
'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
|
||||
));
|
||||
}
|
||||
|
||||
$newses =
|
||||
$db->query(
|
||||
'SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'news').
|
||||
' WHERE type = ' . NEWS .
|
||||
($canEdit ? '' : ' AND hidden != 1') .
|
||||
' ORDER BY date' .
|
||||
' DESC LIMIT ' . $config['news_limit']);
|
||||
$newses = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news') . ' WHERE type = ' . NEWS . ($canEdit ? '' : ' AND hidden != 1') . ' ORDER BY date' . ' DESC LIMIT ' . $config['news_limit']);
|
||||
if($newses->rowCount() > 0)
|
||||
{
|
||||
foreach($newses as $news)
|
||||
@ -303,13 +180,13 @@ if(!$news_cached)
|
||||
$admin_options = '';
|
||||
if($canEdit)
|
||||
{
|
||||
$admin_options = '<br/><br/><a href="?subtopic=news&action=edit&id=' . $news['id'] . '" title="Edit">
|
||||
$admin_options = '<br/><br/><a target="_blank" rel="noopener noreferrer" href="/admin/?p=news&action=edit&id=' . $news['id'] . '" title="Edit">
|
||||
<img src="images/edit.png"/>Edit
|
||||
</a>
|
||||
<a id="delete" href="?subtopic=news&action=delete&id=' . $news['id'] . '" onclick="return confirm(\'Are you sure?\');" title="Delete">
|
||||
<a id="delete" target="_blank" rel="noopener noreferrer" href="/admin/?p=news&action=delete&id=' . $news['id'] . '" onclick="return confirm(\'Are you sure?\');" title="Delete">
|
||||
<img src="images/del.png"/>Delete
|
||||
</a>
|
||||
<a href="?subtopic=news&action=hide&id=' . $news['id'] . '" title="' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . '">
|
||||
<a target="_blank" rel="noopener noreferrer" href="/admin/?p=news&action=hide&id=' . $news['id'] . '" title="' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . '">
|
||||
<img src="images/' . ($news['hidden'] != 1 ? 'success' : 'error') . '.png"/>
|
||||
' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . '
|
||||
</a>';
|
||||
@ -353,94 +230,6 @@ else
|
||||
|
||||
class News
|
||||
{
|
||||
static public function verify($title, $body, $article_text, $article_image, &$errors)
|
||||
{
|
||||
if(!isset($title[0]) || !isset($body[0])) {
|
||||
$errors[] = 'Please fill all inputs.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strlen($title) > TITLE_LIMIT) {
|
||||
$errors[] = 'News title cannot be longer than ' . TITLE_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strlen($body) > BODY_LIMIT) {
|
||||
$errors[] = 'News content cannot be longer than ' . BODY_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strlen($article_text) > ARTICLE_TEXT_LIMIT) {
|
||||
$errors[] = 'Article text cannot be longer than ' . ARTICLE_TEXT_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strlen($article_image) > ARTICLE_IMAGE_LIMIT) {
|
||||
$errors[] = 'Article image cannot be longer than ' . ARTICLE_IMAGE_LIMIT . ' characters.';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function add($title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||
return false;
|
||||
|
||||
$db->insert(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'date' => time(), 'category' => $category, 'player_id' => isset($player_id) ? $player_id : 0, 'comments' => $comments, 'article_text' => ($type == 3 ? $article_text : ''), 'article_image' => ($type == 3 ? $article_image : '')));
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function get($id) {
|
||||
global $db;
|
||||
return $db->select(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
}
|
||||
|
||||
static public function update($id, $title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||
return false;
|
||||
|
||||
$db->update(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'category' => $category, 'last_modified_by' => isset($player_id) ? $player_id : 0, 'last_modified_date' => time(), 'comments' => $comments, 'article_text' => $article_text, 'article_image' => $article_image), array('id' => $id));
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if($db->select(TABLE_PREFIX . 'news', array('id' => $id)) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
else
|
||||
$errors[] = 'News with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'News id not set.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function toggleHidden($id, &$errors)
|
||||
{
|
||||
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));
|
||||
else
|
||||
$errors[] = 'News with id ' . $id . ' does not exists.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'News id not set.';
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function getCached($type)
|
||||
{
|
||||
global $template_name;
|
||||
|
@ -56,11 +56,11 @@ foreach($groupList as $id => $group)
|
||||
'group_name' => $group->getName(),
|
||||
'player' => $member,
|
||||
'outfit' => $config['team_display_outfit'] ? $config['outfit_images_url'] . '?id=' . $member->getLookType() . ($outfit_addons ? '&addons=' . $member->getLookAddons() : '') . '&head=' . $member->getLookHead() . '&body=' . $member->getLookBody() . '&legs=' . $member->getLookLegs() . '&feet=' . $member->getLookFeet() : null,
|
||||
'status' => $member->isOnline(),
|
||||
'status' => $config['team_display_status'] ? $member->isOnline() : null,
|
||||
'link' => getPlayerLink($member->getName()),
|
||||
'flag_image' => getFlagImage($member->getAccount()->getCountry()),
|
||||
'world_name' => getWorldName($member->getWorldId()),
|
||||
'last_login' => $lastLogin
|
||||
'flag_image' => $config['account_country'] ? getFlagImage($member->getAccount()->getCountry()) : null,
|
||||
'world_name' => ($config['multiworld'] || $config['team_display_world']) ? getWorldName($member->getWorldId()) : null,
|
||||
'last_login' => $config['team_display_lastlogin'] ? $lastLogin : null
|
||||
);
|
||||
}
|
||||
|
||||
|
189
system/templates/admin.news.form.html.twig
Normal file
189
system/templates/admin.news.form.html.twig
Normal file
@ -0,0 +1,189 @@
|
||||
{% if action %}
|
||||
<div class="row">
|
||||
<form method="post" action="{{ news_link_form }}" id="news-edit-form">
|
||||
{% if action == 'edit' %}
|
||||
<input type="hidden" name="id" value="{{ news_id }}"/>
|
||||
{% endif %}
|
||||
<div class="col-md-8" id="page-edit-table">
|
||||
<div class="box box-info">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{% if action == 'edit' %}Edit{% else %}Add{% endif %} news</h3>
|
||||
</div>
|
||||
|
||||
<div class="box-body">
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-sm-2 control-label">Title</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<input type="text" id="title" name="title" class="form-control" autocomplete="off" style="cursor: auto;" value="{{ title }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<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">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="article-text" class="form-group"{% if type is not defined or type != constant('ARTICLE') %} style="display: none;"{% endif %}>
|
||||
<label for="article_text" class="col-sm-2 control-label">Article short text</label>
|
||||
|
||||
<div class="col-sm-10" id="body-parent">
|
||||
<textarea class="form-control" name="article_text" id="article_text" cols="50" rows="5">{% if article_text is not empty %}{{ article_text }}{% endif %}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="article-image" class="form-group"{% if type is not defined or type != constant('ARTICLE') %} style="display: none;"{% endif %}>
|
||||
<label for="article_image" class="col-sm-2 control-label">Article image</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<input class="form-control" type="text" name="article_image" id="article_image" value="{% if article_image is not empty %}{{ article_image }}{% else %}images/news/announcement.jpg{% endif %}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if action == 'edit' %}
|
||||
{% if player is defined %}
|
||||
<div class="form-group">
|
||||
<label for="author" class="col-sm-2 control-label">Author</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" id="author" name="original_id" disabled="disabled">
|
||||
<option value="{{ player.getId() }}">{{ player.getName() }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group">
|
||||
<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">
|
||||
{% 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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% 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>
|
||||
{% 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>
|
||||
</div>
|
||||
</div>
|
||||
{% elseif comments is not null %}
|
||||
<input type="hidden" name="forum_section" id="forum_section" value="{{ comments }}" />
|
||||
{% endif %}
|
||||
|
||||
<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" 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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box-footer">
|
||||
<td align="right"><input type="submit" class="btn btn-info pull-right" value="Save"/></td>
|
||||
<td align="left">
|
||||
<input type="button" onclick="window.location = '{{ constant('ADMIN_URL') }}?p=news';" class="btn btn-default" value="Cancel"/>
|
||||
</td>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% 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 emoticons',
|
||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | emoticons 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;
|
||||
});
|
||||
|
||||
$("#news-edit-form").submit(function( event ) {
|
||||
unsaved = false;
|
||||
});
|
||||
|
||||
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>
|
||||
{% endif %}
|
188
system/templates/admin.news.html.twig
Normal file
188
system/templates/admin.news.html.twig
Normal file
@ -0,0 +1,188 @@
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">News:</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<a href="?p=news&action=new&type=1"><span class="btn btn-success">New</span></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<table class="tb_datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th>Title</th>
|
||||
<th>Date</th>
|
||||
<th>Player</th>
|
||||
<th style="width: 150px;">Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for news in newses[constant('NEWS')] %}
|
||||
<tr>
|
||||
<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 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">
|
||||
<i class="fa fa-edit"></i>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<a href="?p=news&action=delete&id={{ news.id }}" class="ico" onclick="return confirm('Are you sure?');" title="Delete">
|
||||
<span class="btn btn-danger btn-sm delete btn-flat">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<a href="?p=news&action=hide&id={{ news.id }}" class="ico" title="{% if news.hidden != 1 %}Hide{% else %}Show{% endif %}">
|
||||
{% if news.hidden != 1 %}
|
||||
<span class="btn btn-primary btn-sm btn-flat">
|
||||
<i class="fa fa-eye"></i>
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="btn btn-default btn-sm btn-flat">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Tickers:</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<a href="?p=news&action=new&type=2"><span class="btn btn-success">New</span></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<table class="tb_datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th>Title</th>
|
||||
<th>Date</th>
|
||||
<th>Player</th>
|
||||
<th style="width: 150px;">Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ticker in newses[constant('TICKER')] %}
|
||||
<tr>
|
||||
<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 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">
|
||||
<i class="fa fa-edit"></i>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<a href="?p=news&action=delete&id={{ ticker.id }}" class="ico" onclick="return confirm('Are you sure?');" title="Delete">
|
||||
<span class="btn btn-danger btn-sm delete btn-flat">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<a href="?p=news&action=hide&id={{ ticker.id }}" class="ico" title="{% if news.hidden != 1 %}Hide{% else %}Show{% endif %}">
|
||||
{% if ticker.hidden != 1 %}
|
||||
<span class="btn btn-primary btn-sm btn-flat">
|
||||
<i class="fa fa-eye"></i>
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="btn btn-default btn-sm btn-flat">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Articles:</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<a href="?p=news&action=new&type=3"><span class="btn btn-success">New</span></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<table class="tb_datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th>Title</th>
|
||||
<th>Date</th>
|
||||
<th>Player</th>
|
||||
<th style="width: 150px;">Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for article in newses[constant('ARTICLE')] %}
|
||||
<tr>
|
||||
<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 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">
|
||||
<i class="fa fa-edit"></i>
|
||||
</span>
|
||||
</a>
|
||||
<a href="?p=news&action=delete&id={{ article.id }}" class="ico" onclick="return confirm('Are you sure?');" title="Delete">
|
||||
<span class="btn btn-danger btn-sm delete btn-flat">
|
||||
<i class="fa fa-trash"></i>
|
||||
</span>
|
||||
</a>
|
||||
<a href="?p=news&action=hide&id={{ article.id }}" class="ico" title="{% if news.hidden != 1 %}Hide{% else %}Show{% endif %}">
|
||||
{% if article.hidden != 1 %}
|
||||
<span class="btn btn-primary btn-sm btn-flat">
|
||||
<i class="fa fa-eye"></i>
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="btn btn-default btn-sm btn-flat">
|
||||
<i class="fa fa-eye-slash"></i>
|
||||
</span>
|
||||
{% endif %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('.tb_datatable').DataTable({
|
||||
"order": [[ 0, "desc" ]]
|
||||
});
|
||||
});
|
||||
</script>
|
@ -1,238 +0,0 @@
|
||||
<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 emoticons',
|
||||
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | emoticons 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>
|
@ -52,89 +52,17 @@
|
||||
</tr>
|
||||
|
||||
{% for group in groupmember|reverse %}
|
||||
{% for member in group.members|reverse %}
|
||||
<tr>
|
||||
<td>{{ group.group_name }}</td>
|
||||
|
||||
{% if config.team_display_outfit %}
|
||||
<td>
|
||||
<img style="position:absolute;margin-top:{% if member.player.looktype in [75, 266, 302] %}-20px;margin-left:-0px;{% else %}-45px;margin-left:-25px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
<td>
|
||||
{% if config.account_country %}
|
||||
{{ member.flag_image|raw }}
|
||||
{% endif %}
|
||||
{{ member.link|raw }}
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
<td>
|
||||
{% if member.status %}
|
||||
<span style="color: green"><b>Online</b></span>
|
||||
{% else %}
|
||||
<span style="color: red"><b>Offline</b></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
<td>
|
||||
<span><b>{{ member.world_name }}</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
<td>
|
||||
{{ member.last_login }}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% elseif config.team_style == 2 %}
|
||||
{% for group in groupmember|reverse %}
|
||||
<div style="text-align:center"><h2>{{ group.group_name }}</h2></div>
|
||||
|
||||
<table cellspacing="1" cellpadding="4" border="0" width="100%">
|
||||
{% if group.members is not empty %}
|
||||
{% for member in group.members|reverse %}
|
||||
<tr>
|
||||
{% if config.team_display_outfit %}
|
||||
<td width="5%"><span><b>Outfit</b></span></td>
|
||||
{% endif %}
|
||||
<td>{{ group.group_name }}</td>
|
||||
|
||||
<td width="40%">
|
||||
<span><b>Name</b></span>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
<td>
|
||||
<span><b>Status</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
<td>
|
||||
<span><b>World</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
<td>
|
||||
<span><b>Last login</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{% for member in group.members %}
|
||||
<tr>
|
||||
{% if config.team_display_outfit %}
|
||||
<td>
|
||||
<img style="position:absolute;margin-top:{% if member.player.looktype in [75, 266, 302] %}-20px;margin-left:-0px;{% else %}-45px;margin-left:-25px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<td>
|
||||
{% if config.account_country %}
|
||||
{{ member.flag_image|raw }}
|
||||
@ -162,10 +90,86 @@
|
||||
<td>
|
||||
{{ member.last_login }}
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% elseif config.team_style == 2 %}
|
||||
{% for group in groupmember|reverse %}
|
||||
{% if group.members is not empty %}
|
||||
<div style="text-align:center"><h2>{{ group.group_name }}</h2></div>
|
||||
|
||||
<table cellspacing="1" cellpadding="4" border="0" width="100%">
|
||||
<tr>
|
||||
{% if config.team_display_outfit %}
|
||||
<td width="5%"><span><b>Outfit</b></span></td>
|
||||
{% endif %}
|
||||
|
||||
<td width="40%">
|
||||
<span><b>Name</b></span>
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
<td>
|
||||
<span><b>Status</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
<td>
|
||||
<span><b>World</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
<td>
|
||||
<span><b>Last login</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{% for member in group.members %}
|
||||
<tr>
|
||||
{% if config.team_display_outfit %}
|
||||
<td>
|
||||
<img style="position:absolute;margin-top:{% if member.player.looktype in [75, 266, 302] %}-20px;margin-left:-0px;{% else %}-45px;margin-left:-25px;{% endif %}" src="{{ member.outfit }}" alt="player outfit"/>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
<td>
|
||||
{% if config.account_country %}
|
||||
{{ member.flag_image|raw }}
|
||||
{% endif %}
|
||||
{{ member.link|raw }}
|
||||
</td>
|
||||
|
||||
{% if config.team_display_status %}
|
||||
<td>
|
||||
{% if member.status %}
|
||||
<span style="color: green"><b>Online</b></span>
|
||||
{% else %}
|
||||
<span style="color: red"><b>Offline</b></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if (config.multiworld or config.team_display_world) %}
|
||||
<td>
|
||||
<span><b>{{ member.world_name }}</b></span>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
||||
{% if config.team_display_lastlogin %}
|
||||
<td>
|
||||
{{ member.last_login }}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user