Pelzini

This is the code documentation for the Pelzini project

source of /viewer/controllers/tag.php

Shows information about a specific tag
  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 tag
  23.  *
  24.  * @package Viewer
  25.  * @author Josh Heidenreich
  26.  * @since 0.3
  27.  * @tag i18n-done
  28.  **/
  29.  
  30. require_once 'functions.php';
  31.  
  32. $_GET['name'] = trim($_GET['name']);
  33. if ($_GET['name'] == '') {
  34. require_once 'head.php';
  35. echo "Invalid tag specified";
  36. require_once 'foot.php';
  37. }
  38.  
  39. $name_sql = db_quote ($_GET['name']);
  40.  
  41. $skin['page_name'] = str(STR_TAG_PAGE_TITLE, 'name', $_GET['name']);
  42. require_once 'head.php';
  43.  
  44. echo '<h2>', str(STR_TAG_TITLE, 'name', $_GET['name']), '</h2>';
  45.  
  46.  
  47.  
  48. // Show files
  49. $q = "SELECT files.id, files.name
  50. FROM files
  51. INNER JOIN item_info_tags ON item_info_tags.linktype = " . LINK_TYPE_FILE . " AND item_info_tags.linkid = files.id
  52. WHERE item_info_tags.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><strong>", get_file_link($row['name']), "</strong></p>";
  67. echo '</div>';
  68.  
  69. $file_ids[] = $row['id'];
  70. $alt = ! $alt;
  71. }
  72. echo '</div>';
  73. }
  74.  
  75.  
  76. // Show classes
  77. $q = "SELECT classes.id, classes.name
  78. FROM classes
  79. INNER JOIN item_info_tags ON item_info_tags.linktype = " . LINK_TYPE_CLASS . " AND item_info_tags.linkid = classes.id
  80. WHERE item_info_tags.name = {$name_sql}
  81. ORDER BY classes.name";
  82. $res = db_query($q);
  83. if (db_num_rows($res) > 0) {
  84. echo '<a name="classes"></a>';
  85. echo '<h3>', str(STR_CLASSES), '</h3>';
  86.  
  87. $alt = false;
  88. echo '<div class="list">';
  89. while ($row = db_fetch_assoc ($res)) {
  90. $class = 'item';
  91. if ($alt) $class .= '-alt';
  92.  
  93. echo "<div class=\"{$class}\">";
  94. echo "<p><strong>", get_class_link($row['name']), "</strong></p>";
  95. echo '</div>';
  96.  
  97. $alt = ! $alt;
  98. }
  99. echo '</div>';
  100. }
  101.  
  102.  
  103. // Show functions
  104. $q = "SELECT functions.id, functions.name, classes.name AS classname,
  105. interfaces.name AS interfacename
  106. FROM functions
  107. INNER JOIN item_info_tags ON item_info_tags.linktype = " . LINK_TYPE_FUNCTION . " AND item_info_tags.linkid = functions.id
  108. LEFT JOIN classes ON functions.classid = classes.id
  109. LEFT JOIN interfaces ON functions.interfaceid = interfaces.id
  110. WHERE item_info_tags.name = {$name_sql}
  111. ORDER BY interfacename, classname, functions.name";
  112. $res = db_query($q);
  113. if (db_num_rows($res) > 0) {
  114. echo '<a name="functions"></a>';
  115. echo '<h3>', str(STR_FUNCTIONS), '</h3>';
  116.  
  117. $alt = false;
  118. echo '<div class="list">';
  119. while ($row = db_fetch_assoc ($res)) {
  120. $class = 'item';
  121. if ($alt) $class .= '-alt';
  122.  
  123. // display the function
  124. echo "<div class=\"{$class}\">";
  125.  
  126. $classname = null;
  127. if ($row['classname']) $classname = $row['classname'];
  128. if ($row['interfacename']) $classname = $row['interfacename'];
  129.  
  130. echo "<p><strong>", get_function_link($classname, $row['name']), "</strong> ";
  131. if ($row['classname']) echo str(STR_FROM_CLASS, 'class', get_object_link($row['classname']));
  132. if ($row['interfacename']) echo str(STR_FROM_INTERFACE, 'interface', get_object_link($row['interfacename']));
  133. echo "</p>";
  134. echo "</div>";
  135.  
  136. $alt = ! $alt;
  137. }
  138. echo '</div>';
  139. }
  140.  
  141.  
  142. // Show constants
  143. $q = "SELECT constants.id, constants.name, constants.fileid
  144. FROM constants
  145. INNER JOIN item_info_tags ON item_info_tags.linktype = " . LINK_TYPE_CONSTANT . " AND item_info_tags.linkid = constants.id
  146. WHERE item_info_tags.name = {$name_sql}
  147. ORDER BY constants.name";
  148. $res = db_query($q);
  149. if (db_num_rows($res) > 0) {
  150. echo '<a name="constants"></a>';
  151. echo '<h3>', str(STR_CONSTANTS), '</h3>';
  152.  
  153. $alt = false;
  154. echo '<div class="list">';
  155. while ($row = db_fetch_assoc ($res)) {
  156. $row['name'] = htmlspecialchars($row['name']);
  157.  
  158. $class = 'item';
  159. if ($alt) $class .= '-alt';
  160.  
  161. echo "<div class=\"{$class}\">";
  162. echo "<p><strong>{$row['name']}</strong></p>";
  163. echo '</div>';
  164.  
  165. $alt = ! $alt;
  166. }
  167. echo '</div>';
  168. }
  169.  
  170.  
  171. require_once 'foot.php';
  172. ?>
  173.