PageRenderTime 32ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/phpmyfaq/admin/glossary.main.php

https://github.com/cyrke/phpMyFAQ
PHP | 115 lines | 86 code | 12 blank | 17 comment | 20 complexity | 2c4831551b3f4ba37882446f40fe0f82 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * The main glossary index file
  4. *
  5. * PHP Version 5.3
  6. *
  7. * This Source Code Form is subject to the terms of the Mozilla Public License,
  8. * v. 2.0. If a copy of the MPL was not distributed with this file, You can
  9. * obtain one at http://mozilla.org/MPL/2.0/.
  10. *
  11. * @category phpMyFAQ
  12. * @package Administration
  13. * @author Thorsten Rinne <thorsten@phpmyfaq.de>
  14. * @copyright 2005-2012 phpMyFAQ Team
  15. * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
  16. * @link http://www.phpmyfaq.de
  17. * @since 2005-09-15
  18. */
  19. if (!defined('IS_VALID_PHPMYFAQ')) {
  20. header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
  21. exit();
  22. }
  23. printf('<header><h2>%s</h2></header>', $PMF_LANG['ad_menu_glossary']);
  24. if ($permission['addglossary'] || $permission['editglossary'] || $permission['delglossary']) {
  25. printf(
  26. '<p><a class="btn btn-success" href="?action=addglossary"><i class="icon-plus icon-white"></i> %s</a></p>',
  27. $PMF_LANG['ad_glossary_add']
  28. );
  29. $glossary = new PMF_Glossary($faqConfig);
  30. if ('saveglossary' == $action && $permission['addglossary']) {
  31. $item = PMF_Filter::filterInput(INPUT_POST, 'item', FILTER_SANITIZE_STRIPPED);
  32. $definition = PMF_Filter::filterInput(INPUT_POST, 'definition', FILTER_SANITIZE_STRIPPED);
  33. if ($glossary->addGlossaryItem($item, $definition)) {
  34. echo '<p class="alert alert-success"><a href="#" class="close" data-dismiss="alert">×</a>';
  35. echo $PMF_LANG['ad_glossary_save_success'] . '</p>';
  36. } else {
  37. echo '<p class="alert alert-error"><a href="#" class="close" data-dismiss="alert">×</a>';
  38. echo $PMF_LANG['ad_glossary_save_error'];
  39. echo '<br />'.$PMF_LANG["ad_adus_dberr"].'<br />';
  40. echo $faqConfig->getDb()->error() . '</p>';
  41. }
  42. }
  43. if ('updateglossary' == $action && $permission['editglossary']) {
  44. $id = PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT);
  45. $item = PMF_Filter::filterInput(INPUT_POST, 'item', FILTER_SANITIZE_STRIPPED);
  46. $definition = PMF_Filter::filterInput(INPUT_POST, 'definition', FILTER_SANITIZE_STRIPPED);
  47. if ($glossary->updateGlossaryItem($id, $item, $definition)) {
  48. echo '<p class="alert alert-success"><a href="#" class="close" data-dismiss="alert">×</a>';
  49. echo $PMF_LANG['ad_glossary_update_success'] . '</p>';
  50. } else {
  51. echo '<p class="alert alert-error"><a href="#" class="close" data-dismiss="alert">×</a>';
  52. echo $PMF_LANG['ad_glossary_update_error'];
  53. echo '<br />'.$PMF_LANG["ad_adus_dberr"].'<br />';
  54. echo $faqConfig->getDb()->error() . '</p>';
  55. }
  56. }
  57. if ('deleteglossary' == $action && $permission['editglossary']) {
  58. $id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
  59. if ($glossary->deleteGlossaryItem($id)) {
  60. echo '<p class="alert alert-success"><a href="#" class="close" data-dismiss="alert">×</a>';
  61. echo $PMF_LANG['ad_glossary_delete_success'] . '</p>';
  62. } else {
  63. echo '<p class="alert alert-error"><a href="#" class="close" data-dismiss="alert">×</a>';
  64. echo $PMF_LANG['ad_glossary_delete_error'];
  65. echo '<br />'.$PMF_LANG["ad_adus_dberr"].'<br />';
  66. echo $faqConfig->getDb()->error() . '</p>';
  67. }
  68. }
  69. $glossaryItems = $glossary->getAllGlossaryItems();
  70. echo '<table class="table table-striped">';
  71. printf(
  72. '<thead><tr><th>%s</th><th>%s</th><th style="width: 16px">&nbsp;</th></tr></thead>',
  73. $PMF_LANG['ad_glossary_item'],
  74. $PMF_LANG['ad_glossary_definition']
  75. );
  76. foreach ($glossaryItems as $items) {
  77. echo '<tr>';
  78. printf(
  79. '<td><a href="%s%d">%s</a></td>',
  80. '?action=editglossary&amp;id=',
  81. $items['id'],
  82. $items['item']
  83. );
  84. printf(
  85. '<td>%s</td>',
  86. $items['definition']
  87. );
  88. printf(
  89. '<td><a onclick="return confirm(\'%s\'); return false;" href="%s%d">',
  90. $PMF_LANG['ad_user_del_3'],
  91. '?action=deleteglossary&amp;id=',
  92. $items['id']
  93. );
  94. printf(
  95. '<span title="%s" class="label label-important"><i class="icon-trash icon-white"></i></span></a></td>',
  96. $PMF_LANG['ad_entry_delete']
  97. );
  98. echo '</tr>';
  99. }
  100. echo '</table>';
  101. } else {
  102. echo $PMF_LANG["err_NotAuth"];
  103. }