生成 HTML 分页以实现可访问性。
安全包:https://github.com/rancoud/Security
作曲家需要 rancoud/分页
$currentPage = 1;$countElements = 10;$countElementPerPage = 5;$p = new Pagination();$html = $p->generateHtml($currentPage, $countElements, $countElementPerPage);echo $html;
它将输出
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
根代表<ul>
项目代表<li>
链接代表<a>
范围 | 类型 | 默认值 | 描述 |
---|---|---|---|
配置 | 大批 | [] | 用于更改分页行为的参数 |
generateHtml(currentPage: int, countElements: int, countElementPerPage: int): 字符串
generateData(currentPage: int, countElements: int, countElementPerPage: int): 数组
countPages(countElements: int, countElementPerPage: int): int
locateItemInPage(countElementPerPage:int,indexItem:int):int
url(字符串)(示例)
show_all_links (bool: false)(示例)
use_previous (bool: false) (示例)
always_use_previous (bool: false)(示例)
use_next (bool: false) (示例)
always_use_next (bool: false)(示例)
use_dots (bool: false)(示例)
count_pages_pair_limit (int: 0) (示例)
count_pages_pair_adjacent (int: 2) (示例)
text_previous(字符串:上一页)(示例)
text_next(字符串:下一页)(示例)
text_dots(字符串:...)(示例)
text_page(字符串:{{PAGE}})(示例)
aria_label_link(字符串:转到页面 {{PAGE}})(示例)
aria_label_current_link(字符串:当前页面,第 {{PAGE}} 页)(示例)
aria_label_nav(字符串:分页)(示例)
aria_label_previous(字符串:上一页)(示例)
aria_label_next(字符串:下一页)(示例)
千位分隔符(字符串)(示例)
root_tag(字符串:ul)(示例)
root_attrs(字符串)(示例)
use_nav(布尔:true)(示例)
nav_attrs(字符串)(示例)
item_tag(字符串:li)(示例)
item_attrs(字符串)(示例)
item_attrs_current(字符串)(示例)
item_previous_attrs(字符串)(示例)
item_previous_attrs_disabled(字符串)(示例)
item_next_attrs(字符串)(示例)
item_next_attrs_disabled(字符串)(示例)
item_dots_attrs(字符串)(示例)
link_tag(字符串:a)(示例)
link_attrs(字符串)(示例)
link_attrs_current(字符串)(示例)
link_previous_attrs_disabled(字符串)(示例)
link_next_attrs_disabled(字符串)(示例)
dot_tag(字符串:span)(示例)
dot_attrs(字符串)(示例)
use_pretty_html (bool: true) (示例)
html_tab_sequence(字符串:t)(示例)
html_initial_indentation (int: 0) (示例)
esc_attr(布尔:true)(示例)
esc_html(布尔:true)(示例)
字符集(字符串:UTF-8)(示例)
您必须自己清理这些参数:
导航属性
根属性
项目属性
当前项目属性
项目上一个属性
item_previous_attrs_disabled
项目下一个属性
item_next_attrs_disabled
项目点属性
链接属性
当前链接属性
link_previous_attrs_disabled
link_next_attrs_disabled
点属性
html_tab_sequence
页面附加在末尾
$conf = ['url' => 'https://example.com/news/page/'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="https://示例。 com/新闻/页/2" aria-label="页 2">2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['url' => 'https://example.com/news/page/{{PAGE}}/?date=desc'];echo (新分页($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="https://示例。 com/新闻/页/2/?日期=desc" aria-label="Page 2">2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式后
$conf = ['url' => '{{PAGE}}?date=desc'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2?日期=desc" aria-label= “第2页”2</a></li></ul></nav>
⏫ 配置参数/URL
$conf = ['show_all_links' => true];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li><a href="4" aria-label="页码 4">4</a></li><li><a href="5" aria-label="页码 5">5</a></ li><li><a href="6" aria-label="Page 6">6</a></li></ul></nav>
⏫ 配置参数/行为
$conf = ['use_previous' => true];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="上一页">上一页</a></li><li><a href="1" aria-label="页 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ 配置参数/行为
如果没有上一页,则上一页在链接标记上具有aria-disabled=true
$conf = ['always_use_previous' => true];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="上一页" aria-disabled="true">上一页</a></li><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/行为
$conf = ['use_next' => true];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="2" aria-label="下一页">下一页</a></li></ul></nav>
⏫ 配置参数/行为
如果没有下一页,则下一页在链接标记上具有aria-disabled=true
$conf = ['always_use_next' => true];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="#" aria-label="Page 2" aria-current="page">2</a></li><li><a href="#" aria-label="下一页" aria-disabled="true">下一页</a></li></ul></nav>
⏫ 配置参数/行为
$conf = ['use_dots' => true];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"> <span>…</span></li></ul></nav>
⏫ 配置参数/行为
$conf = ['count_pages_pair_limit' => 1];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="3" aria-label="页 3">3</a></li><li><a href="4" aria-label="页 4">4</一个></li><li><a href="#" aria-label="页面 5" aria-current="页面">5</a></li><li><a href="6" aria-label="页面 6"> 6</a></li><li><a href="7" aria-label="Page 7">7</a></li><li><a href="60" aria-label="页 60">60</a></li></ul></nav>
⏫ 配置参数/行为
$conf = ['count_pages_pair_adjacent' => 1];echo (新分页($conf))->generateHtml(5, 300, 5);
<nav aria-label="分页"><ul><li><a href="4" aria-label="Page 4">4</a></li><li><a href ="#" aria-label="页面 5" aria-current="页面">5</a></li><li><a href="6" aria-label="页面 6"> 6</a></li></ul></nav>
⏫ 配置参数/行为
count_pages_pair_limit 0 + count_pages_pair_adjacent 0
$conf = ['count_pages_pair_limit' => 0,'count_pages_pair_adjacent' => 0];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 5" aria-current="page">5</a></li></ul></nav>
count_pages_pair_limit 2 + count_pages_pair_adjacent 2
$conf = ['count_pages_pair_limit' => 2,'count_pages_pair_adjacent' => 2];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="2" aria-label="页 2">2</a></li><li><a href="3" aria-label="页 3">3</ a></li><li><a href="4" aria-label="页 4">4</a></li><li><a href="#" aria-label="页面 5" aria-current="页面">5</a></li><li><a href="6" aria-label="页面 6"> 6</a></li><li><a href="7" aria-label="Page 7">7</a></li><li><a href="59" aria-label="页码 59">59</a></li><li><a href="60" aria-label="页码 60">60</a></ li></ul></nav>
⏫ 配置参数/行为
$conf = ['use_previous' => true,'text_previous' => 'prev'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="上一页 page">上一页</a></li><li><a href ="1" aria-label="页 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['use_next' => true,'text_next' => 'next'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="2" aria-label="Next page">下一页</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['use_dots' => true,'text_dots' => 'dots'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"><span>点</span></li></ul></nav>
⏫ 配置参数/标签
页面附加在末尾
$conf = ['text_page' => 'yolo'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">yolo 1</a></li><li><a href="2" aria-label="页面 2" >yolo 2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['text_page' => 'yo {{PAGE}} lo'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">哟 1 lo</a></li><li><a href="2" aria-label="Page 2 ”哟2罗</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['aria_label_link' => 'aria 标签链接'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="aria label  ;link">2</a></li></ul></nav>
采用 {{PAGE}} 模式
$conf = ['aria_label_link' => 'aria 标签链接 {{PAGE}}'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="aria label  ;link 2">2</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['aria_label_current_link' => 'aria 标签当前链接'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="aria label current link" aria-current="page">1</a></li><li><a href="2" aria-label= “第2页”>2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['aria_label_current_link' => 'aria标签当前链接{{PAGE}}'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="aria label current link 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['aria_label_nav' => 'aria 标签导航'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="aria label nav"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['use_previous' => true,'aria_label_previous' => 'prev'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="prev">上一页</a></li><li><a href="1 " aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['use_next' => true,'aria_label_next' => 'next'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="2" aria-label="next">下一页</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['thousands_separator' => ';','count_pages_pair_limit' => 1];echo (new Pagination($conf))->generateHtml(1, 1000, 1);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li><a href="1000" aria-label="页 1000">1;000</a></li></ul></nav>
⏫ 配置参数/标签
$conf = ['root_tag' => 'root'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><root><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></root></nav>
⏫ 配置参数/HTML 标记/根
$conf = ['root_attrs' => 'data-root="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul data-root="attrs"><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/根
$conf = ['use_nav' => false];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul>
⏫ 配置参数/HTML 标记/根
$conf = ['nav_attrs' => 'data-item="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页" data-item="attrs"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/根
$conf = ['item_tag' => 'item'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><item><a href="#" aria-label="页面 1" aria-current="页面">1</a></item><item><a href="2" aria-label="页面 2"> 2</a></item></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['item_attrs' => 'data-item="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li data-item="attrs"><a href="2" aria-label="页 2">2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['item_attrs' => 'data-item="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li data-item="attrs 2"><a href="2" aria-label= “第2页”2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['item_attrs_current' => 'data-item-current="attrs"'];echo (新分页($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li data-item-current="attrs"><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['item_attrs_current' => 'data-item-current="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li data-item-current="attrs 1"><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['use_previous' => true,'item_previous_attrs' => 'data-item-previous="attrs"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-previous="attrs"><a href="1" aria-label="上一页">上一页</a> </li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['use_previous' => true,'item_previous_attrs' => 'data-item-previous="attrs {{PAGE}}"'];echo (新分页($conf))->generateHtml(2, 10 , 5);
<nav aria-label="Pagination"><ul><li data-item-previous="attrs 1"><a href="1" aria-label="上一页">上一页</a ></li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['always_use_previous' => true,'item_previous_attrs_disabled' => 'data-item-previous-disabled="attrs"'];echo (新分页($conf))->generateHtml(1, 10, 5) ;
<nav aria-label="分页"><ul><li data-item-previous-disabled="attrs"><a href="#" aria-label="上一页" aria-disabled="true">上一页</a></li><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['always_use_previous' => true,'item_previous_attrs_disabled' => 'data-item-previous-disabled="attrs {{PAGE}}"'];echo (新分页($conf))->generateHtml(1 , 10, 5);
<nav aria-label="分页"><ul><li data-item-previous-disabled="attrs 0"><a href="#" aria-label="上一页" aria-disabled="true">上一页</a></li><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['use_next' => true,'item_next_attrs' => 'data-item-next="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li data-item-next="attrs"><a href="2" aria-label="下一页">下一页</a></li> </ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['use_next' => true,'item_next_attrs' => 'data-item-next="attrs {{PAGE}}"'];echo (新分页($conf))->generateHtml(1, 10 , 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li data-item-next="attrs 2"><a href="2" aria-label="下一页">下一页</a></li ></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['always_use_next' => true,'item_next_attrs_disabled' => 'data-item-next-disabled="attrs"'];echo (新分页($conf))->generateHtml(2, 10, 5) ;
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="#" aria-label="Page 2" aria-current="page">2</a></li><li data-item-next-disabled="attrs"><a href="# ;” aria-label="下一页" aria-disabled="true">下一页</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['always_use_next' => true,'item_next_attrs_disabled' => 'data-item-next-disabled="attrs {{PAGE}}"'];echo (新分页($conf))->generateHtml(2 , 10, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="#" aria-label="Page 2" aria-current="page">2</a></li><li data-item-next-disabled="attrs 2"><a href="&# x23;” aria-label="下一页" aria-disabled="true">下一页</a></li></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['use_dots' => true,'item_dots_attrs' => 'data-item-dots="attrs"'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li data-item-dots="attrs ” aria-hidden="true"><span>…</span></li></ul></nav>
⏫ 配置参数/HTML 标记/项目
$conf = ['link_tag' => 'link'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><link href="#" aria-label="页面 1" aria-current="页面">1</link></li><li><link href="2" aria-label="页面 2"> 2</link></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['link_attrs' => 'data-link="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a data-link="attrs" href="2" aria-label="页 2">2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['link_attrs' => 'data-link="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a data-link="attrs 2" href="2" aria-label= “第2页”2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['link_attrs_current' => 'data-link-current="attrs"'];echo (新分页($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a data-link-current="attrs" href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['link_attrs_current' => 'data-link-current="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a data-link-current="attrs 1" href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['always_use_previous' => true,'link_previous_attrs_disabled' => 'data-item-next-disabled="attrs"'];echo (新分页($conf))->generateHtml(1, 10, 5) ;
<nav aria-label="分页"><ul><li><a data-item-next-disabled="attrs" href="#" aria-label="上一页" aria-disabled="true">上一页</a></li><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['always_use_previous' => true,'link_previous_attrs_disabled' => 'data-item-next-disabled="attrs {{PAGE}}"'];echo (新分页($conf))->generateHtml(1 , 10, 5);
<nav aria-label="分页"><ul><li><a data-item-next-disabled="attrs 0" href="#" aria-label="上一页" aria-disabled="true">上一页</a></li><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['always_use_next' => true,'link_next_attrs_disabled' => 'data-item-next-disabled="attrs"'];echo (新分页($conf))->generateHtml(2, 10, 5) ;
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="#" aria-label="Page 2" aria-current="page">2</a></li><li><a data-item-next-disabled="attrs" href="# ;” aria-label="下一页" aria-disabled="true">下一页</a></li></ul></nav>
页面替换为 {{PAGE}} 模式
$conf = ['always_use_next' => true,'link_next_attrs_disabled' => 'data-item-next-disabled="attrs {{PAGE}}"'];echo (新分页($conf))->generateHtml(2 , 10, 5);
<nav aria-label="分页"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href ="#" aria-label="Page 2" aria-current="page">2</a></li><li><a data-item-next-disabled="attrs 2" href="&# x23;” aria-label="下一页" aria-disabled="true">下一页</a></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['use_dots' => true,'dot_tag' => 'p'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"> <p>…</p></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['use_dots' => true,'dot_attrs' => 'data-dot="attrs"'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"> <跨度data-dot="attrs">...</span></li></ul></nav>
⏫ 配置参数/HTML 标记/链接
$conf = ['use_pretty_html' => false];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/缩进
$conf = ['html_tab_sequence' => ''];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/缩进
$conf = ['html_initial_indentation' => 1];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/缩进
$conf = ['esc_attr' => false];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="第 1 页" aria-current="page">1</a></li><li ><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/安全性
$conf = ['esc_html' => false,'text_page' => '<em>{{PAGE}}</em>'];echo (new Pagination($conf))->generateHtml(1, 10, 5 );
<nav aria-label="分页"><ul><li><a href="#" aria-label="Page 1" aria-current="page"><em>1</em></a></li><li><a href="2" aria-label="第2页"><em>2</em></a></li></ul></nav>
⏫ 配置参数/HTML 标记/安全性
$conf = ['charset' => 'EUC-JP'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="分页"><ul><li><a href="#" aria-label="页面 1" aria-current="页面">1</a></li><li><a href="2" aria-label="页面 2"> 2</a></li></ul></nav>
⏫ 配置参数/HTML 标记/安全性
$conf = ['always_use_previous' => true,'always_use_next' => true,'use_dots' => true, ]var_dump(new Pagination($conf))->generateData(1, 3000, 5);array (size=3) 'previous' => object(RancudPaginationItem)[2] public 'ariaLabel' => 字符串 '上一页' (长度=18) 公共 'href' => 字符串 '#' (长度=6)公共'itemAttrs'=>字符串''(长度=0) 公共'linkAttrs'=>字符串''(长度=0) public 'text' => string '上一页' (长度=13) 公共 'isCurrent' => 布尔值 false 公共 'isDots' => 布尔值 false 公共 'isDisabled' => 布尔值 true 公共“页面”=> int 0 '链接' => 数组 (大小=4) 0 => 对象(RancudPaginationItem)[4] 公共'ariaLabel'=>字符串'Page 1'(长度=11)公共'href'=>字符串'#' (长度=6)公共'itemAttrs'=>字符串''(长度=0) 公共'linkAttrs'=>字符串''(长度=0) 公共“文本”=>字符串“1”(长度=1) public 'isCurrent' => 布尔值 true 公共 'isDots' => 布尔值 false 公共 'isDisabled' => 布尔值 false 公共“页面”=> int 1 1 => 对象(RancudPaginationItem)[5] 公共'ariaLabel'=>字符串'Page 2'(长度=11)公共'href'=>字符串'2'(长度=1) 公共'itemAtrs'=>字符串''(长度=0) 公共'linkAttrs'=>字符串''(长度=0) 公共“文本”=>字符串“2”(长度=1) 公共 'isCurrent' => 布尔值 false 公共 'isDots' => 布尔值 false 公共 'isDisabled' => 布尔值 false 公共“页面”=> int 2 2 => 对象(RancudPaginationItem)[6] 公共'ariaLabel'=>字符串'Page 3'(长度=11)公共'href'=>字符串'3'(长度=1) 公共'itemAtrs'=>字符串''(长度=0) 公共'linkAttrs'=>字符串''(长度=0) 公共“文本”=>字符串“3”(长度=1) 公共 'isCurrent' => 布尔值 false 公共 'isDots' => 布尔值 false 公共 'isDisabled' => 布尔值 false 公共'页面' => int 3 3 => 对象(RancoudPaginationItem)[7] 公共'ariaLabel'=>字符串'Page 4'(长度=11)公共'href'=>字符串'4'(长度=1) 公共'itemAtrs'=>字符串''(长度=0) 公共'linkAttrs'=>字符串''(长度=0) 公共'文本'=>字符串'...'(长度= 3) 公共 'isCurrent' => 布尔值 false public 'isDots' => 布尔值 true 公共 'isDisabled' => 布尔值 false 公共“页面”=> int 4 '下一个'=> 对象(RancudPaginationItem)[8] 公共'ariaLabel'=>字符串'下一页'(长度= 14)公共'href'=>字符串'2'(长度= 1) 公共'itemAtrs'=>字符串''(长度=0) 公共'linkAttrs'=>字符串''(长度=0) public 'text' => string '下一页' (长度=9) 公共 'isCurrent' => 布尔值 false 公共 'isDots' => 布尔值 false 公共 'isDisabled' => 布尔值 false 公共“页面”=> int 2
用于 php-cs-fixer 和 phpunit 的composer ci
和覆盖率
php-cs-fixer 的composer lint
phpunit 和覆盖率的composer test