1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 02:04:35 +02:00

Various minor adjustments and bump version to 3.0.120

This commit is contained in:
Ryan Cramer
2018-11-30 13:52:24 -05:00
parent 0442572885
commit d7b7acb8e5
7 changed files with 33 additions and 13 deletions

View File

@@ -108,6 +108,7 @@ class PageArray extends PaginatedArray implements WirePaginatable {
*/ */
public function getItemKey($item) { public function getItemKey($item) {
if(!$item instanceof Page) return null; if(!$item instanceof Page) return null;
if(!$this->duplicateChecking) return parent::getItemKey($item);
// first see if we can determine key from our index // first see if we can determine key from our index
$id = $item->id; $id = $item->id;

View File

@@ -10,7 +10,7 @@
* *
* Hookable methods: * 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 DatabaseQuerySelect getQuery($selectors, array $options)
* @method string getQueryAllowedTemplatesWhere(DatabaseQuerySelect $query, $where) * @method string getQueryAllowedTemplatesWhere(DatabaseQuerySelect $query, $where)
* @method void getQueryJoinPath(DatabaseQuerySelect $query, $selector) * @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 $fieldCnt = array(); // counts number of instances for each field to ensure unique table aliases for ANDs on the same field
$lastSelector = null; $lastSelector = null;
$sortSelectors = array(); // selector containing 'sort=', which gets added last $sortSelectors = array(); // selector containing 'sort=', which gets added last
$subqueries = array();
$joins = array(); $joins = array();
// $this->extraJoins = array(); // $this->extraJoins = array();
$database = $this->wire('database'); $database = $this->wire('database');

View File

@@ -452,7 +452,7 @@ class PageTraversal {
* @param Page $page * @param Page $page
* @param string $selector Optional selector. When specified, will filter the found siblings. * @param string $selector Optional selector. When specified, will filter the found siblings.
* @param array $options Options to pass to the _next() method * @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()) { public function nextAll(Page $page, $selector = '', array $options = array()) {
@@ -467,7 +467,7 @@ class PageTraversal {
* @param Page $page * @param Page $page
* @param string $selector Optional selector. When specified, will filter the found siblings. * @param string $selector Optional selector. When specified, will filter the found siblings.
* @param array $options Options to pass to the _next() method * @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()) { public function prevAll(Page $page, $selector = '', array $options = array()) {
@@ -1001,7 +1001,7 @@ class PageTraversal {
* @param Page $page * @param Page $page
* @param string|array $selector Optional selector. When specified, will filter the found siblings. * @param string|array $selector Optional selector. When specified, will filter the found siblings.
* @param PageArray $siblings Optional siblings to use instead of the default. * @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) { public function nextAllSiblings(Page $page, $selector = '', PageArray $siblings = null) {

View File

@@ -138,15 +138,29 @@ class PaginatedArray extends WireArray implements WirePaginatable {
return $this->numStart; 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? * Is there a next pagination containing more items in this PaginatedArray after the current one?
* *
* #pw-group-other * #pw-group-other
* *
* @return int * @return int
* @since 3.0.120
* *
*/ */
public function hasNext() { public function hasNextPagination() {
return $this->getStart() + $this->count() < $this->getTotal(); return $this->getStart() + $this->count() < $this->getTotal();
} }
@@ -156,9 +170,10 @@ class PaginatedArray extends WireArray implements WirePaginatable {
* #pw-group-other * #pw-group-other
* *
* @return bool * @return bool
* @since 3.0.120
* *
*/ */
public function hasPrev() { public function hasPrevPagination() {
return $this->getStart() > 0; return $this->getStart() > 0;
} }

View File

@@ -44,7 +44,7 @@ class ProcessWire extends Wire {
* Reversion revision number * Reversion revision number
* *
*/ */
const versionRevision = 119; const versionRevision = 120;
/** /**
* Version suffix string (when applicable) * Version suffix string (when applicable)
@@ -784,7 +784,6 @@ class ProcessWire extends Wire {
* @param array $options Options to modify default behaviors (experimental): * @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"). * - `siteDir` (string): Name of "site" directory in $rootPath that contains site's config.php, no slashes (default="site").
* @return Config * @return Config
* @throws WireException
* *
*/ */
public static function buildConfig($rootPath = '', $rootURL = null, array $options = array()) { public static function buildConfig($rootPath = '', $rootURL = null, array $options = array()) {

View File

@@ -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. * 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 * @return bool
* *
*/ */

View File

@@ -102,8 +102,10 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count
* *
*/ */
public function isValidItem($item) { public function isValidItem($item) {
if($this->className() === 'WireArray') return true; if($item instanceof Wire) return true;
return $item instanceof Wire; $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() { public function makeBlankItem() {
$class = wireClassName($this, false); $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; 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 given an array of keys, return all matching items
if(is_array($key)) { if(is_array($key)) {
if(ctype_digit(implode('', array_keys($key)))) {
/** @var array $key */ /** @var array $key */
if(ctype_digit(implode('', array_keys($key)))) {
$items = array(); $items = array();
foreach($key as $k) { foreach($key as $k) {
$item = $this->get($k); $item = $this->get($k);