mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +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;
|
||||
|
||||
|
@@ -51,6 +51,7 @@
|
||||
* @property int $timeInputSelect jQuery UI timeSelect type (requires datepicker)—specify 1 to use a `<select>` for time input, or 0 to use a slider (default=0)
|
||||
* @property string $dateInputFormat Date input format to use, see WireDateTime::$dateFormats (default='Y-m-d')
|
||||
* @property string $timeInputFormat Time input format to use, see WireDateTime::$timeFormats (default='')
|
||||
* @property string $placeholder Placeholder attribute text
|
||||
*
|
||||
* Properties specific to "html" input type
|
||||
* ========================================
|
||||
|
@@ -202,7 +202,7 @@ var Inputfields = {
|
||||
}
|
||||
|
||||
function opened() {
|
||||
$inputfield.trigger('opened');
|
||||
$inputfield.trigger('opened', $inputfield);
|
||||
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
||||
$inputfield.children('.InputfieldContent').show();
|
||||
}
|
||||
@@ -214,7 +214,7 @@ var Inputfields = {
|
||||
|
||||
function closed() {
|
||||
if($inputfield.css('overflow') == 'hidden') $inputfield.css('overflow', '');
|
||||
$inputfield.trigger('closed');
|
||||
$inputfield.trigger('closed', $inputfield);
|
||||
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
||||
$inputfield.children('.InputfieldContent').hide();
|
||||
}
|
||||
@@ -261,7 +261,7 @@ var Inputfields = {
|
||||
|
||||
// handle either open or close
|
||||
if(open && isCollapsed) {
|
||||
$inputfield.addClass('InputfieldStateToggling').trigger('openReady');
|
||||
$inputfield.addClass('InputfieldStateToggling').trigger('openReady', $inputfield);
|
||||
if(duration && jQuery.ui) {
|
||||
$inputfield.toggleClass('InputfieldStateCollapsed', duration, opened);
|
||||
} else {
|
||||
@@ -269,7 +269,7 @@ var Inputfields = {
|
||||
opened();
|
||||
}
|
||||
} else if(!open && !isCollapsed) {
|
||||
$inputfield.addClass('InputfieldStateToggling').trigger('closeReady');
|
||||
$inputfield.addClass('InputfieldStateToggling').trigger('closeReady', $inputfield);
|
||||
if(duration && jQuery.ui) {
|
||||
$inputfield.toggleClass('InputfieldStateCollapsed', duration, closed);
|
||||
} else {
|
||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user