Pelzini

This is the code documentation for the Pelzini project

source of /viewer/controllers/namespace.php

Displays information about a specific package
  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 a specific package
  23.  *
  24.  * @package Viewer
  25.  * @author Josh Heidenreich
  26.  * @since 0.1
  27.  * @tag i18n-done
  28.  **/
  29.  
  30. require_once 'functions.php';
  31.  
  32.  
  33. $sql_name = db_quote($_GET['name']);
  34. $q = "SELECT id, name FROM namespaces WHERE name = {$sql_name} AND projectid = {$project['id']} LIMIT 1";
  35. $res = db_query($q);
  36.  
  37. if (! $namespace = db_fetch_assoc ($res)) {
  38. require_once 'head.php';
  39. echo '<h2>', str(STR_ERROR_TITLE), '</h2>';
  40. echo str(STR_NAMESPACE_INVALID);
  41. require_once 'foot.php';
  42. }
  43.  
  44. $namespace['name'] = htmlspecialchars($namespace['name']);
  45.  
  46. $skin['page_name'] = $namespace['name'];
  47. require_once 'head.php';
  48.  
  49. echo '<h2>', str(STR_NAMESPACE_PAGE_TITLE, 'name', $namespace['name']), '</h2>';
  50.  
  51.  
  52. // Show sub-namespaces
  53. $q = "SELECT id, name
  54. FROM namespaces
  55. WHERE parentid = {$namespace['id']}
  56. ORDER BY name";
  57. $res = db_query($q);
  58. if (db_num_rows($res) > 0) {
  59. echo '<div>';
  60. echo '<a name="classes"></a>';
  61. echo '<h3>', str(STR_NAMESPACES), '</h3>';
  62. echo '<img src="assets/icon_remove.png" alt="" title="Hide this result" onclick="hide_content(event)" class="showhide" style="margin-top: -40px;">';
  63.  
  64. $alt = false;
  65. echo '<div class="list content">';
  66. while ($row = db_fetch_assoc ($res)) {
  67. $class = 'item';
  68. if ($alt) $class .= '-alt';
  69.  
  70. echo "<div class=\"{$class}\">";
  71. echo "<p><strong><a href=\"namespace?name=", htmlspecialchars($row['name']), "\">", htmlspecialchars($row['name']), "</a></strong></p>";
  72. echo '</div>';
  73.  
  74. $alt = ! $alt;
  75. }
  76. echo '</div>';
  77. echo '</div>';
  78. }
  79.  
  80.  
  81. // Show classes
  82. $q = "SELECT id, name, description
  83. FROM classes
  84. WHERE namespaceid = {$namespace['id']}
  85. ORDER BY name";
  86. $res = db_query($q);
  87. if (db_num_rows($res) > 0) {
  88. echo '<div>';
  89. echo '<a name="classes"></a>';
  90. echo '<h3>', str(STR_CLASSES), '</h3>';
  91. echo '<img src="assets/icon_remove.png" alt="" title="Hide this result" onclick="hide_content(event)" class="showhide" style="margin-top: -40px;">';
  92.  
  93. $alt = false;
  94. echo '<div class="list content">';
  95. while ($row = db_fetch_assoc ($res)) {
  96. $class = 'item';
  97. if ($alt) $class .= '-alt';
  98.  
  99. echo "<div class=\"{$class}\">";
  100. echo "<p><strong>", get_class_link($row['name']), "</strong></p>";
  101. echo delink_inline($row['description']);
  102. echo '</div>';
  103.  
  104. $alt = ! $alt;
  105. }
  106. echo '</div>';
  107. echo '</div>';
  108. }
  109.  
  110.  
  111. // Show interfaces
  112. $q = "SELECT id, name, description
  113. FROM interfaces
  114. WHERE namespaceid = {$namespace['id']}
  115. ORDER BY name";
  116. $res = db_query($q);
  117. if (db_num_rows($res) > 0) {
  118. echo '<div>';
  119. echo '<a name="interfaces"></a>';
  120. echo '<h3>', str(STR_INTERFACES), '</h3>';
  121. echo '<img src="assets/icon_remove.png" alt="" title="Hide this result" onclick="hide_content(event)" class="showhide" style="margin-top: -40px;">';
  122.  
  123. $alt = false;
  124. echo '<div class="list content">';
  125. while ($row = db_fetch_assoc ($res)) {
  126. $class = 'item';
  127. if ($alt) $class .= '-alt';
  128.  
  129. echo "<div class=\"{$class}\">";
  130. echo "<p><strong>", get_interface_link($row['name']), "</strong></p>";
  131. echo delink_inline($row['description']);
  132. echo '</div>';
  133.  
  134. $alt = ! $alt;
  135. }
  136. echo '</div>';
  137. echo '</div>';
  138. }
  139.  
  140.  
  141. // Show functions
  142. $q = "SELECT id, name, description, arguments
  143. FROM functions
  144. WHERE namespaceid = {$namespace['id']} AND classid IS NULL AND interfaceid IS NULL
  145. ORDER BY name";
  146. $res = db_query($q);
  147. if (db_num_rows($res) > 0) {
  148. echo '<div>';
  149. echo '<a name="functions"></a>';
  150. echo '<h3>', str(STR_FUNCTIONS), '</h3>';
  151. echo '<img src="assets/icon_remove.png" alt="" title="Hide this result" onclick="hide_content(event)" class="showhide" style="margin-top: -40px;">';
  152.  
  153. $alt = false;
  154. echo '<div class="list content">';
  155. while ($row = db_fetch_assoc ($res)) {
  156. $class = 'item';
  157. if ($alt) $class .= '-alt';
  158.  
  159. // display the function
  160. echo "<div class=\"{$class}\">";
  161. echo "<p><strong>", get_function_link(null, $row['name']), "</strong></p>";
  162. echo delink_inline($row['description']);
  163. echo "</div>";
  164.  
  165. $alt = ! $alt;
  166. }
  167. echo '</div>';
  168. echo '</div>';
  169. }
  170.  
  171.  
  172. require_once 'foot.php';
  173.  
  174.