PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » Pager » Bug #4946

Allow for different url separator

Details

Request #4946Allow for different url separator
Submitted2005-07-29 14:19 UTC
Fromreywob at php dot net
Assignedquipo
StatusBogus
PackagePager
PHP VersionIrrelevant
OS-
Roadmaps(Not assigned)

Comments

[2005-07-29 14:19 UTC] reywob at php dot net

Description:
------------
When using a custom URL setup for use with mod_rewrite (eg:
$params = array(
'append' => false,
'urlVar' => 'num',
'path' => '/cat/' . $cat_id,
'fileName' => '-%d', //Pager replaces "%d" with page number...
);
)

Pager assumes that you want a / added between the params 'path' and 'fileName'.

From the above, I want to produce URLs such as:
/cat/foo/22-2, /cat/foo/22-3 etc.

Instead it produces:
/cat/foo/22/-2, /cat/foo/22/-3

An extra parameter, urlSeparator, solves this problem, and the following patch provides this. I have tested it on PHP 4.3.10

Test script:
---------------
*** C:\Temp\Tortoise3464.rev.1.38-Common.php Mon Jul 04 09:18:42 2005
--- C:\code\pear\Pager\Common.php Fri Jul 29 15:13:36 2005
***************
*** 1285,1290 ****
--- 1285,1291 ----
'extraVars',
'excludeVars',
'currentPage',
+ 'urlSeparator',
);

foreach ($options as $key => $value) {
***************
*** 1292,1297 ****
--- 1293,1303 ----
$this->{'_' . $key} = $value;
}
}
+
+ if (!isset($this->_urlSeparator)) {
+ print 'Seaparator not set';
+ $this->_urlSeparator = '/';
+ }

//autodetect http method
if (!isset($options['httpMethod'])
***************
*** 1312,1318 ****
} else {
$this->_url = $this->_path;
if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
! $this->_url .= '/';
}
if (!strstr($this->_fileName, '%d')) {
trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
--- 1318,1324 ----
} else {
$this->_url = $this->_path;
if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
! $this->_url .= $this->_urlSeparator;
}
if (!strstr($this->_fileName, '%d')) {
trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);

[2005-07-29 14:47 UTC] reywob at php dot net

Doh :)