diff --git a/assets/css/photos.css b/assets/css/photos.css index 14b498f..229d251 100644 --- a/assets/css/photos.css +++ b/assets/css/photos.css @@ -6,25 +6,47 @@ .photos_folder a:hover, .photos_path a:hover, #download_album:hover { box-shadow: 0 0 10px #000; - background-color: #e0e0e0; - color: black; + background-color: #635247; } .photos_folder a { - font-size: 25px; text-decoration: none; border-radius: 5px; min-width: 100px; height: 100px; padding: 10px; margin: 5px; + position: relative; display: inline-flex; align-items: center; justify-content: center; background-color: #1a1a1a; box-shadow: 0 0 4px #000; transition: 0.3s; - color: #e0e0e0; +} + +#folder_title { + position: absolute; + top: 10px; + color: #73b795; + font-size: 25px; + text-shadow: 0 0 5px #1c1c1c; +} + +#folder_photos, #folder_albums { + color: #808080; + font-size: 18px; + text-shadow: 0 0 5px #1c1c1c; +} + +#folder_photos { + position: absolute; + bottom: 30px; +} + +#folder_albums { + position: absolute; + bottom: 0; } .photos img { @@ -168,7 +190,7 @@ display: block; } -#loading svg{ +#loading svg { position: relative; width: 25px; height: 25px; @@ -194,14 +216,14 @@ height: 50px; } -#photo_buttons{ +#photo_buttons { position: fixed; display: block; z-index: 10; /* Block selection of buttons (useful for mobile devices) */ - -webkit-user-select: none; /* Chrome all / Safari all */ - -moz-user-select: none; /* Firefox all */ - -ms-user-select: none; /* IE 10+ */ + -webkit-user-select: none; /* Chrome all / Safari all */ + -moz-user-select: none; /* Firefox all */ + -ms-user-select: none; /* IE 10+ */ } #close_back { @@ -256,8 +278,28 @@ @media screen and (max-width: 480px) { .photos_folder a { - font-size: 15px; min-width: 50px; height: 50px; } + #folder_title { + position: absolute; + top: 5px; + color: #e0e0e0; + font-size: 15px; + } + + #folder_photos, #folder_albums { + color: #808080; + font-size: 10px; + } + + #folder_photos { + position: absolute; + bottom: 20px; + } + + #folder_albums { + position: absolute; + bottom: 0; + } } diff --git a/includes/photos/folder_template.php b/includes/photos/folder_template.php index 21b1345..d9dd925 100644 --- a/includes/photos/folder_template.php +++ b/includes/photos/folder_template.php @@ -1 +1,18 @@ - + + + 1): ?> + photos + + photo + + vide + + + 1): ?> + albums + + album + + + + diff --git a/photos.php b/photos.php index dd99003..0aa849c 100644 --- a/photos.php +++ b/photos.php @@ -60,19 +60,20 @@ function isAlbumAvailable($path) function createDirectories($path) { $path = photoRoot . $path; - $files = scandir($path); $displayedItems = 0; - foreach ($files as $key => $value) { - $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); - if (isValidDirectory($realPath, $value)) { - $folderTitle = $value; - $folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value; - include("includes/photos/folder_template.php"); - $displayedItems++; - } + $folders = getDirectories($path); + foreach ($folders as $key => $value) { + $folderTitle = $value; + $photos = getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value); + $albums = getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value); + $folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value; + include("includes/photos/folder_template.php"); + $displayedItems++; + } } + /** * Get all photos in the specified path and creates them on the page * @param string $path path to search photos in @@ -93,6 +94,24 @@ function createPhotos($path) } } +/** + * get folders in the given path + * @param string $path path to search folders in + * @return array array of folders + */ +function getDirectories($path) +{ + $files = scandir($path); + $folders = []; + foreach ($files as $key => $value) { + $realPath = realpath($path . DIRECTORY_SEPARATOR . $value); + if (isValidDirectory($realPath, $value)) { + array_push($folders, $value); + } + } + return $folders; +} + /** * Counts directories in the specified folder * @param string $path path to search directories in @@ -100,7 +119,6 @@ function createPhotos($path) */ function getDirectoriesCount($path) { - $path = photoRoot . $path; $files = scandir($path); $dirCount = 0; foreach ($files as $key => $value) { @@ -119,7 +137,6 @@ function getDirectoriesCount($path) */ function getPhotoCount($path) { - $path = photoRoot . $path; $files = scandir($path); $fileCount = 0; foreach ($files as $key => $value) { @@ -131,6 +148,31 @@ function getPhotoCount($path) return $fileCount; } +/** + * Get the count of all directories, recursively from the path specified + * @param string $path root for search + * @return int total number of directories + */ +function getTotalAlbumCount($path) +{ + $folders = getDirectories($path); + $total = sizeof($folders); + foreach ($folders as $key => $value) { + $total += getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value); + } + return $total; +} + +function getTotalPhotoCount($path) +{ + $folders = getDirectories($path); + $total = getPhotoCount($path); + foreach ($folders as $key => $value) { + $total += getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value); + } + return $total; +} + /** * Check if the given image is valid * @param string $imagePath absolute path of the image @@ -207,7 +249,7 @@ function generatePath($path) generatePath(getActivePath()); ?> - 0): ?> + 0): ?>
.zip" id="download_album"> Télécharger l'album - photos + photos - 0): ?> + 0): ?>