pile/www/_templates/admin_doc_edit.php

38 lines
1.8 KiB
PHP
Raw Normal View History

2017-03-07 09:38:47 +01:00
<div class="text document edit-form">
2018-07-31 15:58:23 +02:00
<form method="post" id="form" action="admin.php?action=edit_item<?= empty($doc) ? "" : "&item=" . $doc["ID"] ?>"
enctype="multipart/form-data">
<strong>Title:</strong> <input id="title-input" type="text" name="Title"
value="<?= empty($doc) ? "" : $doc["Title"] ?>"><br>
2017-03-07 09:38:47 +01:00
<strong>Author:</strong> <input type="text" name="Author" value="<?= empty($doc) ? "" : $doc["Author"] ?>"><br>
2018-07-31 15:58:23 +02:00
<strong>Date published:</strong> <input type="text" name="Published"
value="<?= empty($doc) ? "" : $doc["Published"] ?>"><br>
2017-03-07 09:38:47 +01:00
<strong>Description:</strong><br>
2018-07-31 15:58:23 +02:00
<textarea name="Description" cols="120" rows="20">
2017-03-07 09:38:47 +01:00
<?= empty($doc) ? "" : $doc["Description"] ?>
</textarea><br>
<strong>File:</strong> <input id="file-input" type="file" name="upfile" onchange="updateTitle()"><br>
2017-03-07 09:38:47 +01:00
<strong>URL:</strong> <input type="text" name="URL" value="<?= empty($doc) ? "" : $doc["URL"] ?>"><br>
2018-09-17 11:25:56 +02:00
<strong>Tags:</strong> <input type="text" name="Tags" value="<?php
2018-07-31 15:58:23 +02:00
if (!empty($doc)) {
$tags = [];
foreach ($doc["tags"] as $tag) {
array_push($tags, $tag["Name"]);
}
echo implode(", ", $tags);
} else if (!empty($_GET["tag"])) {
2019-05-05 13:00:39 +02:00
echo $tag["Name"];
2018-07-31 15:58:23 +02:00
}
2017-03-07 09:38:47 +01:00
?>"><br>
2018-07-31 15:58:23 +02:00
<input type="submit">
2017-03-07 09:38:47 +01:00
</form>
</div>
<script>
function updateTitle() {
const titleInput = document.getElementById("title-input");
if (titleInput.value.length === 0) {
const filename = document.getElementById("file-input").value;
titleInput.value = filename.replace(/.*[\/\\]/, '').replace(/\.[\w]{2,}$/, '');
}
}
</script>