Ejemplo n.º 1
0
 protected function _newDirData($list, $uid)
 {
     if ($list && is_array($list)) {
         foreach ($list as $key => $value) {
             $dir_id = $value['id'];
             //上传文件链接
             $list[$key]['upload_file_url'] = url("myweb", "photo::photolist", "upload_{$dir_id}");
             //删除文件夹链接
             $list[$key]['del_dir_url'] = url("myweb", "photo::deldir", "del_{$dir_id}");
             $first_src = UploadFile::getUploadFileTitleByDirId($dir_id, $uid);
             if ($first_src) {
                 //设置了封面
                 $first_src = $first_src[0];
                 $cache_dir = '/temp/photo/' . $first_src['uid'] . '/' . $first_src['type_id'] . '/' . $first_src['dir_id'] . '/';
                 $file_path = $cache_dir . md5($first_src['upload_path']) . '.' . $first_src['file_type'];
                 if (!is_file(ROOT_PATH . $file_path)) {
                     PhotoM::cachePhoto($cache_dir, $first_src['upload_path'], $first_src['file_type']);
                 }
                 $list[$key]['photo_first_photo_src'] = $file_path;
             } else {
                 //没有设置封面,默认为第一张
                 $list2 = UploadFile::getUploadFileByDirId($dir_id, $uid);
                 if ($list2) {
                     $list2 = $list2[0];
                     $cache_dir = '/temp/photo/' . '/' . $list2['uid'] . '/' . $list2['type_id'] . '/' . $list2['dir_id'] . '/';
                     $file_path2 = $cache_dir . md5($list2['upload_path']) . '.' . $list2['file_type'];
                     if (!is_file(ROOT_PATH . $file_path2)) {
                         PhotoM::cachePhoto($cache_dir, $list2['upload_path'], $list2['file_type']);
                     }
                     $list[$key]['photo_first_photo_src'] = $file_path2;
                 } else {
                     $list[$key]['photo_first_photo_src'] = '';
                 }
             }
         }
     }
     return $list;
 }
Ejemplo n.º 2
0
 protected function _newFileData($list)
 {
     if ($list && is_array($list)) {
         //缓存图片开始
         headerCache();
         //缓存图片结束
         foreach ($list as $key => $value) {
             $id = $value['id'];
             //缓存上传的图片(缩放后的图片)
             $cache_dir = '/temp/photo/' . $value['uid'] . '/' . $value['type_id'] . '/' . $value['dir_id'] . '/';
             $file_path = $cache_dir . md5($value['upload_path']) . '.' . $value['file_type'];
             if (!is_file(ROOT_PATH . $file_path)) {
                 PhotoM::cachePhoto($cache_dir, $value['upload_path'], $value['file_type']);
             }
             $list[$key]['upload_path'] = $file_path;
             $list[$key]['del_file_url'] = url("myweb", "photo::del", "dfile_" . $value['dir_id'] . "_" . $id);
         }
     }
     return $list;
 }