/** * Display the list of paginated Posts (draft and published) */ function home() { Doo::loadHelper('DooPager'); Doo::loadModel('Post'); $p = new Post(); //if default, no sorting defined by user, show this as pager link if ($this->sortField == 'createtime' && $this->orderType == 'desc') { $pager = new DooPager(Doo::conf()->APP_URL . 'admin/post/page', $p->count(), 6, 10); } else { $pager = new DooPager(Doo::conf()->APP_URL . "admin/post/sort/{$this->sortField}/{$this->orderType}/page", $p->count(), 6, 10); } if (isset($this->params['pindex'])) { $pager->paginate(intval($this->params['pindex'])); } else { $pager->paginate(1); } $data['rootUrl'] = Doo::conf()->APP_URL; $data['pager'] = $pager->output; //Order by ASC or DESC if ($this->orderType == 'desc') { $data['posts'] = $p->limit($pager->limit, null, $this->sortField, array('select' => 'id,createtime,status,title,totalcomment')); $data['order'] = 'asc'; } else { $data['posts'] = $p->limit($pager->limit, $this->sortField, null, array('select' => 'id,createtime,status,title,totalcomment')); $data['order'] = 'desc'; } $this->render('admin', $data); }
# menampilkan aksi edit dan hapus untuk artikel milik member login if (\Ngaji\Http\Request::is_authenticated() and $post['account_id'] == \Ngaji\Http\Request::user()->id ): ?> <?php echo Html::anchor("post/edit/" . $post['id'], '<i class="fa fa-edit"></i> Edit', ['class' => 'btn btn-sm btn-flat']); ?> <?php echo Html::anchor("#", '<i class="fa fa-trash-o"></i> Delete', ['class' => 'btn btn-sm btn-flat', 'data-post-id' => $post['id'], 'data-post-title' => $post['title'], 'data-href' => sprintf("%s/post/delete/%d", HOSTNAME, $post['id']), 'data-toggle' => "modal", 'data-target' => "#confirm-delete"]); ?> <? endif; ?> </p> <div class="attachment"> <article> <?php echo Post::limit($post['post']); ?> </article> </div> <div class="attachment"> <span class="badge bg-primary"><i class="fa fa-eye"> </i> <?php echo $post['viewers']; ?> </span> <span class="badge bg-olive"> <i class="fa fa-comment"></i> <?php echo $post['comment_count']; ?> </span>