<?php
include_once('etc/vars.php');
// ******************************************************************
// AUTHOR BLOCKS
// Blocks Available:
// - blockGetAuthorList
// (Prints list of all authors.)
// - blockGetAuthorDetails
// (Prints full name of author from DB.)
// ******************************************************************
// **** blockGetAuthorList Function ****
// Input: RowStart
// Output: To screen
// Description: Prints list of all authors into a table.
function blockGetAuthorList($rowStart)
{
global $displayLimit;
// Get author list and display it, starting at the passed in number, and displaying
// a set number of items (plus to be able to check if there's extra beyond the displayed).
$authorList = getAuthorList($rowStart, $displayLimit + 1);
if (!$authorList == '') // Display list if authors are found in DB.
{
print '<h2>Author Listing</h2>';
print '<table width="100%" cellpadding="3" class="titletable">'; // <table>
print '<tr><th width="450">Author</th><th width="50">Books</th></tr>';
$displayItems = 1;
$evenRow = false;
// Loop until total number of items are displayed.
while ($displayItems <= $displayLimit)
{
// If there is another book in the table, display it.
if ($author = dbGetRow($authorList))
{
if ($evenRow == false)
print '<tr class="darkrow">';
else
print '<tr class="lightrow">';
// Print author info. // <tr>
print '<td><a href="author.php?a=' . $author[0] . '">' .
$author[2] . ' ' . $author[1] . ' ' . $author[3] . '</a></td>'; // <td></td>
print '<td align="center">'; // <td>
// Total all books for an author.
$books = getBookCount($author[0]);
if ($bookCount = dbGetRow($books))
{
print $bookCount[0];
}
print '</td></tr>'; // </td></tr>
}
// Increment number of items displayed.
$displayItems++;
if ($evenRow == false)
$evenRow = true;
else
$evenRow = false;
}
print '</table>'; // </table>
blockPageNavigation('a', $rowStart, NULL, NULL);
}
else // Print error when author lookup returns no results.
{
print 'No authors found. Either there is a database problem, or this is a brand new installation that is working, but is simply empty!';
}
}
// **** blockGetAuthorDetails Function ****
// Input: Author ID
// Output: To screen
// Description: Prints details of the author (first name, last name, and 'extension').
function blockGetAuthorDetails($author_id)
{
$authors = getAuthor($author_id);
if ($author = dbGetRow($authors))
{
print '<h2>' . $author[2] . ' ' . $author[1] . ' ' . $author[3] . '</h2>';
}
}
?>