entry.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * scientia
  4. *
  5. * Copyright 2023 - 2024 Johannes Keßler
  6. *
  7. * https://www.bananas-playground.net/projekt/scientia/
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  21. */
  22. require_once 'lib/entry.class.php';
  23. $Entry = new Entry($DB);
  24. $TemplateData['data'] = array();
  25. if(!empty($_id)) {
  26. $TemplateData['data'] = $Entry->load($_year,$_month,$_day,$_id);
  27. $TemplateData['data']['breadcrumb'] = array($_year,$_month,$_day);
  28. }
  29. if(isset($_POST['submitForm']) && isset($_POST['fdata'])) {
  30. $fdata = $_POST['fdata'];
  31. if(isset($fdata['entry']) && Summoner::validate($fdata['entry'])) {
  32. $_dataToSave = trim($fdata['entry']);
  33. if(!empty($_id) && isset($_POST['deleteEntry']) && $_POST['deleteEntry'] == "yes") {
  34. $do = $Entry->delete($_id);
  35. $_r = '/';
  36. }
  37. elseif(!empty($_id)) {
  38. $do = $Entry->update($_dataToSave,$_id);
  39. $_r = '/'.$_year.'/'.$_month.'/'.$_day.'/'.$_id;
  40. }
  41. else {
  42. $do = $Entry->create($_dataToSave);
  43. $_r = date('/Y/m/d/').$do;;
  44. }
  45. if($do !== false) {
  46. $TemplateData['refresh'] = $_r;
  47. }
  48. }
  49. }