Pelzini

This is the code documentation for the Pelzini project

source of /viewer/controllers/enumeration.php

Shows information about a specific enumeration
  1. <?php
  2. /*
  3. Copyright 2008 Josh Heidenreich
  4.  
  5. This file is part of Pelzini.
  6.  
  7. Pelzini 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. Pelzini 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 Pelzini. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20.  
  21. /**
  22.  * Shows information about a specific enumeration
  23.  *
  24.  * @package Viewer
  25.  * @author Josh Heidenreich
  26.  * @since 0.3
  27.  * @see ParserEnumeration
  28.  * @tag i18n-done
  29.  **/
  30.  
  31. require_once 'functions.php';
  32.  
  33.  
  34. // Determine what to show
  35. $sql_name = db_quote($_GET['name']);
  36. $q = new SelectQuery();
  37. $q->addFields('enumerations.id, enumerations.name, enumerations.description, enumerations.virtual, files.name AS filename, enumerations.sinceid');
  38. $q->setFrom('enumerations');
  39. $q->addInnerJoin('files ON enumerations.fileid = files.id');
  40. $q->addWhere("enumerations.name = {$sql_name}");
  41. $q->addProjectWhere();
  42.  
  43. $q = $q->buildQuery();
  44. $res = db_query ($q);
  45. $enumeration = db_fetch_assoc ($res);
  46.  
  47.  
  48. if ($enumeration == null) {
  49. require_once 'head.php';
  50. echo '<h2>', str(STR_ERROR_TITLE), '</h2>';
  51. echo '<p>', str(STR_ENUM_INVALID), '</p>';
  52. require_once 'foot.php';
  53. }
  54.  
  55.  
  56. $skin['page_name'] = str(STR_ENUM_BROWSER_TITLE, 'name', $enumeration['name']);
  57. require_once 'head.php';
  58.  
  59.  
  60. echo '<h2>', str(STR_ENUM_PAGE_TITLE, 'name', $enumeration['name']), '</h2>';
  61.  
  62. echo process_inline($enumeration['description']);
  63.  
  64.  
  65. echo "<ul>";
  66. echo '<li>', str(STR_FILE, 'filename', $enumeration['filename']), '</li>';
  67.  
  68. if ($enumeration['virtual']) {
  69. echo '<li>', str(STR_ENUM_VIRTUAL), '</li>';
  70. }
  71.  
  72. if ($enumeration['sinceid']) {
  73. echo '<li>', str(STR_AVAIL_SINCE, 'version', get_since_version($enumeration['sinceid'])), '</li>';
  74. }
  75. echo "</ul>";
  76.  
  77.  
  78. show_authors ($enumeration['id'], LINK_TYPE_ENUMERATION);
  79. show_tables ($enumeration['id'], LINK_TYPE_ENUMERATION);
  80.  
  81.  
  82. // Show constants
  83. $q = "SELECT name, value, description
  84. FROM constants
  85. WHERE enumerationid = {$enumeration['id']}
  86. ORDER BY value";
  87. $res = db_query($q);
  88. if (db_num_rows($res) > 0) {
  89. echo '<a name="constants"></a>';
  90. echo '<h3>', str(STR_CONSTANTS), '</h3>';
  91.  
  92. echo "<table class=\"function-list\">\n";
  93. echo '<tr><th>', str(STR_NAME), '</th><th>', str(STR_VALUE), '</th><th>', str(STR_DESCRIPTION), "</th></tr>\n";
  94. while ($row = db_fetch_assoc ($res)) {
  95. // encode for output
  96. $row['name'] = htmlspecialchars($row['name']);
  97. $row['value'] = htmlspecialchars($row['value']);
  98. if ($row['description'] == null) $row['description'] = '&nbsp;';
  99.  
  100. // display the constant
  101. echo "<tr>";
  102. echo "<td><code>{$row['name']}</code></td>";
  103. echo "<td><code>{$row['value']}</code></td>";
  104. echo "<td>{$row['description']}</td>";
  105. echo "</tr>\n";
  106. }
  107. echo "</table>\n";
  108. }
  109.  
  110.  
  111. show_see_also ($enumeration['id'], LINK_TYPE_FUNCTION);
  112. show_tags ($enumeration['id'], LINK_TYPE_ENUMERATION);
  113.  
  114.  
  115. require_once 'foot.php';
  116. ?>
  117.