diff --git a/include/util.php b/include/util.php index 69ec102..8ac9c63 100644 --- a/include/util.php +++ b/include/util.php @@ -242,6 +242,22 @@ function getNumberOfImages() return $row->num_images; } +/* Get the number of queued bug links in the database */ +function getNumberOfQueuedBugLinks() +{ + $result = query_appdb("SELECT count(*) as num_buglinks FROM buglinks WHERE queued='true';"); + $row = mysql_fetch_object($result); + return $row->num_buglinks; +} + +/* Get the number of bug links in the database */ +function getNumberOfBugLinks() +{ + $result = query_appdb("SELECT count(*) as num_buglinks FROM buglinks;"); + $row = mysql_fetch_object($result); + return $row->num_buglinks; +} + function lookupVendorName($vendorId) { $sResult = query_appdb("SELECT * FROM vendor ". @@ -706,4 +722,60 @@ function perform_search_and_output_results($search_words) outputSearchTableForhResult($search_words, $hResult); } +function display_page_range($currentPage=1, $pageRange=1, $totalPages=1, $linkurl=NULL) +{ + if($linkurl==NULL) + { + $linkurl = $_SERVER['PHP_SELF']."?"; + } + /* display the links to each of these pages */ + $currentPage = max(1,(min($currentPage,$totalPages))); + $pageRange = min($pageRange,$totalPages); + + if($currentPage <= ceil($pageRange/2)) + { + $startPage = 1; + $endPage = $pageRange; + } else + { + if($currentPage + ($pageRange/2) > $totalPages) + { + $startPage = $totalPages - $pageRange; + $endPage = $totalPages; + } else + { + $startPage = $currentPage - floor($pageRange/2); + $endPage = $currentPage + floor($pageRange/2); + } + } + $startPage = max(1,$startPage); + + if($currentPage != 1) + { + echo "|< "; + $previousPage = $currentPage - 1; + echo "< "; + } else + { + echo "|< < "; + } + /* display the desired range */ + for($x = $startPage; $x <= $endPage; $x++) + { + if($x != $currentPage) + echo "$x "; + else + echo "$x "; + } + + if($currentPage < $totalPages) + { + $nextPage = $currentPage + 1; + echo "> "; + echo ">| "; + } else + echo "> >|"; + +} + ?>