From aaf5d6edc0842a0ae23d9e291b7678c56c1d4a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.chilliet@fusiondirectory.org> Date: Thu, 8 Oct 2020 15:00:04 +0200 Subject: [PATCH] :sparkles: feat(management) Extend ObjectTypeColumn to be able to plug it on a field Used by archive plugin issue #6119 --- .../columns/class_ObjectTypeColumn.inc | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/include/management/columns/class_ObjectTypeColumn.inc b/include/management/columns/class_ObjectTypeColumn.inc index 0d7a9820a..a29b7b084 100644 --- a/include/management/columns/class_ObjectTypeColumn.inc +++ b/include/management/columns/class_ObjectTypeColumn.inc @@ -30,12 +30,28 @@ class ObjectTypeColumn extends Column function renderCell (ListingEntry $entry): string { - if ($entry->isTemplate()) { + if (isset($this->attributes)) { + $isTemplate = FALSE; + $types = $this->getAttributeValues($entry); + } else { + $isTemplate = $entry->isTemplate(); + if ($entry->type) { + $types = [$entry->type]; + } else { + $types = []; + } + } + if ($isTemplate) { $infos = objects::infos($entry->getTemplatedType()); return '<img title="'.htmlescape($entry->dn).'" src="'.htmlescape('geticon.php?context=devices&icon=template&size=16').'" alt="'.htmlescape(sprintf(_('%s template'), $infos['name'])).'"/>'; - } elseif ($entry->type) { - $infos = objects::infos($entry->type); - return '<img title="'.htmlescape($entry->dn).'" src="'.htmlescape($infos['icon']).'" alt="'.htmlescape($infos['name']).'"/>'; + } elseif (!empty($types)) { + $cell = ''; + foreach ($types as $type) { + $infos = objects::infos($type); + $title = (isset($this->attributes) ? $infos['name'] : $entry->dn); + $cell .= '<img title="'.htmlescape($title).'" src="'.htmlescape($infos['icon']).'" alt="'.htmlescape($infos['name']).'"/>'; + } + return $cell; } else { return ' '; } -- GitLab