Пример #1
0
 public function update_user($id)
 {
     $config['upload_path'] = './uploads/';
     $config['allowed_types'] = 'gif|jpg|png';
     $config['max_size'] = '1000';
     $config['max_width'] = '1024';
     $config['max_height'] = '768';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload('images')) {
         $error = array('error' => $this->upload->display_errors());
     } else {
         $data_file = array('upload_data' => $this->upload->data());
     }
     $post = new Post();
     $post->title = $this->input->post('title-post');
     $post->slug = url_title($post->title, '-', TRUE);
     $post->content = $this->input->post('content');
     if ($data_file) {
         $post->image_feature = 'uploads/' . $data_file['upload_data']['file_name'];
     }
     $post->updated_at = now();
     $post->updated_by = $this->session->userdata('user_id');
     $post->post_type = 'page';
     $post->flag_sticky = $this->input->post('sticky');
     $post->save();
     if ($this->input->post('categories')) {
         $cats = explode(",", $this->input->post('categories'));
         foreach ($cats as $caty) {
             if (!Category::find_by_title(trim($caty))) {
                 $cat = new Category();
                 $cat->title = trim($caty);
                 $cat->save();
             } else {
                 $cat = Category::find_by_title(trim($caty));
             }
             if (!Post_to_category::find('all', array('post_id' => $post->id, 'category_id' => $cat->id))) {
                 $ptc = new Post_to_category();
                 $ptc->post_id = $post->id;
                 $ptc->category_id = $cat->id;
                 $ptc->save();
             }
         }
     }
     if ($this->input->post('tags')) {
         $tags = explode(",", $this->input->post('tags'));
         foreach ($tags as $tagy) {
             if (!Tag::find_by_title(trim($tagy))) {
                 $tag = new Tag();
                 $tag->title = trim($tagy);
                 $tag->save();
             } else {
                 $tag = Tag::find_by_title(trim($tagy));
             }
             if (!Post_to_tag::find('all', array('post_id' => $post->id, 'tag_id' => $tag->id))) {
                 $ptc = new Post_to_tag();
                 $ptc->post_id = $post->id;
                 $ptc->tag_id = $tag->id;
                 $ptc->save();
             }
         }
     }
     $this->session->set_flashdata('info', 'The Page #' . $post->id . ' has been updated <br/> ' . (isset($error) ? $error['error'] : ''));
     redirect('admin/posts');
 }
Пример #2
0
                            <?php 
            echo word_limiter($post->content, 60);
            ?>
                        </div>
                        <br />
                        <div class="pull-right"><a href="<?php 
            echo base_url('web/articles/' . $post->slug);
            ?>
" class="btn btn-default read-more">Read more</a></div>

                        <span class="label label-default">Published November 20, 2010 by Ahmad Awdiyanto </span>
                        <br />


                        <?php 
            $cats = Post_to_category::all(array('post_id' => $post->id));
            ?>

                        <?php 
            if ($cats) {
                ?>
                            <span class="small under-categories label label-info">
                                <span class="category-titles">Categories :</span>
                                <?php 
                foreach ($cats as $cat) {
                    ?>
                                <a href="<?php 
                    echo base_url('web/categories/' . Category::find($cat->category_id)->slug);
                    ?>
"><?php 
                    echo Category::find($cat->category_id)->title;
Пример #3
0
<div class="panel panel-default sidebar">
    <div class="panel-heading"><strong>Categories</strong></div>
    <div class="panel-body">
        <ul class="list-group">
            <?php 
$cats = Category::find('all');
foreach ($cats as $cat) {
    echo '<li class="list-group-item">';
    echo anchor('web/categories/' . $cat->slug, $cat->title);
    echo '<span class="badge">';
    echo Post_to_category::count(array('category_id' => $cat->id));
    echo '</span>';
    echo '</li>';
}
?>
        </ul>
    </div>
</div>