public function edit_pic() { lib()->load('Picture'); $pic = new Picture(); $list = $pic->get(req()->get('id'), login_user()->getId()); $this->theme->setBreadcrumb("编辑图片"); $this->theme->setTitle("编辑图片"); $this->__view("User/header.php"); $this->__view("Photo/edit_pic.php", ['list' => isset($list[0]) ? $list : [$list]]); $this->__view("User/footer.php"); }
/** * 设置图集封面ID * @param int $g_id * @param int $p_id 为0时置空 * @param int $u_id * @return array|null */ public function set_front_cover($g_id, $p_id, $u_id) { $g_id = intval($g_id); $p_id = intval($p_id); $u_id = intval($u_id); $this->galleryOwnerCheck($g_id, $u_id); lib()->load('Picture'); if ($p_id < 1) { $p_id = NULL; $this->db->update("gallery", ['gallery_front_cover' => $p_id], ['id' => $g_id]); return NULL; } else { $p = new Picture(); $p->picOwnerCheck($p_id, $u_id); $this->db->update("gallery", ['gallery_front_cover' => $p_id], ['id' => $g_id]); return $p->get($p_id, $u_id); } }
/** * 图片上传 */ public function picture_upload() { try { $this->ajax = true; $req = req()->_plain(); $this->throwMsgCheck('is_post', 'is_login', 'is_active'); $this->__lib('Picture', 'Server'); $pic = new Picture(); $server = new Server(); $this->rt_msg['content'] = $pic->add($req->post('name'), $req->post('tag'), $req->post('desc'), @$_FILES['files'], $server->getNowServer(), login_user()); $this->rt_msg['status'] = count($this->rt_msg['content']['list']) > 0; if ($this->rt_msg['status'] && $req->post('get_msg') == 1) { $this->rt_msg['content']['msg'] = $pic->get(join(',', $this->rt_msg['content']['list']), login_user()->getId()); } } catch (\Exception $ex) { $this->rt_msg['msg'] = $ex->getMessage(); $this->rt_msg['code'] = $ex->getCode(); } }