summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.php47
-rw-r--r--lib/new-story-dialog.inc.php38
2 files changed, 77 insertions, 8 deletions
diff --git a/index.php b/index.php
index f290c1f..a7c71a5 100644
--- a/index.php
+++ b/index.php
@@ -7,6 +7,9 @@ $storiesDir = __DIR__.DIRECTORY_SEPARATOR.'stories';
$storiesDirContent = getDirectoryContent($storiesDir);
+$isAuthenticated = true;
+$isAdmin = true;
+
$currentStory = $_GET['story'];
$currentStoryIsSet = isset($currentStory) && !empty($currentStory);
$stories = array();
@@ -17,8 +20,10 @@ foreach ($storiesDirContent as $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)) {
@@ -32,13 +37,17 @@ foreach ($storiesDirContent as $storyName) {
$currentStoryName = visibleName($currentStory);
-function printEntities($entities) {
+function printEntities($entities, $storyName = NULL) {
foreach ($entities as $entity=>$description) {
$name = visibleName($entity);
+ $imgName = (NULL != $storyName) ? 'passphoto.png' : 'logo.png';
+ $imgPath = 'stories/'.((NULL != $storyName) ? (urlencode($storyName).'/') : '');
+ $imgPath .= urlencode($entity);
+?>
<!-- <?=$name;?> -->
<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($entity)?>/<?=urlencode($entity);?>/passphoto.png" alt="<?=$name;?>" title="<?=$name;?>">
+ <img class="img-fluid rounded mb-3 mb-md-0 figure-pic" src="<?=$imgPath.'/'.$imgName;?>" alt="<?=$name;?>" title="<?=$name;?>">
</div>
<div class="col-md-5">
<h3><?=$name;?></h3>
@@ -68,19 +77,34 @@ function printEntities($entities) {
height: 300px;
width: 300px;
}
- .story-logo {
+ .story-header {
font-size: 2em;
}
.spacer {
height: 55px;
}
+ .floating-action-btn {
+ position: fixed;
+ bottom: 45px;
+ right: 34px;
+ background-color: #ff8000;
+ border-radius: 50%;
+ box-shadow: 5px 5px 5px #ccc;
+ width: 50px;
+ height: 50px;
+ line-height: 50px;
+ text-align: center;
+ vertical-align: middle;
+ font-size: 2.6em;
+ cursor: pointer;
+ }
</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>
+ <a class="navbar-brand" href="index.php">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>
@@ -92,7 +116,7 @@ function printEntities($entities) {
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<?php
- foreach ($stories as $storyName) {
+ foreach ($stories as $storyName=>$desc) {
$visibleName = visibleName($storyName);
$cssClass = ($visibleName == $currentStoryName) ? " class=\"active\"" : "";
?>
@@ -109,15 +133,22 @@ function printEntities($entities) {
<?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;?>">
+ <img class="img-fluid mb-3 mb-md-0 story-header" src="stories/<?=urlencode($currentStory)?>/header.png" alt="<?=$currentStoryName;?>" title="<?=$currentStoryName;?>">
</div>
</div>
<?php
printEntities($characters);
} else {
- printEntities(stories);
+ printEntities($stories);
+}
+?>
+</div>
+<?php
+if ($isAuthenticated && $isAdmin) {
+ if (!$currentStoryIsSet) {
+ include(__DIR__.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'new-story-dialog.inc.php');
+ }
}
?>
- </div>
</body>
</html>
diff --git a/lib/new-story-dialog.inc.php b/lib/new-story-dialog.inc.php
new file mode 100644
index 0000000..ee55e4b
--- /dev/null
+++ b/lib/new-story-dialog.inc.php
@@ -0,0 +1,38 @@
+<?php
+?>
+ <span id="add-new-story-btn" class="floating-action-btn" data-toggle="modal" data-target="#newStoryModal">
+ +
+ </span>
+ <!-- Modal -->
+ <div class="modal fade" id="newStoryModal" role="dialog">
+ <div class="modal-dialog">
+ <!-- Modal content-->
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal">&times;</button>
+ <h4 class="modal-title">Neue Kindergeschichte anlegen</h4>
+ </div>
+ <div class="modal-body">
+ <form action="" method="post" enctype="multipart/form-data" id="create-story-form">
+ <div class="form-group">
+ <label for="name">Name der Kindergeschichte:</label>
+ <input type="text" class="form-control" id="story-name" name="story-name">
+ </div>
+ <div class="form-group">
+ <label for="story-description">Beschreibung der Kindergeschichte:</label>
+ <textarea class="form-control" rows="5" id="story-description" name="story-description"></textarea>
+ </div>
+ <div class="form-group">
+ <label for="story-logo">Logo der Kindergeschichte:</label>
+ <input type="file" name="story-logo" id="story-logo">
+ </div>
+ <div class="form-group">
+ <label for="story-header">Header Bild der Kindergeschichte:</label>
+ <input type="file" name="story-header" id="story-header">
+ </div>
+ <button type="submit" class="btn btn-info btn-sm">Anlegen</button>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>