forked from vergnet/site-accueil-insa
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 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
||||
|
|
70
photos.php
70
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());
|
||||
?>
|
||||
</ul>
|
||||
<?php if (getDirectoriesCount(getActivePath()) > 0): ?>
|
||||
<?php if (getDirectoriesCount(photoRoot . getActivePath()) > 0): ?>
|
||||
<div class="photos_folder">
|
||||
<?php
|
||||
createDirectories(getActivePath());
|
||||
|
@ -219,10 +261,10 @@ function generatePath($path)
|
|||
href="photos<?php echo getActivePath() . DIRECTORY_SEPARATOR . GetActiveFolder(getActivePath()) ?>.zip"
|
||||
id="download_album">
|
||||
<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>
|
||||
<?php endif; ?>
|
||||
<?php if (getPhotoCount(getActivePath()) > 0): ?>
|
||||
<?php if (getPhotoCount(photoRoot . getActivePath()) > 0): ?>
|
||||
<div class="photos">
|
||||
<?php
|
||||
createPhotos(getActivePath());
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 187 KiB |
Loading…
Reference in a new issue