Split header in file, Minor visual changes

Made code a little prettier
This commit is contained in:
Dusk 2022-01-27 15:10:00 +01:00
parent c171629563
commit e0e1097b49
2 changed files with 44 additions and 22 deletions

11
include/header.php Normal file
View File

@ -0,0 +1,11 @@
<?php
$header = <<<HEADER
<head>
<meta charset="utf-8"/>
<title>Magatzem de Dusk</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Els fitxers de Dusk">
<link rel="icon" type="image/png" href="static/favicon.png" sizes="32x32">
</head>
HEADER;

View File

@ -1,15 +1,9 @@
<!DOCTYPE html>
<html lang="ca">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Dusk Kino</title>
<link rel="icon" type="image/png" href="./favicon.apng" sizes="32x32">
</head>
<body>
<html>
<?php
include 'include/header.php';
function link_from_file(string $filename, string $name = null, string $css_class = null ) : string {
// Check if css_class is null
$css_class = $css_class ? " class=\"$css_class\"" : '';
@ -21,6 +15,10 @@ function link_from_file(string $filename, string $name = null, string $css_class
function filter_files_dir($files_array, string $path) : array {
$ret_array = ['dir' => [], 'file' => []];
foreach($files_array as $file) {
// Hidden Files are not shown
if(substr($file, 0, 1) == '.') {
continue;
}
if(is_dir($path . $file)) {
// Append dir to array
$ret_array['dir'][] = $file;
@ -33,6 +31,14 @@ function filter_files_dir($files_array, string $path) : array {
return $ret_array;
}
echo($header);
echo("\n");
?>
<body>
<h1>Magatzem de Dusk</h1>
<?php
// Debug
//var_dump($_SERVER);
// Debug
@ -58,29 +64,34 @@ $resource_array = filter_files_dir($files_in_folder, $path);
// Show folder links
{
foreach($resource_array['dir'] as $dir) {
if(substr($dir, 0, 1) == '.') {
continue;
if(!empty($resource_array['dir'])) {
echo('<h2>Directoris</h2>');
}
echo(link_from_file($request_uri . $dir));
echo('<ul>');
foreach($resource_array['dir'] as $dir) {
echo('<li>' . link_from_file($request_uri . $dir, null, "dir_link") . '</li>');
echo('<br/>');
}
echo('<hr/>');
echo('</ul>');
}
echo("\n");
//Show file links
{
foreach($resource_array['file'] as $file) {
if(substr($file, 0, 1) == '.') {
continue;
if(!empty($resource_array['file'])) {
echo('<h2>Fitxers</h2>');
}
echo(link_from_file($request_uri . $file));
echo('<ul>');
foreach($resource_array['file'] as $file) {
echo('<li>' . link_from_file($request_uri . $file, null, 'file_link') . '</li>');
echo('<br/>');
}
echo('<hr/>');
echo('</ul>');
}
?>
echo("\n");
?>
</body>
</html>