Exemplo n.º 1
0
 function upload_it()
 {
     //load the helper
     //$this->load->helper('form');
     //Configure
     //set the path where the files uploaded will be copied. NOTE if using linux, set the folder to permission 777
     $config['upload_path'] = './assets/front/img/portfolio_images';
     // set the filter image types
     $config['allowed_types'] = 'gif|jpg|png';
     //load the upload library
     $this->load->library('upload', $config);
     $this->upload->initialize($config);
     //$this->upload->set_allowed_types('*');
     $data['upload_data'] = '';
     //if not successful, set the error message
     if (!$this->upload->do_upload('userfile')) {
         redirect(base_url() . "Portfolio_ajout?op=failed", "location");
     } else {
         //else, set the success message
         $data = array('msg' => "Upload success!");
         $dataa = $this->upload->data();
         $this->load->model('entities/PortfolioEntry');
         $temp = new PortfolioEntry();
         $temp->initialize($this->input->post(), $dataa);
         PortfolioManagement::insert_portfolio_entry($temp);
         echo $dataa['file_name'];
         $data['upload_data'] = $this->upload->data();
         redirect(base_url() . "Portfolio_ajout?op=success", "location");
     }
 }
Exemplo n.º 2
0
 public function index()
 {
     // Getting data
     $website = WebsiteManagement::get_website();
     $menu = PageManagement::get_pages();
     $portfolio = PortfolioManagement::get_portfolio();
     PageManagement::add_visit(3);
     $this->load->view('front/header', array('website' => $website));
     $this->load->view('front/portfolio_content', array('website' => $website, 'menu' => $menu, 'portfolio' => $portfolio));
     $this->load->view('front/footer', array('website' => $website));
 }
Exemplo n.º 3
0
 public function operations($type)
 {
     switch ($type) {
         case 'general_settings':
             $this->load->model('entities/website');
             $temp = new Website();
             $temp->initialize($this->input->post());
             WebsiteManagement::update_website($temp);
             redirect(base_url() . "panel/general_settings", "location");
             break;
         case 'supprimer_portfolio':
             $data = $this->input->get();
             $id = $data['id'];
             PortfolioManagement::delete_portfolio_content($id);
             redirect(base_url() . "panel/page/portfolio", "location");
             break;
         case 'supprimer_post':
             $data = $this->input->get();
             $id = $data['id'];
             BlogManagement::delete_blog_post($id);
             break;
         case 'editer_post':
             $this->load->model('entities/Post');
             $post = BlogManagement::get_post($this->input->post('id'));
             $post->title = $this->input->post('title');
             $post->description = $this->input->post('description');
             $post->content = $this->input->post('content');
             BlogManagement::update_blog_post($post);
             echo 'ok';
             break;
         case 'ajouter_post':
             $this->load->model('entities/Post');
             $temp = new Post();
             $temp->initialize($this->input->post());
             BlogManagement::insert_blog_post($temp);
             echo 'ok';
             break;
         case 'upload_slider_image':
             # Started working with file upload.
             $validFiles = array('upload_path' => './assets/front/img/slider_images', 'allowed_types' => 'jpg|png', 'file_name' => 'slider_image_' . $this->input->post('slide_to_update') . '.jpg', 'max_size' => 250000, 'overwrite' => TRUE);
             $this->load->library('upload', $validFiles);
             $this->load->model('entities/SliderImage');
             $slider_entry = SliderManagement::get_slider_entry($this->input->post('slide_to_update'));
             $slider_entry->title = $this->input->post('article_title');
             $slider_entry->description = $this->input->post('article_description');
             if ($this->upload->do_upload('to_upload_image')) {
                 $slider_entry->image = 'slider_image_' . $this->input->post('slide_to_update') . '.jpg';
             } else {
                 echo $this->upload->display_errors();
             }
             SliderManagement::update_slider($slider_entry);
             redirect(base_url() . "panel/page/accueil", "location");
             break;
         default:
             break;
     }
 }