Esempio n. 1
0
 public function index()
 {
     //header('content-type:text/html;charset=utf-8');
     $userId = $_SESSION['qq']['userId'];
     $collect = new CollectModel();
     //查询收藏
     $user_collect = $collect->getCollectByuserId($userId);
     $article = new ArticleModel();
     $arr = array();
     foreach ($user_collect as $v) {
         //根据收藏的文章id查询文章
         $a = $article->getArticleById($v['articleId']);
         //取出admin的昵称
         $a['adminName'] = $this->getAdmin($a['adminId']);
         $arr[] = $a;
     }
     $comment = new CommentModel();
     $commentAlbum = $comment->getCommentByAlbum($userId);
     $album = new AlbumModel();
     $articles = array();
     $albums = array();
     foreach ($commentAlbum as $v) {
         if ($v['albumId'] != null) {
             $c = $album->getAlbumById($v['albumId']);
             $c['adminName'] = $this->getAdmin($v['adminId']);
             $albums[] = $c;
         }
     }
     $commentArticle = $comment->getCommentByArticle($userId);
     foreach ($commentArticle as $v) {
         if ($v['articleId'] != null) {
             $a = $article->getArticleById($v['articleId']);
             $a['adminName'] = $this->getAdmin($v['adminId']);
             $articles[] = $a;
         }
     }
     var_dump($albums);
     $this->assign('user', $_SESSION['qq']['userName']);
     //评论过的相册
     $this->assign('albums', $albums);
     //评论过的文章
     $this->assign('articles', $articles);
     //收藏
     $this->assign('user_collect', $arr);
     $this->display();
 }
Esempio n. 2
0
 public function addalbumComment()
 {
     if (!$_SESSION['qq']) {
         $result['code'] = '021';
         $result['message'] = '未登录,请登录账号!';
     } else {
         //实例化model
         $commentModel = new CommentModel();
         $albumModel = new AlbumModel();
         $albumId = $_GET['albumId'];
         $content = $_GET['comment'];
         //根据相册id查询相册信息
         $albumInfo = $albumModel->getAlbumById($albumId);
         $data = array('userId' => $_SESSION['qq']['userId'], 'albumId' => $albumId, 'content' => $content, 'adminId' => $albumInfo['adminId']);
         $commentId = $commentModel->addComment($data);
         if ($commentId) {
             $commentInfo = $commentModel->getCommentById($commentId);
             $result['code'] = '0';
             $result['message'] = '恭喜,评论成功!';
             $result['info'] = $commentInfo;
         } else {
             $result['code'] = '022';
             $result['message'] = '抱歉,评论失败!';
         }
     }
     echo json_encode($result);
     exit;
 }
Esempio n. 3
0
 public function photoUpdate()
 {
     $albumId = $_GET['albumId'];
     $photo = new PhotosModel();
     $photos = $photo->getPhotos($albumId);
     $album = new AlbumModel();
     $albums = $album->getAlbumById($albumId);
     //var_dump($_POST);
     if ($_POST) {
         $arr = array();
         foreach ($_POST['photo_description'] as $k => $v) {
             $newk = trim($k, "'");
             //echo $newk;
             $arr['fileName'] = $newk;
             $arr['description'] = $v;
             $data = $photo->getPhotosByFileName($newk);
             //var_dump($arr);
             if (!empty($data)) {
                 $row = $photo->updatePhotos($data['photoId'], $arr);
             } else {
                 $arr['fileName'] = '/asset/upload/' . $arr['fileName'];
                 $arr['albumId'] = $albumId;
                 $row = $photo->addPhotos($arr);
             }
             //$this->row=$row;
         }
         //var_dump($_POST);
         $update = array();
         $update['albumName'] = $_POST['albumName'];
         $update['description'] = $_POST['description'];
         if (isset($_POST['frontCover']) && !empty($_POST['frontCover'])) {
             $update['frontCover'] = $_POST['frontCover'];
         }
         //var_dump($update);
         $rows = $album->updateAlbum($albumId, $update);
         S('相册修改成功');
     }
     $album_photos = array();
     foreach ($photos as $v) {
         if ($albums['frontCover'] == $v['fileName']) {
             $v['frontCover'] = 1;
         } else {
             $v['frontCover'] = 0;
         }
         $album_photos[] = $v;
     }
     //相册的信息
     $this->assign('albums', $albums);
     //该相册下的所有图片
     $this->assign('photos', $album_photos);
     $this->display();
 }
Esempio n. 4
0
 public function albumInfo()
 {
     $blogerId = Data::get($_GET['blogerId'], Data::Int);
     $albumId = Data::get($_GET['albumId'], Data::Int);
     if (!is_int($blogerId) && $blogerId <= 0) {
         R('Index', 'index');
     }
     if (!is_int($albumId) && $albumId <= 0) {
         R('Index', 'index');
     }
     // $blogerId=$_GET['blogerId'];
     // $albumId=$_GET['albumId'];
     $album = new AlbumModel();
     $albums = $album->getAlbumById($albumId);
     $photo = new PhotosModel();
     $photos = $photo->getPhotos($albumId);
     $time = 0;
     foreach ($photos as $v) {
         $addtime = strtotime($v['addTime']);
         if ($time < $addtime) {
             $time = $addtime;
         }
     }
     $time = date("Y-m-d H:i:s", $time);
     $photoCount = $photo->getPhotosCountByAlbumId($albumId);
     $comment = new CommentModel();
     $a = $comment->getCommentByAlbumId($albumId);
     $user = new UserModel();
     $comments = array();
     foreach ($a as $v) {
         $users = $v;
         $users['user'] = $user->getUserById($v['userId']);
         $comments[] = $users;
     }
     //博主个人信息
     $blogerInfo = $this->getBlogerInfo($blogerId);
     $this->assign('blogerInfo', $blogerInfo);
     //某博主信息
     $count = $this->articleCount($blogerId);
     $this->assign('count', $count);
     //某博主文章总数
     //获取所有文章标签
     $allTags = $this->getAllTags();
     $this->assign("allTags", $allTags);
     //所有文章标签
     //获取所有文章分类
     $allTypes = $this->getAllTypes($blogerId);
     $this->assign("allTypes", $allTypes);
     //某人所有文章分类
     $latestComments = $this->getLatestComments($blogerId, '0,3');
     $this->assign('latestComments', $latestComments);
     //最新三条评论
     //用户个人信息
     $allUserInfo = $this->getAllUserInfo();
     $this->assign('allUserInfo', $allUserInfo);
     //某用户信息
     //该相册下的所有评论
     $this->assign('comments', $comments);
     //该相册下的所有相片
     $this->assign('photos', $photos);
     //相片最后的添加时间
     $this->assign('time', $time);
     //相册的相片数
     $this->assign('photoCount', $photoCount);
     //相册的部分信息
     $this->assign('album', $albums);
     $this->display();
 }