mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 17:54:44 +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.
|
* - `$this` - If you are setting a value.
|
||||||
*/
|
*/
|
||||||
public function data($key = null, $value = null) {
|
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(is_array($key)) {
|
||||||
if($value === true) {
|
if($value === true) {
|
||||||
$this->data = $key;
|
$this->data = $key;
|
||||||
@@ -219,7 +219,7 @@ class WireData extends Wire implements \IteratorAggregate, \ArrayAccess {
|
|||||||
$this->data = array_merge($this->data, $key);
|
$this->data = array_merge($this->data, $key);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
} else if(is_null($value)) {
|
} else if($value === null) {
|
||||||
return isset($this->data[$key]) ? $this->data[$key] : null;
|
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||||
} else {
|
} else {
|
||||||
$this->data[$key] = $value;
|
$this->data[$key] = $value;
|
||||||
|
@@ -106,6 +106,9 @@ abstract class WireSaveableItems extends Wire implements \IteratorAggregate {
|
|||||||
return $query;
|
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(
|
$functionFields = array(
|
||||||
'sort' => '',
|
'sort' => '',
|
||||||
'limit' => '',
|
'limit' => '',
|
||||||
@@ -117,25 +120,33 @@ abstract class WireSaveableItems extends Wire implements \IteratorAggregate {
|
|||||||
|
|
||||||
foreach($selectors as $selector) {
|
foreach($selectors as $selector) {
|
||||||
|
|
||||||
if(!$database->isOperator($selector->operator))
|
if(!$database->isOperator($selector->operator)) {
|
||||||
throw new WireException("Operator '{$selector->operator}' may not be used in {$this->className}::load()");
|
throw new WireException("Operator '$selector->operator' may not be used in {$this->className}::load()");
|
||||||
|
}
|
||||||
|
|
||||||
if(in_array($selector->field, $functionFields)) {
|
if(isset($functionFields[$selector->field])) {
|
||||||
$functionFields[$selector->field] = $selector->value;
|
$functionFields[$selector->field] = $selector->value;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($selector->field, $fields)) {
|
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);
|
$selectorField = $database->escapeTableCol($selector->field);
|
||||||
$value = $database->escapeStr($selector->value);
|
$query->where("$selectorField$selector->operator?", $selector->value); // QA
|
||||||
$query->where("{$selectorField}{$selector->operator}'$value'"); // QA
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($functionFields['sort'] && in_array($functionFields['sort'], $fields)) $query->orderby("$functionFields[sort]");
|
$sort = $functionFields['sort'];
|
||||||
if($functionFields['limit']) $query->limit(($functionFields['start'] ? ((int) $functionFields['start']) . "," : '') . $functionFields['limit']);
|
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;
|
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 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 $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 $timeInputFormat Time input format to use, see WireDateTime::$timeFormats (default='')
|
||||||
|
* @property string $placeholder Placeholder attribute text
|
||||||
*
|
*
|
||||||
* Properties specific to "html" input type
|
* Properties specific to "html" input type
|
||||||
* ========================================
|
* ========================================
|
||||||
|
@@ -202,7 +202,7 @@ var Inputfields = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function opened() {
|
function opened() {
|
||||||
$inputfield.trigger('opened');
|
$inputfield.trigger('opened', $inputfield);
|
||||||
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
||||||
$inputfield.children('.InputfieldContent').show();
|
$inputfield.children('.InputfieldContent').show();
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ var Inputfields = {
|
|||||||
|
|
||||||
function closed() {
|
function closed() {
|
||||||
if($inputfield.css('overflow') == 'hidden') $inputfield.css('overflow', '');
|
if($inputfield.css('overflow') == 'hidden') $inputfield.css('overflow', '');
|
||||||
$inputfield.trigger('closed');
|
$inputfield.trigger('closed', $inputfield);
|
||||||
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
if($inputfield.hasClass('InputfieldColumnWidth')) {
|
||||||
$inputfield.children('.InputfieldContent').hide();
|
$inputfield.children('.InputfieldContent').hide();
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ var Inputfields = {
|
|||||||
|
|
||||||
// handle either open or close
|
// handle either open or close
|
||||||
if(open && isCollapsed) {
|
if(open && isCollapsed) {
|
||||||
$inputfield.addClass('InputfieldStateToggling').trigger('openReady');
|
$inputfield.addClass('InputfieldStateToggling').trigger('openReady', $inputfield);
|
||||||
if(duration && jQuery.ui) {
|
if(duration && jQuery.ui) {
|
||||||
$inputfield.toggleClass('InputfieldStateCollapsed', duration, opened);
|
$inputfield.toggleClass('InputfieldStateCollapsed', duration, opened);
|
||||||
} else {
|
} else {
|
||||||
@@ -269,7 +269,7 @@ var Inputfields = {
|
|||||||
opened();
|
opened();
|
||||||
}
|
}
|
||||||
} else if(!open && !isCollapsed) {
|
} else if(!open && !isCollapsed) {
|
||||||
$inputfield.addClass('InputfieldStateToggling').trigger('closeReady');
|
$inputfield.addClass('InputfieldStateToggling').trigger('closeReady', $inputfield);
|
||||||
if(duration && jQuery.ui) {
|
if(duration && jQuery.ui) {
|
||||||
$inputfield.toggleClass('InputfieldStateCollapsed', duration, closed);
|
$inputfield.toggleClass('InputfieldStateCollapsed', duration, closed);
|
||||||
} else {
|
} else {
|
||||||
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user