entry.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Bibliotheca
  4. *
  5. * Copyright 2018-2023 Johannes Keßler
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  19. */
  20. require_once 'lib/mancubus.class.php';
  21. $Mancubus = new Mancubus($DB,$Doomguy);
  22. require_once 'lib/manageentry.class.php';
  23. $ManageEntry = new Manageentry($DB,$Doomguy);
  24. require_once 'lib/trite.class.php';
  25. $Trite = new Trite($DB,$Doomguy);
  26. $_collection = '';
  27. if(isset($_GET['collection']) && !empty($_GET['collection'])) {
  28. $_collection = trim($_GET['collection']);
  29. $_collection = Summoner::validate($_collection,'digit') ? $_collection : '';
  30. }
  31. $_id = '';
  32. if(isset($_GET['id']) && !empty($_GET['id'])) {
  33. $_id = trim($_GET['id']);
  34. $_id = Summoner::validate($_id,'digit') ? $_id : '';
  35. }
  36. $TemplateData['pageTitle'] = '?';
  37. $TemplateData['fieldViewDefault'] = Summoner::themefile('entry/field-unknown.html', UI_THEME);
  38. $TemplateData['entry'] = array();
  39. $TemplateData['loadedCollection'] = array();
  40. $TemplateData['storagePath'] = '';
  41. $TemplateData['showEdit'] = false;
  42. if(!empty($_collection) && !empty($_id)) {
  43. $TemplateData['loadedCollection'] = $Trite->load($_collection);
  44. if(!empty($TemplateData['loadedCollection'])) {
  45. $Mancubus->setCollection($Trite->param('id'));
  46. $TemplateData['entry'] = $Mancubus->getEntry($_id);
  47. $TemplateData['storagePath'] = PATH_WEB_STORAGE.'/'.$Trite->param('id').'/'.$_id;
  48. $TemplateData['navSearchAction'] = array('p' => 'collections', 'collection' => $Trite->param('id'));
  49. $ManageEntry->setCollection($Trite->param('id'));
  50. $TemplateData['showEdit'] = $ManageEntry->canEditEntry($_id);
  51. if(isset($TemplateData['entry']['fields']['title'])) {
  52. $TemplateData['pageTitle'] = $TemplateData['entry']['fields']['title']['value'].' - '.$Trite->param('name');
  53. }
  54. else {
  55. $TemplateData['pageTitle'] = ' - '.$Trite->param('name');
  56. }
  57. }
  58. else {
  59. $TemplateData['message']['content'] = $I18n->t('global.message.couldNotLoadCollection');
  60. $TemplateData['message']['status'] = 'error';
  61. }
  62. }
  63. else {
  64. $TemplateData['message']['status'] = 'error';
  65. $TemplateData['message']['content'] = $I18n->t('global.message.missingQueryParams');
  66. }