1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 03:34:33 +02:00

Minor fixes in WireArray, PaginatedArray and CommentStars classes

This commit is contained in:
Ryan Cramer
2020-02-14 14:49:59 -05:00
parent 93f422a2cf
commit d154a8de28
3 changed files with 5 additions and 4 deletions

View File

@@ -291,7 +291,7 @@ class PaginatedArray extends WireArray implements WirePaginatable {
} else { } else {
if($count > $limit) $count = $limit; if($limit && $count > $limit) $count = $limit;
$end = $start + $count; $end = $start + $count;
if($end > $total) $total = $end; if($end > $total) $total = $end;
$start++; // make 1 based rather than 0 based... $start++; // make 1 based rather than 0 based...

View File

@@ -825,6 +825,7 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count
*/ */
public function getRandom($num = 1, $alwaysArray = false) { public function getRandom($num = 1, $alwaysArray = false) {
$items = $this->makeNew(); $items = $this->makeNew();
if($num < 1) return $items;
$count = $this->count(); $count = $this->count();
if(!$count) { if(!$count) {
if($num == 1 && !$alwaysArray) return null; if($num == 1 && !$alwaysArray) return null;

View File

@@ -52,9 +52,9 @@ class CommentStars extends WireData {
foreach(self::$defaults as $key => $value) { foreach(self::$defaults as $key => $value) {
$this->set($key, $value); $this->set($key, $value);
} }
$this->set('countLabelSingular', $this->_('%1$s (%2$s rating)')); if(!strlen($this->countLabelSingular)) $this->set('countLabelSingular', $this->_('%1$s (%2$s rating)'));
$this->set('countLabelPlural', $this->_('%1$s (%2$s ratings)')); if(!strlen($this->countLabelPlural)) $this->set('countLabelPlural', $this->_('%1$s (%2$s ratings)'));
$this->set('unratedLabel', $this->_('not yet rated')); if(!strlen($this->unratedLabel)) $this->set('unratedLabel', $this->_('not yet rated'));
} }
/** /**