Systemtest_tk/subs/parts/userarea/news.php

128 lines
5.9 KiB
PHP
Raw Normal View History

2019-08-08 13:35:16 +00:00
<?php
/**
* /subs/parts/userarea/news.php
* @version 1.0
* @desc Userarea: news
* @author Fándly Gergő Zoltán (gergo@systemtest.tk, systemtest.tk)
* @copy 2018 Fándly Gergő Zoltán
* License:
Systemtest.tk website's.
Copyright (C) 2018 Fándly Gergő Zoltán
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
?>
<div id="newslist">
<table class="footable" style="text-align: left">
<thead>
<tr>
<th data-breakpoints="xs sm"><?php echo $lang['owner'] ?></th>
<th><?php echo $lang['date'] ?></th>
<th><?php echo $lang['subject']."/".$lang['eng'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['subject']."/".$lang['hun'] ?></th>
<th data-breakpoints="xs sm md"><?php echo $lang['subject']."/".$lang['rou'] ?></th>
<th data-breakpoints="xs"><?php echo $lang['published'] ?></th>
<th data-breakpoints="xs sm"><?php echo $lang['operations'] ?></th>
</tr>
</thead>
<tbody>
<?php
$sql=$db->prepare("SELECT n.id, u.fullname AS owner, n.date, n.subject_eng, n.subject_hun, n.subject_rou, n.published FROM news AS n INNER JOIN users AS u ON (u.id=n.owner) ORDER BY date DESC");
$sql->execute();
while($row=$sql->fetch(PDO::FETCH_ASSOC)){
echo "
<tr>
<td>".$row['owner']."</td>
<td>".$row['date']."</td>
<td>".$row['subject_eng']."</td>
<td>".$row['subject_hun']."</td>
<td>".$row['subject_rou']."</td>
<td>".($row['published']==1?$lang['tyes']:$lang['tno'])."</td>
<td>
<button type=\"button\" onclick=\"newsEdit(".$row['id'].")\">".$lang['edit']."</button>
<button type=\"button\" onclick=\"newsDelete(".$row['id'].", this)\">".$lang['delete']."</button>
</td>
</tr>
";
}
?>
</tbody>
</table>
<hr class="placeholder">
<button type="button" onclick="newNews()"><i class="fa fa-plus-circle"></i> <?php echo $lang['new'] ?></button>
</div>
<div id="newsEdit" style="display: none">
<hr class="placeholder">
<form method="POST" action="" class="ajaxform">
<input type="hidden" name="news_id" id="news_id">
<fieldset style="width: 95%">
<legend><?php echo $lang['editor'] ?></legend>
<table>
<tr>
<td><?php echo $lang['subject']."/".$lang['eng'].": " ?></td>
<td><input type="text" name="news_subject_eng" placeholder="<?php echo $lang['name']."..." ?>" required style="width: 95%"></td>
</tr>
<tr>
<td><?php echo $lang['subject']."/".$lang['hun'].": " ?></td>
<td><input type="text" name="news_subject_hun" placeholder="<?php echo $lang['name']."..." ?>" required style="width: 95%"></td>
</tr>
<tr>
<td><?php echo $lang['subject']."/".$lang['rou'].": " ?></td>
<td><input type="text" name="news_subject_rou" placeholder="<?php echo $lang['name']."..." ?>" required style="width: 95%"></td>
</tr>
<tr>
<td><?php echo $lang['published'].": " ?></td>
<td>
<div class="checkbox">
<input type="checkbox" name="news_published" id="news_published" hidden>
<label for="news_published"></label>
</div>
</td>
</tr>
<tr>
<td><?php echo $lang['autosave'].": " ?></td>
<td>
<div class="checkbox">
<input type="checkbox" id="autosave" onclick="newsAutoSave()" hidden>
<label for="autosave"></label>
</div>
</td>
</tr>
</table>
<br>
<p><?php echo $lang['editor']."/".$lang['eng'] ?></p>
<div id="engEditorContainer" style="background: rgb(255, 255, 255)">
<div id="engEditor"></div>
</div>
<br>
<p><?php echo $lang['editor']."/".$lang['hun'] ?></p>
<div id="hunEditorContainer" style="background: rgb(255, 255, 255)">
<div id="hunEditor"></div>
</div>
<br>
<p><?php echo $lang['editor']."/".$lang['rou'] ?></p>
<div id="rouEditorContainer" style="background: rgb(255, 255, 255)">
<div id="rouEditor"></div>
</div>
<p style="text-align: right"><i><?php echo $lang['last_saved'].": " ?><span id="lastSaved"></span></i></p>
<br>
<br>
<button type="button" class="green" onclick="newsSave()"><i class="fa fa-save"></i> <?php echo $lang['save'] ?></button>
<button type="button" class="red" onclick="newsDiscard()"><i class="fa fa-trash"></i> <?php echo $lang['discard'] ?></button>
</fieldset>
</form>
</div>