From 2ec5cbc2aa2fe992d2cccaf6d160950adef521ef Mon Sep 17 00:00:00 2001 From: steckbrief Date: Sun, 10 Dec 2017 20:22:33 +0100 Subject: create story and character improved --- config/config.inc.php | 3 +++ config/text.inc.php | 4 ++++ createCharacter.php | 39 +++++++++++++++++++++++++++++++++++++ createStory.php | 13 +++++++++++-- index.php | 22 +++++++++++++++------ js/stories.js | 42 ++++++++++++++++++++++++++++++++++++++++ lib/commons | 2 +- lib/functions.stories.inc.php | 8 ++++++-- lib/new-character-dialog.inc.php | 41 +++++++++++++++++++++++++++++++++++++++ lib/new-story-dialog.inc.php | 6 ++++++ 10 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 config/config.inc.php create mode 100644 config/text.inc.php create mode 100644 createCharacter.php create mode 100644 js/stories.js create mode 100644 lib/new-character-dialog.inc.php diff --git a/config/config.inc.php b/config/config.inc.php new file mode 100644 index 0000000..f4ea2f5 --- /dev/null +++ b/config/config.inc.php @@ -0,0 +1,3 @@ + diff --git a/config/text.inc.php b/config/text.inc.php new file mode 100644 index 0000000..b5ec213 --- /dev/null +++ b/config/text.inc.php @@ -0,0 +1,4 @@ + + diff --git a/createCharacter.php b/createCharacter.php new file mode 100644 index 0000000..f5015bb --- /dev/null +++ b/createCharacter.php @@ -0,0 +1,39 @@ + diff --git a/createStory.php b/createStory.php index 83d9000..f3c5666 100644 --- a/createStory.php +++ b/createStory.php @@ -13,11 +13,20 @@ $storyName = getMandatoryPostParameter('story-name', '', true); $storyLogoFile = getOptionalFileParameter('story-logo'); $storyDescription = getOptionalPostParameter('story-description'); -$pathToStory = __DIR__.DIRECTORY_SEPARATOR.'stories'.DIRECTORY_SEPARATOR.generateDirectoryName($storyName); +$pathToStory = generatePath(['stories', $storyName], __DIR__); $result = createEntity($pathToStory, $storyDescription, $storyLogoFile, 'logo.png'); if (TRUE !== $result) { - sendHttpReturnCodeAndJson(500, $result); + switch ($result) { + case 1: + sendHttpReturnCodeAndJson(409, 'Story exists already'); + break; + case 2: + sendHttpReturnCodeAndJson(500, 'Could not create directory for story'); + break; + default: + sendHttpReturnCodeAndJson(500, 'Unexpected error'); + } } else { sendHttpReturnCodeAndMessage(201); } diff --git a/index.php b/index.php index a7c71a5..d5654a2 100644 --- a/index.php +++ b/index.php @@ -1,16 +1,20 @@ +