obsidian-web/templates/content.php

93 lines
2.2 KiB
PHP
Raw Normal View History

<div id="content">
<?php
/**
* We enumerate the folders and files, as a form of basic indexing.
*/
$categories = listFolders( $imagesFolder );
//echo "<span> cats: ". var_dump($categories) ."</span";
$pictures = listFiles( $imagesFolder );
//echo "<span> pics: ". var_dump($pictures) . "</span";
if ( count( $categories ) > 0 ) {
echo "<div id='categories'>\n";
foreach ( $categories as $category ) {
if (file_exists( $category."/.gridhide") ) {
continue;
}
$file = absoluteToRelative( $category, $imagesFolder );
$name = tidyName( $category );
$createFile = false;
foreach( $newImages as $entry ) {
$path = realpath( $category );
if( isInFolder( $path, $entry ) ) {
$createFile = true;
break;
}
}
$image = addslashes( absoluteToRelative( listFiles( $category, true, true), $imagesFolder ));
echo "<div class='folder' stlye='";
echo "background: url('?thumb=$image') no-repeat center center;";
echo "-webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;'>";
if( $createFile ) { ?>
<div class="new"></div>
<?php }
echo "<div class='title'> <a href='?category=$file'> $name </a> </div> </div>";
}?>
</div>
<?php
}
if( count( $pictures ) > 0 ) { ?>
<div id="thumbs">
<?php
foreach ($pictures as $file ) {
2020-10-08 06:04:46 +00:00
$picture = absoluteToRelative( $file, $config["images"]);
$picture = str_replace("\\", "/", $picture);
console_log($picture);
//$name = tidyName( $file );
$createFile = "";
2020-10-08 06:04:46 +00:00
foreach( $newImages as $entry ) {
$path = realPath( $file );
if( isInFolder( $path, $entry ) ) {
$createFile = "new";
break;
}
}
echo "<div class='thumb $createFile'> <a href='?image=$picture'> <img src='?thumb=$picture'> </a> </div>";
}?>
</div>
<?php
} ?>
</div>
<div id="viewer">
<div id="lightbox">
</div>
</div>
</div id="loading">
2020-10-08 06:04:46 +00:00
<?php echo $error ?>
</div>