Initial commit.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?
|
||||
require_once('open_db.lib.php');
|
||||
require_once("get_data.lib.php");
|
||||
include_once("Numbers/Words.php");
|
||||
|
||||
function sort_options($link) {
|
||||
$queue = get_queue();
|
||||
$search = get_search_args();
|
||||
$sort = get_sort_arg();
|
||||
$order = get_order();
|
||||
$start = get_start_num();
|
||||
$show = get_show_num();
|
||||
$which_sort = array(
|
||||
'date' => 'date',
|
||||
'author' => 'author',
|
||||
'title' => 'title',
|
||||
);
|
||||
$which_order = array(
|
||||
'asc' => '',
|
||||
'desc' => 'z-a',
|
||||
);
|
||||
$options = array();
|
||||
foreach ($which_sort as $sort_key=>$sort_value) {
|
||||
foreach ($which_order as $order_key=>$order_value) {
|
||||
if ($sort_key == 'date')
|
||||
$order_value = ($order_key == 'asc') ? '' : 'descending' ;
|
||||
$display = '<span>' . $sort_value;
|
||||
$display .= $order_value ? " " . $order_value : "";
|
||||
$display .= '</span>';
|
||||
if ($sort == $sort_key && $order == $order_key) {
|
||||
array_push($options, $display);
|
||||
} else {
|
||||
$href = '<a href="'.$link.'?sort='.$sort_key.'&order='.$order_key;
|
||||
if (isset($_GET['queue'])) $href .= '&queue='.$_GET['queue'];
|
||||
if (isset($_GET['search'])) $href .= '&search='.$search;
|
||||
if (isset($_GET['start'])) $href .= '&start='.$start;
|
||||
if (isset($_GET['show'])) $href .= '&show='.$show;
|
||||
$href .= '">'.$display.'</a>';
|
||||
|
||||
array_push($options, $href);
|
||||
}
|
||||
}
|
||||
}
|
||||
$string = '<div class="options">Sort by: ' . implode(' <span class="bar">|</span> ', $options) . '</div>'."\n";
|
||||
return $string;
|
||||
}
|
||||
|
||||
function get_pager() {
|
||||
global $editable;
|
||||
$queue = get_queue();
|
||||
$search = get_search_args();
|
||||
$sort = get_sort_arg();
|
||||
$order = get_order();
|
||||
$start = get_start_num();
|
||||
$show = get_show_num();
|
||||
|
||||
$prev = $start+$show;
|
||||
$next = $start-$show;
|
||||
|
||||
// If next is less than 0, make sure we can see the next stories
|
||||
if ($next < 0) $next = 0;
|
||||
|
||||
$link = $editable ? "" : "/article";
|
||||
$queue_url = $queue ? 1 : 0;
|
||||
|
||||
$string = '<div class="pager">';
|
||||
// Are there later stories?
|
||||
if ($start > 0) {
|
||||
$string .= "\n".'<span class="next"><a href="'.$link.'?start='.$next;
|
||||
if (isset($_GET['queue'])) $string .= '&queue='.$queue_url;
|
||||
if (isset($_GET['search'])) $string .= '&search='.$search;
|
||||
if (isset($_GET['show'])) $string .= '&show='.$show;
|
||||
if (isset($_GET['sort'])) $string .= '&sort='.$sort;
|
||||
if (isset($_GET['order'])) $string .= '&order='.$order;
|
||||
$articles = ($show == 1) ? "article" : Numbers_Words::toWords($show)." articles";
|
||||
$string .= '">« Next '.$articles.'</a></span>';
|
||||
}
|
||||
// Are there earlier stories?
|
||||
if ($prev < get_count()) {
|
||||
$string .= "\n".'<span class="prev"><a href="'.$link.'?start='.$prev;
|
||||
if (isset($_GET['queue'])) $string .= '&queue='.$queue_url;
|
||||
if (isset($_GET['search'])) $string .= '&search='.$search;
|
||||
if (isset($_GET['show'])) $string .= '&show='.$show;
|
||||
if (isset($_GET['sort'])) $string .= '&sort='.$sort;
|
||||
if (isset($_GET['order'])) $string .= '&order='.$order;
|
||||
$articles = ($show == 1) ? "article" : Numbers_Words::toWords($show)." articles";
|
||||
$string .= '">Previous '.$articles.' »</a></span>';
|
||||
}
|
||||
$string .= "</div>\n";
|
||||
return $string;
|
||||
}
|
||||
Reference in New Issue
Block a user