/** * @param int $id 图片ID * @param int $c_p 页数,默认使用0,根据其进行排序 */ public function picture($id = 0, $c_p = 0) { $id = intval($id); $c_p = intval($c_p); $n = func_num_args(); if ($n < 1 || $n > 2 || $c_p < 0 || $id < 1) { $this->__load_404(); return; } $this->__lib('Picture', 'PictureComment'); $pic = new Picture(); $info = $pic->get_pic($id); if (!is_array($info)) { $this->__load_404(); } else { $this->theme->setTitle("第 {$info['pic_id']} 号图片"); $this->__view("Home/header.php"); $this->__view("Show/picture.php", ['info' => $info, 'CommentData' => new PictureComment($info['pic_id'], $c_p, $info)]); $this->__view("Home/footer.php"); } }
/** * 获取当前设置的图集信息 * @return array */ private function get() { $where = ['gallery.id' => $this->gallery_id]; if ($this->user_id !== NULL) { $where = ['AND' => ['gallery.id' => $this->gallery_id, 'gallery.users_id' => intval($this->user_id)]]; } $this->info = $this->db->select("gallery", ['[><]users' => ['users_id' => 'id'], '[>]users_like_gallery' => ['id' => 'gallery_id', '______' => ['users_like_gallery.users_id' => is_login() ? login_user()->getId() : 0]]], ['users.user_name' => 'user_name', 'users.user_url' => 'user_url', 'users.user_aliases' => 'user_aliases', 'users.user_status' => 'user_status', 'users.user_avatar' => 'user_avatar', 'gallery.id' => 'gallery_id', 'gallery.users_id' => 'user_id', 'gallery.gallery_title' => 'gallery_title', 'gallery.gallery_description' => 'gallery_description', 'gallery.gallery_create_time' => 'gallery_create_time', 'gallery.gallery_like_count' => 'gallery_like_count', 'gallery.gallery_update_time' => 'gallery_update_time', 'gallery.gallery_comment_count' => 'gallery_comment_count', 'gallery.gallery_comment_status' => 'gallery_comment_status', 'gallery.gallery_front_cover' => 'gallery_front_cover', 'gallery.gallery_status' => 'gallery_status', 'users_like_gallery.like_time' => 'gallery_like_time'], $where); if (!isset($this->info[0])) { $this->info = NULL; $this->error = _('Gallery not found.'); } else { lib()->load('Avatar', 'User'); $this->info = $this->info[0]; $this->info['user_avatar'] = Avatar::get($this->info['user_avatar'], User::getUser($this->info['user_id'])); $this->info['gallery_tags'] = $this->getTags($this->gallery_id); $this->info['gallery_pictures'] = $this->getPictures($this->gallery_id); $front_cover = intval($this->info['gallery_front_cover']); if ($front_cover > 0) { lib()->load('Picture'); $pic = new Picture(); $this->info['front_cover'] = $pic->get_pic($front_cover); } } return $this->info; }
/** * 获取某一图片的详细信息 */ public function picture_url() { try { $req = req()->_plain(); $this->throwMsgCheck('is_get', 'is_login'); $this->__lib("Picture"); $pic = new Picture(); $this->rt_msg['content'] = $pic->get_pic($req->get('id')); $this->rt_msg['status'] = true; } catch (\Exception $ex) { $this->rt_msg['msg'] = $ex->getMessage(); $this->rt_msg['code'] = $ex->getCode(); } }