国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.7KB

  1. <?php if (!defined('DEDEINC')) exit('Request Error!');
  2. /**
  3. *
  4. * @version $Id: arcpagelist.lib.php 1 9:29 2010年7月6日Z tianya $
  5. * @package DedeBIZ.Taglib
  6. * @copyright Copyright (c) 2020, DedeBIZ.COM
  7. * @license https://www.dedebiz.com/license
  8. * @link https://www.dedebiz.com
  9. */
  10. function lib_arcpagelist(&$ctag, &$refObj)
  11. {
  12. global $dsql;
  13. $attlist = "tagid|,style|1";
  14. FillAttsDefault($ctag->CAttribute->Items, $attlist);
  15. extract($ctag->CAttribute->Items, EXTR_SKIP);
  16. $row = $dsql->GetOne("SELECT * FROM `#@__arcmulti` WHERE tagid='$tagid'");
  17. if (is_array($row)) {
  18. $ids = explode(',', $row['arcids']);
  19. $totalnum = count($ids);
  20. $pagestr = '<div id="page_' . $tagid . '">';
  21. if ($row['pagesize'] < $totalnum) {
  22. $pagestr .= multipage($totalnum, 1, $row['pagesize'], $tagid);
  23. } else {
  24. $pagestr .= '共1页';
  25. }
  26. $pagestr .= '</div>';
  27. return $pagestr;
  28. } else {
  29. $pagestr = '<div id="page_' . $tagid . '">';
  30. $pagestr .= '没有检索到对应分页';
  31. $pagestr .= '</div>';
  32. return $pagestr;
  33. }
  34. }
  35. /**
  36. * 分页函数
  37. *
  38. * @access public
  39. * @param string $allItemTotal 所有记录
  40. * @param string $currPageNum 当前页面数
  41. * @param string $pageSize 显示条数
  42. * @param string $tagid 标签ID
  43. * @return string
  44. */
  45. function multipage($allItemTotal, $currPageNum, $pageSize, $tagid = '')
  46. {
  47. if ($allItemTotal == 0) return "";
  48. //计算总页数
  49. $pagesNum = ceil($allItemTotal / $pageSize);
  50. //第一页显示
  51. $firstPage = ($currPageNum <= 1) ? $currPageNum . "</b>&lt;&lt;" : "<a href='javascript:multi(1,\"{$tagid}\")' title='第1页'>1&lt;&lt;</a>";
  52. //最后一页显示
  53. $lastPage = ($currPageNum >= $pagesNum) ? "&gt;&gt;" . $currPageNum : "<a href='javascript:multi(" . $pagesNum . ",\"{$tagid}\")' title='第" . $pagesNum . "页'>&gt;&gt;" . $pagesNum . "</a>";
  54. //上一页显示
  55. $prePage = ($currPageNum <= 1) ? "上页" : "<a href='javascript:multi(" . ($currPageNum - 1) . ",\"{$tagid}\")' accesskey='p' title='上一页'>[上一页]</a>";
  56. //下一页显示
  57. $nextPage = ($currPageNum >= $pagesNum) ? "下页" : "<a href='javascript:multi(" . ($currPageNum + 1) . ",\"{$tagid}\")' title='下一页'>[下一页]</a>";
  58. //按页显示
  59. $listNums = "";
  60. for ($i = ($currPageNum - 4); $i < ($currPageNum + 9); $i++) {
  61. if ($i < 1 || $i > $pagesNum) continue;
  62. if ($i == $currPageNum) $listNums .= "<a href='javascript:void(0)' class='thislink'>" . $i . "</a>";
  63. else $listNums .= " <a href='javascript:multi(" . $i . ",\"{$tagid}\")' title='" . $i . "'>" . $i . "</a> ";
  64. }
  65. $returnUrl = $listNums;
  66. return $returnUrl;
  67. }