PageRenderTime 43ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/phpmyfaq/admin/report.view.php

https://github.com/cyrke/phpMyFAQ
PHP | 145 lines | 121 code | 6 blank | 18 comment | 21 complexity | 2035ce8609a0b0c0dd3fee0755453ef9 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * View a generated report
  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 Gustavo Solt <gustavo.solt@mayflower.de>
  14. * @author Thorsten Rinne <thorsten@phpmyfaq.de>
  15. * @copyright 2011-2012 phpMyFAQ Team
  16. * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
  17. * @link http://www.phpmyfaq.de
  18. * @since 2011-01-12
  19. */
  20. if (!defined('IS_VALID_PHPMYFAQ')) {
  21. header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
  22. exit();
  23. }
  24. if ($permission['reports']) {
  25. printf('<h2>%s</h2>', $PMF_LANG['ad_menu_reports']);
  26. $useCategory = PMF_Filter::filterInput(INPUT_POST, 'report_category', FILTER_VALIDATE_INT);
  27. $useSubcategory = PMF_Filter::filterInput(INPUT_POST, 'report_sub_category', FILTER_VALIDATE_INT);
  28. $useTranslation = PMF_Filter::filterInput(INPUT_POST, 'report_translations', FILTER_VALIDATE_INT);
  29. $useLanguage = PMF_Filter::filterInput(INPUT_POST, 'report_language', FILTER_VALIDATE_INT);
  30. $useId = PMF_Filter::filterInput(INPUT_POST, 'report_id', FILTER_VALIDATE_INT);
  31. $useSticky = PMF_Filter::filterInput(INPUT_POST, 'report_sticky', FILTER_VALIDATE_INT);
  32. $useTitle = PMF_Filter::filterInput(INPUT_POST, 'report_title', FILTER_VALIDATE_INT);
  33. $useCreationDate = PMF_Filter::filterInput(INPUT_POST, 'report_creation_date', FILTER_VALIDATE_INT);
  34. $useOwner = PMF_Filter::filterInput(INPUT_POST, 'report_owner', FILTER_VALIDATE_INT);
  35. $useLastModified = PMF_Filter::filterInput(INPUT_POST, 'report_last_modified_person', FILTER_VALIDATE_INT);
  36. $useUrl = PMF_Filter::filterInput(INPUT_POST, 'report_url', FILTER_VALIDATE_INT);
  37. $useVisits = PMF_Filter::filterInput(INPUT_POST, 'report_visits', FILTER_VALIDATE_INT);
  38. ?>
  39. <table class="table table-striped">
  40. <thead>
  41. <tr>
  42. <?php
  43. ($useCategory) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_category']) : '';
  44. ($useSubcategory) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_sub_category']) : '';
  45. ($useTranslation) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_translations']) : '';
  46. ($useLanguage) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_language']) : '';
  47. ($useId) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_id']) : '';
  48. ($useSticky) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_sticky']) : '';
  49. ($useTitle) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_title']) : '';
  50. ($useCreationDate) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_creation_date']) : '';
  51. ($useOwner) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_owner']) : '';
  52. ($useLastModified) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_last_modified_person']) : '';
  53. ($useUrl) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_url']) : '';
  54. ($useVisits) ? printf('<th>%s</th>', $PMF_LANG['ad_stat_report_visits']) : '';
  55. ?>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. <?php
  60. $report = new PMF_Report($faqConfig);
  61. foreach ($report->getReportingData() as $data) {
  62. echo '<tr>';
  63. if ($useCategory) {
  64. if (0 != $data['category_parent']) {
  65. printf('<td>%s</td>', $data['category_parent']);
  66. } else {
  67. printf('<td>%s</td>', $data['category_name']);
  68. }
  69. }
  70. if ($useSubcategory) {
  71. if (0 != $data['category_parent']) {
  72. printf('<td>%s</td>', $data['category_name']);
  73. } else {
  74. echo '<td>n/a</td>';
  75. }
  76. }
  77. if ($useTranslation) {
  78. printf('<td>%d</td>', $data['faq_translations']);
  79. }
  80. if ($useLanguage) {
  81. printf('<td>%s</td>', $languageCodes[strtoupper($data['faq_language'])]);
  82. }
  83. if ($useId) {
  84. printf('<td>%d</td>', $data['faq_id']);
  85. }
  86. if ($useSticky) {
  87. printf('<td>%s</td>', $data['faq_sticky']);
  88. }
  89. if ($useTitle) {
  90. printf('<td>%s</td>', $data['faq_question']);
  91. }
  92. if ($useCreationDate) {
  93. printf('<td>%s</td>', $data['faq_creation']);
  94. }
  95. if ($useOwner) {
  96. printf('<td>%s</td>', $data['faq_org_author']);
  97. }
  98. if ($useLastModified) {
  99. printf('<td>%s</td>', $data['faq_last_author']);
  100. }
  101. if ($useUrl) {
  102. $url = sprintf('<a href="../index.php?action=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s">Link</a>',
  103. $data['category_id'],
  104. $data['faq_id'],
  105. $data['faq_language']
  106. );
  107. printf('<td>%s</td>', $url);
  108. }
  109. if ($useVisits) {
  110. printf('<td>%d</td>', $data['faq_visits']);
  111. }
  112. echo '</tr>';
  113. }
  114. ?>
  115. </tbody>
  116. </table>
  117. <form action="?action=reportexport" method="post">
  118. <input type="hidden" name="report_category" id="report_category" value="<?php echo $useCategory; ?>" /></td>
  119. <input type="hidden" name="report_sub_category" id="report_sub_category" value="<?php echo $useSubcategory; ?>" /></td>
  120. <input type="hidden" name="report_translations" id="report_translations" value="<?php echo $useTranslation; ?>" /></td>
  121. <input type="hidden" name="report_language" id="report_language" value="<?php echo $useLanguage; ?>" /></td>
  122. <input type="hidden" name="report_id" id="report_id" value="<?php echo $useId; ?>" /></td>
  123. <input type="hidden" name="report_sticky" id="report_sticky" value="<?php echo $useSticky; ?>" /></td>
  124. <input type="hidden" name="report_title" id="report_title" value="<?php echo $useTitle; ?>" /></td>
  125. <input type="hidden" name="report_creation_date" id="report_creation_date" value="<?php echo $useCreationDate; ?>" /></td>
  126. <input type="hidden" name="report_owner" id="report_owner" value="<?php echo $useOwner; ?>" /></td>
  127. <input type="hidden" name="report_last_modified_person" id="report_last_modified_person" class="radio" value="<?php echo $useLastModified; ?>">
  128. <input type="hidden" name="report_url" id="report_url" value="<?php echo $useUrl; ?>" /></td>
  129. <input type="hidden" name="report_visits" id="report_visits" value="<?php echo $useVisits; ?>" /></td>
  130. <div class="form-actions">
  131. <button class="btn btn-primary" type="submit">
  132. <?php echo $PMF_LANG["ad_stat_report_make_csv"]; ?>
  133. </button>
  134. </div>
  135. </form>
  136. <?php
  137. } else {
  138. echo $PMF_LANG['err_NotAuth'];
  139. }