|
From: <ph...@us...> - 2007-08-27 16:55:09
|
Revision: 1019
http://xoops.svn.sourceforge.net/xoops/?rev=1019&view=rev
Author: phppp
Date: 2007-08-27 09:55:11 -0700 (Mon, 27 Aug 2007)
Log Message:
-----------
Added xoPageNav plugin from old trunk, manually
Added Paths:
-----------
XoopsCore/trunk/htdocs/class/smarty/xoops_plugins/function.xoPageNav.php
Added: XoopsCore/trunk/htdocs/class/smarty/xoops_plugins/function.xoPageNav.php
===================================================================
--- XoopsCore/trunk/htdocs/class/smarty/xoops_plugins/function.xoPageNav.php (rev 0)
+++ XoopsCore/trunk/htdocs/class/smarty/xoops_plugins/function.xoPageNav.php 2007-08-27 16:55:11 UTC (rev 1019)
@@ -0,0 +1,47 @@
+<?php
+/*
+ itemsCount: Total number of items in the current list
+ pageSize: Number of items in each page
+ offset: Index of the 1st item currently displayed
+ linksCount: Number of direct links to show (default to 5)
+ url: URL mask used to generate links (%s will be replace by offset)
+ itemsCount=$items_count pageSize=$module_config.perpage offset=$offset
+ url="viewcat.php?cid=`$entity.cid`&orderby=`$sort_order`&offset=%s"
+*/
+
+function smarty_function_xoPageNav( $params, &$smarty ) {
+ global $xoops;
+
+ extract( $params );
+ if ( $pageSize < 1 ) {
+ $pageSize = 10;
+ }
+ $pagesCount = intval( $itemsCount / $pageSize );
+ if ( $itemsCount <= $pageSize || $pagesCount < 2 ) {
+ return '';
+ }
+ $str = '';
+ $currentPage = intval( $offset / $pageSize ) + 1;
+ $lastPage = intval( $itemsCount / $pageSize ) + 1;
+
+ $minPage = min( 1, ceil( $currentPage - $linksCount/2 ) );
+ $maxPage = max( $lastPage, floor( $currentPage + $linksCount/2 ) );
+
+ if ( $currentPage > 1 ) {
+ $str .= '<a href="' . $xoops->url( str_replace( '%s', $offset-$pageSize, $url ) ) . '">Previous</a>';
+ }
+ for ( $i = $minPage; $i <= $maxPage; $i++ ) {
+ $tgt = htmlspecialchars( $xoops->url( str_replace( '%s', ($i - 1) * $pageSize, $url ) ), ENT_QUOTES );
+ $str .= "<a href='$tgt'>$i</a>";
+ }
+ if ( $currentPage < $lastPage ) {
+ $str .= '<a href="' . $xoops->url( str_replace( '%s', $offset+$pageSize, $url ) ) . '">Next</a>';
+ }
+ $class = @!empty($class) ? htmlspecialchars( $class, ENT_QUOTES ) : 'pagenav';
+
+ $str = "<div class='$class'>$str</div>";
+ return $str;
+
+}
+
+?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|