Saturday, February 28, 2009

[Bug Report] Bug in PaginatorHelper

Version: 1.2.1.8004
File: libs/view/helpers/paginator.php on line 163
Function: sortDir()

if 'order' is set as a string. e.g. my pagination option is set as
follows:

$this->paginate['Product'] = array(
'limit' => 18,
'recursive' => 0,
'fields' => array('Product.id', 'Product.title'),
'order' => 'Product.id DESC'
);

then when i call $paginator->sortDir() in my view, it returns asc.
because sortDir() does not parse 'order' option of string type.

solution:
i'm new to php, so i dont know if it is a proper way

function sortDir($model = null, $options = array()) {
......
if (isset($options['direction'])) {
$dir = strtolower($options['direction']);
} elseif (isset($options['order']) && is_array($options['order'])) {
$dir = strtolower(current($options['order']));
} elseif (isset($options['order']) && is_string($options['order']))
{
if (preg_match('/(\w+)$/', $options['order'], $result) && isset
($result[1])) {
$dir = strtolower($result[1]);
}
}
......
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: