產生 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="頁 2">2</a></li ></ul ></導覽>
頁面替換為 {{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 </ 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=" 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="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><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(11 , 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 "> <span 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 => 對象(RancudPaginationItem)[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