mirror of
https://github.com/itflow-org/itflow
synced 2026-12-05 10:39:00 +00:00
59 lines
2.9 KiB
PHP
59 lines
2.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Make it a document - an uploaded .md file becomes a document written in Markdown, in the same
|
|
* folder, that can be edited (make_file_document, agent/post/file.php; functions/markdown_upload.php).
|
|
*/
|
|
|
|
require_once '../../../includes/modal_header.php';
|
|
|
|
enforceUserPermission('module_support', 2);
|
|
|
|
$file_id = intval($_GET['id'] ?? 0);
|
|
|
|
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT file_client_id, file_ext, file_name, file_folder_id, file_archived_at FROM files WHERE file_id = $file_id LIMIT 1"));
|
|
if (!$row) {
|
|
echo json_encode(['error' => 'That file no longer exists.']);
|
|
exit;
|
|
}
|
|
$client_id = intval($row['file_client_id']);
|
|
enforceClientAccess();
|
|
|
|
$is_markdown = in_array(strtolower((string) $row['file_ext']), markdownUploadExtensions(), true);
|
|
$file_name = escapeHtml($row['file_name']);
|
|
$folder_name = escapeHtml(folderDisplayName(folderOwnedId($row['file_folder_id'], $client_id)));
|
|
|
|
ob_start();
|
|
|
|
?>
|
|
<div class="modal-header bg-dark">
|
|
<h5 class="modal-title text-truncate"><i class="fab fa-fw fa-markdown me-2"></i>Make <strong><?= $file_name ?></strong> a document</h5>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<form action="post.php" method="post" autocomplete="off">
|
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
|
<input type="hidden" name="file_id" value="<?= $file_id ?>">
|
|
<div class="modal-body">
|
|
<?php if (!$is_markdown || $row['file_archived_at']) { ?>
|
|
<div class="alert alert-warning mb-0">Only a .md file in Files can be made a document.</div>
|
|
<?php } elseif (!documentMarkdownReady()) { ?>
|
|
<div class="alert alert-warning mb-0">Markdown documents arrive with the next database update - run it from Maintenance > Update first.</div>
|
|
<?php } else { ?>
|
|
<p>It becomes a document written in Markdown, in <strong><?= $folder_name ?></strong>, that you can edit - named by the heading it starts with.</p>
|
|
<ul class="mb-0 ps-3">
|
|
<li>The pictures it uses that are in this client's Files are copied into it. Any that aren't are listed after, to add in the editor.</li>
|
|
<li>The uploaded file is replaced by the document, with what it was linked to. Its <strong>Export</strong> menu gives you a .md again.</li>
|
|
</ul>
|
|
<?php } ?>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<?php if ($is_markdown && !$row['file_archived_at'] && documentMarkdownReady()) { ?>
|
|
<button type="submit" name="make_file_document" class="btn btn-primary fw-bold"><i class="fas fa-file-alt me-2"></i>Make it a document</button>
|
|
<?php } ?>
|
|
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
|
|
</div>
|
|
</form>
|
|
|
|
<?php
|
|
require_once '../../../includes/modal_footer.php';
|