From 391875ea8389d043360961cf2c5a69f2b6d7a91a Mon Sep 17 00:00:00 2001 From: steckbrief Date: Thu, 28 Dec 2017 13:46:55 +0100 Subject: update and delete added --- lib/commons | 2 +- lib/functions.stories.inc.php | 30 ++++++++++++++++++++---------- lib/new-character-dialog.inc.php | 14 ++++++++++++-- lib/new-story-dialog.inc.php | 14 ++++++++++++-- 4 files changed, 45 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/commons b/lib/commons index b28e7e4..406f05c 160000 --- a/lib/commons +++ b/lib/commons @@ -1 +1 @@ -Subproject commit b28e7e4125cd8ce0f25dbcaaad14a2ef2446cdb2 +Subproject commit 406f05cd56a6b4d8192ea00b15bb9edef68c7331 diff --git a/lib/functions.stories.inc.php b/lib/functions.stories.inc.php index 5e0527e..8f35e27 100644 --- a/lib/functions.stories.inc.php +++ b/lib/functions.stories.inc.php @@ -13,20 +13,30 @@ function generateDirectoryName($name) { return urlencode($name); } +function saveEntity($path, $description, $file, $filename) { + // create description file + if (file_put_contents($path.DIRECTORY_SEPARATOR.'description.txt', $description) === FALSE) { + // Error on writing description file + } + // move uploaded logo + if (NULL === $file || move_uploaded_file($file['tmp_name'], $path.DIRECTORY_SEPARATOR.$filename) || $file['error'] == UPLOAD_ERR_NO_FILE) { + return TRUE; + } else { + return 3; + } +} + +function editEntity($path, $description, $file, $filename) { + if (dir_exists($path)) { + return saveEntity($path, $description, $file, $filename); + } +} + function createEntity($path, $description, $file, $filename) { if (!dir_exists($path)) { // create directory for story if (mkdir($path)) { - // create description file - if (file_put_contents($path.DIRECTORY_SEPARATOR.'description.txt', $description) === FALSE) { - // Error on writing description file - } - // move uploaded logo - if (NULL === $file || move_uploaded_file($file['tmp_name'], $path.DIRECTORY_SEPARATOR.$filename) || $file['error'] == UPLOAD_ERR_NO_FILE) { - return TRUE; - } else { - return 3; - } + return saveEntity($path, $description, $file, $filename); } else { // Error on directory creation // return 'Could not create directory "'.$path; diff --git a/lib/new-character-dialog.inc.php b/lib/new-character-dialog.inc.php index 5cf25c0..0e77ad1 100644 --- a/lib/new-character-dialog.inc.php +++ b/lib/new-character-dialog.inc.php @@ -10,7 +10,7 @@ @@ -38,4 +39,13 @@ createNewCharacter(); event.preventDefault(); }); + $('#newCharacterModal').on('hide.bs.modal', function(evt) { + formReset(); + }); + function formReset() { + $('#create-char-form')[0].reset(); + $('#char-action').val('create'); + $('#modal-title').text('Neuen Charakter anlegen'); + $('#create-char-btn').text('Anlegen'); + } diff --git a/lib/new-story-dialog.inc.php b/lib/new-story-dialog.inc.php index 73c6abf..c833933 100644 --- a/lib/new-story-dialog.inc.php +++ b/lib/new-story-dialog.inc.php @@ -10,7 +10,7 @@ @@ -41,4 +42,13 @@ createNewStory(); event.preventDefault(); }); + $('#newCharacterModal').on('hide.bs.modal', function(evt) { + formReset(); + }); + function formReset() { + $('#create-story-form')[0].reset(); + $('#story-action').val('create'); + $('#modal-title').text('Neue Kindergeschichte anlegen'); + $('#create-story-btn').text('Anlegen'); + } -- cgit v1.2.3