Пример #1
0
 public function photoCreat2()
 {
     $errors = $this->errors;
     $flag = array();
     //实例化Model
     $albumModel = new AlbumModel();
     $photosModel = new PhotosModel();
     $commentModel = new CommentModel();
     if ($_POST) {
         $pdata = $_POST;
         //新建相册
         if (isset($pdata['albumName']) && $pdata['albumName'] != NULL) {
             $data['adminId'] = $_SESSION['admin']['adminId'];
             $data['addTime'] = date('Y-m-d H:i:s');
             $data['albumName'] = $pdata['albumName'];
             $data['description'] = $pdata['description'];
             $albumId = $albumModel->addAlbum($data);
             if (!$albumId) {
                 $flag[0] = '相册添加失败';
             }
         } else {
             if (isset($pdata['albumId']) && $pdata['albumId']) {
                 $albumId = $pdata['albumId'];
             } else {
                 $flag[1] = '未选择相册,也未新建相册';
             }
         }
         if ($albumId) {
             //设置封面
             if (isset($pdata['frontCover']) && $pdata['frontCover']) {
                 $row = $albumModel->updateAlbum($albumId, array('frontCover' => $pdata['frontCover']));
                 if (!$row) {
                     $flag[2] = '设置封面失败';
                 }
             } else {
                 $pdata['frontCover'] = '/asset/upload/' . $pdata['fileName'][0];
                 $row = $albumModel->updateAlbum($albumId, array('frontCover' => $pdata['frontCover']));
                 if (!$row) {
                     $flag[2] = '设置封面失败';
                 }
             }
             //添加照片
             if (isset($pdata['fileName']) && $pdata['fileName']) {
                 foreach ($pdata['fileName'] as $key => $value) {
                     $arr['albumId'] = $albumId;
                     $arr['fileName'] = '/asset/upload/' . $value;
                     $arr['description'] = $pdata['photo_description'][$value];
                     $result = $photosModel->addPhotos($arr);
                     if (!$result) {
                         $flag['photo'][] = '相片添加失败';
                     }
                 }
             }
         }
         if ($flag) {
             echo "<pre>";
             var_dump($flag);
             echo "</pre>";
             exit;
             E('相片上传失败');
         } else {
             S('成功', U('Index', 'albumInfo', array('albumId' => $albumId)));
         }
     }
     //某博主的所有相册
     $albums = $albumModel->getAlbumByAdminId($_SESSION['admin']['adminId']);
     //var_dump($albums);exit;
     $photos = $photosModel->getPhotos($albums[0]['albumId']);
     $this->assign('photos', $photos);
     $this->assign('albums', $albums);
     $this->display();
 }
Пример #2
0
 public function albumlist()
 {
     //获取博主Id
     $_GET['blogerId'] = 1;
     //测试
     $blogerId = Data::get($_GET['blogerId'], Data::Int);
     //$blogerId =1;//测试
     if (!isset($_GET['blogerId']) || empty($blogerId)) {
         R('Index', 'index');
     }
     //实例化Model
     $photoModel = new PhotosModel();
     $albumModel = new AlbumModel();
     $userModel = new UserModel();
     $commentModel = new CommentModel();
     $articleTagModel = new ArticleTagModel();
     $articletypeModel = new ArticleTypeModel();
     //$adminModel = new AdminModel();
     //博主个人信息
     $blogerInfo = $this->getBlogerInfo($blogerId);
     //获取所有文章分类
     //$allTypes = $this->getAllTypes($blogerId);
     //var_dump($allTypes);exit();
     $allTypes = $articletypeModel->getCatrgoryByadminId($blogerId);
     //获取所有文章标签
     $allTags = $articleTagModel->getArticleTag();
     //最新三条评论
     $latestComments = $commentModel->getLatestComments($blogerId, '0,3');
     //用户个人信息
     $allUserInfo = $userModel->getAllUserInfo();
     //根据adminId获取相册
     $albums = $albumModel->getAlbumByAdminId($blogerId);
     //根据adminId获取相册数量
     $count = $albumModel->getAlbumCountByAdminId($blogerId);
     if ($count > $pagesize) {
         $page = new Page($count, $p, $pagesize);
         $str = $page->show('themeuk.php');
     }
     $albumsArr = array();
     foreach ($albums as $key => $value) {
         //根据albumId获取照片的数量
         $value['photocount'] = $photoModel->getPhotosCountByAlbumId($value['albumId']);
         //根据adminId获取相册数量
         $value['albumcount'] = $albumModel->getAlbumCountByAdminId($blogerId);
         //$description = $value['description'];
         //$value['photocount'] = $photos;
         //根据albumid获取相册信息
         $value['albumInfo'] = $albumModel->getAlbumById($value['albumId']);
         //var_dump($albumInfo);exit;
         $albumsArr[$value['photoId']] = $value;
     }
     $this->assign('page', $str);
     $this->assign('albums', $albums);
     $this->assign("allTags", $allTags);
     //所有文章标签
     $this->assign('albumName', $albumName);
     //相册名
     //$this->assign('description',$description);//相册描述
     //$this->assign('albumInfo','');
     $this->assign('allTypes', $allTypes);
     $this->assign("photoId", $value);
     $this->assign('count', $count);
     //相册数量
     $this->assign('blogerInfo', $blogerInfo);
     //博主个人信息
     $this->assign('latestComments', $latestComments);
     //最新三条评论
     $this->assign('allUserInfo', $allUserInfo);
     //某用户信息
     $this->assign("pageTitle", "个人主页");
     $this->display();
 }
Пример #3
0
 public function albumList()
 {
     //测试
     //$_GET['blogerId']=1;
     $blogerId = Data::get($_GET['blogerId'], Data::Int);
     if (!is_int($blogerId) && $blogerId <= 0) {
         R('Index', 'index');
     }
     $album = new AlbumModel();
     $pageSize = 9;
     $count = $album->getAlbumCountByAdminId($blogerId);
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     $pian = ($page - 1) * $pageSize;
     $limit = "{$pian},{$pageSize}";
     $albums = $album->getAlbumByAdminId($blogerId, $limit);
     if ($page < $count) {
         $pager = new Page($count, $page, $pageSize);
         $str = $pager->show('themeuk.php');
     }
     $photo = new PhotosModel();
     $arr = array();
     //var_dump($albums);
     foreach ($albums as $v) {
         //根据相册id查询出所有的相片
         $a = $v;
         $photos = $photo->getPhotos($v['albumId']);
         $addtime = 0;
         //遍历相片
         foreach ($photos as $v) {
             //$row=$photo->getPhotosById($v['photoId']);
             $time = strtotime($v['addTime']);
             if ($addtime < $time) {
                 $addtime = $time;
             }
         }
         $a['time'] = date("Y-m-d H:i:s", $addtime);
         $a['count'] = $photo->getPhotosCountByAlbumId($v['albumId']);
         $arr[] = $a;
         //var_dump($v);
     }
     //var_dump($arr);
     //博主个人信息
     $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('page', $str);
     $this->assign('albums', $arr);
     $this->display();
 }