Categories now have their background color and font color, which effects the client and admin side
This commit is contained in:
parent
ec548a46b7
commit
9ca1050979
@ -75,10 +75,10 @@ class Posts
|
||||
{
|
||||
$this->checkValid();
|
||||
|
||||
$posts = [];
|
||||
$datas = [];
|
||||
|
||||
$post = $this->model->showAll([
|
||||
['status', '=', 1]
|
||||
$data = $this->model->showJoin([
|
||||
['pengumuman.status', '=', 1]
|
||||
]);
|
||||
|
||||
$url = 'Data/pengumuman.html';
|
||||
@ -87,30 +87,31 @@ class Posts
|
||||
$privilege = '';
|
||||
|
||||
if (Session::exists('userid')) {
|
||||
$post = $this->model->showAll();
|
||||
$data = $this->model->showJoin();
|
||||
if ($args != '') {
|
||||
$post = $this->model->showAll([
|
||||
['status', '=', $args]
|
||||
$data = $this->model->showJoin([
|
||||
['pengumuman.status', '=', $args]
|
||||
]);
|
||||
}
|
||||
$privilege = Session::get('privilege');
|
||||
$status = 'loggedin';
|
||||
}
|
||||
|
||||
if ($post !== false) {
|
||||
if (array_key_exists(0, $post)) {
|
||||
$posts = $post;
|
||||
if ($data !== false) {
|
||||
if (array_key_exists(0, $data)) {
|
||||
$datas = $data;
|
||||
} else {
|
||||
$posts[] = $post;
|
||||
$datas[] = $data;
|
||||
}
|
||||
|
||||
// Replace \n or \r with <br />
|
||||
for ($i=0; $i < count($posts); $i++) {
|
||||
$posts[$i]['content'] = preg_replace('/\r\n/', '<br />', $posts[$i]['content']);
|
||||
for ($i=0; $i < count($datas); $i++) {
|
||||
$datas[$i]['content'] = preg_replace('/\r\n/', '<br />', $datas[$i]['content']);
|
||||
}
|
||||
}
|
||||
|
||||
View::render($url, [
|
||||
'posts' => $posts,
|
||||
'posts' => $datas,
|
||||
'status' => $status,
|
||||
'privilege' => $privilege,
|
||||
'token' => Token::generate()
|
||||
@ -121,7 +122,7 @@ class Posts
|
||||
{
|
||||
if (Session::exists('userid')) {
|
||||
$date = new \DateTime();
|
||||
$now = $date->format("d-m-Y");
|
||||
$now = $date->format("Y-m-d");
|
||||
|
||||
$get_categories = $this->model->showAll([], 'kategori');
|
||||
$categories = [];
|
||||
@ -188,7 +189,7 @@ class Posts
|
||||
], $table);
|
||||
|
||||
$date = new \DateTime();
|
||||
$timestamp = $date->format("d-m-Y");
|
||||
$timestamp = $date->format("Y-m-d");
|
||||
|
||||
View::render(
|
||||
'Data/edit_pengumuman.html',
|
||||
|
@ -27,6 +27,8 @@ class Post extends \Core\Model
|
||||
[
|
||||
'id int(3) NOT NULL AUTO_INCREMENT',
|
||||
'category varchar(20) NOT NULL',
|
||||
'background char(7) NOT NULL DEFAULT "#ffffff"',
|
||||
'foreground char(7) NOT NULL DEFAULT "#000000"',
|
||||
'status tinyint(1) NOT NULL DEFAULT 1',
|
||||
'PRIMARY KEY (id)'
|
||||
],
|
||||
@ -114,6 +116,56 @@ class Post extends \Core\Model
|
||||
}
|
||||
}
|
||||
|
||||
public function showJoin($conditions = [])
|
||||
{
|
||||
try {
|
||||
$db = static::connectDB();
|
||||
|
||||
$sql = "SELECT pengumuman.id, kategori.background, kategori.foreground, pengumuman.valid_at, pengumuman.expired_at, pengumuman.content, pengumuman.status FROM pengumuman INNER JOIN kategori ON pengumuman.category=kategori.id";
|
||||
|
||||
if ($conditions) {
|
||||
$sql .= " WHERE";
|
||||
foreach ($conditions as $condition) {
|
||||
|
||||
$keys[] = $condition[0];
|
||||
$operators[] = $condition[1];
|
||||
$values[] = $condition[2];
|
||||
}
|
||||
|
||||
$x = 0;
|
||||
foreach ($keys as $key) {
|
||||
$sql .= " $key $operators[$x] ?";
|
||||
$x++;
|
||||
if ($x < count($keys)) {
|
||||
$sql .= " AND";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = $db->prepare($sql);
|
||||
if (count($conditions)) {
|
||||
$x = 1;
|
||||
foreach ($values as $value) {
|
||||
$query->bindValue($x, $value);
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
$query->execute();
|
||||
if ($query->rowCount() == 1) {
|
||||
$result = $query->fetch(\PDO::FETCH_ASSOC);
|
||||
} elseif ($query->rowCount() > 1) {
|
||||
$result = $query->fetchAll(\PDO::FETCH_ASSOC);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
} catch (PDOException $e) {
|
||||
throw new \Exception($e->getMessage(), 444);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function entry($args, $table = 'pengumuman')
|
||||
{
|
||||
if (count($args)) {
|
||||
@ -144,8 +196,6 @@ class Post extends \Core\Model
|
||||
|
||||
try {
|
||||
$sql = "INSERT INTO {$table} ({$keys}) VALUES {$values}";
|
||||
var_dump($sql);
|
||||
var_dump($args);
|
||||
|
||||
$db = static::connectDB();
|
||||
|
||||
|
20
App/Views/Data/edit_kategori.html
Normal file
20
App/Views/Data/edit_kategori.html
Normal file
@ -0,0 +1,20 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Ubah Kategori{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<main class="documentation">
|
||||
<section>
|
||||
<form method="post">
|
||||
<div class="flex four-600 two">
|
||||
<h1>Kategori
|
||||
</h1>
|
||||
<h1>
|
||||
<input type="text" name="category" value="{{ category.category }}">
|
||||
</h1>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
{% endblock %}
|
@ -6,54 +6,97 @@
|
||||
<main class="documentation">
|
||||
<section>
|
||||
<h1>Kategori</h1>
|
||||
<h2>List</h2>
|
||||
<ul>
|
||||
{% for cat in categories %}
|
||||
<li>{{ cat.category }}
|
||||
|
||||
<div class="flex two-600 full grow">
|
||||
|
||||
<div>
|
||||
<form method="post">
|
||||
<input type="hidden" name="id" value="{{ cat.id }}">
|
||||
{% if cat.status == 1 %}
|
||||
<input type="hidden" name="status" value="0">
|
||||
<input type="hidden" name="_method" value="delete">
|
||||
{% elseif cat.status == 0 %}
|
||||
<input type="hidden" name="status" value="1">
|
||||
<input type="hidden" name="_method" value="put">
|
||||
{% endif %}
|
||||
<h2>Tambah Kategori</h2>
|
||||
<div class="flex three-600 two grow">
|
||||
<div class="third-600 full">
|
||||
<label for="category">Nama</label>
|
||||
</div>
|
||||
<div class="two-third-600 full">
|
||||
<input type="text" name="category">
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="_addon" value="kategori">
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
<div class="third-600 full">
|
||||
<label for="background">Background</label>
|
||||
</div>
|
||||
<div class="two-third-600 full">
|
||||
<input type="color" name="background">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="shyButton
|
||||
{% if cat.status == 1 %}
|
||||
error">Nonaktifkan
|
||||
{% elseif cat.status == 0 %}
|
||||
success">Aktifkan
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="third-600 full">
|
||||
<label for="foreground">Teks</label>
|
||||
</div>
|
||||
<div class="two-third-600 full">
|
||||
<input type="color" name="foreground">
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<h2>Tambah</h2>
|
||||
<div class="flex three grow">
|
||||
<div class="third-600 full">
|
||||
<input type="text" name="category" value="" placeholder="Kategori">
|
||||
</div>
|
||||
<div class="third-600 none"></div>
|
||||
<div class="third-600 none"></div>
|
||||
<input type="hidden" name="_method" value="post">
|
||||
<input type="hidden" name="_addon" value="kategori">
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
|
||||
<div>
|
||||
<button type="submit" class="third-600 full">
|
||||
<input type="hidden" name="_method" value="post">
|
||||
<input type="hidden" name="_addon" value="kategori">
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
<button type="submit" class="pseudo full">
|
||||
<i class="fa fa-plus fa-fw" aria-hidden="true"></i>
|
||||
<span style="font-size:smaller;">Tambah</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>List</h2>
|
||||
<ul style="margin-top:0;">
|
||||
{% for cat in categories %}
|
||||
<li>
|
||||
<div style="height:initial;text-align:center;border-radius:5px;background-color:{{ cat.background }};color:{{ cat.foreground }};">
|
||||
<span>
|
||||
{{ cat.category }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex two-600 full grow" style="margin:0;">
|
||||
<div>
|
||||
<a href="#" class="pseudo button full">
|
||||
<i class="fa fa-edit fa-fw"></i>
|
||||
<span style="font-size:smaller;">Ubah</span>
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<form method="post">
|
||||
<input type="hidden" name="id" value="{{ cat.id }}">
|
||||
{% if cat.status == 1 %}
|
||||
<input type="hidden" name="status" value="0">
|
||||
<input type="hidden" name="_method" value="delete">
|
||||
{% elseif cat.status == 0 %}
|
||||
<input type="hidden" name="status" value="1">
|
||||
<input type="hidden" name="_method" value="put">
|
||||
{% endif %}
|
||||
|
||||
<input type="hidden" name="_addon" value="kategori">
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
|
||||
<button type="submit" class="pseudo full" style="height:100%;">
|
||||
|
||||
{% if cat.status == 1 %}
|
||||
<i class="fa fa-times-circle-o fa-fw"></i>
|
||||
<span class="font-size:smaller;">Matikan</span>
|
||||
{% elseif cat.status == 0 %}
|
||||
<span class="font-size:smaller;">Matikan</span>
|
||||
{% endif %}
|
||||
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fourth-600 none"></div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
{% endblock %}
|
||||
|
@ -22,24 +22,27 @@
|
||||
{% block body %}
|
||||
|
||||
<main class="documentation">
|
||||
<div style="background:#fff;text-align:left;width:100%;padding:80px 0 0;">
|
||||
<div style="text-align:left;width:100%;">
|
||||
|
||||
{% if privilege == "" %}
|
||||
<div id="slidr-div">
|
||||
{% if not posts %}
|
||||
<div style="background:#fff;text-align:left;width:100vw;padding:10vh 0 0;">
|
||||
<h1 class="fitty">Tidak ada pengumuman</h1>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="slidr-div">
|
||||
{% for post in posts %}
|
||||
<div data-slidr="{{ post.id }}" style="width: 100%;">
|
||||
<div class="fitty" style="padding: 0 5rem">
|
||||
<div data-slidr="{{ post.id }}" style="color:{{ post.foreground }};background-color:{{ post.background }};width:100%;height:100vh;padding:15vh 0;">
|
||||
<div class="fitty" style="padding:0 5rem">
|
||||
{{ post.content|rendermd }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<div style="background:#fff;text-align:left;width:100vw;padding:10vh 0 0;">
|
||||
<div class="filter flex six-600 four grow">
|
||||
<div class="sixth-600 none"></div>
|
||||
<a href="/" class="navy noFitty">Semua</a>
|
||||
@ -54,57 +57,57 @@
|
||||
</a>
|
||||
|
||||
{% for post in posts %}
|
||||
<div class="fourth-900 half-600 card box">
|
||||
<span class="stack" style="font-size:smaller;color:rgba(17,17,17,.4);margin-bottom:.6em;">[{{ post.valid_at|date("d/m/Y") }} - {{ post.expired_at|date("d/m/Y") }}]</span>
|
||||
<span class="stack">{{ post.content|rendermd }}</span>
|
||||
<form method="post">
|
||||
<footer class="flex full grow">
|
||||
{% if post.status != 0 %}
|
||||
<div class="half-900">
|
||||
<a href="/posts/edit/{{ post.id }}" class="button full">
|
||||
<i class="fa fa-edit fa-fw"></i>
|
||||
<span style="font-size:smaller;">Ubah</span>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="half-900">
|
||||
<span class="button pseudo full" style="color:rgba(17,17,17,.3)">Nonaktif</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if (post.status == 1 and editor_now.id == creator.id) %}
|
||||
<div class="half-900">
|
||||
<input type="hidden" name="id" value="{{ post.id }}">
|
||||
<input type="hidden" name="status" value="0">
|
||||
<!-- Method -->
|
||||
<input type="hidden" name="_method" value="delete">
|
||||
<!-- Token -->
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
<button type="submit" class="error full">
|
||||
<i class="fa fa-times-circle-o fa-fw" aria-hidden="true"></i>
|
||||
<span style="font-size:smaller;">Matikan</span>
|
||||
</button>
|
||||
</div>
|
||||
{% elseif (post.status == 2 and editor_now.id == creator.id) %}
|
||||
<div class="half-900">
|
||||
<input type="hidden" name="id" value="{{ post.id }}">
|
||||
<input type="hidden" name="valid_at" value="##date##">
|
||||
<!-- Method -->
|
||||
<input type="hidden" name="_method" value="put">
|
||||
<!-- Token -->
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
<button type="submit" class="success full">
|
||||
<i class="fa fa-check fa-fw" aria-hidden="true"></i>
|
||||
<span style="font-size:smaller;">Aktifkan</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</footer>
|
||||
</form>
|
||||
<div class="fourth-900 half-600 card box" style="background-color:{{ post.background }};">
|
||||
<span class="stack" style="font-size:smaller;color:rgba(17,17,17,.4);margin-bottom:.6em;">[{{ post.valid_at|date("d/m/Y") }} - {{ post.expired_at|date("d/m/Y") }}]</span>
|
||||
<span class="stack" style="color:{{ post.foreground }};">{{ post.content|rendermd }}</span>
|
||||
<form method="post">
|
||||
<footer class="flex full grow">
|
||||
{% if post.status != 0 %}
|
||||
<div class="half-900">
|
||||
<a href="/posts/edit/{{ post.id }}" class="button full">
|
||||
<i class="fa fa-edit fa-fw"></i>
|
||||
<span style="font-size:smaller;">Ubah</span>
|
||||
</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="half-900">
|
||||
<span class="button pseudo full" style="color:rgba(17,17,17,.3)">Nonaktif</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if (post.status == 1 and editor_now.id == creator.id) %}
|
||||
<div class="half-900">
|
||||
<input type="hidden" name="id" value="{{ post.id }}">
|
||||
<input type="hidden" name="status" value="0">
|
||||
<!-- Method -->
|
||||
<input type="hidden" name="_method" value="delete">
|
||||
<!-- Token -->
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
<button type="submit" class="error full">
|
||||
<i class="fa fa-times-circle-o fa-fw" aria-hidden="true"></i>
|
||||
<span style="font-size:smaller;">Matikan</span>
|
||||
</button>
|
||||
</div>
|
||||
{% elseif (post.status == 2 and editor_now.id == creator.id) %}
|
||||
<div class="half-900">
|
||||
<input type="hidden" name="id" value="{{ post.id }}">
|
||||
<input type="hidden" name="valid_at" value="##date##">
|
||||
<!-- Method -->
|
||||
<input type="hidden" name="_method" value="put">
|
||||
<!-- Token -->
|
||||
<input type="hidden" name="_token" value="{{ token }}">
|
||||
<button type="submit" class="success full">
|
||||
<i class="fa fa-check fa-fw" aria-hidden="true"></i>
|
||||
<span style="font-size:smaller;">Aktifkan</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</footer>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
@ -24,6 +24,10 @@
|
||||
padding-right: .6em;
|
||||
}
|
||||
|
||||
.flex>h1 {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
nav.transparent {
|
||||
box-shadow: none;
|
||||
background: none;
|
||||
|
Loading…
Reference in New Issue
Block a user