Pelzini

This is the code documentation for the Pelzini project

source of /viewer/controllers/author.php

Shows information about a specific author
  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 author
  23.  *
  24.  * @package Viewer
  25.  * @author Josh Heidenreich
  26.  * @since 0.2
  27.  * @tag i18n-done
  28.  **/
  29.  
  30. $_GET['name'] = trim($_GET['name']);
  31. if ($_GET['name'] == '') {
  32. require_once 'head.php';
  33. echo "Invalid author specified";
  34. require_once 'foot.php';
  35. }
  36.  
  37. $name_sql = db_quote ($_GET['name']);
  38.  
  39. $skin['page_name'] = str(STR_AUTHOR_PAGE_TITLE, 'name', $_GET['name']);
  40. require_once 'head.php';
  41.  
  42.  
  43.  
  44.  
  45. echo '<h2>', str(STR_AUTHOR_TITLE, 'name', $_GET['name']), '</h2>';
  46.  
  47.  
  48. // Show files
  49. $q = "SELECT files.id, files.name, item_authors.description
  50. FROM files
  51. INNER JOIN item_authors ON item_authors.linktype = " . LINK_TYPE_FILE . " AND item_authors.linkid = files.id
  52. WHERE item_authors.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 process_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_authors.description
  79. FROM classes
  80. INNER JOIN item_authors ON item_authors.linktype = " . LINK_TYPE_CLASS . " AND item_authors.linkid = classes.id
  81. WHERE item_authors.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 process_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_authors.description, classes.name AS classname,
  107. interfaces.name AS interfacename
  108. FROM functions
  109. INNER JOIN item_authors ON item_authors.linktype = " . LINK_TYPE_FUNCTION . " AND item_authors.linkid = functions.id
  110. LEFT JOIN classes ON functions.classid = classes.id
  111. LEFT JOIN interfaces ON functions.interfaceid = interfaces.id
  112. WHERE item_authors.name = {$name_sql}
  113. ORDER BY interfacename, classname, functions.name";
  114. $res = db_query($q);
  115. if (db_num_rows($res) > 0) {
  116. echo '<a name="functions"></a>';
  117. echo '<h3>', str(STR_FUNCTIONS), '</h3>';
  118.  
  119. $alt = false;
  120. echo '<div class="list">';
  121. while ($row = db_fetch_assoc ($res)) {
  122. $class = 'item';
  123. if ($alt) $class .= '-alt';
  124.  
  125. // display the function
  126. echo "<div class=\"{$class}\">";
  127.  
  128. $classname = null;
  129. if ($row['classname']) $classname = $row['classname'];
  130. if ($row['interfacename']) $classname = $row['interfacename'];
  131.  
  132. echo "<p><i>{$row['action']}</i> <strong>", get_function_link($classname, $row['name']), "</strong> ";
  133. if ($row['classname']) echo str(STR_FROM_CLASS, 'class', get_object_link($row['classname']));
  134. if ($row['interfacename']) echo str(STR_FROM_INTERFACE, 'interface', get_object_link($row['interfacename']));
  135. echo "</p>";
  136.  
  137. echo process_inline($row['description']);
  138. echo "</div>";
  139.  
  140. $alt = ! $alt;
  141. }
  142. echo '</div>';
  143. }
  144.  
  145.  
  146. require_once 'foot.php';
  147. ?>
  148.