=encoding euc-jp =head1 名前 Data::Pageset - ページの番号付けとページセット =head1 概要 use Data::Pageset; my $page_info = Data::Pageset->new({ 'total_entries' => $total_entries, 'entries_per_page' => $entries_per_page, # オプション、渡さなくてもデフォルトの値が使われる。 'current_page' => $current_page, 'pages_per_set' => $pages_per_set, }); # 一般的なページインフォメーション print " First page: ", $page_info->first_page, "\n"; print " Last page: ", $page_info->last_page, "\n"; print " Next page: ", $page_info->next_page, "\n"; print " Previous page: ", $page_info->previous_page, "\n"; # 現在のページにある結果 print "First entry on page: ", $page_info->first, "\n"; print " Last entry on page: ", $page_info->last, "\n"; # オブジェクトの生成後にセットあたりのページ数を加えられる $page_info->pages_per_set($pages_per_set); # ページセットのインフォメーション print "First page of previous page set: ", $page_info->previous_set, "\n"; print " First page of next page set: ", $page_info->next_set, "\n"; # 現在のセットにあるページ番号を出力 foreach my $page (@{$page_info->pages_in_set()}) { if($page == $page_info->current_page()) { print "$page "; } else { print "$page "; } } =head1 説明 The object produced by Data::Pageset can be used to create page navigation, it inherits from Data::Page and has access to all methods from this object. Data::Pagesetが生成するオブジェクトはページナビゲーションを 作成するために利用できる。Data::Pageを継承しているので、この オブジェクトからData::Pageの全メソッドにアクセスできる。 In addition it also provides methods for dealing with set of pages, so that if there are too many pages you can easily break them into chunks for the user to browse through. 加えて、このモジュールはページセットを扱うメソッドも提供する。 そのため、たくさんのページがあっても、ユーザーが閲覧するのに 適した塊に簡単に分けることができる。 The object can easily be passed to a templating system such as Template Toolkit or be used within a script. このオブジェクトは、Template Toolkitのようなテンプレート システムに容易に渡したり、スクリプト内で利用することができる。 =head1 メソッド =head2 new() use Data::Pageset; my $page_info = Data::Pageset->new({ 'total_entries' => $total_entries, 'entries_per_page' => $entries_per_page, # Optional, will use defaults otherwise. 'current_page' => $current_page, 'pages_per_set' => $pages_per_set, }); This is the constructor of the object, it requires an anonymous hash containing the 'total_entries', how many data units you have, and the number of 'entries_per_page' to display. Optionally the 'current_page' (defaults to page 1) and pages_per_set (how many pages to display) can be added. If the pages_per_set are not passed in they can be added later, though obviously if it is never added you will not be able to use the page set specific functionality. これはオブジェクトのコンストラクタだ。一つの無名ハッシュをとる。 ハッシュは、いくつデータユニットを持っているのかを示す 'total_entries'と、表示数を表す'entries_per_page'を含む。オプション として'current_page'(デフォルトは1)とpages_per_set(何ページ 表示するか)を加えられる。the pages_per_setを渡していなくても、後で 加えることができる。ただし、加えなかった場合は、ページセットに 特化した機能を使うことはできない。 =head2 pages_per_set() $page_info->pages_per_set($number_of_pages_per_set); Calling this method initalises the calculations required to use the paging methods below. The value can also be passed into the constructor method new(). このメソッドを呼び出すと、下にあげたページ処理メソッドを使うのに 必要な計算を初期化する。また、値はコンストラクタメソッドnew()へと 渡される。 If called without any arguments it will return the current number of pages per set. 引数無しで呼び出すと、現在のセットあたりのページ数が返される。 =head2 previous_set() print "Back to previous set which starts at ", $page_info->previous_set(), "\n"; This method returns the page number at the start of the previous page set. undef is return if pages_per_set has not been set. このメソッドは、ひとつ前のページセットの始まりとなるページ番号を返す。 pages_per_setがセットされていなければundefが返される。 =head2 next_set() print "Next set starts at ", $page_info->next_set(), "\n"; This method returns the page number at the start of the next page set. undef is return if pages_per_set has not been set. このメソッドは、次のページセットの始まりとなるページ番号を返す。 pages_per_setがセットされていなければundefが返される。 =head2 pages_in_set() foreach my $page_num (@{$page_info->pages_in_set()}) { print "Page: $page_num \n"; } This method returns an array ref of the the page numbers within the current set. undef is return if pages_per_set has not been set. このメソッドは現在のセット内にあるページ番号の配列リファレンスを返す。 pages_per_setがセットされていなければundefが返される。 =head1 問題点 There has been one report of problems with Perl 5.6.0 and Apache::Template, please let me know if you experience this as well. Perl 5.6.0とApache::Templateを使った場合に問題があるという 報告が1件ある。あなたも同様の経験をされたことがあるかお知らせ頂きたい。 =head1 エクスポート None by default. なし。 =head1 作者 Leo Lapworth LLAP@cuckoo.org - let me know if you've used this module - go on... you know you want to. このモジュールを使ったことがあるか、そしてまだ使っているか…… あなたの望むことについて教えて欲しい。 =head1 参考 L. =head1 著作権 Copyright (C) 2003, Leo Lapworth This module is free software; you can redistribute it or modify it under the same terms as Perl itself.