function amr_pagetext($thispage = 1, $totalitems, $rowsperpage = 30)
 {
     /* echo's paging text based on parameters - */
     $lastpage = ceil($totalitems / $rowsperpage);
     if ($thispage > $lastpage) {
         $thispage = $lastpage;
     }
     $from = ($thispage - 1) * $rowsperpage + 1;
     $to = $from + $rowsperpage - 1;
     if ($to > $totalitems) {
         $to = $totalitems;
     }
     $totalpages = ceil($totalitems / $rowsperpage);
     $base = amr_adjust_query_args();
     $paging_text = paginate_links(array('total' => $totalpages, 'current' => $thispage, 'base' => @add_query_arg('listpage', '%#%', $base), 'format' => '', 'end_size' => 2, 'mid_size' => 2, 'add_args' => false));
     if ($paging_text) {
         $paging_text = PHP_EOL . '<div class="tablenav">' . PHP_EOL . '<div class="tablenav-pages">' . sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s', 'amr-users') . '</span>&nbsp;%s', number_format_i18n($from), number_format_i18n($to), number_format_i18n($totalitems), $paging_text . '</div>' . PHP_EOL . '</div>');
     }
     return $paging_text;
 }
function amr_make_sortable($colname, $colhead)
{
    /* adds a link to the column headings so that one can resort against the cache */
    $dir = 'SORT_ASC';
    if (!empty($_REQUEST['sort']) and $_REQUEST['sort'] === $colname) {
        if (!empty($_REQUEST['dir'])) {
            if ($_REQUEST['dir'] === 'SORT_ASC') {
                $dir = 'SORT_DESC';
            } else {
                $dir = 'SORT_ASC';
            }
        }
    }
    //$link = remove_query_arg(array('refresh'));
    $link = amr_adjust_query_args();
    //keep filtering when re sorting etc
    $link = add_query_arg('sort', $colname, $link);
    $link = add_query_arg('dir', $dir, $link);
    if (!empty($_REQUEST['rows_per_page'])) {
        $link = add_query_arg('rows_per_page', (int) $_REQUEST['rows_per_page'], $link);
    }
    return '<a title="' . __('Click to sort.  Click again to change direction.', 'amr-users') . '" href="' . htmlentities($link) . '">' . $colhead . '</a>';
}