<?php
include_once('etc/vars.php');
// ******************************************************************
// MISCELLANEOUS BLOCKS
// Blocks Available:
// - blockPageNavigation
// (Gets navigation links for a inputted list.)
// - blockBookFormats
// (Gets box of formats available for inputted book.)
// - blockAuthorBooks
// (Gets list of books by author of inputted book.)
// ******************************************************************
// **** blockPageNavigation Function ****
// Input: PageType, RowStart, ModifierType , ModifierValue
// Output: To screen
// Description: Prints Page Navigation, for books, authors, categories, or formats,
// with modifiers (filters) available for books (books of a particular
// author, etc).
function blockPageNavigation($pageType, $rowStart, $modifierType = NULL, $modifierValue = NULL)
{
global $displayLimit;
//For Debugging
//print "PageType: $pageType<br>RowStart: $rowStart<br>ModifierType: $modifierType<br>ModifierValue: $modifierValue";
switch ($pageType)
{
case 'a': // Author
$linkName = "author.php";
$itemRecordset = getAuthorCount();
break;
case 'b': // Book
$linkName = "book.php";
switch ($modifierType)
{
case 'a': // Author
$itemRecordset = getBookCount($modifierValue);
break;
case 'c': // Category
$itemRecordset = getBookCount(NULL, $modifierValue);
break;
case 'f': // Format
$itemRecordset = getBookCount(NULL, NULL, $modifierValue);
break;
default:
$itemRecordset = getBookCount();
}
break;
case 'c': // Category
$linkName = "topic.php";
// $itemRecordset = getBookCount();
break;
case 'f': // Format
$linkName = "format.php";
// $itemRecordset = getBookCount();
break;
}
print '<div class="navigation">';
// Display the Previous Button
if ($rowStart <> 0)
{
print '<a href="' . $linkName . '?s=' . ($rowStart - $displayLimit) . '">Previous</a> ';
}
// Display the Page Number Buttons
$itemCount = dbGetRow($itemRecordset);
$pagesNeeded = ceil(($itemCount[0] / $displayLimit));
$currentPage = 1;
// Display the first page number (if required)
if ($pagesNeeded > 1)
{
if ((($currentPage - 1) * $displayLimit) == $rowStart)
{
print $currentPage;
}
else
{
print '<a href="' . $linkName . '?s=' . (($currentPage - 1) * $displayLimit) . '">' . $currentPage . '</a>';
}
}
// Display the rest of the page number (if required)
while ($currentPage < $pagesNeeded)
{
$currentPage++;
if ((($currentPage - 1) * $displayLimit) == $rowStart)
{
print $currentPage;
}
else
{
print '<a href="' . $linkName . '?s=' . (($currentPage - 1) * $displayLimit) . '">' . $currentPage . '</a>';
}
}
// Display the Next Button
if (($rowStart + $displayLimit) / $displayLimit < $pagesNeeded)
{
print ' <a href="' . $linkName . '?s=' . ($rowStart + $displayLimit) . '">Next</a>';
}
print '</div>';
}
// **** blockBookFormats Function ****
// Input: doc_id
// Output: Floating div with list of formats available.
// Description: Gets list of all formats for current book.
// Sorted By: Alphabetical Order
function blockBookFormats($doc_id)
{
if (!$doc_id == '')
{
?>
<div class="sidebartitle">
Also available in...
</div>
<div class="sidebaritems">
<?php
$formatList = getBookFormatList($doc_id);
if (!$formatList == '')
{
while ($format = dbGetRow($formatList))
{
print '<img src="images/' . $format[0] . '.gif" align="middle" alt="' . $format[1] . '"> <a href="display.php?d=' .
$doc_id . '&f=' . $format[0] . '">' . $format[1] . ' Version</a><br />';
}
}
?>
</div>
<?php
}
}
// **** blockAuthorBooks Function ****
// Input: doc_id
// Output: Floating div with list of the author's other books.
// Description: Gets list of all other books of the author.
// Sorted By: Alphabetical Order
function blockAuthorBooks($doc_id)
{
if (!$doc_id == '')
{
$bookList = getAuthorOtherBookList($doc_id);
if (!$bookList == '')
{
if ($book = dbGetRow($bookList))
{
print '<div class="sidebartitle">Books by ' . $book[5] . ' ' . $book[4] . '</div>';
print '<div class="sidebaritems">';
print '<a href="display.php?d=' . $book[0] . '" target="_blank">' . $book[1] . '</a><br />';
while ($book = dbGetRow($bookList))
{
print '<a href="display.php?d=' . $book[0] . '" target="_blank">' . $book[1] . '</a><br />';
}
print '</div>';
}
}
}
}
?>