Show album and photo count on folders
This commit is contained in:
parent
87268e2061
commit
3680857183
4 changed files with 126 additions and 25 deletions
|
@ -6,25 +6,47 @@
|
||||||
|
|
||||||
.photos_folder a:hover, .photos_path a:hover, #download_album:hover {
|
.photos_folder a:hover, .photos_path a:hover, #download_album:hover {
|
||||||
box-shadow: 0 0 10px #000;
|
box-shadow: 0 0 10px #000;
|
||||||
background-color: #e0e0e0;
|
background-color: #635247;
|
||||||
color: black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.photos_folder a {
|
.photos_folder a {
|
||||||
font-size: 25px;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
background-color: #1a1a1a;
|
background-color: #1a1a1a;
|
||||||
box-shadow: 0 0 4px #000;
|
box-shadow: 0 0 4px #000;
|
||||||
transition: 0.3s;
|
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 {
|
.photos img {
|
||||||
|
@ -168,7 +190,7 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#loading svg{
|
#loading svg {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
|
@ -194,7 +216,7 @@
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#photo_buttons{
|
#photo_buttons {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
display: block;
|
display: block;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
@ -256,8 +278,28 @@
|
||||||
|
|
||||||
@media screen and (max-width: 480px) {
|
@media screen and (max-width: 480px) {
|
||||||
.photos_folder a {
|
.photos_folder a {
|
||||||
font-size: 15px;
|
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
height: 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,18 @@
|
||||||
<a href="<?= $folderLink ?>"><?= $folderTitle ?></a>
|
<a href="<?= $folderLink ?>">
|
||||||
|
<span id="folder_title"><?= $folderTitle ?></span>
|
||||||
|
<?php if ($photos > 1): ?>
|
||||||
|
<span id="folder_photos"><?= $photos ?> photos</span>
|
||||||
|
<?php elseif ($photos == 1): ?>
|
||||||
|
<span id="folder_photos"><?= $photos ?> photo</span>
|
||||||
|
<?php else: ?>
|
||||||
|
<span id="folder_photos">vide</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($albums > 1): ?>
|
||||||
|
<span id="folder_albums"><?= $albums ?> albums</span>
|
||||||
|
<?php elseif ($albums == 1): ?>
|
||||||
|
<span id="folder_albums"><?= $albums ?> album</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
62
photos.php
62
photos.php
|
@ -60,19 +60,20 @@ function isAlbumAvailable($path)
|
||||||
function createDirectories($path)
|
function createDirectories($path)
|
||||||
{
|
{
|
||||||
$path = photoRoot . $path;
|
$path = photoRoot . $path;
|
||||||
$files = scandir($path);
|
|
||||||
$displayedItems = 0;
|
$displayedItems = 0;
|
||||||
foreach ($files as $key => $value) {
|
$folders = getDirectories($path);
|
||||||
$realPath = realpath($path . DIRECTORY_SEPARATOR . $value);
|
foreach ($folders as $key => $value) {
|
||||||
if (isValidDirectory($realPath, $value)) {
|
|
||||||
$folderTitle = $value;
|
$folderTitle = $value;
|
||||||
|
$photos = getTotalPhotoCount($path . DIRECTORY_SEPARATOR . $value);
|
||||||
|
$albums = getTotalAlbumCount($path . DIRECTORY_SEPARATOR . $value);
|
||||||
$folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value;
|
$folderLink = "?" . urlParam . "=" . getActivePath() . DIRECTORY_SEPARATOR . $value;
|
||||||
include("includes/photos/folder_template.php");
|
include("includes/photos/folder_template.php");
|
||||||
$displayedItems++;
|
$displayedItems++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all photos in the specified path and creates them on the page
|
* Get all photos in the specified path and creates them on the page
|
||||||
* @param string $path path to search photos in
|
* @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
|
* Counts directories in the specified folder
|
||||||
* @param string $path path to search directories in
|
* @param string $path path to search directories in
|
||||||
|
@ -100,7 +119,6 @@ function createPhotos($path)
|
||||||
*/
|
*/
|
||||||
function getDirectoriesCount($path)
|
function getDirectoriesCount($path)
|
||||||
{
|
{
|
||||||
$path = photoRoot . $path;
|
|
||||||
$files = scandir($path);
|
$files = scandir($path);
|
||||||
$dirCount = 0;
|
$dirCount = 0;
|
||||||
foreach ($files as $key => $value) {
|
foreach ($files as $key => $value) {
|
||||||
|
@ -119,7 +137,6 @@ function getDirectoriesCount($path)
|
||||||
*/
|
*/
|
||||||
function getPhotoCount($path)
|
function getPhotoCount($path)
|
||||||
{
|
{
|
||||||
$path = photoRoot . $path;
|
|
||||||
$files = scandir($path);
|
$files = scandir($path);
|
||||||
$fileCount = 0;
|
$fileCount = 0;
|
||||||
foreach ($files as $key => $value) {
|
foreach ($files as $key => $value) {
|
||||||
|
@ -131,6 +148,31 @@ function getPhotoCount($path)
|
||||||
return $fileCount;
|
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
|
* Check if the given image is valid
|
||||||
* @param string $imagePath absolute path of the image
|
* @param string $imagePath absolute path of the image
|
||||||
|
@ -207,7 +249,7 @@ function generatePath($path)
|
||||||
generatePath(getActivePath());
|
generatePath(getActivePath());
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php if (getDirectoriesCount(getActivePath()) > 0): ?>
|
<?php if (getDirectoriesCount(photoRoot . getActivePath()) > 0): ?>
|
||||||
<div class="photos_folder">
|
<div class="photos_folder">
|
||||||
<?php
|
<?php
|
||||||
createDirectories(getActivePath());
|
createDirectories(getActivePath());
|
||||||
|
@ -219,10 +261,10 @@ function generatePath($path)
|
||||||
href="photos<?php echo getActivePath() . DIRECTORY_SEPARATOR . GetActiveFolder(getActivePath()) ?>.zip"
|
href="photos<?php echo getActivePath() . DIRECTORY_SEPARATOR . GetActiveFolder(getActivePath()) ?>.zip"
|
||||||
id="download_album">
|
id="download_album">
|
||||||
<span id="download_text"><i class="fas fa-download"></i>Télécharger l'album</span>
|
<span id="download_text"><i class="fas fa-download"></i>Télécharger l'album</span>
|
||||||
<span id="album_photo_count"><?php echo getPhotoCount(getActivePath()) ?> photos</span>
|
<span id="album_photo_count"><?php echo getPhotoCount(photoRoot . getActivePath()) ?> photos</span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (getPhotoCount(getActivePath()) > 0): ?>
|
<?php if (getPhotoCount(photoRoot . getActivePath()) > 0): ?>
|
||||||
<div class="photos">
|
<div class="photos">
|
||||||
<?php
|
<?php
|
||||||
createPhotos(getActivePath());
|
createPhotos(getActivePath());
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 187 KiB |
Loading…
Reference in a new issue