Commit 6cd15087 by KyrieCettyara

memperbaiki bookmark

parent 23cc3855
......@@ -81,6 +81,8 @@ class ArtikelController extends BaseController
]);
} else {
$this->bookmarkIsExist($key);
return view('byId', [
"value" => $value,
"data" => $data,
......@@ -88,6 +90,31 @@ class ArtikelController extends BaseController
}
}
private function bookmarkIsExist($id_artikel)
{
$model = new BookmarkModel();
$id_user = session()->get('id_user');
$value = $model->bookmarkCheck($id_user, $id_artikel);
if ($value == null) {
$data = [
'isExist' => false,
];
session()->set($data);
} else {
$data = [
'isExist' => true,
'id_bookmark' => $value['id_bookmark']
];
session()->set($data);
}
}
public function setArtikelSession($value)
{
$data = [
......@@ -114,7 +141,7 @@ class ArtikelController extends BaseController
$bookmarkModel->save($allValue);
return redirect()->to(base_url('bookmark'));
return redirect()->back();
}
public function addArtikel()
......
......@@ -50,26 +50,28 @@ class UserController extends BaseController
$allValue = $model->getBookmark($key);
return view('listBookmark', [
return view('list', [
"allValue" => $allValue,
"data" => $data,
]);
}
public function bookmarkById($key = null)
{
$data['title'] = 'Sistem Informasi Tapanuli Utara';
$model = new BookmarkModel();
$allValue = $model->getBookmarkDetail($key);
return view('bookmarkDetail', [
"allValue" => $allValue,
"data" => $data,
]);
}
public function deleteBookmark($id)
{
$model = new BookmarkModel();;
......@@ -80,6 +82,6 @@ class UserController extends BaseController
$session->setFlashdata("success", "Artikel Berhasil Dihapus");
return redirect()->to(base_url('bookmark'));
return redirect()->back();
}
}
......@@ -57,4 +57,12 @@ class BookmarkModel extends Model
->where('id_bookmark', $key)
->get()->getResultArray();
}
public function bookmarkCheck($id_user, $id_artikel)
{
return $this->db->table('bookmark')
->where('id_user', $id_user)
->where('id_artikel', $id_artikel)
->get()->getRowArray(1);
}
}
......@@ -6,10 +6,12 @@
<div class="row">
<div class="col">
<div class="panel-body">
<h1>Tambah Artikel</h1>
<hr>
<form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post">
<div class="form-group">
<label for="name">Jenis Artikel</label>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Jenis Artikel</label>
<div class="col-sm-10">
<select name="id_jenis_artikel" id="id_jenis_artikel" class="form-control">
<?php foreach ($data as $value) : ?>
......@@ -19,20 +21,26 @@
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="gambar">Gambar</label>
<input type="file" class="form-control" name="gambar" id="gambar">
</div>
<div class="form-group">
<label for="judul_artikel">Judul Artikel</label>
<div class="form-group row">
<label for="gambar" class="col-sm-2 col-form-label">Gambar</label>
<div class="col-sm-10">
<input type="file" class="form-control" style="height: fit-content;" name="gambar" id="gambar">
</div>
</div>
<div class="form-group row">
<label for="judul_artikel" class="col-sm-2 col-form-label">Judul Artikel</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</div>
<div class="form-group">
<label for="isi_artikel">Isi</label>
</div>
<div class="form-group row">
<label for="isi_artikel" class="col-sm-2 col-form-label">Isi</label>
<div class="col-sm-10">
<textarea type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea>
</div>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
</div>
......
......@@ -4,22 +4,27 @@
<div class="container">
<div class="row">
<div class="col">
<div class="card">
<div class="coll">
<div class="detail">
<?php $image = $value['gambar']; ?>
<img id="gambar" src="<?php echo base_url("upload/$image"); ?> " />
<div class=" card-body">
<?php if (session()->get('isLoggedIn')) : ?>
<a href="<?= base_url('tambah-bookmark') ?> " class=" btn btn-primary">Bookmark</a></br></br>
<?php if (session()->get('isExist')) : ?>
<a href="<?= base_url('delete-bookmark/' . session()->get('id_bookmark')); ?>" title="Hapus Bookmark">
<i class="fa fa-bookmark fa-lg" aria-hidden="true"><span class="text"></span> </i>
</a></br></br>
<?php else : ?>
<a href="<?= base_url('tambah-bookmark') ?> " title="Tambah Bookmark">
<i class="fa fa-bookmark-o fa-lg" aria-hidden="true"><span class="text"></span></i>
</a></br></br>
<?php endif ?>
<h5 class="card-title"><?= $value['judul_artikel']; ?></h5>
<p class="card-text"><?= $value['isi_artikel']; ?></p>
<?php endif ?>
</div>
<h3 class="title"><?= $value['judul_artikel']; ?></h3>
<p><?= $value['isi_artikel']; ?></p>
</div>
</div>
</div>
......
......@@ -19,7 +19,7 @@
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="<?php echo base_url('assets/vendor/bootstrap/css/bootstrap.min.css'); ?> " rel="stylesheet">
<link href="<?php echo base_url('assets/vendor/bootstrap-icons/bootstrap-icons.css'); ?> " rel="stylesheet">
......
#--------------------------------------------------------------------
# Example Environment Configuration file
#
# This file can be used as a starting point for your own
# custom .env files, and contains most of the possible settings
# available in a default install.
#
# By default, all of the settings are commented out. If you want
# to override the setting, you must un-comment it by removing the '#'
# at the beginning of the line.
#--------------------------------------------------------------------
#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT = development
#--------------------------------------------------------------------
# APP
#--------------------------------------------------------------------
# app.baseURL = ''
# app.forceGlobalSecureRequests = false
# app.sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'
# app.sessionCookieName = 'ci_session'
# app.sessionExpiration = 7200
# app.sessionSavePath = NULL
# app.sessionMatchIP = false
# app.sessionTimeToUpdate = 300
# app.sessionRegenerateDestroy = false
# app.CSPEnabled = false
#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------
database.default.hostname = localhost:3306
database.default.database = informasi_taput
database.default.username = root
database.default.password =
database.default.DBDriver = MySQLi
database.default.DBPrefix =
# database.tests.hostname = localhost
# database.tests.database = ci4
# database.tests.username = root
# database.tests.password = root
# database.tests.DBDriver = MySQLi
# database.tests.DBPrefix =
#--------------------------------------------------------------------
# CONTENT SECURITY POLICY
#--------------------------------------------------------------------
# contentsecuritypolicy.reportOnly = false
# contentsecuritypolicy.defaultSrc = 'none'
# contentsecuritypolicy.scriptSrc = 'self'
# contentsecuritypolicy.styleSrc = 'self'
# contentsecuritypolicy.imageSrc = 'self'
# contentsecuritypolicy.base_uri = null
# contentsecuritypolicy.childSrc = null
# contentsecuritypolicy.connectSrc = 'self'
# contentsecuritypolicy.fontSrc = null
# contentsecuritypolicy.formAction = null
# contentsecuritypolicy.frameAncestors = null
# contentsecuritypolicy.frameSrc = null
# contentsecuritypolicy.mediaSrc = null
# contentsecuritypolicy.objectSrc = null
# contentsecuritypolicy.pluginTypes = null
# contentsecuritypolicy.reportURI = null
# contentsecuritypolicy.sandbox = false
# contentsecuritypolicy.upgradeInsecureRequests = false
#--------------------------------------------------------------------
# COOKIE
#--------------------------------------------------------------------
# cookie.prefix = ''
# cookie.expires = 0
# cookie.path = '/'
# cookie.domain = ''
# cookie.secure = false
# cookie.httponly = false
# cookie.samesite = 'Lax'
# cookie.raw = false
#--------------------------------------------------------------------
# ENCRYPTION
#--------------------------------------------------------------------
# encryption.key =
# encryption.driver = OpenSSL
# encryption.blockSize = 16
# encryption.digest = SHA512
#--------------------------------------------------------------------
# HONEYPOT
#--------------------------------------------------------------------
# honeypot.hidden = 'true'
# honeypot.label = 'Fill This Field'
# honeypot.name = 'honeypot'
# honeypot.template = '<label>{label}</label><input type="text" name="{name}" value=""/>'
# honeypot.container = '<div style="display:none">{template}</div>'
#--------------------------------------------------------------------
# SECURITY
#--------------------------------------------------------------------
# security.tokenName = 'csrf_token_name'
# security.headerName = 'X-CSRF-TOKEN'
# security.cookieName = 'csrf_cookie_name'
# security.expires = 7200
# security.regenerate = true
# security.redirect = true
# security.samesite = 'Lax'
#--------------------------------------------------------------------
# LOGGER
#--------------------------------------------------------------------
# logger.threshold = 4
......@@ -135,10 +135,7 @@ input.src {
}
#gambar {
width: 100%;
height: 400px;
object-fit: cover;
object-position: center;
width: 50%;
display: block;
margin-left: auto;
margin-right: auto;
......@@ -154,3 +151,25 @@ input.src {
border-radius: 25px;
background-color: #009961;
}
.row > .coll {
display: flex;
justify-content: center;
}
.row > .coll > .detail {
text-align: justify;
text-justify: inter-word;
font-family: "Poppins", sans-serif;
width: 75%;
}
.row > .coll > .detail > .title {
padding-top: 15px;
font-family: "Poppins", sans-serif;
}
.row > .coll > .btn {
float: right;
border-radius: 25px;
background-color: #009961;
}
......@@ -1681,10 +1681,7 @@ section {
}
#gambar {
width: 100%;
height: 400px;
object-fit: cover;
object-position: center;
width: 50%;
display: block;
margin-left: auto;
margin-right: auto;
......@@ -1693,6 +1690,11 @@ section {
.card > .card-body {
text-align: justify;
text-justify: inter-word;
font-family: "Poppins", sans-serif;
}
.card > .card-body > .card-title {
font-family: "Poppins", sans-serif;
}
.card > .card-body > .btn {
......@@ -1700,3 +1702,24 @@ section {
border-radius: 25px;
background-color: #009961;
}
.row > .coll {
display: flex;
justify-content: center;
}
.row > .coll > .detail {
text-align: justify;
text-justify: inter-word;
font-family: "Poppins", sans-serif;
width: 75%;
}
.row > .coll > .detail > .title {
padding-top: 15px;
font-family: "Poppins", sans-serif;
}
.row > .coll > .detail > a {
padding-top: 10px;
float: right;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment