include "top.php";
function display($startcat)
{
global $lo, $sl;
extract($GLOBALS);
$cat = (isset($_REQUEST['cat'])) ? $_REQUEST['cat'] : $cat;
if($startcat < 0)
{
$col = "parentid";
}
else
{
$col = "catid";
}
$query = "select * from category where $col = '$startcat' order by catorder, catname";
$result = mysqli_query($dblink,$query);
$i = 0;
while($row = mysqli_fetch_array($result))
{
$rows[$i++] = $row;
}
if($startcat < 0)
{
$catnames = parentCats($startcat);
}
else
{
$catnames = parentCats($cat);
}
$catid = $startcat;
$catline = "\n";
if($catid != 0)
{
$catline .= "Home\n";
}
if($catid == -1)
{
$catline .= "> Main Library\n";
$titleline = "Main Library";
}
else if($catid == -2)
{
$catline .= "> Reading Room\n";
$titleline = "Reading Room";
}
else if($catnames[0]->parentid == -1)
{
$catline .= "> Main Library\n";
$titleline = "Main Library";
}
else if($catnames[0]->parentid == -2)
{
$catline .= "> Reading Room\n";
$titleline = "Reading Room";
}
for($i = 0; $i < count($catnames); $i++)
{
if($i < count($catnames) - 1)
{
$catline .= "> catid . "&lo=$lo&sl=$sl\">" . $catnames[$i]->catname . "\n";
}
else
{
$catline .= "> " . $catnames[$i]->catname . "\n";
}
$titleline .= " > " . $catnames[$i]->catname;
}
printtop($titleline);
print "
\n";
print "| \n";
print $catline;
print " | \n";
#print "Search the OBL"\n";
print " | \n";
print "
|
\n";
print "| \n";
if($sl <= 0)
{
$sl = 0;
}
$query2 = "select * from catchild where catid = '$catid'";
$result2 = mysqli_query($dblink,$query2);
if(mysqli_num_rows($result2) > 0 && $catid > 0)
{
if($sl == 1)
{
print "Hide Links";
}
else
{
print "Show Links\n";
}
$showlinks = $sl;
}
else if($catid <= 0)
{
$showlinks = 0;
}
else
{
$showlinks = 1;
print " \n";
}
print " |
| \n";
if($showlinks == 1)
{
print "Order links by:\n";
if($lo == "t")
{
print "Reverse Date Title | \n";
}
else
{
$lo = "d";
print "Reverse Date Title\n";
}
}
if($catid < 0)
{
#print "Select a category below to start browsing.\n";
print "\n
\n\n";
}
print "
\n";
print "\n\n";
print "| \n";
for($i = 0; $i < count($rows); $i++)
{
displayCategory($rows[$i]['catid'], $showlinks, 1);
# break into two columns if the listing gets large
if(count($rows) > 20 && $i == (int) (count($rows) / 2))
{
print " | \n";
}
}
print " | \n";
print " |
\n";
printfoot();
}
function displayCatText($startcat)
{
extract($GLOBALS);
if($startcat < 0)
{
$col = "parentid";
}
else
{
$col = "catid";
}
$query = "select * from category where $col = '$startcat' order by catorder, catname";
$result = mysqli_query($dblink,$query);
$i = 0;
while($row = mysqli_fetch_array($result))
{
$rows[$i++] = $row;
}
for($i = 0; $i < count($rows); $i++)
{
displayCategoryText($rows[$i]['catid'], 0, 1);
}
}
function displayCategoryText($catid, $showlinks, $level)
{
global $dblink, $cat, $lo, $sl, $showpage;
$query = "select catname, catnotes from category where catid = '$catid'";
$result = mysqli_query($dblink,$query);
$row = mysqli_fetch_array($result);
$catname = $row['catname'];
$catnotes = $row['catnotes'];
if($lo == 't')
{
$linkorder = "link.title";
}
else
{
$lo = "d";
$linkorder = "link.date desc, title";
}
print "$catname; ";
}
function displayCategory($catid, $showlinks, $level)
{
global $dblink, $cat, $lo, $sl, $showpage;
$query = "select catname, catnotes from category where catid = '$catid'";
$result = mysqli_query($dblink,$query);
$row = mysqli_fetch_array($result);
$catname = $row['catname'];
$catnotes = $row['catnotes'];
if($lo == 't')
{
$linkorder = "link.title";
}
else
{
$lo = "d";
$linkorder = "link.date desc, title";
}
if($cat <= 0 && $level == 1)
{
print "";
}
if($level > 1 && $catid > 0)
{
print "- \n";
print "";
}
else if($cat > 0)
{
print "
\n";
}
print "$catname";
if($level > 1 || $cat < 0)
{
print "
\n";
}
# if at the top level, only display the name, so return
if($cat <= 0)
{
print "
\n";
return;
}
$query = "select * from linkparent where catid = '$catid'";
$result = mysqli_query($dblink,$query);
$numrows = mysqli_num_rows($result);
if($numrows > 0 && $showlinks == 0)
{
print " ($numrows)\n";
}
if($catnotes != "")
{
print "
\n";
print "$catnotes\n\n";
}
else
{
print "
\n";
}
if($showlinks == 1)
{
$query = "select * from type order by typename desc";
$result = mysqli_query($dblink,$query);
$j = 0;
while($row = mysqli_fetch_assoc($result))
{
$types[$j++] = $row;
}
$cats = parentCats($catid);
#if($cats[0]->parentid == -1)
#{
for($j = 0; $j < count($types); $j++)
{
$query = "select * from linkparent, link where linkparent.catid = '$catid' && linkparent.linkid = link.linkid && link.typeid = " . $types[$j]['typeid'] . " && link.available = 1 order by $linkorder";
$result = mysqli_query($dblink,$query);
$linkrows = array();
if(mysqli_num_rows($result) > 0)
{
print "" . $types[$j]['typename'] . "\n
\n";
#print "
\n";
$i = 0;
while($row = mysqli_fetch_array($result))
{
$linkrows[$i++] = $row;
}
for($i = 0; $i < count($linkrows); $i++)
{
displayLink($linkrows[$i]['linkid'], $level);
}
#print "
\n";
}
}
#}
#else
#{
#$query = "select * from linkparent, link where linkparent.catid = '$catid' && linkparent.linkid = link.linkid && link.available = 1 order by $linkorder";
#$result = mysqli_query($dblink,$query);
#print "\n";
#while($row = mysqli_fetch_array($result))
#{
#displayLink($row['linkid'], $level);
#}
#print "
\n";
#}
}
# get all the child categories and their names
$query = "select * from category where parentid = '$catid'";
$result = mysqli_query($dblink,$query);
$catchildren = array();
while($row = mysqli_fetch_array($result))
{
array_push($catchildren, $row);
}
# sort the child categories by name
usort($catchildren, "catCompare");
reset($catchildren);
# display each of them
foreach($catchildren as $row)
{
displayCategory($row['catid'], $showlinks, $level + 1);
}
if($level > 1)
{
print "
\n";
}
}
function displayLink($linkid, $level)
{
global $dblink;
$query = "select * from link where linkid = '$linkid'";
$result = mysqli_query($dblink,$query);
$row = mysqli_fetch_object($result);
#print "\n";
print formatLink($row, 0, 0);
#print "\n";
}
function displayNew($num)
{
global $dblink, $indexpage;
$query = "select * from link where dispnew = 1 order by dateofentry desc limit $num";
$result = mysqli_query($dblink,$query);
$newlinks = array();
while($row = mysqli_fetch_object($result))
{
array_push($newlinks, $row);
}
printtop("What's New");
print "| \n";
print "Home > What's New\n";
print " \n \n\n";
#print " \n";
foreach($newlinks as $row)
{
$rdateofentry = redoDate($row->dateofentry);
if($rdateofentry != "")
{
#print "- \n";
print formatLink($row, 1, 0);
print "\n
\n";
#print " \n";
}
}
#print " \n";
print " |
\n";
printfoot();
}
function displayNoticeBoard($num)
{
global $dblink, $indexpage;
$output = '';
$query = "select * from link where notice = 1 order by dateofentry desc";
if($num > 0)
{
$query .= " limit $num";
}
$result = mysqli_query($dblink,$query);
$noticelinks = array();
while($row = mysqli_fetch_object($result))
{
array_push($noticelinks, $row);
}
if($num == 0)
{
printtop("Notice Board");
print "| \n";
print "Home > Notice Board\n";
print " \n \n\n";
}
else
{
$output .= " \n";
}
#$output .= "\n";
foreach($noticelinks as $row)
{
$title = $row->title;
#if(strlen($title)>100)
#{
#$title = substr($title, 0, 100);
#$output .= "url\">$title ...";
#}
#else
#{
#$output .= "url\">$title";
#}
#$output .= "- \n";
$output .= "url\">$title";
$output .= "\n($row->source)\n";
#$output .= "
\n";
$output .= "\n \n";
}
if($num != 0)
{
$output .= "\n";
}
else
{
$output .= " |
|