summaryrefslogtreecommitdiffstats
path: root/index.php
blob: 6ccf8d7faaa7a0986ee2c123fbbe9ce25a17c12e (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
<?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)) {
        array_push($stories, $storyName);
        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) {
        $cssClass = ($storyName == $currentStory) ? " class=\"active\"" : "";
        $visibleName = visibleName($storyName);
    ?>
    <li<?=$cssClass;?>><a href="index.php?story=<?=$storyName;?>"><?=$visibleName;?></a></li>
    <?php
    }
    ?>
</ul>
                </div>
            </div>
        </nav>
        <div class="spacer"></div>
        <div class="container">
            <div class="row">
                <div class="col-md-7 text-center">
                    <img class="img-fluid mb-3 mb-md-0 story-logo" src="<?=$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="<?=$currentStory?>/<?=$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
            }
            ?>
        </div>
    </body>
</html>