SaveAlbumThumbSortType($album_data['sharename'], $data); csSYNOPhotoDB::GetDBInstance()->SetSessionCache(true); return $createID; } /** * @param $shareName * @param $params * @return * 0 - success * -1 - general fail * -2 - no manage right * -3 - not admin */ static function SYNOPHOTO_ADMIN_UpdateAlbum($shareName, $params) { // description, title - manage right if ((null !== $params['description'] || null !== $params['title']) && null === $params['sort_by'] && null === $params['sort_direction'] && null === $params['allow_comment'] && null === $params['type'] && null === $params['password'] && null === $params['conversion']) { if (!csSynoPhotoMisc::CheckAlbumManageable(('' === $shareName) ? '/' : $shareName)) { return -2; } // not changed } elseif (null === $params['description'] && null === $params['title'] && null === $params['sort_by'] && null === $params['sort_direction'] && null === $params['allow_comment'] && null === $params['type'] && null === $params['password'] && null === $params['conversion']) { return 0; } else { // title, sort_by, sort_direction, allow_comment, type, password, conversion - admin if (!isset($_SESSION[SYNOPHOTO_ADMIN_USER]['admin_syno_user'])) { return -3; } } if ('' === $shareName) { $shareName = '/'; } $setCondition = array(); $setQueryParam = array(); if (null !== $params['title']) { $setValue = "title = ? "; array_push($setCondition, $setValue); $setQueryParam[] = stripcslashes($params['title']); } if (null !== $params['description']) { $setValue = "description = ?"; array_push($setCondition, $setValue); $setQueryParam[] = stripcslashes($params['description']); } $objs = Album::GetBySharename(array($shareName), true); $share = $objs[$shareName]; if ($share) { $shareid = $share['shareid']; } else { return -1; } if ('public' === $params['type']) { $setValue = "public = 't', password = ''"; array_push($setCondition, $setValue); /* clear access right table if album is public */ PHOTO_DB_Query("DELETE FROM " . PHOTO_ACCESS_RIGHT_TABLE . " WHERE shareid = ".$shareid); } else if ('private' === $params['type']) { $setValue = "public = 'f', password = ''"; array_push($setCondition, $setValue); /* remove all permissions if album is password */ PHOTO_DB_Query("DELETE FROM " . PHOTO_ACCESS_RIGHT_TABLE . " WHERE shareid = ".$shareid); PHOTO_DB_Query("DELETE FROM " . PHOTO_UPLOAD_RIGHT_TABLE . " WHERE shareid = ".$shareid); PHOTO_DB_Query("DELETE FROM " . PHOTO_MANAGE_RIGHT_TABLE . " WHERE shareid = ".$shareid); } else if ('password' === $params['type'] && $params['password'] !== '') { $setValue = "public = 'f',password='".md5($params['password'])."'"; array_push($setCondition, $setValue); /* remove all permissions if album is password */ PHOTO_DB_Query("DeLETE FROM " . PHOTO_ACCESS_RIGHT_TABLE . " WHERE shareid = ".$shareid); PHOTO_DB_Query("DELETE FROM " . PHOTO_UPLOAD_RIGHT_TABLE . " WHERE shareid = ".$shareid); PHOTO_DB_Query("DELETE FROM " . PHOTO_MANAGE_RIGHT_TABLE . " WHERE shareid = ".$shareid); } if (null !== $params['allow_comment']) { if($params['allow_comment'] == 'true') { $setValue = "comment = 't'"; } else { $setValue = "comment = 'f'"; } array_push($setCondition, $setValue); } if (null !== $params['conversion']) { if ($params['conversion'] === 'true' && !$share['conversion']) { $needReindex = true; $setValue = "conversion = 't'"; array_push($setCondition, $setValue); } elseif ($params['conversion'] !=='true' && $share['conversion']) { $setValue = "conversion = 'f'"; array_push($setCondition, $setValue); } } $setString = implode(',', $setCondition); $query = "UPDATE photo_share SET {$setString} WHERE sharename = ?"; $setQueryParam[] = $shareName; $db_result = PHOTO_DB_Query($query, $setQueryParam); //sort $data = array(); if (null !== $params['sort_by']) { $data['type'] = self::ConvertToSortCode($params['sort_by']); } if (null !== $params['sort_direction']) { $data['order'] = self::ConvertToSortDirectionCode($params['sort_direction']); } if ('/' !== $shareName) { csSYNOPhotoAlbum::GetAlbumInstance()->SaveAlbumThumbSortType($shareName, $data); } csSYNOPhotoDB::GetDBInstance()->SetSessionCache(true); if ($needReindex) { @exec("/usr/syno/bin/synoindex -P PhotoStation -R " . escapeshellarg(SYNOPHOTO_SERVICE_REAL_DIR . "/" . $shareName)); } return 0; } static function ConvertToTypeName($type) { switch ($type) { case 0: $typeName = 'album'; break; case 1: $typeName = 'photo'; break; case 2: $typeName = 'video'; break; default: break; } return $typeName; } static function ConvertToSortDirection($value) { switch ($value) { case -1: $sortDirection = 'default'; break; case 0: $sortDirection = 'asc'; break; case 1: $sortDirection = 'desc'; break; default: break; } return $sortDirection; } static function ConvertToSortDirectionCode($name) { switch ($name) { case 'default': $sortCode = -1; break; case 'asc': $sortCode = 0; break; case 'desc': $sortCode = 1; break; default: break; } return $sortCode; } static function ConvertToSortName($type) { switch ($type) { case -1: $sortBy = 'default'; break; case 0: $sortBy = 'filename'; break; case 1: $sortBy = 'takendate'; break; case 2: $sortBy = 'createdate'; break; case 3: $sortBy = 'preference'; break; default: break; } return $sortBy; } static function ConvertToSortCode($name) { switch ($name) { case 'default': $sortCode = -1; break; case 'filename': $sortCode = 0; break; case 'takendate': $sortCode = 1; break; case 'createdate': $sortCode = 2; break; case 'preference': $sortCode = 3; break; default: break; } return $sortCode; } static function FilterByType($items, $type) { $filterItems = array(); foreach ($items as $item) { $typeName = self::ConvertToTypeName($item['itemType']); if (in_array($typeName, $type)) { array_push($filterItems, $item); } } return $filterItems; } static function SortItem($photo_video_items, $sortBy, $sortDirection, $offset, $limit) { $itemsSort = array(); // sort by photo, video if ('filename' === $sortBy) { if ('asc' === $sortDirection) { usort($photo_video_items, 'self::SortFilename_ASC'); } else { usort($photo_video_items, 'self::SortFilename_DESC'); } } elseif ('takendate' === $sortBy) { if ('asc' === $sortDirection) { usort($photo_video_items, 'self::SortTakendate_ASC'); } else { usort($photo_video_items, 'self::SortTakendate_DESC'); } } elseif ('createdate' === $sortBy) { if ('asc' === $sortDirection) { usort($photo_video_items, 'self::SortCreatedate_ASC'); } else { usort($photo_video_items, 'self::SortCreatedate_DESC'); } } if (false === $offset && false === $limit) { return $photo_video_items; } // set offset and limit $cutItemsSort = array(); if (0 > (int)$limit) { $cutItemsSort = array_slice($photo_video_items, $offset); } else { $cutItemsSort = array_slice($photo_video_items, $offset, $limit); } return $cutItemsSort; } private function ExtractItem($items, &$albumItems, &$photo_video_items) { $index = count($items); foreach ($items as $key => $item) { if ('album' !== self::ConvertToTypeName($item['itemType'])) { $index = $key; break; } } $albumItems = array_slice($items, 0, $index); $photo_video_items = array_slice($items, $index); } static function SortFilename_ASC($a, $b) { if ($a['name'] == $b['name']) { return 0; } return ($a['name'] < $b['name']) ? -1 : 1; } static function SortFilename_DESC($a, $b) { if ($a['name'] == $b['name']) { return 0; } return ($a['name'] > $b['name']) ? -1 : 1; } static function SortTakendate_ASC($a, $b) { if ($a['takendate'] == $b['takendate']) { return ($a['name'] < $b['name']) ? -1 : 1; } return ($a['takendate'] < $b['takendate']) ? -1 : 1; } static function SortTakendate_DESC($a, $b) { if ($a['takendate'] == $b['takendate']) { return ($a['name'] > $b['name']) ? -1 : 1; } return ($a['takendate'] > $b['takendate']) ? -1 : 1; } static function SortCreatedate_ASC($a, $b) { if ($a['createdate'] == $b['createdate']) { return ($a['name'] < $b['name']) ? -1 : 1; } return ($a['createdate'] < $b['createdate']) ? -1 : 1; } static function SortCreatedate_DESC($a, $b) { if ($a['createdate'] == $b['createdate']) { return ($a['name'] > $b['name']) ? -1 : 1; } return ($a['createdate'] > $b['createdate']) ? -1 : 1; } static function SortPreference($items, $sharePath) { $sort = csSYNOPhotoAlbum::GetAlbumThumbSortType($sharePath); $list = array(); $result = array(); if (!empty($sort['list'])) { $list = $sort['list']; $preArr = array(); foreach ($list as $key) { foreach ($items as $item) { if ($key === $item['name']) { array_push($result, $item); } } } // rest photo and video item foreach ($items as $item) { if (!in_array($item, $result)) { array_push($result, $item); } } } else { $result = $items; } return $result; } /* * @return [string] broken / small, large */ static function GetThumbStatus($dbPath, $needSize, $orig_resolutionx, $orig_resolutiony, $blThumbRotated, $blConversion) { /* special case for gif, return original file */ $path = SYNOPHOTO_SERVICE_REAL_DIR_PREFIX.$dbPath; $info = pathinfo($path); if ('gif' === strtolower($info['extension'])) { $ret['status'] = 'small,large'; if ($needSize) { $imgInfo = @getImageSize($path); $mtime = @filemtime($path); $ret['size']['preview']['resolutionx'] = $imgInfo[0]; $ret['size']['preview']['resolutiony'] = $imgInfo[1]; $ret['size']['preview']['mtime'] = $mtime; $ret['size']['small']['resolutionx'] = $imgInfo[0]; $ret['size']['small']['resolutiony'] = $imgInfo[1]; $ret['size']['small']['mtime'] = $mtime; $ret['size']['large']['resolutionx'] = $imgInfo[0]; $ret['size']['large']['resolutiony'] = $imgInfo[1]; $ret['size']['large']['mtime'] = $mtime; } return $ret; } if ($needSize) { $ret['size']['preview']['resolutionx'] = 0; $ret['size']['preview']['resolutiony'] = 0; $ret['size']['small']['resolutionx'] = 0; $ret['size']['small']['resolutiony'] = 0; $ret['size']['large']['resolutionx'] = 0; $ret['size']['large']['resolutiony'] = 0; } $file_name = basename($path); $dir = dirname($path); if (SYNOPhotoEA::checkFilePathByDirFile($dir, $file_name, SYNOPhotoEA::FILE_THUMB_M_FAIL, $thumbSmallBroken) && SYNOPhotoEA::checkFilePathByDirFile($dir, $file_name, SYNOPhotoEA::FILE_THUMB_XL_FAIL, $thumbLargeBroken)) { $ret['status'] = 'broken'; } else { $thumbStatus = array(); $hasSmall = $hasLarge = false; if (!$blConversion) { $thumbStatus[] = 'disable'; } if (SYNOPhotoEA::checkFilePathByDirFile($dir, $file_name, SYNOPhotoEA::FILE_THUMB_M, $thumbSmallPath)) { $hasSmall = true; if ($needSize) { $ret['size']['small'] = self::CalculateThumbSize($orig_resolutionx, $orig_resolutiony, $blThumbRotated, SYNOPHOTO_THUMBMEDIUM_WIDTH); $ret['size']['small']['mtime'] = @filemtime($thumbSmallPath); } } if (SYNOPhotoEA::checkFilePathByDirFile($dir, $file_name, SYNOPhotoEA::FILE_THUMB_PREVIEW, $thumbPreviewPath)) { $thumbStatus[] = 'preview'; if ($needSize) { if ($hasSmall) { $ret['size']['preview'] = self::CalculateThumbSize($orig_resolutionx, $orig_resolutiony, $blThumbRotated, SYNOPHOTO_THUMBPREVIEW_WIDTH); } else { $ret['size']['preview'] = self::GetThumbSize($path, $thumbPreviewPath); } $ret['size']['preview']['mtime'] = @filemtime($thumbPreviewPath); } //use preview-thumb as small-thumb in thumbnail-less browsing if (!$blConversion && !$hasSmall) { $hasSmall = true; if ($needSize) { $ret['size']['small'] = $ret['size']['preview']; $ret['size']['small']['mtime'] = $ret['size']['preview']['mtime']; } } } if (SYNOPhotoEA::checkFilePathByDirFile($dir, $file_name, SYNOPhotoEA::FILE_THUMB_XL, $thumbLargePath)) { $hasLarge = true; if ($needSize) { $ret['size']['large'] = self::CalculateThumbSize($orig_resolutionx, $orig_resolutiony, $blThumbRotated, SYNOPHOTO_THUMBXLARGE_WIDTH); $ret['size']['large']['mtime'] = @filemtime($thumbLargePath); } } if (!$hasLarge && SYNOPhotoEA::checkFilePathByDirFile($dir, $file_name, SYNOPhotoEA::FILE_THUMB_LARGE_PREVIEW, $thumbLargePreviewPath)) { $thumbStatus[] = 'large'; if ($needSize) { $ret['size']['large'] = self::GetThumbSize($path, $thumbLargePreviewPath); $ret['size']['large']['mtime'] = @filemtime($thumbLargePreviewPath); } } //use original file as large thumb in thumbnail-less browsing if (!$blConversion && !$hasLarge && in_array(strtolower($info['extension']), array('jpeg', 'bmp', 'png', 'jpg', 'jpe'/*, 'image/tiff'*/))) { $hasLarge = true; if ($needSize) { $ret['size']['large']['resolutionx'] = $orig_resolutionx; $ret['size']['large']['resolutiony'] = $orig_resolutiony; $ret['size']['large']['mtime'] = @filemtime($path); } $thumbStatus[] = "large_original"; } if ($hasSmall) { $thumbStatus[] = 'small'; } if ($hasLarge) { $thumbStatus[] = 'large'; } $ret['status'] = implode(',', $thumbStatus); } return $ret; } static function CalculateThumbSize($orig_resolutionx, $orig_resolutiony, $blThumbRotated, $thumbSize) { $thumb['resolutionx'] = $thumb['resolutiony'] = 0; if (0 >= $orig_resolutionx || 0 >= $orig_resolutiony || 0 >= $thumbSize) { goto End; } $ratio = $orig_resolutionx / $orig_resolutiony; if (0 >= $ratio) { goto End; } $thumb['resolutionx'] = $orig_resolutionx; $thumb['resolutiony'] = $orig_resolutiony; if ($thumbSize < $orig_resolutionx && $thumbSize < $orig_resolutiony) { if ($orig_resolutionx >= $orig_resolutiony) { $thumb['resolutionx'] = ceil($thumbSize * $ratio); $thumb['resolutiony'] = $thumbSize; } else { $thumb['resolutionx'] = $thumbSize; $thumb['resolutiony'] = ceil($thumbSize / $ratio); } } if ($blThumbRotated) { $tmp = $thumb['resolutionx']; $thumb['resolutionx'] = $thumb['resolutiony']; $thumb['resolutiony'] = $tmp; } End: return $thumb; } static function GetThumbSize($imgPath, $thumbPath) { $thumbInfo = @getImageSize($thumbPath); $ret = array( 'resolutionx' => $thumbInfo[0], 'resolutiony' => $thumbInfo[1] ); $info = pathinfo($imgPath); if (!in_array(strtolower($info['extension']), array('jpeg', 'bmp', 'png', 'jpg', 'jpe'/*, 'image/tiff'*/))) { goto END; } $imgInfo = @getImageSize($imgPath); $rotated = ($thumbInfo[0] > $thumbInfo[1] && $imgInfo[0] <= $imgInfo[1]) || ($thumbInfo[0] <= $thumbInfo[1] && $imgInfo[0] > $imgInfo[1]); if ($rotated && $thumbInfo[0] > $imgInfo[1]) { $ret['resolutionx'] = $imgInfo[1]; $ret['resolutiony'] = $imgInfo[0]; } else if (!$rotated && $thumbInfo[0] > $imgInfo[0]) { $ret['resolutionx'] = $imgInfo[0]; $ret['resolutiony'] = $imgInfo[1]; } END: return $ret; } static function FillThumbStatus(&$item, $coverDBPath, $needThumbSize, $orig_resolutionx, $orig_resolutiony, $blThumbRotated, $blConversion) { if ('' !== $coverDBPath) { $thumbnail = self::GetThumbStatus($coverDBPath, $needThumbSize, $orig_resolutionx, $orig_resolutiony, $blThumbRotated, $blConversion); } else { $thumbnail = array('status' => 'default'); if (!$blConversion) { $thumbnail['status'] .= ',disable'; } if ($needThumbSize) { $thumbnail['size'] = array( 'preview' => array('resolutionx' => 0, 'resolutiony' => 0), 'small' => array('resolutionx' => 0, 'resolutiony' => 0), 'large' => array('resolutionx' => 0, 'resolutiony' => 0) ); } } $item['thumbnail_status'] = $thumbnail['status']; if ($needThumbSize) { if (!is_array($item['additional'])) { $item['additional'] = array(); } $item['additional']['thumb_size'] = $thumbnail['size']; $item['additional']['thumb_size']['sig'] = bin2hex($coverDBPath); } } static function GetCoverResolutionRotation($coverPath) { if ('' === $coverPath) { return array(0, 0, false); } $file = csSYNOPhotoMisc::IsPhotoFile($coverPath) ? File::GetPhotoByDBPath(array($coverPath)) : File::GetVideoByDBPath(array($coverPath)); $info = $file[$coverPath]; return array((int)$info['resolutionx'], (int)$info['resolutiony'], 0 !== (int)$info['version'] % 2); } static function GetAlbumPermission($sharePath) { $permission['browse'] = csSYNOPhotoMisc::CheckAlbumAccessible($sharePath); $permission['upload'] = csSYNOPhotoMisc::CheckAlbumUploadable($sharePath); $permission['manage'] = csSYNOPhotoMisc::CheckAlbumManageable($sharePath); return $permission; } static function GetUnConfirmItemList($limit=false, $offset=false) { $result = array(); $limitOffsetString = PHOTO_DB_GetLimitOffsetString($limit, $offset); $query = "SELECT photo_image.path FROM photo_image_label LEFT JOIN photo_image ON photo_image_label.image_id=photo_image.id WHERE status='f'"; $queryCount = "SELECT COUNT(DISTINCT photo_image.path) FROM photo_image_label LEFT JOIN photo_image ON photo_image_label.image_id=photo_image.id WHERE status='f'"; $albumCondition = csSYNOPhotoMisc::GetAccessibleAlbumQueryConditionWithExcludeFormat(); if(!$albumCondition['albumCond']) { return $result; } $query .= " AND {$albumCondition['albumCond']}"; $query .= " ORDER BY photo_image.create_time DESC "; $query .= $limitOffsetString; $queryCount .= " AND {$albumCondition['albumCond']}"; $db_result = PHOTO_DB_Query($query, $albumCondition['sqlParam']); while (false !== ($row = PHOTO_DB_FetchRow($db_result))) { if ($row['path']) { $result[SYNOPHOTO_SERVICE_REAL_DIR_PREFIX.$row['path']] = SYNOPHOTO_ITEM_TYPE_PHOTO; } } $db_result = PHOTO_DB_Query($queryCount, $sqlParam); $row = PHOTO_DB_FetchRow($db_result); $result['total'] = $row[0]; return $result; } /* * @param $videoPath video db path */ static function GetConvertedVideoInfo($dPath) { $query = "SELECT * FROM video_convert WHERE video_path = ?"; $sqlParam = array($dPath); $db_result = PHOTO_DB_Query($query, $sqlParam); $videoArr = array(); while ($videoInfo = PHOTO_DB_FetchRow($db_result)) { $videoQuality['id'] = bin2hex(SYNOPHOTO_SERVICE_REAL_DIR_PREFIX.$videoInfo['convert_file_path']); $videoQuality['container'] = $videoInfo['container_type']; $videoQuality['vcodec'] = $videoInfo['vcodec']; $videoQuality['acodec'] = $videoInfo['acodec']; $videoQuality['filesize'] = (int)$videoInfo['filesize']; $videoQuality['resolutionx'] = (int)$videoInfo['resolutionx']; $videoQuality['resolutiony'] = (int)$videoInfo['resolutiony']; $videoQuality['video_bitrate'] = (int)$videoInfo['video_bitrate']; $videoQuality['audio_bitrate'] = (int)$videoInfo['audio_bitrate']; $videoQuality['video_profile'] = (int)$videoInfo['video_profile']; $videoQuality['video_level'] = (int)$videoInfo['video_level']; $videoQuality['profile_name'] = self::GetConvertedName($videoInfo['convert_file_path']); array_push($videoArr, $videoQuality); } return $videoArr; } static function GetConvertedName($convertPath) { $fileName = basename($convertPath); $pool = array(SYNOPhotoEA::FILE_FILM_FLV, SYNOPhotoEA::FILE_FILM_H264_MP4, SYNOPhotoEA::FILE_FILM_H_MP4, SYNOPhotoEA::FILE_FILM_M_MP4, SYNOPhotoEA::FILE_FILM_L_MP4, SYNOPhotoEA::FILE_FILM_MOBILE_MP4, SYNOPhotoEA::FILE_FILM_MOBILE_IPHONE, SYNOPhotoEA::FILE_FILM_MOBILE_ANDROID); foreach ($pool as $name) { $oldName = SYNOPhotoEA::SYNO_PHOTO_PREFIX_OLD.$name; $newName = SYNOPhotoEA::SYNO_PHOTO_PREFIX.$name; if ($oldName === $fileName || $newName === $fileName) { if (SYNOPhotoEA::FILE_FILM_FLV === $name) { $ret = 'flv'; } elseif (SYNOPhotoEA::FILE_FILM_H264_MP4 === $name) { $ret = 'orig_h264'; } elseif (SYNOPhotoEA::FILE_FILM_MPEG4_MP4 === $name) { $ret = 'orig_mp4'; } elseif (SYNOPhotoEA::FILE_FILM_H_MP4 === $name) { $ret = 'high'; } elseif (SYNOPhotoEA::FILE_FILM_M_MP4 === $name) { $ret = 'medium'; } elseif (SYNOPhotoEA::FILE_FILM_L_MP4 === $name) { $ret = 'low'; } elseif (SYNOPhotoEA::FILE_FILM_MOBILE_MP4 === $name) { $ret = 'mobile'; } elseif (SYNOPhotoEA::FILE_FILM_MOBILE_IPHONE === $name) { $ret = 'orig_iphone'; } elseif (SYNOPhotoEA::FILE_FILM_MOBILE_ANDROID === $name) { $ret = 'orig_android'; } elseif (SYNOPhotoEA::FILE_FILM_CONVERT_MPEG4_MP4 === $name) { $ret = 'convert_mp4'; } break; } } return $ret; } static function IsAlbumCommentalbGlobal($checkSession = false) { $blAllowUserComment = ('on' === csSYNOPhotoMisc::GetConfigDB("photo", "allow_user_comment", "photo_config")); $blAllowGuestComment = ('on' === csSYNOPhotoMisc::GetConfigDB("photo", "allow_guest_comment", "photo_config")); if ($blAllowGuestComment) { return true; } elseif ($blAllowUserComment) { if ($checkSession) { csSYNOPhotoMisc::CheckSessionTimeOut(true); return true; } else { if (isset($_SESSION[SYNOPHOTO_ADMIN_USER]['reg_syno_user']) || isset($_SESSION[SYNOPHOTO_ADMIN_USER]['admin_syno_user'])) { return true; } } } return false; } static function IsShowAlbumHit() { $value = csSYNOPhotoMisc::GetConfigDB("photo", "show_album_hit", "photo_config"); $show_album_hit = 'off' === $value ? false : true ; return $show_album_hit; } static function FormAlbum($album_db_object, $global_allow_comment, $show_hits) { $name = pathinfo($album_db_object['sharename'], PATHINFO_BASENAME); $res = array( 'sharepath' => $album_db_object['sharename'], 'name' => $name, 'title' => $album_db_object['title'] ? $album_db_object['title'] : $name, 'description' => $album_db_object['description'], 'hits' => $show_hits ? $album_db_object['hits'] : 0, 'type' => $album_db_object['public'] ? 'public' : ($album_db_object['password'] ? 'password' : 'private'), 'conversion' => $album_db_object['conversion'], 'allow_comment' => $global_allow_comment ); return $res; } static function FormAdditional($type, $item, $params) { if ('album' === $type) { $sharePath = $item['sharename']; $shareid = $item['shareid']; if (in_array('album_sorting', $params['additional'])) { $sortData = csSYNOPhotoAlbum::GetAlbumInstance()->GetAlbumThumbSortType($sharePath); $sortBy = AlbumAPIUtil::ConvertToSortName($sortData['type']); $additional['album_sorting']['sort_by'] = $sortBy; $additional['album_sorting']['sort_direction'] = AlbumAPIUtil::ConvertToSortDirection($sortData['order']); $additional['album_sorting']['has_preference_sort'] = !empty($sortData); } if (in_array('album_permission', $params['additional'])) { // here $additional['album_permission'] = AlbumAPIUtil::GetAlbumPermission($sharePath); } if (in_array('item_count', $params['additional'])) { $additional['item_count'] = array( 'photo' => Album::GetPhotoCount($item['shareid']), 'video' => Album::GetVideoCount($item['shareid']) ); } } elseif ('photo' === $type) { if (in_array('photo_exif', $params['additional'])) { $photoInfo = $item; $additional['photo_exif']['takendate'] = $photoInfo['timetaken']; $additional['photo_exif']['camera'] = $photoInfo['camera_make']; $additional['photo_exif']['camera_model'] = $photoInfo['camera_model']; $additional['photo_exif']['exposure'] = $photoInfo['exposure']; $additional['photo_exif']['aperture'] = $photoInfo['aperture']; $additional['photo_exif']['iso'] = (int)$photoInfo['iso']; $additional['photo_exif']['gps'] = json_decode($photoInfo['gps'], true); $additional['photo_exif']['focal_length'] = $photoInfo['focal_length_v2']; $additional['photo_exif']['lens'] = $photoInfo['lens_v2']; $additional['photo_exif']['flash'] = $photoInfo['flash_v2']; } } elseif ('video' === $type) { if (in_array('video_codec', $params['additional'])) { $videoInfo = $item; $additional['video_codec']['container'] = $videoInfo['container_type']; $additional['video_codec']['vcodec'] = $videoInfo['video_codec']; $additional['video_codec']['acodec'] = $videoInfo['audio_codec']; $additional['video_codec']['resolutionx'] = (int)$videoInfo['resolutionx']; $additional['video_codec']['resolutiony'] = (int)$videoInfo['resolutiony']; $additional['video_codec']['frame_bitrate'] = (int)$videoInfo['frame_bitrate']; $additional['video_codec']['video_bitrate'] = (int)$videoInfo['video_bitrate']; $additional['video_codec']['audio_bitrate'] = (int)$videoInfo['audio_bitrate']; } if (in_array('video_quality', $params['additional'])) { $additional['video_quality'] = AlbumAPIUtil::GetConvertedVideoInfo($item['path']); } } if (in_array('file_location', $params['additional'])) { $additional['file_location'] = 'album' === $type ? $sharePath : substr($item['path'], strlen(SYNOPHOTO_SERVICE_REAL_DIR_PATH)); } return $additional; } static function GetRootAlbumInfo($params){ $info['description'] = ''; $info['sharepath'] = '/'; $info['name'] = '/'; $info['title'] = csSYNOPhotoMisc::GetConfigDB("photo", "photo_page_title", "photo_config"); $info['hits'] = null; $info['allow_comment'] = ('on' === csSYNOPhotoMisc::GetConfigDB("photo", "album_def_allow_comment", "photo_config")) ? true : false; $info['type'] = 'public'; $info['conversion'] = csSYNOPhotoMisc::IsAlbumAllowConversion('/'); $item['id'] = null; $item['info'] = $info; if (in_array('album_sorting', $params['additional'])) { $value = csSYNOPhotoMisc::GetConfigDB("album", "album_order_type", "photo_config"); $additional['album_sorting']['sort_by'] = ('1' === $value) ? 'preference' : 'filename'; $value = csSYNOPhotoMisc::GetConfigDB("album", "album_order_type_is_desc", "photo_config"); $additional['album_sorting']['sort_direction'] = ('1' === $value) ? 'desc' : 'asc'; $value = csSYNOPhotoAlbum::GetAlbumThumbSortType($info['sharepath']); $additional['album_sorting']['has_preference_sort'] = !empty($value); } if (in_array('album_permission', $params['additional'])) { $permission = self::GetAlbumPermission('/'); $additional['album_permission'] = $permission; } if (null !== $additional) { $item['additional'] = $additional; } return $item; } } ?>