Permalink
Browse files

Add the 'model' key to PaginatorHelper::counter()

Its available as both '%model%' and '{:model}'
Fixes #1773
  • Loading branch information...
1 parent 28ba1c9 commit b4a780332fb143e1381e4cee12eb2f04a184dd1b @markstory markstory committed Jun 19, 2011
@@ -2056,6 +2056,9 @@ public function testCounter() {
$result = $this->Paginator->counter(array('format' => 'range'));
$expected = '1 - 3 of 13';
$this->assertEqual($expected, $result);
+
+ $result = $this->Paginator->counter('Showing %page% of %pages% %model%');
+ $this->assertEquals('Showing 1 of 5 clients', $result);
}
/**
@@ -537,7 +537,7 @@ public function defaultModel() {
* - `model` The model to use, defaults to PaginatorHelper::defaultModel();
* - `format` The format string you want to use, defaults to 'pages' Which generates output like '1 of 5'
* set to 'range' to generate output like '1 - 3 of 13'. Can also be set to a custom string, containing
- * the following placeholders `%page%`, `%pages%`, `%current%`, `%count%`, `%start%`, `%end%` and any
+ * the following placeholders `%page%`, `%pages%`, `%current%`, `%count%`, `%model%`, `%start%`, `%end%` and any
* custom content you would like.
* - `separator` The separator string to use, default to ' of '
*
@@ -588,12 +588,13 @@ public function counter($options = array()) {
'%current%' => $paging['current'],
'%count%' => $paging['count'],
'%start%' => $start,
- '%end%' => $end
+ '%end%' => $end,
+ '%model%' => strtolower(Inflector::humanize(Inflector::tableize($options['model'])))
);
$out = str_replace(array_keys($map), array_values($map), $options['format']);
$newKeys = array(
- '{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}'
+ '{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}'
);
$out = str_replace($newKeys, array_values($map), $out);
break;
@@ -862,4 +863,4 @@ public function last($last = 'last >>', $options = array()) {
}
return $out;
}
-}
+}

0 comments on commit b4a7803

Please sign in to comment.