diff options
Diffstat (limited to 'Neutron-trunk/cms-special/admin-v2/calendar')
3 files changed, 304 insertions, 0 deletions
diff --git a/Neutron-trunk/cms-special/admin-v2/calendar/add/index.php b/Neutron-trunk/cms-special/admin-v2/calendar/add/index.php new file mode 100644 index 0000000..1029788 --- /dev/null +++ b/Neutron-trunk/cms-special/admin-v2/calendar/add/index.php @@ -0,0 +1,140 @@ +<?php require_once "../../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?> +<?php $pageConfig = [ "domName" => "Ajouter un événement - Calendrier", "headerName" => "Ajouter un événement" ]; require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?> + <div id="datainput"> + <h3><?= $lang["admin-calendar"]["create"]["date"] ?></h3> + <ul> + <li><?= $lang["admin-calendar"]["create"]["day"] ?> </li> + <select id="day"> + <option value="01" <?php if ("01" == date('d')) {echo("selected");} ?>>1er</option> + <option value="02" <?php if ("02" == date('d')) {echo("selected");} ?>>2</option> + <option value="03" <?php if ("03" == date('d')) {echo("selected");} ?>>3</option> + <option value="04" <?php if ("04" == date('d')) {echo("selected");} ?>>4</option> + <option value="05" <?php if ("05" == date('d')) {echo("selected");} ?>>5</option> + <option value="06" <?php if ("06" == date('d')) {echo("selected");} ?>>6</option> + <option value="07" <?php if ("07" == date('d')) {echo("selected");} ?>>7</option> + <option value="08" <?php if ("08" == date('d')) {echo("selected");} ?>>8</option> + <option value="09" <?php if ("09" == date('d')) {echo("selected");} ?>>9</option> + <option value="10" <?php if ("10" == date('d')) {echo("selected");} ?>>10</option> + <option value="11" <?php if ("11" == date('d')) {echo("selected");} ?>>11</option> + <option value="12" <?php if ("12" == date('d')) {echo("selected");} ?>>12</option> + <option value="13" <?php if ("13" == date('d')) {echo("selected");} ?>>13</option> + <option value="14" <?php if ("14" == date('d')) {echo("selected");} ?>>14</option> + <option value="15" <?php if ("15" == date('d')) {echo("selected");} ?>>15</option> + <option value="16" <?php if ("16" == date('d')) {echo("selected");} ?>>16</option> + <option value="17" <?php if ("17" == date('d')) {echo("selected");} ?>>17</option> + <option value="18" <?php if ("18" == date('d')) {echo("selected");} ?>>18</option> + <option value="19" <?php if ("19" == date('d')) {echo("selected");} ?>>19</option> + <option value="20" <?php if ("20" == date('d')) {echo("selected");} ?>>20</option> + <option value="21" <?php if ("21" == date('d')) {echo("selected");} ?>>21</option> + <option value="22" <?php if ("22" == date('d')) {echo("selected");} ?>>22</option> + <option value="23" <?php if ("23" == date('d')) {echo("selected");} ?>>23</option> + <option value="24" <?php if ("24" == date('d')) {echo("selected");} ?>>24</option> + <option value="25" <?php if ("25" == date('d')) {echo("selected");} ?>>25</option> + <option value="26" <?php if ("26" == date('d')) {echo("selected");} ?>>26</option> + <option value="27" <?php if ("27" == date('d')) {echo("selected");} ?>>27</option> + <option value="28" <?php if ("28" == date('d')) {echo("selected");} ?>>28</option> + <option value="29" <?php if ("29" == date('d')) {echo("selected");} ?>>29</option> + <option value="30" <?php if ("30" == date('d')) {echo("selected");} ?>>30</option> + <option value="31" <?php if ("31" == date('d')) {echo("selected");} ?>>31</option> + </select><br><br> + <li><?= $lang["admin-calendar"]["create"]["month"] ?> </li> + <select id="month"> + <option disabled><?= $lang["admin-calendar"]["create"]["trimesters"][0] ?></option> + <option value="1" <?php if ("01" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][0] ?></option> + <option value="2" <?php if ("02" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][1] ?></option> + <option value="3" <?php if ("03" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][2] ?></option> + <option disabled><?= $lang["admin-calendar"]["create"]["trimesters"][1] ?></option> + <option value="4" <?php if ("04" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][3] ?></option> + <option value="5" <?php if ("05" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][4] ?></option> + <option value="6" <?php if ("06" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][5] ?></option> + <option disabled><?= $lang["admin-calendar"]["create"]["trimesters"][2] ?></option> + <option value="7" <?php if ("07" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][6] ?></option> + <option value="8" <?php if ("08" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][7] ?></option> + <option value="9" <?php if ("09" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][8] ?></option> + <option disabled><?= $lang["admin-calendar"]["create"]["trimesters"][3] ?></option> + <option value="10" <?php if ("10" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][9] ?></option> + <option value="11" <?php if ("11" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][10] ?></option> + <option value="12" <?php if ("12" == date('m')) {echo("selected");} ?>><?= $lang["admin-calendar"]["create"]["months"][11] ?></option> + </select><br><br> + <li><?= $lang["admin-calendar"]["create"]["year"] ?></li> + <select id="year"> + <option value="<?= date('Y') ?>" selected><?= date('Y') ?></option> + <option value="<?= date('Y') + 1 ?>"><?= date('Y') + 1 ?></option> + <option value="<?= date('Y') + 2 ?>"><?= date('Y') + 2 ?></option> + <option value="<?= date('Y') + 3 ?>"><?= date('Y') + 3 ?></option> + <option value="<?= date('Y') + 4 ?>"><?= date('Y') + 4 ?></option> + <option value="<?= date('Y') + 5 ?>"><?= date('Y') + 5 ?></option> + </select> + </ul> + <h3><?= $lang["admin-calendar"]["create"]["info"] ?></h3> + <ul> + <li><?= $lang["admin-calendar"]["create"]["name"] ?></li> + <input type="text" placeholder="<?= $lang["admin-calendar"]["create"]["nameph"] ?>" id="name"><br><br> + <li><?= $lang["admin-calendar"]["create"]["desc"] ?> <i>(<?= $lang["admin-calendar"]["create"]["mandatory"] ?>)</i></li> + <input type="text" placeholder="<?= $lang["admin-calendar"]["create"]["web"] ?>" id="desc"><br><br> + <li><?= $lang["admin-calendar"]["create"]["web"] ?> <i>(<?= $lang["admin-calendar"]["create"]["mandatory"] ?>)</i> :</li> + <input onchange="validateUrl()" onkeyup="validateUrl()" onkeydown="validateUrl()" type="text" placeholder="<?= $lang["admin-calendar"]["create"]["webph"] ?>" id="link"><img id="link_check" src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/image/storeloader.svg" style="vertical-align:middle;" class="hide" width="24px" height="24px"><a class="hide" id="link_invalid"><img src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/image/close.svg" style="vertical-align:middle;" class="invert" width="24px" height="24px"></a> + </ul> + <p><table class="message_info"><tbody><tr><td><img src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/image/message_info.svg" class="message_img"></td><td style="width:100%;"><p><?= $lang["admin-calendar"]["create"]["notice"] ?></p></td></tr></tbody></table></p> + <div style="text-align: center;"><p><a class="button" onclick="createCmsEvent()"><?= $lang["admin-calendar"]["create"]["complete"] ?></a></p></div><br> + </div> +<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/postcontent.php"; ?> + +<script> + +function UrlRegex(str) { + var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string + '(\\#[-a-z\\d_]*)?$','i'); // fragment locator + return !!pattern.test(str); +} + +function validateUrl() { + document.getElementById('link_invalid').classList.add('hide'); + document.getElementById('link_check').classList.remove('hide'); + setTimeout(() => { + if (!UrlRegex(document.getElementById('link').value)) { + document.getElementById('link_invalid').classList.remove('hide'); + } else { + document.getElementById('link_invalid').classList.add('hide'); + } + document.getElementById('link_check').classList.add('hide'); + }, 2000) +} + +function createCmsEvent() { + document.getElementById('datainput').classList.add('hide') + var formData = new FormData(); + formData.append("day", document.getElementById('day').value); + formData.append("month", document.getElementById('month').value); + formData.append("year", document.getElementById('year').value); + formData.append("name", document.getElementById('name').value); + formData.append("desc", document.getElementById('desc').value); + formData.append("link", document.getElementById('link').value); + $.ajax({ + type: "POST", + dataType: 'html', + url: "<?= $GLOBALS["SYSTEM_ROOT"] ?>/api/admin/calendar_create.php", + success: function (data) { + if (data == "ok") { + location.href = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/calendar"; + } else { + alert("<?= $lang["admin-errors"]["errorprefix"] ?>" + data) + document.getElementById('datainput').classList.remove('hide') + } + }, + error: function (error) { + alert("<?= $lang["admin-errors"]["connerror"] ?>") + document.getElementById('datainput').classList.remove('hide') + }, + data: formData, + cache: false, + contentType: false, + processData: false + }); +} + +</script>
\ No newline at end of file diff --git a/Neutron-trunk/cms-special/admin-v2/calendar/index.php b/Neutron-trunk/cms-special/admin-v2/calendar/index.php new file mode 100644 index 0000000..e596551 --- /dev/null +++ b/Neutron-trunk/cms-special/admin-v2/calendar/index.php @@ -0,0 +1,86 @@ +<?php require_once "../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?> +<?php $pageConfig = [ "domName" => "Calendrier", "headerName" => "Gestion des événements" ]; include_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?> + <?php + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/calendar_events")) { + $calevn = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/calendar_events"); + } else { + $calevn = "3"; + } + + ?> + <?= $lang["admin-calendar"]["show"][0] ?> <select onchange="updateNextEvents()" id="nextevents"> + <option value="1" <?php if ($calevn == "1") { echo("selected"); } ?>>1</option> + <option value="2" <?php if ($calevn == "2") { echo("selected"); } ?>>2</option> + <option value="3" <?php if ($calevn == "3") { echo("selected"); } ?>>3</option> + <option value="4" <?php if ($calevn == "4") { echo("selected"); } ?>>4</option> + <option value="5" <?php if ($calevn == "5") { echo("selected"); } ?>>5</option> + <option value="6" <?php if ($calevn == "6") { echo("selected"); } ?>>6</option> + <option value="7" <?php if ($calevn == "7") { echo("selected"); } ?>>7</option> + <option value="8" <?php if ($calevn == "8") { echo("selected"); } ?>>8</option> + <option value="9" <?php if ($calevn == "9") { echo("selected"); } ?>>9</option> + <option value="10" <?php if ($calevn == "10") { echo("selected"); } ?>>10</option> + </select> <?= $lang["admin-calendar"]["show"][1] ?> + <h3><?= $lang["admin-calendar"]["events"] ?></h3> + <ul> + <?php + + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json")) { + $dbraw = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json"); + $corrupted = false; + if (isJson($dbraw)) { + $events = json_decode($dbraw); + foreach ($events->events as $event) { + if (isset($event->timestamp)) { + echo("<li><span style=\"cursor:help;\" title=\"" . $event->description . "\">" . $event->name . "</span> (" . $event->datestr . ")" . " - <a class=\"sblink\" href=\"{$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/calendar/manage/?id=" . $event->timestamp . "\" title=\"{$lang['admin-calendar']['manageph']}\">" . $lang["admin-calendar"]["manage"] . "</a></li>"); + } + } + } else { + echo("<div style=\"color:red; text-align: center;\"><b><u>{$lang['admin-calendar']['corrupt'][0]}</u> {$lang['admin-calendar']['corrupt'][1]} <u>{$lang['admin-calendar']['corrupt'][2]}</u></b></div>"); + $corrupted = true; + } + } else { + echo("<div style=\"text-align: center;\">{$lang['admin-calendar']['nothing']}</div>"); + } + + ?> + <?php + + if (!$corrupted) { + echo('<br><li><i><a href="' . $GLOBALS["SYSTEM_ROOT"] . '/cms-special/admin/calendar/add" title="' . $lang["admin-calendar"]["addph"] . '" class="sblink">' . $lang["admin-calendar"]["add"] . '</a></i></li>'); + } + + ?> + </ul> +<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/postcontent.php"; ?> +<script> + +function updateNextEvents() { + value = document.getElementById('nextevents').value; + var formData = new FormData(); + formData.append("value", value); + document.getElementById('nextevents').disabled = true; + $.ajax({ + type: "POST", + dataType: 'html', + url: "<?= $GLOBALS["SYSTEM_ROOT"] ?>/api/admin/calendar_nextevents.php", + success: function (data) { + if (data == "ok") { + document.getElementById('nextevents').disabled = false; + } else { + alert("<?= $lang["admin-errors"]["errorprefix"] ?>" + data) + document.getElementById('nextevents').disabled = false; + } + }, + error: function (error) { + alert("<?= $lang["admin-errors"]["connerror"] ?>") + document.getElementById('nextevents').disabled = false; + }, + data: formData, + cache: false, + contentType: false, + processData: false + }); +} + +</script>
\ No newline at end of file diff --git a/Neutron-trunk/cms-special/admin-v2/calendar/manage/index.php b/Neutron-trunk/cms-special/admin-v2/calendar/manage/index.php new file mode 100644 index 0000000..a6f4ebd --- /dev/null +++ b/Neutron-trunk/cms-special/admin-v2/calendar/manage/index.php @@ -0,0 +1,78 @@ +<?php require_once "../../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?> +<?php $pageConfig = [ "domName" => "Supprimer un événement - Calendrier", "headerName" => "Supprimer un événement" ]; include_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?> +<?php +$eventsraw = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json"); +if (isset($_GET['id'])) {} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS['SYSTEM_ROOT'] . "/cms-special/admin/calendar';</script>"); +} +if (isJson($eventsraw)) { + $events = json_decode($eventsraw); + foreach ($events->events as $element) { + if (isset($element->timestamp)) { + if ($element->timestamp == $_GET['id']) { + $event = $element; + } + } + } +} else { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS['SYSTEM_ROOT'] . "/cms-special/admin/calendar';</script>"); +} +if (!isset($event)) { + require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit("<script>location.href = '" . $GLOBALS['SYSTEM_ROOT'] . "/cms-special/admin/calendar';</script>"); +} +?> + <h3><?= $lang["admin-calendar"]["info"] ?></h3> + <ul> + <li><b><?= $event->name ?></b></li> + <?php + + if (trim($event->description) != "") { + echo("<li><i>" . $event->description . "</i></li>"); + } + + if (isset($event->link)) { + if (trim($event->link) != "") { + echo("<li><i>" . $event->link . "</i></li>"); + } + } + + ?> + <li><?= $event->datestr ?> (<code><?= $event->timestamp ?></code>)</li> + </ul> + <h3><?= $lang["admin-calendar"]["deleteask"] ?></h3> + <ul id="delete"> + <li><a class="sblink" href="<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/calendar" title="<?= $lang["admin-calendar"]["deletenoph"] ?>"><?= $lang["admin-calendar"]["deleteno"] ?></a></li> + <li><a class="sblink" onclick="deleteEvent()" title="<?= $lang["admin-calendar"]["deleteyesph"] ?>"><?= $lang["admin-calendar"]["deleteyes"] ?></a></li> + </ul> +<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/postcontent.php"; ?> + +<script> + +function deleteEvent() { + document.getElementById('delete').classList.add('hide') + var formData = new FormData(); + formData.append("id", <?= $event->timestamp ?>); + $.ajax({ + type: "POST", + dataType: 'html', + url: "<?= $GLOBALS["SYSTEM_ROOT"] ?>/api/admin/calendar_delete.php", + success: function (data) { + if (data == "ok") { + location.href = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/cms-special/admin/calendar"; + } else { + alert("<?= $lang["admin-errors"]["errorprefix"] ?>" + data) + document.getElementById('delete').classList.remove('hide') + } + }, + error: function (error) { + alert("<?= $lang["admin-errors"]["connerror"] ?>") + document.getElementById('delete').classList.remove('hide') + }, + data: formData, + cache: false, + contentType: false, + processData: false + }); +} + +</script>
\ No newline at end of file |