summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
m---------lib/commons0
-rw-r--r--lib/functions.stories.inc.php30
-rw-r--r--lib/new-character-dialog.inc.php14
-rw-r--r--lib/new-story-dialog.inc.php14
4 files changed, 44 insertions, 14 deletions
diff --git a/lib/commons b/lib/commons
-Subproject b28e7e4125cd8ce0f25dbcaaad14a2ef2446cdb
+Subproject 406f05cd56a6b4d8192ea00b15bb9edef68c733
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 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
- <h4 class="modal-title">Neuen Charakter anlegen</h4>
+ <h4 id="modal-title" class="modal-title">Neuen Charakter anlegen</h4>
</div>
<div class="modal-body">
<form action="" method="post" enctype="multipart/form-data" id="create-char-form">
@@ -27,7 +27,8 @@
<label for="story-logo">Foto des Charakters:</label>
<input type="file" name="char-passphoto" id="char-passphoto">
</div>
- <button type="submit" class="btn btn-info btn-sm">Anlegen</button>
+ <input type="hidden" value="create" id="char-action" name="char-action">
+ <button type="submit" id="create-char-btn" class="btn btn-info btn-sm">Anlegen</button>
</form>
</div>
</div>
@@ -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');
+ }
</script>
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 @@
<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>
+ <h4 id="modal-title" class="modal-title">Neue Kindergeschichte anlegen</h4>
</div>
<div class="modal-body">
<form action="" method="post" enctype="multipart/form-data" id="create-story-form">
@@ -30,7 +30,8 @@
<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>
+ <input type="hidden" value="create" name="story-action" id="story-action">
+ <button type="submit" id="create-story-btn" class="btn btn-info btn-sm">Anlegen</button>
</form>
</div>
</div>
@@ -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');
+ }
</script>