public function index($pid) { if (!is_numeric($pid)) { show_404(); } $production = $this->production_service->get_production_by_id($pid); if (empty($production)) { show_404(); } $production['pic_thumb'] = Common::get_thumb_url($production['pic'], 'thumb2_'); if (isset($this->user['id'])) { $production['like_status'] = $this->production_service->check_has_like($pid, $this->user['id']); } else { $production['like_status'] = 0; } $body['production'] = $production; $uid = isset($this->user['id']) ? $this->user['id'] : NULL; //获取相关联的专题 //$data['topic'] = $this->production_service->get_topic_by_production($pid,$uid); $data['css'] = array('font-awesome/css/font-awesome.min.css', 'base.css', 'alert.css'); $data['javascript'] = array('jquery.js', 'alert.min.js', 'masonry.pkgd.min.js', 'jquery.imageloader.js', 'error.js', 'validate.js', 'zoomtoo.js', 'zoom.js'); $user['user'] = $this->user; $data['title'] = $production['name']; $body['top'] = $this->load->view('common/top', $user, TRUE); $body['sign'] = $this->load->view('common/sign', '', TRUE); $body['footer'] = $this->load->view('common/footer', '', TRUE); $body['user'] = $this->user; $this->load->view('common/head', $data); $this->load->view('production_detail', $body); }
/** * [get_artist_production 获取艺术家作品列表] * @param [type] $page [description] * @param [type] $aid [description] * @return [type] [description] */ public function get_artist_production($page, $aid) { $production = $this->production_model->get_production_list($page, NULL, NULL, $aid); foreach ($production as $k => $v) { $production[$k]['pic'] = Common::get_thumb_url($production[$k]['pic']); } return $production; }
/** * [get_production_like_list 获取艺术品收藏列表] * @param [type] $page [页数] * @param [type] $uid [用户id] * @return [type] [description] */ public function get_production_like_list($page, $uid) { $like = $this->production_like_model->get_like_list($page, $uid); foreach ($like as $k => $v) { $production = $this->production_model->get_production_by_id($v['pid']); //获取艺术品详情 if (!empty($production)) { $production['pic'] = Common::get_thumb_url($production['pic']); unset($production['creat_by']); unset($production['modify_by']); unset($production['modify_time']); unset($like[$k]['pid']); $like[$k]['production'] = $production; } else { unset($like[$k]); } } return $like; }
/** * [enter_index 进入主页] * @return [type] [description] */ public function enter_index() { //专题 $latest_topic = $this->article_model->get_article_list(0, NULL, NULL, 2); foreach ($latest_topic as $key => $value) { //对每篇文章内容进行字数截取 $latest_topic[$key]['content'] = Common::extract_article($latest_topic[$key]['id'], $latest_topic[$key]['title'], $latest_topic[$key]['content']); $latest_topic[$key]['content']['article_bigimage'] = str_replace('thumb1_', 'thumb2_', $latest_topic[$key]['content']['article_image']); //对文章标题字数截取 $latest_topic[$key]['content']["sort_title"] = mb_strlen($latest_topic[$key]['content']["article_title"]) > 9 ? mb_substr($latest_topic[$key]['content']["article_title"], 0, 9) . '..' : $latest_topic[$key]['content']["article_title"]; unset($latest_topic[$key]['id']); unset($latest_topic[$key]['title']); } //艺术品 $latest_production = $this->production_model->get_production_list(); //获取艺术品类型信息 $this->load->model('production_type_model'); $production_type = $this->production_type_model->get_type_arr(); foreach ($latest_production as $k => $v) { //显示缩略图 $latest_production[$k]['pic'] = Common::get_thumb_url($v['pic']); $latest_production[$k]['bigpic'] = $v['pic']; $latest_production[$k]['intro'] = Common::extract_content($latest_production[$k]['intro']); //获取艺术家信息 if (!empty($v['aid'])) { $latest_production[$k]['artist'] = $this->artist_model->get_artist_base_id($v['aid']); } else { $latest_production[$k]['artist'] = NULL; } unset($latest_production[$k]['aid']); //艺术品信息 if (!empty($v['type'])) { $latest_production[$k]['type_name'] = isset($production_type[$v['type']]) ? $production_type[$v['type']] : ""; } } //$latest_artist = $this->artist_model->get_artist_list(0,6,'id DESC'); $slider = $this->slider_model->get_slider_list(); $result = array('topic' => $latest_topic, 'production' => $latest_production, 'slider' => $slider); return $result; }
private function _delete_oss_pic($pic) { try { $this->load->library('oss'); //删除原图 $arr = explode('/', $pic); //$count = count($arr); unset($arr[0]); unset($arr[1]); unset($arr[2]); $pic = implode('/', $arr); $this->oss->delete_object($pic); //删除缩略图 $toFile = Common::get_thumb_url($pic, 'thumb1_'); $toFile1 = Common::get_thumb_url($pic, 'thumb2_'); $this->oss->delete_object($toFile); $this->oss->delete_object($toFile1); return TRUE; } catch (Exception $e) { return FALSE; } }
/** * [_get_all_good_list 获取用户的所有购物车物品] * @param [type] $uid [用户id] * @return [type] [description] */ private function _get_all_good_list($uid) { $goods = $this->cart_model->get_good_list_by_uid($uid); foreach ($goods as $k => $v) { //获取物品详情 $p = $this->production_model->get_production_by_id($goods[$k]['pid']); $p['pic'] = Common::get_thumb_url($p['pic']); unset($goods[$k]['pid']); unset($goods[$k]['uid']); $goods[$k]['production'] = $p; $this->load->model('artist_model'); if (!empty($p['aid'])) { $goods[$k]['artist'] = $this->artist_model->get_artist_base_id($p['aid']); } else { $goods[$k]['artist'] = NULL; } } return $goods; }
/** * [upload_production 上传图片(保存缩略图与原图)] * @param [type] $form_name [description] * @param [type] $uid [description] * @return [type] [description] */ public function upload_production($form_name, $uid) { $config['upload_path'] = './public/production/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '5000'; $config['remove_spaces'] = TRUE; if (isset($_FILES[$form_name])) { $imgname = $this->security->sanitize_filename($_FILES[$form_name]["name"]); //获取上传的文件名称 $filetype = pathinfo($imgname, PATHINFO_EXTENSION); //获取后缀 $config['file_name'] = time() . "_{$uid}." . $filetype; //图片新路径 $pic_path = substr($config['upload_path'], 2) . $config['file_name']; $this->load->library('upload', $config); $upload_result = $this->upload->do_upload($form_name); //判断宽高是否超出限制 $src_w = $this->upload->data('image_width'); $src_h = $this->upload->data('image_height'); /* if($src_w < 600) { @unlink("./{$pic_path}"); $result['error'] = lang('error_OVER_SIZE'); return $result; } */ //最小宽 $min_width = 300; $min_width1 = 600; $min_height = $src_h * ($min_width / $src_w); $min_height1 = $src_h * ($min_width1 / $src_w); //上传成功 if ($upload_result) { /** * [生成缩略图] * $tofile [缩略图本地保存路径] * $osspath[原图本地保存路径] */ $toFile = Common::get_thumb_url($pic_path, 'thumb1_'); $toFile1 = Common::get_thumb_url($pic_path, 'thumb2_'); $thumb_result = $this->cimage->img2thumb("./{$pic_path}", "./{$toFile}", $min_width, $min_height, 1); $thumb_result1 = $this->cimage->img2thumb("./{$pic_path}", "./{$toFile1}", $min_width1, $min_height1, 1); //生成缩略图成功 if ($thumb_result && $thumb_result1) { //上传缩略图到oss $oss_result = $this->oss->upload_by_file($toFile); $oss_result1 = $this->oss->upload_by_file($toFile1); //缩略图上传成功 if ($oss_result && $oss_result1) { /** * [上传原图到oss] * $oss_result [type] */ $oss_result = $this->oss->upload_by_file($pic_path); //设置上传结果 $result = $oss_result; //上传原图成功 if ($oss_result) { //设置图片url $result = array(); $result['success'] = 0; $result['pic'] = OSS_URL . "/{$pic_path}"; $result['thumb'] = OSS_URL . "/{$toFile1}"; } else { //删除oss上缩略图 $this->oss->delete_object($toFile); $this->oss->delete_object($toFile1); } } //删除本地缩略图 @unlink($toFile); @unlink($toFile1); } else { $result['error'] = lang('error_INVALID_REQUEST'); } //删除原图 @unlink("./{$pic_path}"); } else { $result = array(); $result['error'] = $this->upload->display_errors(); } } else { $result = array(); $result['error'] = lang('error_INVALID_REQUEST'); } return $result; }