Commit 6cd15087 by KyrieCettyara

memperbaiki bookmark

parent 23cc3855
...@@ -81,6 +81,8 @@ class ArtikelController extends BaseController ...@@ -81,6 +81,8 @@ class ArtikelController extends BaseController
]); ]);
} else { } else {
$this->bookmarkIsExist($key);
return view('byId', [ return view('byId', [
"value" => $value, "value" => $value,
"data" => $data, "data" => $data,
...@@ -88,6 +90,31 @@ class ArtikelController extends BaseController ...@@ -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) public function setArtikelSession($value)
{ {
$data = [ $data = [
...@@ -114,7 +141,7 @@ class ArtikelController extends BaseController ...@@ -114,7 +141,7 @@ class ArtikelController extends BaseController
$bookmarkModel->save($allValue); $bookmarkModel->save($allValue);
return redirect()->to(base_url('bookmark')); return redirect()->back();
} }
public function addArtikel() public function addArtikel()
......
...@@ -50,26 +50,28 @@ class UserController extends BaseController ...@@ -50,26 +50,28 @@ class UserController extends BaseController
$allValue = $model->getBookmark($key); $allValue = $model->getBookmark($key);
return view('listBookmark', [ return view('list', [
"allValue" => $allValue, "allValue" => $allValue,
"data" => $data, "data" => $data,
]); ]);
} }
public function bookmarkById($key = null) public function bookmarkById($key = null)
{ {
$data['title'] = 'Sistem Informasi Tapanuli Utara'; $data['title'] = 'Sistem Informasi Tapanuli Utara';
$model = new BookmarkModel(); $model = new BookmarkModel();
$allValue = $model->getBookmarkDetail($key); $allValue = $model->getBookmarkDetail($key);
return view('bookmarkDetail', [ return view('bookmarkDetail', [
"allValue" => $allValue, "allValue" => $allValue,
"data" => $data, "data" => $data,
]); ]);
} }
public function deleteBookmark($id) public function deleteBookmark($id)
{ {
$model = new BookmarkModel();; $model = new BookmarkModel();;
...@@ -80,6 +82,6 @@ class UserController extends BaseController ...@@ -80,6 +82,6 @@ class UserController extends BaseController
$session->setFlashdata("success", "Artikel Berhasil Dihapus"); $session->setFlashdata("success", "Artikel Berhasil Dihapus");
return redirect()->to(base_url('bookmark')); return redirect()->back();
} }
} }
...@@ -57,4 +57,12 @@ class BookmarkModel extends Model ...@@ -57,4 +57,12 @@ class BookmarkModel extends Model
->where('id_bookmark', $key) ->where('id_bookmark', $key)
->get()->getResultArray(); ->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,32 +6,40 @@ ...@@ -6,32 +6,40 @@
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<div class="panel-body"> <div class="panel-body">
<h1>Tambah Artikel</h1>
<hr> <hr>
<form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post"> <form class="" enctype="multipart/form-data" action="<?= base_url('ArtikelController/addArtikel'); ?>" method="post">
<div class="form-group"> <div class="form-group row">
<label for="name">Jenis Artikel</label> <label for="name" class="col-sm-2 col-form-label">Jenis Artikel</label>
<select name="id_jenis_artikel" id="id_jenis_artikel" class="form-control"> <div class="col-sm-10">
<select name="id_jenis_artikel" id="id_jenis_artikel" class="form-control">
<?php foreach ($data as $value) : ?> <?php foreach ($data as $value) : ?>
<option value="<?= $value['id_jenis_artikel']; ?>">
<?= $value['nama_jenis_artikel']; ?>
</option>
<?php endforeach; ?>
</select>
<option value="<?= $value['id_jenis_artikel']; ?>">
<?= $value['nama_jenis_artikel']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div> </div>
<div class="form-group"> <div class="form-group row">
<label for="gambar">Gambar</label> <label for="gambar" class="col-sm-2 col-form-label">Gambar</label>
<input type="file" class="form-control" name="gambar" id="gambar"> <div class="col-sm-10">
<input type="file" class="form-control" style="height: fit-content;" name="gambar" id="gambar">
</div>
</div> </div>
<div class="form-group"> <div class="form-group row">
<label for="judul_artikel">Judul Artikel</label> <label for="judul_artikel" class="col-sm-2 col-form-label">Judul Artikel</label>
<input type="text" class="form-control" name="judul_artikel" id="judul_artikel"> <div class="col-sm-10">
<input type="text" class="form-control" name="judul_artikel" id="judul_artikel">
</div>
</div> </div>
<div class="form-group"> <div class="form-group row">
<label for="isi_artikel">Isi</label> <label for="isi_artikel" class="col-sm-2 col-form-label">Isi</label>
<textarea type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea> <div class="col-sm-10">
<textarea type="text" class="form-control" name="isi_artikel" id="isi_artikel"></textarea>
</div>
</div> </div>
<button type="submit" class="btn btn-success">Submit</button> <button type="submit" class="btn btn-success">Submit</button>
</form> </form>
......
...@@ -4,22 +4,27 @@ ...@@ -4,22 +4,27 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col"> <div class="coll">
<div class="card"> <div class="detail">
<?php $image = $value['gambar']; ?> <?php $image = $value['gambar']; ?>
<img id="gambar" src="<?php echo base_url("upload/$image"); ?> " /> <img id="gambar" src="<?php echo base_url("upload/$image"); ?> " />
<?php if (session()->get('isLoggedIn')) : ?>
<div class=" card-body"> <?php if (session()->get('isExist')) : ?>
<?php if (session()->get('isLoggedIn')) : ?> <a href="<?= base_url('delete-bookmark/' . session()->get('id_bookmark')); ?>" title="Hapus Bookmark">
<a href="<?= base_url('tambah-bookmark') ?> " class=" btn btn-primary">Bookmark</a></br></br> <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 ?> <?php endif ?>
<h5 class="card-title"><?= $value['judul_artikel']; ?></h5> <?php endif ?>
<p class="card-text"><?= $value['isi_artikel']; ?></p>
</div> <h3 class="title"><?= $value['judul_artikel']; ?></h3>
<p><?= $value['isi_artikel']; ?></p>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<!-- Google Fonts --> <!-- 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://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 --> <!-- 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/css/bootstrap.min.css'); ?> " rel="stylesheet">
<link href="<?php echo base_url('assets/vendor/bootstrap-icons/bootstrap-icons.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 { ...@@ -135,10 +135,7 @@ input.src {
} }
#gambar { #gambar {
width: 100%; width: 50%;
height: 400px;
object-fit: cover;
object-position: center;
display: block; display: block;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
...@@ -154,3 +151,25 @@ input.src { ...@@ -154,3 +151,25 @@ input.src {
border-radius: 25px; border-radius: 25px;
background-color: #009961; 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 { ...@@ -1681,10 +1681,7 @@ section {
} }
#gambar { #gambar {
width: 100%; width: 50%;
height: 400px;
object-fit: cover;
object-position: center;
display: block; display: block;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
...@@ -1693,6 +1690,11 @@ section { ...@@ -1693,6 +1690,11 @@ section {
.card > .card-body { .card > .card-body {
text-align: justify; text-align: justify;
text-justify: inter-word; text-justify: inter-word;
font-family: "Poppins", sans-serif;
}
.card > .card-body > .card-title {
font-family: "Poppins", sans-serif;
} }
.card > .card-body > .btn { .card > .card-body > .btn {
...@@ -1700,3 +1702,24 @@ section { ...@@ -1700,3 +1702,24 @@ section {
border-radius: 25px; border-radius: 25px;
background-color: #009961; 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