chg: [search_all] Added drafty support of meta-fields
parent
4bcdf9534a
commit
e8e1a16673
|
@ -71,6 +71,18 @@ class InstanceTable extends AppTable
|
|||
public function searchAll($value, $limit=5, $model=null)
|
||||
{
|
||||
$results = [];
|
||||
|
||||
// search in metafields. FIXME: To be replaced by the meta-template system
|
||||
$metaFieldTable = TableRegistry::get('MetaFields');
|
||||
$query = $metaFieldTable->find()->where([
|
||||
'value LIKE' => '%' . $value . '%'
|
||||
]);
|
||||
$results['MetaFields']['amount'] = $query->count();
|
||||
$result = $query->limit($limit)->all()->toList();
|
||||
if (!empty($result)) {
|
||||
$results['MetaFields']['entries'] = $result;
|
||||
}
|
||||
|
||||
$models = $this->seachAllTables;
|
||||
if (!is_null($model)) {
|
||||
if (in_array($model, $this->seachAllTables)) {
|
||||
|
|
|
@ -19,14 +19,25 @@
|
|||
</span>', h($tableName), $tableResult['amount']);
|
||||
|
||||
foreach ($tableResult['entries'] as $entry) {
|
||||
$section .= sprintf('<a class="dropdown-item" href="%s">%s</a>',
|
||||
Cake\Routing\Router::URL([
|
||||
'controller' => Cake\Utility\Inflector::pluralize($entry->getSource()),
|
||||
'action' => 'view',
|
||||
h($entry['id'])
|
||||
]),
|
||||
h($entry[$fieldPath])
|
||||
);
|
||||
if ($entry->getSource() == 'MetaFields') {
|
||||
$section .= sprintf('<a class="dropdown-item" href="%s">%s</a>',
|
||||
Cake\Routing\Router::URL([
|
||||
'controller' => Cake\Utility\Inflector::pluralize($entry->scope),
|
||||
'action' => 'view',
|
||||
h($entry->parent_id)
|
||||
]),
|
||||
sprintf('%s (%s::%s)', h($entry->value), h($entry->scope), h($entry->field))
|
||||
);
|
||||
} else {
|
||||
$section .= sprintf('<a class="dropdown-item" href="%s">%s</a>',
|
||||
Cake\Routing\Router::URL([
|
||||
'controller' => Cake\Utility\Inflector::pluralize($entry->getSource()),
|
||||
'action' => 'view',
|
||||
h($entry['id'])
|
||||
]),
|
||||
h($entry[$fieldPath])
|
||||
);
|
||||
}
|
||||
}
|
||||
$remaining = $tableResult['amount'] - count($tableResult['entries']);
|
||||
if ($remaining > 0) {
|
||||
|
|
Loading…
Reference in New Issue