Skip to content

Commit

Permalink
Admin bisa liat komentar
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaswong committed Mar 25, 2014
1 parent e1894cc commit bc66465
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ public function before() {
}

public function action_index() {
$this->template->content = View::forge('admin/index');
//Set view file
$this->view = 'admin/index';

$this->data['comments'] = DB::select('*')->from('caleg_rating')->order_by('created', 'DESC')->execute()->as_array();
}
}
6 changes: 6 additions & 0 deletions server/fuel/app/classes/controller/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
use Fuel\Core\Controller_Template;

class Controller_Base extends Controller_Template {
public $data = array();
public $view = '';

public function before() {
parent::before();
}
Expand All @@ -10,6 +13,9 @@ public function test() {
}

public function after($response) {
if(!empty($this->view)) {
$this->template->content = View::forge($this->view, $this->data);
}
return parent::after($response);
}

Expand Down
6 changes: 4 additions & 2 deletions server/fuel/app/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public static function notifyUsers($dapilId, $caleg, $inputs) {
Util::sendToGCM($headers, $fields);
}
}


}

public static function gravatar($email, $s = 30) {
return 'http://www.gravatar.com/avatar/' . md5(trim(strtolower($email))) . '?s=' . $s . '&d=wavatar';
}

public static function sendToGCM($headers, $fields) {
Expand Down
15 changes: 15 additions & 0 deletions server/fuel/app/views/admin/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<a class="btn btn-danger" data-target="#hapusSemua" role="button" data-toggle="modal">Hapus semua data</a>

<div class="content" id="comments">
<?php foreach($comments as $comment): ?>
<!-- <?php echo print_r($comment, 1) ?> -->
<div class="comment">
<ul>
<li class="image"><img class="comment-pic" src="<?php echo Util::gravatar($comment['user_email']) ?>"></li>
<li><span class="glyphicon glyphicon-envelope"></span> <span class="comment-writer"><a href="mailto:<?php echo $comment['user_email'] ?>"><?php echo $comment['user_email']?></a></span></li>
<li><span class="glyphicon glyphicon-time"></span> <span class="comment-time"><?php echo date("D, d.m.Y h:i:s", $comment['created']) ?></span></li>
</ul>
<strong class="comment-title"><?php echo $comment['title'] ?></strong>
<p class="comment-content"><?php echo nl2br($comment['content']) ?></p>
</div>
<?php endforeach; ?>
</div>

<div class="modal fade" id="hapusSemua" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
Expand Down
24 changes: 24 additions & 0 deletions server/public/assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,28 @@ body {
margin-top:20px;
padding:20px;
padding-top:0;
}

#comments {
margin-top:20px;
}

.comment {
margin-bottom:20px;
border-bottom:1px solid #abcdef;
}

.comment ul {
padding:0;
overflow:hidden;
}

.comment ul li.image {
margin-top:0;
}

.comment ul li {
float:left;
margin:8px 15px 0 0;
list-style-type:none;
}

0 comments on commit bc66465

Please sign in to comment.