blob: 47b88fa9c9633693389978635c2920f6054503d7 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once(__DIR__."/../core.php");
3security::checkType(security::ADMIN, security::METHOD_NOTFOUND);
4
5if (!isset($_GET["id"])) {
6 security::notFound();
7}
8
9$id = (int)$_GET["id"];
10
11$c = calendars::get($id);
12
13if ($c === false) {
14 security::notFound();
15}
16
17$details = json_decode($c["details"], true);
18$export = array(
19 "begins" => $c["begins"],
20 "ends" => $c["ends"],
21 "calendar" => $details
22);
23?>
24
25<style>
26textarea.code {
27 width: 100%;
28 height: 100px;
29}
30</style>
31
32<dynscript>
33document.querySelector("textarea.code").select();
34
35document.getElementById("copy").addEventListener("click", _ => {
36 navigator.clipboard.writeText(document.querySelector("textarea.code").value).then(_ => {
37 document.querySelector(".mdl-js-snackbar").MaterialSnackbar.showSnackbar({
38 message: "Se ha copiado el texto correctamente.",
39 timeout: 5000
40 });
41 }).catch(error => {
42 document.querySelector(".mdl-js-snackbar").MaterialSnackbar.showSnackbar({
43 message: "Ha ocurrido un error copiando el texto. Por favor, cópialo manualmente.",
44 timeout: 5000
45 });
46 console.error(error);
47 });
48});
49</dynscript>
50
51<h4 class="mdl-dialog__title">Exportar calendario</h4>
52<div class="mdl-dialog__content">
53 <p>Este es el código que contiene toda la información del calendario y que puedes usar de plantilla más tarde:</p>
54 <textarea class="code" readonly><?=security::htmlsafe(json_encode($export))?></textarea>
55</div>
56<div class="mdl-dialog__actions">
57 <button data-dyndialog-close class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent cancel">Cerrar</button>
58 <button id="copy" class="mdl-button mdl-js-button mdl-js-ripple-effect">Copiar</button>
59</div>