NobuNobu
nobun****@users*****
2006年 12月 3日 (日) 16:44:54 JST
Index: xoops2jp/html/class/smarty/plugins/function.xoops_pagenavi.php diff -u xoops2jp/html/class/smarty/plugins/function.xoops_pagenavi.php:1.1.2.3.2.4 xoops2jp/html/class/smarty/plugins/function.xoops_pagenavi.php:1.1.2.3.2.5 --- xoops2jp/html/class/smarty/plugins/function.xoops_pagenavi.php:1.1.2.3.2.4 Sun Dec 3 13:52:17 2006 +++ xoops2jp/html/class/smarty/plugins/function.xoops_pagenavi.php Sun Dec 3 16:44:54 2006 @@ -1,80 +1,80 @@ -<?php - -/* - * Smarty plugin - * ------------------------------------------------------------- - * Type: function - * Name: xoops_pagenavi - * Version: 1.0 - * Date: Nov 13, 2005 - * Author: minahito - * Purpose: the place holder for xoops pagenavi. - * Input: pagenavi = - * offset = - * - * Examples: {xoops_pagenavi pagenavi=$pagenavi} - * ------------------------------------------------------------- - */ -function smarty_function_xoops_pagenavi($params, &$smarty) -{ - $ret = ""; - - if (isset($params['pagenavi']) && is_object($params['pagenavi'])) { - - $navi =& $params['pagenavi']; - - $perPage = $navi->getPerpage(); - - $total = $navi->getTotalItems(); - $totalPages = $navi->getTotalPages(); - - if ($totalPages == 0) { - return; - } - - $url = $navi->renderURLForPage(); - $current = $navi->getStart(); - - $offset = isset($params['offset']) ? intval($params['offset']) : 4; - - // - // check prev - // - if($navi->hasPrivPage()) { - $ret .= @sprintf("<a href='%s'>«</a>", $navi->renderURLForPage($navi->getPrivStart())); - } - - // - // counting - // - $counter=1; - $currentPage = $navi->getCurrentPage(); - while($counter<=$totalPages) { - if($counter==$currentPage) { - $ret.=@sprintf("<strong>(%d)</strong> ",$counter); - } - elseif(($counter>$currentPage-$offset && $counter<$currentPage+$offset) || $counter==1 || $counter==$totalPages) { - if($counter==$totalPages && $currentPage<$totalPages-$offset) { - $ret.="... "; - } - $ret .= @sprintf("<a href='%s'>%d</a> ",$navi->renderURLForPage(($counter-1)*$perPage),$counter); - if($counter==1 && $currentPage>1 + $offset) { - $ret.="... "; - } - } - $counter++; - } - - // - // check next - // - $next=$current + $perPage; - if($navi->hasNextPage()) { - $ret.=@sprintf("<a href='%s'>»</a>",$navi->renderURLForPage($navi->getNextStart())); - } - } - - print $ret; -} - -?> +<?php + +/* + * Smarty plugin + * ------------------------------------------------------------- + * Type: function + * Name: xoops_pagenavi + * Version: 1.0 + * Date: Nov 13, 2005 + * Author: minahito + * Purpose: the place holder for xoops pagenavi. + * Input: pagenavi = + * offset = + * + * Examples: {xoops_pagenavi pagenavi=$pagenavi} + * ------------------------------------------------------------- + */ +function smarty_function_xoops_pagenavi($params, &$smarty) +{ + $ret = ""; + + if (isset($params['pagenavi']) && is_object($params['pagenavi'])) { + + $navi =& $params['pagenavi']; + + $perPage = $navi->getPerpage(); + + $total = $navi->getTotalItems(); + $totalPages = $navi->getTotalPages(); + + if ($totalPages == 0) { + return; + } + + $url = $navi->renderURLForPage(); + $current = $navi->getStart(); + + $offset = isset($params['offset']) ? intval($params['offset']) : 4; + + // + // check prev + // + if($navi->hasPrivPage()) { + $ret .= @sprintf("<a href='%s'>«</a>", $navi->renderURLForPage($navi->getPrivStart())); + } + + // + // counting + // + $counter=1; + $currentPage = $navi->getCurrentPage(); + while($counter<=$totalPages) { + if($counter==$currentPage) { + $ret.=@sprintf("<strong>(%d)</strong> ",$counter); + } + elseif(($counter>$currentPage-$offset && $counter<$currentPage+$offset) || $counter==1 || $counter==$totalPages) { + if($counter==$totalPages && $currentPage<$totalPages-$offset) { + $ret.="... "; + } + $ret .= @sprintf("<a href='%s'>%d</a> ",$navi->renderURLForPage(($counter-1)*$perPage),$counter); + if($counter==1 && $currentPage>1 + $offset) { + $ret.="... "; + } + } + $counter++; + } + + // + // check next + // + $next=$current + $perPage; + if($navi->hasNextPage()) { + $ret.=@sprintf("<a href='%s'>»</a>",$navi->renderURLForPage($navi->getNextStart())); + } + } + + print $ret; +} + +?>