// ------------------------------------------------------------- function paging($atts) { global $pretext, $thispage; // assert_page(); extract(lAtts(array( 'item' => 'page', 'url' => 0, 'link' => 1, 'linktext' => '', 'range' => 2, 'escape' => 'html', 'separator' => '', 'wraptag' => '', 'class' => '', 'break' => '', 'html_id' => '', ), $atts)); if (!empty($pretext['author'])) { $author = safe_field('RealName', 'txp_users', "name = '".doSlash($pretext['author'])."'"); } else { $author = ''; } $out = array(); $items = array( 'page' => $thispage['pg'], 'pages' => $thispage['numPages'], 'grand_total' => $thispage['grand_total'], 'result_total' => $thispage['total'], 'first' => 1, 'last' => $thispage['numPages'], 'prev' => (($thispage['pg'] - 1 > 0) ? range((($thispage['pg'] - $range > 0) ? $thispage['pg'] - $range : 1), $thispage['pg'] - 1) : ''), 'next' => (($thispage['pg'] + 1 <= $thispage['numPages']) ? range($thispage['pg'] + 1, (($thispage['pg'] + $range < $thispage['numPages']) ? $thispage['pg'] + $range : $thispage['numPages'])) : ''), 'all' => range(1, $thispage['numPages']), ); $item = do_list($item); $prev_gap = (in_array('prev', $item) && is_array($items['prev']) && $items['prev'][0] > 2) ? $separator : ''; $next_gap = (in_array('next', $item) && is_array($items['next']) && ($count = count($items['next'])) && $items['next'][$count-1] < $thispage['numPages'] - 1) ? $separator : ''; $linkable = array('page', 'pages', 'first', 'last', 'prev', 'next', 'all'); foreach ($item as $index) { if (isset($items[$index])) { if (is_array($items[$index])) { $itlist = $items[$index]; } elseif (empty($items[$index])) { $itlist = array(); } else { $itlist = array($items[$index]); } } else { $itlist = array($index); } foreach ($itlist as $theItem) { $href = (is_numeric($theItem) && in_array($index, $linkable)) ? pagelinkurl(array( 'month' => $pretext['month'], 'pg' => $theItem, 's' => $thispage['s'], 'c' => $thispage['c'], 'context' => $pretext['context'], 'q' => $pretext['q'], 'author' => $author )) : ''; $display = ($linktext) ? $linktext : $theItem; $display = ($escape == 'html') ? htmlspecialchars($display) : $display; $out[] = ($link && $href) ? ($url ? $href : href($display, $href)) : $display; } } return $prev_gap . doWrap($out, $wraptag, $break, $class, '', '', '', $html_id) . $next_gap; } // ------------------------------------------------------------- function if_first_page($atts,$thing) { global $thispage; //assert_page(); return parse(EvalElse($thing, (empty($thispage['pg']) or $thispage['pg'] == 1) )); } // ------------------------------------------------------------- function if_last_page($atts,$thing) { global $thispage; // assert_page(); return parse(EvalElse($thing, ($thispage['pg'] == $thispage['numPages']) )); } // ------------------------------------------------------------- function if_pages($atts,$thing) { global $thispage; // assert_page(); return parse(EvalElse($thing, ($thispage['numPages'] > 1) )); } // ------------------------------------------------------------- function if_page($atts,$thing) { global $thispage; // assert_page(); extract(lAtts(array( 'value' => '', ), $atts)); return parse(EvalElse($thing, in_list($thispage['pg'], $value))); }