*** MTPaginate2.pl 2006-12-15 02:02:42.000000000 +0900
--- MTPaginate2chg.pl 2006-12-15 02:02:42.000000000 +0900
***************
*** 12,21 ****
#
# Copyright (c) 2004-2005 Stepan Riha
# http://www.nonplus.net
# ---------------------------------------------------------------------------
use strict;
! package MTPlugin::Nonplus::MTPaginate;
use MT::Template::Context;
use MT::Util qw( remove_html decode_html encode_html );
--- 12,30 ----
#
# Copyright (c) 2004-2005 Stepan Riha
# http://www.nonplus.net
+ #
+ # + Patch1.0 For Dynamic Parameter To Static(Fake!) URI.
+ # 2006/12/15 By debizoh.
+ #
+ # Remark!!
+ # Distribution of this module is based on distribution restrictions of original module development origin.
+ # No matter what problem may occur by use of a patch, there is no guarantee which copes with it.
+ # Moreover, don't ask original development origin about the action after this patch application.
+ # Please give me use of this patch by accountability.
# ---------------------------------------------------------------------------
use strict;
! package MTPlugin::Nonplus::MTPaginate2;
use MT::Template::Context;
use MT::Util qw( remove_html decode_html encode_html );
***************
*** 26,32 ****
## Register MT handlers
MT::Template::Context->add_tag(PaginateVersion => sub { $VERSION } );
! MT::Template::Context->add_container_tag(Paginate => \&MTPaginate );
MT::Template::Context->add_conditional_tag(PaginateIfMultiplePages => \&MTPaginateIfMultiplePages);
MT::Template::Context->add_conditional_tag(PaginateIfSinglePage => \&MTPaginateIfSinglePage);
--- 35,41 ----
## Register MT handlers
MT::Template::Context->add_tag(PaginateVersion => sub { $VERSION } );
! MT::Template::Context->add_container_tag(Paginate2 => \&MTPaginate );
MT::Template::Context->add_conditional_tag(PaginateIfMultiplePages => \&MTPaginateIfMultiplePages);
MT::Template::Context->add_conditional_tag(PaginateIfSinglePage => \&MTPaginateIfSinglePage);
***************
*** 219,225 ****
$paginate_self =~ s/&$page_selector=[^&]*&/&/;
$paginate_self =~ s/^&//;
$paginate_self = '' if($paginate_self eq '&');
! $pg->{paginate_self} = "?$paginate_self$page_selector";
} elsif($pg->{mode} eq 'php') {
## Set up PHP variables: paginate_current_page ("2") and paginate_self ("/blog/page.pgp?page")
--- 228,234 ----
$paginate_self =~ s/&$page_selector=[^&]*&/&/;
$paginate_self =~ s/^&//;
$paginate_self = '' if($paginate_self eq '&');
! $pg->{paginate_self} = "/$paginate_self$page_selector";
} elsif($pg->{mode} eq 'php') {
## Set up PHP variables: paginate_current_page ("2") and paginate_self ("/blog/page.pgp?page")
***************
*** 232,241 ****
// Values that can be used in other PHP code on the page
\$paginate_num_pages = $numPages;
\$paginate_num_sections = __PAGINATE_NUM_SECTIONS__;
! \$paginate_page_selector = '$page_selector';
! \$paginate_current_page = \@\$_GET['$page_selector'];
// Pin page selector to a valid number (or 'all')
if(\$paginate_current_page=='')
\$paginate_current_page = '$default_page';
--- 241,324 ----
// Values that can be used in other PHP code on the page
+ \$paginate_page_selector = '$page_selector';
+
+ \$get_uri = \$_SERVER{'REQUEST_URI'};
+
+ /* ----------------------------------------------------------------------
+
+ Since it becomes a direct value, change is required
+ if it is breathing out by file names other than index.php.
+
+ ---------------------------------------------------------------------- */
+
+ \$my_scripts = 'index.php';
+
+ \$my_scripts_len = strlen(\$my_scripts);
+ \$uri_starts = strpos(\$get_uri,\$my_scripts);
+ \$uri_starts_pages = strpos(\$get_uri,\$paginate_page_selector,\$uri_starts);
+ \$paginate_current_page = "";
+
+ if (\$uri_starts_pages === false)
+ {
+ //print "start none..
";
+
+ }
+ else
+ {
+ if (\$uri_starts + \$my_scripts_len + 1 == \$uri_starts_pages)
+ {
+ //print "Checking...
";
+
+ if ( substr(\$get_uri,\$uri_starts_pages + strlen(\$paginate_page_selector),1) == "/")
+ {
+ //print "Checking2...
";
+ if (strpos(\$get_uri,"/", \$uri_starts_pages + strlen(\$paginate_page_selector) + 1) )
+ {
+ // Since there is / further, it is disapproval. //
+ // However, in the case of the visitor from some search engines, there may be an additional parameter.
+ // (Un-verifying)
+ // print "bad access....
";
+
+ }
+ else
+ {
+ // Maybe Ok. //
+ \$tmp_uri = substr(\$get_uri,\$uri_starts_pages + strlen(\$paginate_page_selector) + 1 );
+ //print "tmp: \$tmp_uri
";
+
+ if (\$tmp_uri == "all")
+ {
+ // OK //
+ \$paginate_current_page = "all";
+ }
+ else
+ {
+ \$tmp_uri2 = \$tmp_uri;
+
+ \$pattern = '/\\d+/';
+ \$replacement = '';
+ \$tmp_uri3 = preg_replace(\$pattern, \$replacement, \$tmp_uri2);
+ if (\$tmp_uri3 == "")
+ {
+ //print "Checking3...
";
+
+ #---- Maybe Ok ----
+ if ( is_numeric(\$tmp_uri2) )
+ {
+ \$paginate_current_page = \$tmp_uri2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
\$paginate_num_pages = $numPages;
\$paginate_num_sections = __PAGINATE_NUM_SECTIONS__;
!
! //\$paginate_current_page = \@\$_GET['$page_selector'];
// Pin page selector to a valid number (or 'all')
if(\$paginate_current_page=='')
\$paginate_current_page = '$default_page';
***************
*** 255,260 ****
--- 338,344 ----
\$paginate_top_section = 1;
\$paginate_bottom_section = __PAGINATE_NUM_SECTIONS__;
}
+ /*
if(isset(\$_SERVER['QUERY_STRING'])) {
\$paginate_self = '&' . \$_SERVER['QUERY_STRING'] . '&';
\$paginate_self = preg_replace("/&$page_selector=[^&]*&/", "&", \$paginate_self);
***************
*** 266,288 ****
} else {
\$paginate_self = '';
}
! PHP
- my $base_address = $args->{'base_address'} || '_relative';
- if($base_address eq '_absolute') {
- $res .=<
PHP
--- 350,400 ----
} else {
\$paginate_self = '';
}
! */
!
! if (\$uri_starts_pages === false)
! {
! //\$paginate_self = \$get_uri . \$my_scripts . "/page";
!
! if ( substr(\$get_uri,strlen(\$get_uri) - 1 , 1) == "/")
! {
! //print "this" . "
";
! \$paginate_self = \$get_uri . "page";
! }
! else
! {
! //print "this2" . "
";
! \$paginate_self = \$get_uri . "/page";
! }
!
! //print "start none..
";
!
! }
! else
! {
!
! \$paginate_self = substr(\$get_uri,0,\$uri_starts + strlen(\$my_scripts) ) . "/page";
!
! }
PHP
!
! # my $base_address = $args->{'base_address'} || '_relative';
! # if($base_address eq '_absolute') {
! # $res .=<
PHP
***************
*** 377,387 ****
my $page_selector = $pg->{page_selector};
if($pg->{mode} eq 'php') {
return < 1) echo "\$paginate_self=" . (\$paginate_current_page-1); ?>
PHP
} else {
my $current_page = $pg->{current_page};
! return ($current_page ne 'all' && $current_page > 1) ? $pg->{paginate_self} . '=' . ($current_page-1) : '';
}
}
--- 489,499 ----
my $page_selector = $pg->{page_selector};
if($pg->{mode} eq 'php') {
return < 1) echo "\$paginate_self/" . (\$paginate_current_page-1); ?>
PHP
} else {
my $current_page = $pg->{current_page};
! return ($current_page ne 'all' && $current_page > 1) ? $pg->{paginate_self} . '/' . ($current_page-1) : '';
}
}
***************
*** 391,397 ****
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
} else {
my $current_page = $pg->{current_page};
--- 503,509 ----
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
} else {
my $current_page = $pg->{current_page};
***************
*** 405,414 ****
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
} else {
! return $pg->{paginate_self} . '=all';
}
}
--- 517,533 ----
my $num_pages = $pg->{num_pages};
if($pg->{mode} eq 'php') {
return <
PHP
+
+
+ # return <
+ #PHP
} else {
! return $pg->{paginate_self} . '/all';
}
}
***************
*** 442,466 ****
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<$format_current", \$i);
} else {
! echo sprintf("", \$i);
}
}
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<$format_current", \$i);
} else {
! echo sprintf("", \$i);
}
}
PHP
$res .=<$format_all_current", $num_pages);
} else {
! echo sprintf("", $num_pages);
}
PHP
$res .=<{current_page} eq 'all') {
$res .= "$all_current$separator";
} else {
! $res .= "{paginate_self} . "=all\"$title$target>$all$separator";
}
}
--- 599,605 ----
if($pg->{current_page} eq 'all') {
$res .= "$all_current$separator";
} else {
! $res .= "{paginate_self} . "/all\"$title$target>$all$separator";
}
}
***************
*** 502,508 ****
if($pg->{current_page} eq 'all') {
$res .="$all_current$separator";
} else {
! $res .= "{paginate_self} . "=all\"$title$target>$all$separator";
}
}
} else {
--- 621,627 ----
if($pg->{current_page} eq 'all') {
$res .="$all_current$separator";
} else {
! $res .= "{paginate_self} . "/all\"$title$target>$all$separator";
}
}
} else {
***************
*** 515,521 ****
if(\$paginate_current_page == 'all') {
echo '$all_current$separator';
} else {
! echo "$all$separator";
}
PHP
}
--- 634,640 ----
if(\$paginate_current_page == 'all') {
echo '$all_current$separator';
} else {
! echo "$all$separator";
}
PHP
}
***************
*** 528,534 ****
if(\$i == \$paginate_current_page) {
echo sprintf("$format_current", \$i);
} else {
! echo "$format', \$i) . '';
}
}
PHP
--- 647,653 ----
if(\$i == \$paginate_current_page) {
echo sprintf("$format_current", \$i);
} else {
! echo "$format', \$i) . '';
}
}
PHP
***************
*** 539,545 ****
if(\$paginate_current_page == 'all') {
echo '$separator$all_current';
} else {
! echo "$separator$all";
}
PHP
}
--- 658,664 ----
if(\$paginate_current_page == 'all') {
echo '$separator$all_current';
} else {
! echo "$separator$all";
}
PHP
}