mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-13 17:24:54 +02:00
Shortened some code
This commit is contained in:
@@ -131,49 +131,24 @@ if($action == 'edit' || $action == 'new') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$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 = array();
|
||||||
foreach ($query as $_news) {
|
foreach ($query as $_news) {
|
||||||
$_player = new OTS_Player();
|
$_player = new OTS_Player();
|
||||||
$_player->load($_news['player_id']);
|
$_player->load($_news['player_id']);
|
||||||
|
|
||||||
if($_news['type'] == constant('NEWS')){
|
$newses[$_news['type']][] = array(
|
||||||
$newses[] = array(
|
'id' => $_news['id'],
|
||||||
'id' => $_news['id'],
|
'hidden' => $_news['hidden'],
|
||||||
'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' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
||||||
'player_name' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
||||||
'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' => 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' => isset($_player) && $_player->isLoaded() ? $_player->getName() : '',
|
|
||||||
'player_link' => isset($_player) && $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$twig->display('admin.news.html.twig', array(
|
$twig->display('admin.news.html.twig', array(
|
||||||
'newses' => $newses,
|
'newses' => $newses
|
||||||
'tickers' => $tickers,
|
|
||||||
'articles' => $articles
|
|
||||||
));
|
));
|
||||||
|
|
||||||
class News
|
class News
|
||||||
@@ -224,7 +199,7 @@ class News
|
|||||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||||
return false;
|
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));
|
$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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<h3 class="box-title">News:</h3>
|
<h3 class="box-title">News:</h3>
|
||||||
<div class="box-tools pull-right">
|
<div class="box-tools pull-right">
|
||||||
<a href="?p=news&action=new&type=1"><span class="btn btn-success">New</span></a>
|
<a href="?p=news&action=new&type=1"><span class="btn btn-success">New</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for news in newses %}
|
{% for news in newses[constant('NEWS')] %}
|
||||||
<tr>
|
<tr>
|
||||||
<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>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for ticker in tickers %}
|
{% for ticker in newses[constant('TICKER')] %}
|
||||||
<tr>
|
<tr>
|
||||||
<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>
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for article in articles %}
|
{% for article in newses[constant('ARTICLE')] %}
|
||||||
<tr>
|
<tr>
|
||||||
<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>
|
||||||
@@ -183,6 +183,6 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
$('.tb_datatable').DataTable({
|
$('.tb_datatable').DataTable({
|
||||||
"order": [[ 0, "desc" ]]
|
"order": [[ 0, "desc" ]]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
Reference in New Issue
Block a user