tool.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/tentacle.class.php';
  21. $Tools = new Tentacle($DB,$Doomguy);
  22. require_once 'lib/managecollectionfields.class.php';
  23. $ManangeCollectionsFields = new ManageCollectionFields($DB, $Doomguy);
  24. require_once 'lib/manageentry.class.php';
  25. $Manageentry = new Manageentry($DB,$Doomguy);
  26. require_once 'lib/trite.class.php';
  27. $Trite = new Trite($DB,$Doomguy);
  28. $TemplateData['pageTitle'] = 'Tool';
  29. $TemplateData['tool'] = array();
  30. $TemplateData['tool']['viewFile'] = '';
  31. $TemplateData['collection'] = array();
  32. $TemplateData['editEntry'] = array();
  33. $_collection = '';
  34. if(isset($_GET['collection']) && !empty($_GET['collection'])) {
  35. $_collection = trim($_GET['collection']);
  36. $_collection = Summoner::validate($_collection,'digit') ? $_collection : '';
  37. }
  38. $_id = '';
  39. if(isset($_GET['id']) && !empty($_GET['id'])) {
  40. $_id = trim($_GET['id']);
  41. $_id = Summoner::validate($_id,'digit') ? $_id : '';
  42. }
  43. $_t = '';
  44. if(isset($_GET['t']) && !empty($_GET['t'])) {
  45. $_t = trim($_GET['t']);
  46. $_t = Summoner::validate($_t,'nospace') ? $_t : '';
  47. }
  48. if(!empty($_collection) && !empty($_t)) {
  49. $collection = $Trite->load($_collection,"write");
  50. $toolInfo = $Tools->validate($_t);
  51. if(!empty($collection) && !empty($toolInfo)) {
  52. $TemplateData['tool'] = $toolInfo;
  53. $TemplateData['collection'] = $collection;
  54. $ManangeCollectionsFields->setCollection($Trite->param('id'));
  55. $Manageentry->setCollection($Trite->param('id'));
  56. if(!empty($_id)) {
  57. $TemplateData['editEntry'] = $Manageentry->getEditData($_id);
  58. }
  59. $_toolFile = Summoner::themefile('tool/tool-'.$toolInfo['action'].'.php', UI_THEME);
  60. $_toolViewFile = Summoner::themefile('tool/tool-'.$toolInfo['action'].'.html', UI_THEME);
  61. if(file_exists($_toolFile) && file_exists($_toolViewFile)) {
  62. require_once $_toolFile;
  63. $TemplateData['tool']['viewFile'] = $_toolViewFile;
  64. $TemplateData['pageTitle'] .= ' - '.$toolInfo['name'];
  65. }
  66. else {
  67. $TemplateData['tool']['viewFile'] = '';
  68. $TemplateData['message']['content'] = $I18n->t('tool.message.missingFiles');
  69. $TemplateData['message']['status'] = "error";
  70. }
  71. }
  72. else {
  73. $TemplateData['message']['content'] = $I18n->t('global.message.couldNotLoadCollection');
  74. $TemplateData['message']['status'] = "error";
  75. }
  76. }