obsidian-web/templates/content.php
2020-10-08 07:04:46 +01:00

93 lines
2.2 KiB
PHP

<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 ) {
$picture = absoluteToRelative( $file, $config["images"]);
$picture = str_replace("\\", "/", $picture);
console_log($picture);
//$name = tidyName( $file );
$createFile = "";
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">
<?php echo $error ?>
</div>