Skip to content

Commit 1aa5805

Browse files
committed
Dev: Support for options find action
1 parent 31aa0f8 commit 1aa5805

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

Editor.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,7 @@ private function _options($refresh)
22972297
*/
22982298
private function _optionsSearch($http)
22992299
{
2300+
$values = null;
23002301
$field = $this->_find_field($http['field'], 'name');
23012302

23022303
if (!$field) {
@@ -2309,7 +2310,11 @@ private function _optionsSearch($http)
23092310
return;
23102311
}
23112312

2312-
$values = $options->search($this->db(), $http['search']);
2313+
if (isset($http['search'])) {
2314+
$values = $options->search($this->db(), $http['search']);
2315+
} elseif (isset($http['values'])) {
2316+
$values = $options->find($this->db(), $http['values']);
2317+
}
23132318

23142319
if ($values) {
23152320
$this->_out['data'] = $values;
@@ -2441,16 +2446,16 @@ private function _alias($name, $type = 'alias')
24412446
$a = preg_split('/ as /i', $name);
24422447

24432448
return $type === 'alias' ?
2444-
$a[1] :
2445-
$a[0];
2449+
$a[1] :
2450+
$a[0];
24462451
}
24472452

24482453
if (stripos($name, ' ') !== false) {
24492454
$a = preg_split('/ /i', $name);
24502455

24512456
return $type === 'alias' ?
2452-
$a[1] :
2453-
$a[0];
2457+
$a[1] :
2458+
$a[0];
24542459
}
24552460

24562461
return $name;

Editor/Options.php

+20-3
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,10 @@ public function where($_ = null)
309309
*
310310
* @internal
311311
*/
312-
public function exec($db, $refresh, $search = null)
312+
public function exec($db, $refresh, $search = null, $find = null)
313313
{
314314
// If search only, and not a search action, then just return false
315-
if ($this->searchOnly() && $search === null) {
315+
if ($this->searchOnly() && $search === null && $find === null) {
316316
return false;
317317
}
318318

@@ -357,6 +357,10 @@ public function exec($db, $refresh, $search = null)
357357
->get($fields)
358358
->where($this->_where);
359359

360+
if (is_array($find)) {
361+
$q->where_in($value, $find);
362+
}
363+
360364
if (is_string($this->_order)) {
361365
// For cases where we are ordering by a field which isn't included in the list
362366
// of fields to display, we need to add the ordering field, due to the
@@ -375,7 +379,7 @@ public function exec($db, $refresh, $search = null)
375379
}
376380

377381
$q->order($this->_order);
378-
} else if ($this->_order === true) {
382+
} elseif ($this->_order === true) {
379383
// Attempt to do a database order, needed for "limit()"ed results
380384
$q->order($this->_label[0]);
381385
}
@@ -436,6 +440,19 @@ public function exec($db, $refresh, $search = null)
436440
return $out;
437441
}
438442

443+
/**
444+
* Get the objects for a set of values.
445+
*
446+
* @param Database $db Database connection
447+
* @param array $ids IDs to get
448+
*
449+
* @return array|bool
450+
*/
451+
public function find($db, $ids)
452+
{
453+
return $this->exec($db, false, null, $ids);
454+
}
455+
439456
/**
440457
* Do a search for data on the source.
441458
*

0 commit comments

Comments
 (0)