mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 10:15:28 +02:00
Minor updates, plus update the inputfields.js triggered events (openReady, opened, closeReady, closed) to include the Inputfield element in the event arguments for simpler access to it vs the event.target.
This commit is contained in:
@@ -211,7 +211,7 @@ class WireData extends Wire implements \IteratorAggregate, \ArrayAccess {
|
||||
* - `$this` - If you are setting a value.
|
||||
*/
|
||||
public function data($key = null, $value = null) {
|
||||
if(is_null($key)) return $this->data;
|
||||
if($key === null) return $this->data;
|
||||
if(is_array($key)) {
|
||||
if($value === true) {
|
||||
$this->data = $key;
|
||||
@@ -219,7 +219,7 @@ class WireData extends Wire implements \IteratorAggregate, \ArrayAccess {
|
||||
$this->data = array_merge($this->data, $key);
|
||||
}
|
||||
return $this;
|
||||
} else if(is_null($value)) {
|
||||
} else if($value === null) {
|
||||
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||
} else {
|
||||
$this->data[$key] = $value;
|
||||
|
@@ -105,37 +105,48 @@ abstract class WireSaveableItems extends Wire implements \IteratorAggregate {
|
||||
// nothing provided, load all assumed
|
||||
return $query;
|
||||
}
|
||||
|
||||
// Note: ProcessWire core does not appear to ever reach this point as the
|
||||
// core does not use selectors to load any of its WireSaveableItems
|
||||
|
||||
$functionFields = array(
|
||||
'sort' => '',
|
||||
'limit' => '',
|
||||
'start' => '',
|
||||
);
|
||||
);
|
||||
|
||||
$item = $this->makeBlankItem();
|
||||
$fields = array_keys($item->getTableData());
|
||||
|
||||
foreach($selectors as $selector) {
|
||||
|
||||
if(!$database->isOperator($selector->operator))
|
||||
throw new WireException("Operator '{$selector->operator}' may not be used in {$this->className}::load()");
|
||||
|
||||
if(in_array($selector->field, $functionFields)) {
|
||||
$functionFields[$selector->field] = $selector->value;
|
||||
continue;
|
||||
if(!$database->isOperator($selector->operator)) {
|
||||
throw new WireException("Operator '$selector->operator' may not be used in {$this->className}::load()");
|
||||
}
|
||||
|
||||
if(isset($functionFields[$selector->field])) {
|
||||
$functionFields[$selector->field] = $selector->value;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!in_array($selector->field, $fields)) {
|
||||
throw new WireException("Field '{$selector->field}' is not valid for {$this->className}::load()");
|
||||
throw new WireException("Field '$selector->field' is not valid for {$this->className}::load()");
|
||||
}
|
||||
|
||||
$selectorField = $database->escapeTableCol($selector->field);
|
||||
$value = $database->escapeStr($selector->value);
|
||||
$query->where("{$selectorField}{$selector->operator}'$value'"); // QA
|
||||
$query->where("$selectorField$selector->operator?", $selector->value); // QA
|
||||
}
|
||||
|
||||
if($functionFields['sort'] && in_array($functionFields['sort'], $fields)) $query->orderby("$functionFields[sort]");
|
||||
if($functionFields['limit']) $query->limit(($functionFields['start'] ? ((int) $functionFields['start']) . "," : '') . $functionFields['limit']);
|
||||
$sort = $functionFields['sort'];
|
||||
if($sort && in_array($sort, $fields)) {
|
||||
$query->orderby($database->escapeCol($sort));
|
||||
}
|
||||
|
||||
$limit = (int) $functionFields['limit'];
|
||||
if($limit) {
|
||||
$start = $functionFields['start'];
|
||||
$query->limit(($start ? ((int) $start) . ',' : '') . $limit);
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
|
Reference in New Issue
Block a user