diff --git a/wire/core/PageArray.php b/wire/core/PageArray.php index dff27ce5..a467e0b7 100644 --- a/wire/core/PageArray.php +++ b/wire/core/PageArray.php @@ -108,6 +108,7 @@ class PageArray extends PaginatedArray implements WirePaginatable { */ public function getItemKey($item) { if(!$item instanceof Page) return null; + if(!$this->duplicateChecking) return parent::getItemKey($item); // first see if we can determine key from our index $id = $item->id; diff --git a/wire/core/PageFinder.php b/wire/core/PageFinder.php index c7ee5f17..ce1879a8 100644 --- a/wire/core/PageFinder.php +++ b/wire/core/PageFinder.php @@ -10,7 +10,7 @@ * * Hookable methods: * ================= - * @method array|DatabaseQuerySelect find(Selectors $selectors, $options = array()) + * @method array|DatabaseQuerySelect find(Selectors|string|array $selectors, $options = array()) * @method DatabaseQuerySelect getQuery($selectors, array $options) * @method string getQueryAllowedTemplatesWhere(DatabaseQuerySelect $query, $where) * @method void getQueryJoinPath(DatabaseQuerySelect $query, $selector) @@ -1074,6 +1074,7 @@ class PageFinder extends Wire { $fieldCnt = array(); // counts number of instances for each field to ensure unique table aliases for ANDs on the same field $lastSelector = null; $sortSelectors = array(); // selector containing 'sort=', which gets added last + $subqueries = array(); $joins = array(); // $this->extraJoins = array(); $database = $this->wire('database'); diff --git a/wire/core/PageTraversal.php b/wire/core/PageTraversal.php index 441abe70..e8e6a590 100644 --- a/wire/core/PageTraversal.php +++ b/wire/core/PageTraversal.php @@ -452,7 +452,7 @@ class PageTraversal { * @param Page $page * @param string $selector Optional selector. When specified, will filter the found siblings. * @param array $options Options to pass to the _next() method - * @return Page|NullPage Returns all matching pages after this one. + * @return PageArray Returns all matching pages after this one. * */ public function nextAll(Page $page, $selector = '', array $options = array()) { @@ -467,7 +467,7 @@ class PageTraversal { * @param Page $page * @param string $selector Optional selector. When specified, will filter the found siblings. * @param array $options Options to pass to the _next() method - * @return Page|NullPage Returns all matching pages after this one. + * @return PageArray Returns all matching pages after this one. * */ public function prevAll(Page $page, $selector = '', array $options = array()) { @@ -1001,7 +1001,7 @@ class PageTraversal { * @param Page $page * @param string|array $selector Optional selector. When specified, will filter the found siblings. * @param PageArray $siblings Optional siblings to use instead of the default. - * @return Page|NullPage Returns all matching pages after this one. + * @return PageArray Returns all matching pages after this one. * */ public function nextAllSiblings(Page $page, $selector = '', PageArray $siblings = null) { diff --git a/wire/core/PaginatedArray.php b/wire/core/PaginatedArray.php index 910275f0..6b8a573a 100644 --- a/wire/core/PaginatedArray.php +++ b/wire/core/PaginatedArray.php @@ -138,15 +138,29 @@ class PaginatedArray extends WireArray implements WirePaginatable { return $this->numStart; } + /** + * Does this WireArray have more than one pagination? + * + * #pw-group-other + * + * @return bool + * @since 3.0.120 + * + */ + public function hasPagination() { + return $this->getTotal() > 0 && $this->count() < $this->getTotal(); + } + /** * Is there a next pagination containing more items in this PaginatedArray after the current one? * * #pw-group-other * * @return int + * @since 3.0.120 * */ - public function hasNext() { + public function hasNextPagination() { return $this->getStart() + $this->count() < $this->getTotal(); } @@ -156,9 +170,10 @@ class PaginatedArray extends WireArray implements WirePaginatable { * #pw-group-other * * @return bool + * @since 3.0.120 * */ - public function hasPrev() { + public function hasPrevPagination() { return $this->getStart() > 0; } diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index 12d8c186..eb843bca 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -44,7 +44,7 @@ class ProcessWire extends Wire { * Reversion revision number * */ - const versionRevision = 119; + const versionRevision = 120; /** * Version suffix string (when applicable) @@ -784,7 +784,6 @@ class ProcessWire extends Wire { * @param array $options Options to modify default behaviors (experimental): * - `siteDir` (string): Name of "site" directory in $rootPath that contains site's config.php, no slashes (default="site"). * @return Config - * @throws WireException * */ public static function buildConfig($rootPath = '', $rootURL = null, array $options = array()) { diff --git a/wire/core/Selector.php b/wire/core/Selector.php index 8dbf8090..a3aede85 100644 --- a/wire/core/Selector.php +++ b/wire/core/Selector.php @@ -320,7 +320,7 @@ abstract class Selector extends WireData { * * If the value held by this Selector is an array of values, it will check if any one of them matches the value supplied here. * - * @param string|int|Wire $value If given a Wire, then matches will also operate on OR field=value type selectors, where present + * @param string|int|Wire|array $value If given a Wire, then matches will also operate on OR field=value type selectors, where present * @return bool * */ diff --git a/wire/core/WireArray.php b/wire/core/WireArray.php index 8f29a72a..dea220c1 100644 --- a/wire/core/WireArray.php +++ b/wire/core/WireArray.php @@ -102,8 +102,10 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count * */ public function isValidItem($item) { - if($this->className() === 'WireArray') return true; - return $item instanceof Wire; + if($item instanceof Wire) return true; + $className = $this->className(); + if($className === 'WireArray' || $className === 'PaginatedArray') return true; + return false; } /** @@ -184,7 +186,9 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count */ public function makeBlankItem() { $class = wireClassName($this, false); - if($class != 'WireArray') throw new WireException("Class '$class' doesn't yet implement method 'makeBlankItem()' and it needs to."); + if($class != 'WireArray' && $class != 'PaginatedArray') { + throw new WireException("Class '$class' doesn't yet implement method 'makeBlankItem()' and it needs to."); + } return null; } @@ -532,8 +536,8 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count // if given an array of keys, return all matching items if(is_array($key)) { + /** @var array $key */ if(ctype_digit(implode('', array_keys($key)))) { - /** @var array $key */ $items = array(); foreach($key as $k) { $item = $this->get($k);