1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 08:44:46 +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) {
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;

View File

@@ -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');

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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()) {

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

View File

@@ -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);