Pelzini

This is the code documentation for the Pelzini project

source of /viewer/controllers/table.php

Displays information about the usage of a specific database table
  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.  * Displays information about the usage of a specific database table
  23.  *
  24.  * @package Viewer
  25.  * @author Josh Heidenreich
  26.  * @since 0.2
  27.  * @see viewer/tables_list.php
  28.  * @tag i18n-done
  29.  **/
  30.  
  31. require_once 'functions.php';
  32.  
  33. $_GET['name'] = trim($_GET['name']);
  34. if ($_GET['name'] == '') {
  35. require_once 'head.php';
  36. echo "Invalid table specified";
  37. require_once 'foot.php';
  38. }
  39.  
  40. $name_sql = db_quote ($_GET['name']);
  41.  
  42. $skin['page_name'] = str(STR_TABLE_PAGE_TITLE, 'name', $_GET['name']);
  43. require_once 'head.php';
  44.  
  45. echo '<h2>', str(STR_TABLE_TITLE, 'name', $_GET['name']), '</h2>';
  46.  
  47.  
  48. // Show files
  49. $q = "SELECT files.id, files.name, item_tables.action, item_tables.description
  50. FROM files
  51. INNER JOIN item_tables ON item_tables.linktype = " . LINK_TYPE_FILE . " AND item_tables.linkid = files.id
  52. WHERE item_tables.name = {$name_sql}
  53. ORDER BY files.name";
  54. $res = db_query ($q);
  55. if (db_num_rows($res) > 0) {
  56. echo '<h3>', str(STR_FILES), '</h3>';
  57.  
  58. $alt = false;
  59. echo '<div class="list">';
  60. while ($row = db_fetch_assoc ($res)) {
  61. $class = 'item';
  62. if ($alt) $class .= '-alt';
  63.  
  64. // output
  65. echo "<div class=\"{$class}\">";
  66. echo "<p><i>{$row['action']}</i> <strong>", get_file_link($row['name']), "</strong></p>";
  67. echo delink_inline($row['description']);
  68. echo '</div>';
  69.  
  70. $file_ids[] = $row['id'];
  71. $alt = ! $alt;
  72. }
  73. echo '</div>';
  74. }
  75.  
  76.  
  77. // Show classes
  78. $q = "SELECT classes.id, classes.name, item_tables.action, item_tables.description
  79. FROM classes
  80. INNER JOIN item_tables ON item_tables.linktype = " . LINK_TYPE_CLASS . " AND item_tables.linkid = classes.id
  81. WHERE item_tables.name = {$name_sql}
  82. ORDER BY classes.name";
  83. $res = db_query($q);
  84. if (db_num_rows($res) > 0) {
  85. echo '<a name="classes"></a>';
  86. echo '<h3>', str(STR_CLASSES), '</h3>';
  87.  
  88. $alt = false;
  89. echo '<div class="list">';
  90. while ($row = db_fetch_assoc ($res)) {
  91. $class = 'item';
  92. if ($alt) $class .= '-alt';
  93.  
  94. echo "<div class=\"{$class}\">";
  95. echo "<p><i>{$row['action']}</i> <strong>", get_class_link($row['name']), "</strong></p>";
  96. echo delink_inline($row['description']);
  97. echo '</div>';
  98.  
  99. $alt = ! $alt;
  100. }
  101. echo '</div>';
  102. }
  103.  
  104.  
  105. // Show functions
  106. $q = "SELECT functions.id, functions.name, item_tables.action, item_tables.description
  107. FROM functions
  108. INNER JOIN item_tables ON item_tables.linktype = " . LINK_TYPE_FUNCTION . " AND item_tables.linkid = functions.id
  109. WHERE item_tables.name = {$name_sql}
  110. ORDER BY functions.name";
  111. $res = db_query($q);
  112. if (db_num_rows($res) > 0) {
  113. echo '<a name="functions"></a>';
  114. echo '<h3>', str(STR_FUNCTIONS), '</h3>';
  115.  
  116. $alt = false;
  117. echo '<div class="list">';
  118. while ($row = db_fetch_assoc ($res)) {
  119. $class = 'item';
  120. if ($alt) $class .= '-alt';
  121.  
  122. // display the function
  123. echo "<div class=\"{$class}\">";
  124. echo "<p><i>{$row['action']}</i> <strong>", get_function_link(null, $row['name']), "</strong> </p>";
  125. echo delink_inline($row['description']);
  126. echo "</div>";
  127.  
  128. $alt = ! $alt;
  129. }
  130. echo '</div>';
  131. }
  132.  
  133.  
  134. require_once 'foot.php';
  135. ?>
  136.