예제 #1
0
 public function article()
 {
     $cat_slider = config('privatepage_slider');
     $cat_1 = config('privatepage_category_1');
     $cat_2 = config('privatepage_category_2');
     $cat_3 = config('privatepage_category_3');
     $cat_4 = config('privatepage_category_4');
     $privatepage_slider_title = Model\Portal\Category::find($cat_slider);
     $privatepage_slider = Model\Portal\Article::categoryId($cat_slider);
     $privatepage_category_1_title = Model\Portal\Category::find($cat_1);
     $privatepage_category_1_a = Model\Portal\Article::onlyRegistered()->categoryId($cat_1)->take(3)->latest('date');
     $privatepage_category_1_b = Model\Portal\Article::onlyRegistered()->categoryId($cat_1)->take(3)->skip(2)->latest('date');
     $privatepage_category_2_title = Model\Portal\Category::find($cat_2);
     $privatepage_category_2_a = Model\Portal\Article::onlyRegistered()->categoryId($cat_2)->take(3)->latest('date');
     $privatepage_category_2_b = Model\Portal\Article::onlyRegistered()->categoryId($cat_2)->take(3)->skip(2)->latest('date');
     $privatepage_category_3_title = Model\Portal\Category::find($cat_3);
     $privatepage_category_3_a = Model\Portal\Article::onlyRegistered()->categoryId($cat_3)->take(3)->latest('date');
     $privatepage_category_3_b = Model\Portal\Article::onlyRegistered()->categoryId($cat_3)->take(3)->skip(2)->latest('date');
     $privatepage_category_4_title = Model\Portal\Category::find($cat_4);
     $privatepage_category_4_a = Model\Portal\Article::onlyRegistered()->categoryId($cat_4)->take(3)->latest('date');
     $privatepage_category_4_b = Model\Portal\Article::onlyRegistered()->categoryId($cat_4)->take(3)->skip(2)->latest('date');
     $data = array('privatepage_slider_title' => $privatepage_slider_title ? $privatepage_slider_title->name : '', 'privatepage_slider' => $privatepage_slider->count() ? $privatepage_slider->take(9)->latest('date')->get() : collect([]), 'privatepage_category_1_title' => $privatepage_category_1_title ? $privatepage_category_1_title->name : 'No Category', 'privatepage_category_1_a' => $privatepage_category_1_a->count() ? $privatepage_category_1_a->get() : collect([]), 'privatepage_category_1_b' => $privatepage_category_1_b->count() ? $privatepage_category_1_a->get() : collect([]), 'privatepage_category_2_title' => $privatepage_category_2_title ? $privatepage_category_2_title->name : 'No Category', 'privatepage_category_2_a' => $privatepage_category_2_a->count() ? $privatepage_category_2_a->get() : collect([]), 'privatepage_category_2_b' => $privatepage_category_2_b->count() ? $privatepage_category_2_b->get() : collect([]), 'privatepage_category_3_title' => $privatepage_category_3_title ? $privatepage_category_3_title->name : 'No Category', 'privatepage_category_3_a' => $privatepage_category_3_a->count() ? $privatepage_category_3_a->get() : collect([]), 'privatepage_category_3_b' => $privatepage_category_3_b->count() ? $privatepage_category_3_b->get() : collect([]), 'privatepage_category_4_title' => $privatepage_category_4_title ? $privatepage_category_4_title->name : 'No Category', 'privatepage_category_4_a' => $privatepage_category_4_a->count() ? $privatepage_category_4_a->get() : collect([]), 'privatepage_category_4_b' => $privatepage_category_4_b->count() ? $privatepage_category_4_b->get() : collect([]), 'links' => $this->Mod_link->read());
     $latests = Model\Portal\Article::registered()->latest('date')->limit(15)->get();
     $data['latest'] = $latests;
     $this->template->set('active', 'artikel');
     $this->template->set('sidebar', FALSE);
     $this->template->set_layout('privatepage');
     $this->template->build('articlePrivate', $data);
 }
예제 #2
0
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  *      http://example.com/index.php/welcome
  *  - or -
  *      http://example.com/index.php/welcome/index
  *  - or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $visitor = new Library\Visitor\Visitor();
     $data = ['visitor' => $visitor, 'visitor_today' => $visitor->countVisitorToday(), 'visitor_week' => $visitor->countVisitorByWeek(), 'visitor_month' => $visitor->countVisitorByMonth(), 'new_visitor_unique' => $visitor->getVisitorToday()->count(), 'popular_post' => Model\Portal\Article::popular()->get(), 'latest_comment' => Model\Portal\Comment::latest('date')->get()];
     $this->template->inject_partial('script', '<script src="' . base_url('assets/admin/js/analytic.js') . '"></script>');
     $this->template->build('dashboard', $data);
 }
예제 #3
0
 public function index()
 {
     $request = Request::createFromGlobals();
     $term = $request->query->get('term');
     $articles = Model\Portal\Article::search($term)->get();
     $paginate = pagination($articles, 15, 'search');
     $paginate->appends(['term' => $term]);
     $data['searches'] = $paginate;
     $data['term'] = $term;
     $data['links'] = $this->Mod_link->read();
     $this->template->set('sidebar', FALSE);
     $this->template->set('railnews', FALSE);
     $this->template->set('single', TRUE);
     $this->template->set('sidebarCategory', TRUE);
     $this->template->build('index', $data);
 }
예제 #4
0
 public function index()
 {
     $term = $this->input->get('term');
     $articles = Model\Portal\Article::onlyRegistered()->search($term)->get();
     $paginate = pagination($articles, 15, 'search');
     $paginate->appends(['term' => $term]);
     $data['searches'] = $paginate;
     $data['term'] = $term;
     $data['links'] = $this->Mod_link->read();
     $this->template->set('sidebar', FALSE);
     $this->template->set('railnews', FALSE);
     $this->template->set('single', TRUE);
     $this->template->set('sidebarCategory', FALSE);
     $this->template->set_layout('single_private');
     $this->template->build('search', $data);
 }
예제 #5
0
 public function store()
 {
     $article = Model\Portal\Article::withPrivate()->findOrFail(set_value('article_id'));
     $this->form_validation->set_rules('name', 'Name', 'required');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     $this->form_validation->set_rules('content', 'Komentar', 'required');
     $this->form_validation->set_rules('article_id', 'Artikel', 'required');
     if ($this->form_validation->run() == FALSE) {
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'error', 'data' => $this->form_validation->error_array()]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             keepValidationErrors();
             redirect($article->link . '#comments', 'refresh');
         }
     } else {
         $data = array('content' => set_value('content'), 'nama' => set_value('name'), 'email' => set_value('email'), 'artikel_id' => set_value('article_id'), 'parent' => set_value('parent', 0), 'status' => 'draft', 'date' => Carbon::now());
         $comment = Model\Portal\Comment::create($data);
         if ($user = auth()->check()) {
             $comment->user()->associate($user->id);
             if ($user->inRole(['su', 'adm', 'edt', 'ins', 'mdr'])) {
                 $comment->status = 'publish';
             } else {
                 $comment->status = 'draft';
             }
             $comment->save();
         }
         if ($this->request->isXmlHttpRequest()) {
             $response = new Response();
             $response->setContent(json_encode(['status' => 'success', 'data' => $comment]));
             $response->headers->set('Content-Type', 'application/json');
         } else {
             if ($comment->status == 'publish') {
                 set_message_success('Komentar Anda sudah ditampilkan.');
                 redirect($article->link . '#comment-' . $comment->id, 'refresh');
             } else {
                 set_message_success('Komentar Anda akan tampil setelah dimoderasi.');
                 redirect($article->link . '#comments', 'refresh');
             }
         }
     }
 }
예제 #6
0
 public function show($slug = null)
 {
     try {
         $article = Model\Portal\Article::with('contributor', 'editor')->slug($slug);
         $data['article'] = $article;
         $data['contributor'] = $article->contributor;
         $data['editor'] = $article->editor;
         $data['comments'] = $article->comments;
         $data['links'] = $this->Mod_link->read();
         $article->resolveVisitorUnique();
         if ($article->categories->count()) {
             $data['relevance_title'] = $article->categories->first()->name;
             $data['relevance'] = Model\Portal\Article::categoryId($article->categories->first()->id)->where('id', '!=', $article->id)->take(6)->latest('date')->get();
         } else {
             $category_id = config('homepage_category_1');
             $category = Model\Portal\Category::find($category_id);
             if ($category) {
                 $data['relevance_title'] = $category->name;
                 $data['relevance'] = $category->articles()->take(9)->latest('date')->get();
             } else {
                 $data['relevance_title'] = 'No Category';
                 $data['relevance'] = collect();
             }
         }
         $this->template->set('active', $article->categories->first() ? $article->categories->first()->id : '');
         $this->template->set('single', TRUE);
         $this->template->set('sidebarCategory', TRUE);
         $this->template->set('railnews', FALSE);
         $this->template->set('sidebar', FALSE);
         $this->template->title($article->title);
         $this->template->build('show', $data);
     } catch (ModelNotFoundException $e) {
         $data['message'] = 'Artikel tidak ditemukan.';
         $this->template->set('single', TRUE);
         $this->template->set('sidebarCategory', TRUE);
         $this->template->set('railnews', FALSE);
         $this->template->set('sidebar', FALSE);
         $this->template->build('errors/404', $data);
     }
 }
예제 #7
0
 public function index()
 {
     $cat_1 = config('homepage_category_1');
     $cat_2 = config('homepage_category_2');
     $cat_3 = config('homepage_category_3');
     $cat_4 = config('homepage_category_4');
     $homepage_category_1_title = Model\Portal\Category::find($cat_1);
     $homepage_category_1 = Model\Portal\Article::categoryId($cat_1);
     $homepage_category_2_title = Model\Portal\Category::find($cat_2);
     $homepage_category_2_a = Model\Portal\Article::categoryId($cat_2);
     $homepage_category_2_b = Model\Portal\Article::categoryId($cat_2);
     $homepage_category_3_title = Model\Portal\Category::find($cat_3);
     $homepage_category_3 = Model\Portal\Article::categoryId($cat_3);
     $homepage_category_4_title = Model\Portal\Category::find($cat_4);
     $homepage_category_4 = Model\Portal\Article::categoryId($cat_4);
     $data = array('homepage_category_1_title' => $homepage_category_1_title ? $homepage_category_1_title->name : 'No Category', 'homepage_category_1' => $homepage_category_1->count() ? $homepage_category_1->take(10)->latest('date')->get() : collect([]), 'homepage_category_1_link' => $homepage_category_1_title ? portal_url('category/show/' . $homepage_category_1_title->name) : portal_url(), 'homepage_category_2_title' => $homepage_category_2_title ? $homepage_category_2_title->name : 'No Category', 'homepage_category_2_a' => $homepage_category_2_a->count() ? $homepage_category_2_a->take(10)->latest('date')->get() : collect([]), 'homepage_category_2_b' => $homepage_category_2_b->count() ? $homepage_category_2_b->take(2)->skip(2)->latest('date')->get() : collect([]), 'homepage_category_2_link' => $homepage_category_2_title ? portal_url('category/show/' . $homepage_category_2_title->name) : portal_url(), 'homepage_category_3_title' => $homepage_category_3_title ? $homepage_category_3_title->name : 'No Category', 'homepage_category_3' => $homepage_category_3->count() ? $homepage_category_3->take(5)->latest('date')->get() : collect([]), 'homepage_category_3_link' => $homepage_category_3_title ? portal_url('category/show/' . $homepage_category_3_title->name) : portal_url(), 'homepage_category_4_title' => $homepage_category_4_title ? $homepage_category_4_title->name : 'No Category', 'homepage_category_4' => $homepage_category_4->count() ? $homepage_category_4->take(10)->latest('date')->get() : collect([]), 'homepage_category_4_link' => $homepage_category_4_title ? portal_url('category/show/' . $homepage_category_4_title->name) : portal_url(), 'links' => $this->Mod_link->read(), 'latest' => Model\Portal\Article::latest('date')->limit(10)->get());
     $this->template->set('slider', true);
     $this->template->set('railnews', true);
     $this->template->set('sidebar', true);
     $this->template->set('sidebarCategory', false);
     $this->template->build('index', $data);
 }
예제 #8
0
 public function editArticle($id)
 {
     $this->form_validation->set_rules('title', 'Title', 'trim|required');
     $this->form_validation->set_rules('content', 'Content', 'trim|required');
     if ($this->form_validation->run() == FALSE) {
         $artikel = Model\Portal\Article::withDrafts()->withPrivate()->findOrFail($id);
         $cat_ids = array_map(function ($cat) {
             return $cat->kategori_id;
         }, $this->Mod_category->getByArticle($id));
         $data['artikel'] = $artikel;
         $data['categories_checkbox'] = (new Model\Portal\Category())->generateCheckbox(0, $cat_ids);
         $data['status'] = $this->status;
         $this->template->set('sidebar');
         $this->template->set_layout('privatepage');
         $this->template->build('edit', $data);
     } else {
         $artikel = array('title' => set_value('title'), 'content' => set_value('content', '', FALSE));
         $categories = set_value('categories', array());
         $status = set_value('status', 'draft');
         $id = $this->Mod_sendarticle->edit($id, $artikel, $categories);
         $articleLib = new Library\Article\Article();
         $articleLib->set($id);
         $featured_action = $this->input->post('featured[action]');
         switch ($featured_action) {
             case 'upload':
                 $featured_image = $this->input->post('featured[src]');
                 $desciption = $this->input->post('featured[description]');
                 $articleLib->setFeaturedImage($featured_image, $description);
                 break;
             case 'remove':
                 $articleLib->removeFeaturedImage();
             default:
                 break;
         }
         set_message_success('Artikel berhasil diperbarui.');
         redirect('dashboard/editArticle/' . $id, 'refresh');
     }
 }
예제 #9
0
                            </div>
                        </div>
                        <?php 
    }
    ?>
                    <?php 
} else {
    ?>
                        <p class="alert alert-warning">Tidak ada artikel yang ditampilkan.</p>
                    <?php 
}
?>
                </div>
                <div class="tab-pane fade" id="latest-post" role="tabpanel" aria-labelledby="latest-post-tab" aria-expanded="false">
                    <?php 
$latest = Model\Portal\Article::latest('date')->limit(4)->get();
?>
                    <?php 
if ($latest->count()) {
    ?>
                        <?php 
    foreach ($latest as $article) {
        ?>
                        <div class="box-articles-widget">
                            <div class="row">
                                <div class="col-sm-4 col-xs-6">
                                    <div class="box-articles-widget-img">
                                        <a href="<?php 
        echo $article->link;
        ?>
"><img src="<?php 
예제 #10
0
<!-- start:rails news -->
<div class="rails-news">
    <div class="row">
        <div class="col-md-2 col-sm-2 col-xs-2">
            <div class="btn-group btn-group-sm" role="group" aria-label="Small button group">
                <button type="button" class="btn btn-secondary" href="#carousel-rails-news" role="button" data-slide="prev"><i class="fa fa-chevron-left"></i></button>
                <button type="button" class="btn btn-secondary" href="#carousel-rails-news" role="button" data-slide="next"><i class="fa fa-chevron-right"></i></button>
            </div>
        </div>
        <div class="col-md-10 col-sm-10 col-xs-10">
            <div id="carousel-rails-news" class="carousel slide" data-ride="carousel">
                <div class="carousel-inner" role="listbox">
                    <?php 
$i = 0;
$railnews = Model\Portal\Article::latest('date')->take(3)->get();
foreach ($railnews as $article) {
    ?>
                        <div class="carousel-item <?php 
    echo $i == 0 ? 'active' : '';
    ?>
">
                            <p><a href="<?php 
    echo $article->link;
    ?>
"><?php 
    echo $article->title;
    ?>
</a> - <?php 
    echo $article->date->format('d M Y');
    ?>
</p>
예제 #11
0
    ?>
"><?php 
    echo $article->title;
    ?>
</a></h4>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php 
}
?>
                </div>
                <div class="tab-pane fade" id="latest-post" role="tabpanel" aria-labelledby="latest-post-tab" aria-expanded="false">
                    <?php 
foreach (Model\Portal\Article::onlyRegistered()->latest('date')->limit(5)->get() as $article) {
    ?>
                    <div class="box-articles-widget">
                        <div class="row">
                            <div class="col-sm-4 col-xs-6">
                                <div class="box-articles-widget-img">
                                    <a href="<?php 
    echo $article->link;
    ?>
"><img src="<?php 
    echo $article->featured_image;
    ?>
" alt=""></a>
                                </div>
                            </div>
                            <div class="col-sm-8 col-xs-6">
예제 #12
0
 public function unchoice($id)
 {
     try {
         $article = Model\Portal\Article::withPrivate()->findOrFail($id);
         $article->removeEditorChoice();
         set_message_success('Artikel berhasil diperbarui.');
         redirect('article/edit/' . $article->id, 'refresh');
     } catch (ModelNotFoundException $e) {
         set_message_error('Artikel tidak dapat diperbarui.');
         redirect('article/edit/' . $article->id, 'refresh');
     }
 }
예제 #13
0
<?php

$sliders = Model\Portal\Article::latest('date')->slider()->take(3)->get();
?>
<section id="header-main">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                <div id="carousel-slider-top" class="carousel slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                        <?php 
if ($sliders->count() > 0) {
    ?>
                            <?php 
    $i = 0;
    foreach ($sliders as $slider) {
        ?>
                                <li data-target="#carousel-slider-top" data-slide-to="<?php 
        echo $i;
        ?>
"<?php 
        echo $i == 0 ? ' class="active"' : '';
        ?>
></li>
                            <?php 
        $i++;
    }
    ?>
                        <?php 
} else {
    ?>
예제 #14
0
 public function unchoice($id)
 {
     $article = Model\Portal\Article::findOrFail($id);
     $article->removeEditorChoice();
     set_message_success('Artikel berhasil diperbarui.');
     redirect('article/edit/' . $article->id, 'refresh');
 }
예제 #15
0
                            </div>
                        </div>
                        <?php 
    }
    ?>
                    <?php 
} else {
    ?>
                        <p class="alert alert-warning">Tidak ada artikel yang ditampilkan.</p>
                    <?php 
}
?>
                </div>
                <div class="tab-pane fade" id="latest-post" role="tabpanel" aria-labelledby="latest-post-tab" aria-expanded="false">
                    <?php 
$latest = Model\Portal\Article::onlyRegistered()->latest('date')->limit(4)->get();
?>
                    <?php 
if ($latest->count()) {
    ?>
                        <?php 
    foreach ($latest as $article) {
        ?>
                        <div class="box-articles-widget">
                            <div class="row">
                                <div class="col-sm-4 col-xs-6">
                                    <div class="box-articles-widget-img">
                                        <a href="<?php 
        echo $article->link;
        ?>
"><img src="<?php 
예제 #16
0
    ?>
"><?php 
    echo $article->title;
    ?>
</a></h4>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php 
}
?>
                </div>
                <div class="tab-pane fade" id="latest-post" role="tabpanel" aria-labelledby="latest-post-tab" aria-expanded="false">
                    <?php 
foreach (Model\Portal\Article::latest('date')->limit(5)->get() as $article) {
    ?>
                    <div class="box-articles-widget">
                        <div class="row">
                            <div class="col-sm-4 col-xs-6">
                                <div class="box-articles-widget-img">
                                    <a href="<?php 
    echo $article->link;
    ?>
"><img src="<?php 
    echo $article->featured_image;
    ?>
" alt=""></a>
                                </div>
                            </div>
                            <div class="col-sm-8 col-xs-6">