summaryrefslogtreecommitdiffstats
path: root/index.php
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-12-03 22:16:49 +0100
committersteckbrief <steckbrief@chefmail.de>2017-12-03 22:16:49 +0100
commit6bf09a069577fa9fcefdb0f92da81001465a50e0 (patch)
treeef15a4b2df60ae7a39f9f34ddde9de5a6b04d1ff /index.php
parent09915b726ee9bc9896654b7bc832f068b9c3b013 (diff)
floating action button added to open a modal dialog to create a new story
Diffstat (limited to '')
-rw-r--r--index.php47
1 files changed, 39 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>