mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Removed unused np_class.php and added $frm->pagination() method for simple use of the nextprev shortcode, without having to parse {NEXTPREV} text.
This commit is contained in:
@@ -1186,6 +1186,33 @@ class e_form
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render Pagination using 'nextprev' shortcode.
|
||||
* @param string $url eg. e_REQUEST_SELF.'?from=[FROM]'
|
||||
* @param int $total total records
|
||||
* @param int $from value to replace [FROM] with in the URL
|
||||
* @param int $perPage number of items per page
|
||||
* @param array $options template, type, glyphs
|
||||
* @return string
|
||||
*/
|
||||
public function pagination($url='', $total=0, $from=0, $perPage=10, $options=array())
|
||||
{
|
||||
require_once(e_CORE."shortcodes/single/nextprev.php");
|
||||
|
||||
$nextprev = array(
|
||||
'tmpl_prefix' => varset($options['template'],'default'),
|
||||
'total' => intval($total),
|
||||
'amount' => intval($perPage),
|
||||
'current' => intval($from),
|
||||
'url' => urldecode($url),
|
||||
'type' => varset($options['type'],'record'), // page|record
|
||||
'glyphs' => vartrue($options['glyphs'],false) // 1|0
|
||||
);
|
||||
|
||||
return nextprev_shortcode($nextprev);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Render a bootStrap ProgressBar.
|
||||
|
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_np.php");
|
||||
|
||||
/**
|
||||
* Next / Previous handling class
|
||||
*
|
||||
*/
|
||||
class nextprev {
|
||||
|
||||
/**
|
||||
* Generate next / previous pages and appropriate links (
|
||||
*
|
||||
* @param string $url, refer url
|
||||
* @param int $from, start figure
|
||||
* @param int $view, items per page
|
||||
* @param int $total, total items
|
||||
* @param string $td, comfort text
|
||||
* @param string $qs, QUERY_STRING, default null
|
||||
* @param bool $return, Output onto page or return the links
|
||||
* @return nextprev string
|
||||
*/
|
||||
function nextprev($url, $from, $view, $total, $td, $qs = "", $return = false) {
|
||||
if ($total > $view) {
|
||||
$pages = ceil($total / $view);
|
||||
} else {
|
||||
$pages = FALSE;
|
||||
}
|
||||
|
||||
if ($pages) {
|
||||
$nppage = LAN_GOPAGE." ";
|
||||
if ($pages > 10) {
|
||||
$current = ($from/$view)+1;
|
||||
|
||||
for($c = 0; $c <= 2; $c++) {
|
||||
$nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c + 1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
|
||||
}
|
||||
|
||||
if ($current >= 3 && $current <= 5) {
|
||||
for($c = 3; $c <= $current; $c++) {
|
||||
$nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c+1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
|
||||
}
|
||||
}
|
||||
else if($current >= 6 && $current <= ($pages-5)) {
|
||||
$nppage .= " ... ";
|
||||
for($c = ($current-2); $c <= $current; $c++) {
|
||||
$nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c+1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
|
||||
}
|
||||
}
|
||||
$nppage .= " ... ";
|
||||
|
||||
|
||||
if (($current + 5) > $pages && $current != $pages) {
|
||||
$tmp = ($current-2);
|
||||
} else {
|
||||
$tmp = $pages-3;
|
||||
}
|
||||
|
||||
for($c = $tmp; $c <= ($pages-1); $c++) {
|
||||
$nppage .= ($view * $c == $from ? "[<span style='text-decoration:underline'>".($c + 1)."</span>] " : "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
|
||||
}
|
||||
|
||||
} else {
|
||||
for($c = 0; $c < $pages; $c++) {
|
||||
if ($view * $c == $from ? $nppage .= "[<span style='text-decoration:underline'>".($c + 1)."</span>] " : $nppage .= "<a href='{$url}?".($view * $c).($qs ? ".{$qs}" : "")."'>".($c + 1)."</a> ");
|
||||
}
|
||||
}
|
||||
$text = "<div style='text-align:right'><div class='nextprev'><span class='smalltext'>{$nppage}</span></div></div>\n<br /><br />\n";
|
||||
if($return == true){
|
||||
return $text;
|
||||
} else {
|
||||
echo $text;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user