Pelzini

This is the code documentation for the Pelzini project

source of /viewer/controllers/file.php

Shows information about a specific file
  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 file
  23.  *
  24.  * @package Viewer
  25.  * @author Josh Heidenreich
  26.  * @since 0.1
  27.  * @see ParserFile
  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('files.id, files.name, files.description, namespaces.name AS namespace, files.sinceid');
  38. $q->setFrom('files');
  39. $q->addWhere("files.name = {$sql_name}");
  40. $q->addLeftJoin('namespaces ON files.namespaceid = namespaces.id');
  41. $q->addProjectWhere();
  42.  
  43. $q = $q->buildQuery();
  44. $res = db_query ($q);
  45. $file = db_fetch_assoc ($res);
  46.  
  47.  
  48. if ($file == null) {
  49. require_once 'head.php';
  50. echo '<h2>', str(STR_ERROR_TITLE), '</h2>';
  51. echo '<p>', str(STR_FILE_INVALID), '</p>';
  52. require_once 'foot.php';
  53. }
  54.  
  55.  
  56. $skin['page_name'] = $file['name'];
  57. require_once 'head.php';
  58.  
  59.  
  60. echo '<h2>', str(STR_FILE_PAGE_TITLE, 'name', $file['name']), '</h2>';
  61.  
  62. if ($file['namespace'] != null) {
  63. echo '<p>', str(STR_NAMESPACE, 'name', get_namespace_link($file['namespace'])), '</p>';
  64. }
  65.  
  66. if ($file['sinceid'] != null) {
  67. echo '<p>', str(STR_AVAIL_SINCE, 'version', get_since_version($file['sinceid'])), '</p>';
  68. }
  69.  
  70. echo "<p><small><a href=\"file_source?name=", urlencode($file['name']), "\">", str(STR_FILE_VIEW_SOURCE), '</a></small></p>';
  71.  
  72. echo '<br>', process_inline($file['description']);
  73.  
  74.  
  75. show_authors ($file['id'], LINK_TYPE_FILE);
  76. show_tables ($file['id'], LINK_TYPE_FILE);
  77.  
  78.  
  79. // Show classes
  80. $q = "SELECT id, name, description
  81. FROM classes
  82. WHERE fileid = {$file['id']}
  83. ORDER BY name";
  84. $res = db_query($q);
  85. if (db_num_rows($res) > 0) {
  86. echo '<a name="classes"></a>';
  87. echo '<h3>', str(STR_CLASSES), '</h3>';
  88.  
  89. $alt = false;
  90. echo '<div class="list">';
  91. while ($row = db_fetch_assoc ($res)) {
  92. $class = 'item';
  93. if ($alt) $class .= '-alt';
  94.  
  95. echo "<div class=\"{$class}\">";
  96. echo "<p><strong>", get_class_link($row['name']), "</strong></p>";
  97. echo process_inline($row['description']);
  98. echo '</div>';
  99.  
  100. $alt = ! $alt;
  101. }
  102. echo '</div>';
  103. }
  104.  
  105.  
  106. // Show interfaces
  107. $q = "SELECT id, name, description
  108. FROM interfaces
  109. WHERE fileid = {$file['id']}
  110. ORDER BY name";
  111. $res = db_query($q);
  112. if (db_num_rows($res) > 0) {
  113. echo '<a name="interfaces"></a>';
  114. echo '<h3>', str(STR_INTERFACES), '</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. echo "<div class=\"{$class}\">";
  123. echo "<p><strong>", get_interface_link($row['name']), "</strong></p>";
  124. echo process_inline($row['description']);
  125. echo '</div>';
  126.  
  127. $alt = ! $alt;
  128. }
  129. echo '</div>';
  130. }
  131.  
  132.  
  133. // Show functions
  134. $q = "SELECT id, name, description, arguments
  135. FROM functions
  136. WHERE fileid = {$file['id']} AND classid IS NULL AND interfaceid IS NULL
  137. ORDER BY name";
  138. $res = db_query($q);
  139. if (db_num_rows($res) > 0) {
  140. echo '<a name="functions"></a>';
  141. echo '<h3>', str(STR_FUNCTIONS), '</h3>';
  142.  
  143. $alt = false;
  144. echo '<div class="list">';
  145. while ($row = db_fetch_assoc ($res)) {
  146. $class = 'item';
  147. if ($alt) $class .= '-alt';
  148.  
  149. // display the function
  150. echo "<div class=\"{$class}\">";
  151. echo "<p><strong>", get_function_link(null, $row['name']), "</strong></p>";
  152. echo process_inline($row['description']);
  153. echo '</div>';
  154.  
  155. $alt = ! $alt;
  156. }
  157. echo '</div>';
  158. }
  159.  
  160.  
  161. // Show enums
  162. $q = "SELECT id, name, description
  163. FROM enumerations
  164. WHERE fileid = {$file['id']}
  165. ORDER BY name";
  166. $res = db_query($q);
  167. if (db_num_rows($res) > 0) {
  168. echo '<a name="functions"></a>';
  169. echo '<h3>', str(STR_ENUMERATIONS), '</h3>';
  170.  
  171. $alt = false;
  172. echo '<div class="list">';
  173. while ($row = db_fetch_assoc ($res)) {
  174. $class = 'item';
  175. if ($alt) $class .= '-alt';
  176.  
  177. // display the function
  178. echo "<div class=\"{$class}\">";
  179. echo "<p><strong><a href=\"enumeration?name=", urlencode($row['name']), "\">", htmlspecialchars($row['name']), "</a></strong></p>";
  180. echo process_inline($row['description']);
  181. echo '</div>';
  182.  
  183. $alt = ! $alt;
  184. }
  185. echo '</div>';
  186. }
  187.  
  188.  
  189. // Show constants
  190. $q = "SELECT name, value, description
  191. FROM constants
  192. WHERE fileid = {$file['id']} AND enumerationid IS NULL
  193. ORDER BY name";
  194. $res = db_query($q);
  195. if (db_num_rows($res) > 0) {
  196. echo '<a name="constants"></a>';
  197. echo '<h3>', str(STR_CONSTANTS), '</h3>';
  198.  
  199. echo "<table class=\"function-list\">\n";
  200. echo "<tr><th>Name</th><th>Value</th><th>Description</th></tr>\n";
  201. while ($row = db_fetch_assoc ($res)) {
  202. // encode for output
  203. $row['name'] = htmlspecialchars($row['name']);
  204. $row['value'] = htmlspecialchars($row['value']);
  205. if ($row['description'] == null) $row['description'] = '&nbsp;';
  206.  
  207. // display the constant
  208. echo "<tr>";
  209. echo "<td><code>{$row['name']}</code></td>";
  210. echo "<td><code>{$row['value']}</code></td>";
  211. echo "<td>{$row['description']}</td>";
  212. echo "</tr>\n";
  213. }
  214. echo "</table>\n";
  215. }
  216.  
  217.  
  218. show_see_also ($file['id'], LINK_TYPE_FILE);
  219. show_tags ($file['id'], LINK_TYPE_FILE);
  220.  
  221.  
  222. require_once 'foot.php';
  223. ?>
  224.