Tripletail

 view release on metacpan or  search on metacpan

lib/Tripletail/Pager.pm  view on Meta::CPAN

# -----------------------------------------------------------------------------
# Tripletail::Pager - ページング処理
# -----------------------------------------------------------------------------
package Tripletail::Pager;
use strict;
use warnings;
use Tripletail;

1;

sub _new {
    my $class = shift;
    my $DB    = Tripletail::_isa($_[0], 'Tripletail::DB')
              ? shift
              : $TL->getDB(shift);

    my $this = bless {} => $class;

    $this->{db    } = $DB;
    $this->{dbtype} = $DB->getType;

	$this->{pagesize} = 30;
	$this->{current} = 1;
	$this->{maxlinks} = 10;
	$this->{formkey} = 'pageid';
	$this->{formparam} = undef;
	$this->{pagingtype} = 0;
	$this->{tolink} = undef;

    #結果群
	$this->{maxpages} = undef;
	$this->{linkstart} = undef;
	$this->{linkend} = undef;
	$this->{maxrows} = undef;
	$this->{beginrow} = undef;
	$this->{rows} = undef;

	$this->setFormParam(undef);
	$this;
}

sub setToLink {
	my $this = shift;
	my $tolink = shift;

	if(ref($tolink)) {
		die __PACKAGE__."#setToLinkp: arg[1] is a reference. [$tolink] (第1引数がリファレンスです)\n";
	}

	$this->{tolink} = $tolink;
	$this;
}

sub setDbGroup {
	my $this = shift;
	my $dbgroup = shift;

	if(ref($dbgroup)) {
		die __PACKAGE__."#setDbGroup: arg[1] is a reference. [$dbgroup] (第1引数がリファレンスです)\n";
	}

    $this->{db    } = $TL->getDB($dbgroup);
    $this->{dbtype} = $this->{db}->getType;
    $this;
}

sub setPageSize {
	my $this = shift;
	my $size = shift;

	if(!defined($size)) {
		die __PACKAGE__."#setPageSize: arg[1] is not defined. (第1引数が指定されていません)\n";
	} elsif(ref($size)) {
		die __PACKAGE__."#setPageSize: arg[1] is a reference. [$size] (第1引数がリファレンスです)\n";
	} elsif($size !~ /^\d+$/ || $size <= 0) {
		die __PACKAGE__."#setPageSize: arg[1] is not a positive number. [$size] (第1引数が正の整数ではありません)\n";
	}



( run in 1.079 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )