示例#1
0
 public function index($id = '')
 {
     $this->c_categories_m = $this->load->model('c_categories/c_categories_m');
     $cate = $this->c_categories_m->getCategory($id);
     $category = $this->c_categories_m->getCate();
     $tree_option['0'] = lang('root');
     if (count($cate) > 0) {
         $css = getCss($cate, 'module');
         $this->data['css'] = $css;
         $this->data['category'] = $cate;
         $this->data['categories'] = categoriesToTree($category);
         $this->load->view('c_categories', $this->data);
     }
 }
示例#2
0
文件: setting.php 项目: Nnamso/tbox
 public function edit($id = '')
 {
     $this->data['id'] = $id;
     if ($id == '') {
         $categories = $this->c_categories_m->getNew();
     } else {
         $categories = $this->c_categories_m->getCategory($id);
     }
     $category = $this->c_categories_m->getCate();
     $tree_option['0'] = lang('root');
     $this->data['category'] = categoriesToTree($category);
     if (count($categories) > 0) {
         $this->data['categories'] = $categories;
     } else {
         echo '<p class="col-md-12">Data not found.</p>';
         exit;
     }
     $this->load->view('admin/setting', $this->data);
 }
示例#3
0
文件: art.php 项目: Nnamso/tbox
 function edit($id = null)
 {
     $art = $this->input->post('art');
     // save data
     if (count($art) > 3) {
         $upload = false;
         // upload file
         if (isset($_FILES["file"]["name"]) && $_FILES["file"]["name"] != '') {
             $upload = true;
             // check folder and create
             $this->root = ROOTPATH . DS . 'media' . DS . 'cliparts' . DS . $art['cate_id'];
             if (!file_exists($this->root)) {
                 mkdir($this->root, 0755, TRUE);
             }
             $config['upload_path'] = $this->root . DS . 'print';
             if (!is_dir($config['upload_path'])) {
                 mkdir($config['upload_path'], 0755, TRUE);
             }
             $config['allowed_types'] = 'gif|png|jpg|jpge|svg';
             $config['max_size'] = '5120';
             // 5MB
             $this->load->library('upload', $config);
             if (!$this->upload->do_upload('file')) {
                 $this->session->set_flashdata('error', $this->upload->display_errors());
                 redirect('admin/art');
             }
             $file = $this->upload->data();
             $art['fle_url'] = $art['cate_id'] . '/' . $file['file_name'];
             $art['file_name'] = $file['file_name'];
             $art['file_type'] = str_replace('.', '', $file['file_ext']);
             // get color of image
             $art['colors'] = '0';
             if ($art['file_type'] == 'svg') {
                 $this->load->library('svg');
                 $colors = $this->svg->getColors($file['full_path']);
                 if (count($colors)) {
                     $art['colors'] = json_encode($colors);
                 }
             }
         }
         //echo '<pre>';print_r($art); echo '</pre>'; exit;
         if (!isset($art['change_color'])) {
             $art['change_color'] = '0';
         }
         if ($art['slug'] == '') {
             $art['slug'] = $art['title'];
         }
         $art['slug'] = url_title($art['slug']);
         if ($art['fle_url'] != '' && $art['file_name'] != '' && $art['file_type'] != '') {
             $clipart_id = $this->input->post('clipart_id');
             if ($clipart_id > 0) {
                 $clipart_id = $this->art_m->save($art, $clipart_id);
             } else {
                 $clipart_id = $this->art_m->save($art, NULL);
             }
         }
         if ($clipart_id > 0) {
             // create thumb
             if ($upload == true) {
                 $this->load->library('thumb');
                 $this->thumb->file = $file['full_path'];
                 $thumbs = $this->root . DS . 'thumbs';
                 if (!is_dir($thumbs)) {
                     mkdir($thumbs, 0755, TRUE);
                 }
                 $this->thumb->resize($thumbs . DS . md5($clipart_id), array('width' => 100, 'height' => 100));
                 $medium = $this->root . DS . 'medium';
                 if (!is_dir($medium)) {
                     mkdir($medium, 0755, TRUE);
                 }
                 $this->thumb->resize($medium . DS . md5($clipart_id . 'medium'), array('width' => 300, 'height' => 300));
                 $large = $this->root . DS . 'large';
                 if (!is_dir($large)) {
                     mkdir($large, 0755, TRUE);
                 }
                 $this->thumb->resize($large . DS . md5($clipart_id . 'large'), array('width' => 800, 'height' => 800));
             }
         }
         redirect('admin/art');
     } else {
         // get data edit
         $data = array();
         // add and edit clipart
         $this->load->model('categories_m');
         $categories = $this->categories_m->getCategories('clipart');
         if (count($categories) > 0) {
             $categories = categoriesToTree($categories);
             $data['categories'] = $categories;
         } else {
             $data['categories'] = array();
         }
         // add new
         if ($id == null) {
             $data['title'] = lang('art_add');
             $art = $this->art_m->getNew();
             $art->category = $this->input->get('cate_id');
             $art->tags = '';
             $data['art'] = $art;
         } else {
             $data['title'] = lang('art_edit');
             $cate_id = $this->input->get('cate_id');
             $data['art'] = new stdclass();
             if ($cate_id > 0) {
                 $this->load->model('categories_m');
                 $category = $this->categories_m->getCategory('clipart', $cate_id);
             }
             $art = $this->art_m->getArt($id);
             $art->category = $category;
             $data['art'] = $art;
         }
     }
     $this->load->view('admin/clipart/edit', $data);
 }
示例#4
0
文件: custom.php 项目: Nnamso/tbox
 public function delCategory($id = '')
 {
     $this->load->model('categories_m');
     if ($id != '') {
         $categories = $this->categories_m->getAllCategories('article');
         $categories = categoriesToTree($categories, $id);
         $categories = getChildCate($categories);
         $data['parent_id'] = 0;
         if ($this->categories_m->delete($id)) {
             $this->session->set_flashdata('msg', lang('custom_category_delete_success_msg'));
             // update parent_id.
             foreach ($categories as $cate_id) {
                 $this->categories_m->save($data, $cate_id);
             }
         } else {
             $this->session->set_flashdata('error', lang('custom_category_delete_error_msg'));
         }
     } else {
         if ($checkb = $this->input->post('checkb')) {
             if (is_array($checkb)) {
                 $categories = $this->categories_m->getAllCategories('article');
                 $data['parent_id'] = 0;
                 foreach ($checkb as $id) {
                     if ($this->categories_m->delete($id)) {
                         $categories = categoriesToTree($categories, $id);
                         $categories = getChildCate($categories);
                         // update parent_id.
                         foreach ($categories as $cate_id) {
                             $this->categories_m->save($data, $cate_id);
                         }
                         $this->session->set_flashdata('msg', lang('custom_category_delete_success_msg'));
                     } else {
                         $this->session->set_flashdata('error', lang('custom_category_delete_some_error_msg'));
                         break;
                     }
                 }
             }
         }
     }
     redirect(site_url() . 'admin/custom/categories');
 }
示例#5
0
 public function delete($type = '', $id = null)
 {
     if ($id == null) {
         $type = $this->uri->segment(5);
         $id = $this->uri->segment(6);
     }
     $this->categories_m->_primary_key = 'id';
     $this->categories_m->_table_name = 'categories';
     if ($this->categories_m->delete($id)) {
         //udpate children cate.
         $categories = $this->categories_m->getAllCategories('article');
         $categories = categoriesToTree($categories, $id);
         $categories = getChildCate($categories);
         $data['parent_id'] = 0;
         // update parent_id.
         foreach ($categories as $cate_id) {
             $this->categories_m->save($data, $cate_id);
         }
     }
 }