summaryrefslogtreecommitdiffstats
path: root/index.php
blob: 85b72ff0cf5326d2276643dd516eccf5e1fe80d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php

require_once(__DIR__.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'commons'.DIRECTORY_SEPARATOR.'functions.common.inc.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'functions.stories.inc.php');

$storiesDir = __DIR__.DIRECTORY_SEPARATOR.'stories';

$storiesDirContent = getDirectoryContent($storiesDir);

$currentStory = $_GET['story'];
$currentStoryIsSet = isset($currentStory) && !empty($currentStory);
$stories = array();
$characters = array();

foreach ($storiesDirContent as $storyName) {
    $storyPath = $storiesDir.DIRECTORY_SEPARATOR.$storyName;
    if (is_dir($storyPath)) {
        $storyDescription = file_get_contents($storyPath.DIRECTORY_SEPARATOR.'description.txt');
        $stories[$storyName] = $storyDescription;
        if ($currentStoryIsSet && $currentStory == $storyName) {
            $charactersDirContent = array_diff(scandir($storyPath), array('..', '.'));
            foreach ($charactersDirContent as $character) {
                $characterPath = $storyPath.DIRECTORY_SEPARATOR.$character;
                if (is_dir($characterPath)) {
                    $characterDescription = file_get_contents($characterPath.DIRECTORY_SEPARATOR.'description.txt');
                    $characters[$character] = $characterDescription;
                }
            }
        }
    }
}

$currentStoryName = visibleName($currentStory);

?>
<!DOCTYPE html>
<html lang="de">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="https://www.sl-its.de/css/bootstrap.spacelab.min.css">
        <script src="https://www.sl-its.de/js/jquery-1.11.2.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <style type="text/css">
            .figure-desc {
                text-align: justify;
            }
            .figure-pic {
                height: 300px;
                width: 300px;
            }
            .story-logo {
                font-size: 2em;
            }
            .spacer {
                height: 55px;
            }
        </style>
        <title>Kindergeschichten</title>
    </head>
    <body>
        <nav class="navbar navbar-default navbar-fixed-top navbar-right">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">Kindergeschichten</a>
                <button type="button" class="navbar-toggle navbar-toggle-si" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div class="container-fluid">
                <div class="collapse navbar-collapse" id="myNavbar">
                    <ul class="nav navbar-nav">
    <?php
    foreach ($stories as $storyName) {
        $visibleName = visibleName($storyName);
        $cssClass = ($visibleName == $currentStoryName) ? " class=\"active\"" : "";
    ?>
                    <li<?=$cssClass;?>><a href="index.php?story=<?=$storyName;?>"><?=$visibleName;?></a></li>
    <?php
    }
    ?>
                </ul>
                </div>
            </div>
        </nav>
        <div class="spacer"></div>
        <div class="container">
<?php if ($currentStoryIsSet) { ?>
            <div class="row">
                <div class="col-md-7 text-center">
                    <img class="img-fluid mb-3 mb-md-0 story-logo" src="stories/<?=urlencode($currentStory)?>/logo.png" alt="<?=$currentStoryName;?>" title="<?=$currentStoryName;?>">
                </div>
            </div>
            <?php
            foreach ($characters as $character=>$characterDescription) {
                $characterName = visibleName($character);
            ?>
            <!-- <?=$characterName;?> -->
            <div class="row">
                <div class="col-md-7 text-center">
                    <img class="img-fluid rounded mb-3 mb-md-0 figure-pic" src="stories/<?=urlencode($currentStory)?>/<?=urlencode($character);?>/passphoto.png" alt="<?=$characterName;?>" title="<?=$characterName;?>">
                </div>
                <div class="col-md-5">
                    <h3><?=$characterName;?></h3>
                    <p class="figure-desc"><?=$characterDescription;?></p>
                </div>
            </div>
            <!-- /.row -->
            
            <hr>
            <?php
            }
} else {
    foreach ($stories as $story=>$storyDescription) {
        $storyName = visibleName($story);
?>
            <div class="row">
                <div class="col-md-7 text-center">
                    <img class="img-fluid mb-3 mb-md-0 story-logo" src="stories/<?=urlencode($story);?>/logo.png" alt="<?=$storyName;?>" title="<?=$storyName;?>">
                </div>
                <div class="col-md-5">
                    <h3><?=$storyName;?></h3>
                    <p class="figure-desc"><?=$storyDescription;?></p>
                </div>
            </div>
            </div>
<?
    }
}
?>
        </div>
    </body>
</html>