if ($data['readonly'] && !$data['macros']) {
$table = new CObject(_('No macros found.'));
$is_hostprototype = array_key_exists('parent_hostid', $data);
$inherited_width = $is_hostprototype ? ZBX_TEXTAREA_MACRO_INHERITED_WIDTH : ZBX_TEXTAREA_MACRO_VALUE_WIDTH;
->addClass(ZBX_STYLE_TEXTAREA_FLEXIBLE_CONTAINER)
->addClass('inherited-macros-table');
if (CWebUser::getType() == USER_TYPE_SUPER_ADMIN) {
$link = (new CLink(_('configure'), (new CUrl('zabbix.php'))
->setArgument('action', 'macros.edit')
$link = [' (', $link, ')'];
(new CTableColumn(_('Macro')))->addClass('table-col-macro'),
(new CTableColumn(_('Effective value')))->addClass('table-col-value'),
!$data['readonly'] ? (new CTableColumn())->addClass('table-col-action') : null,
$is_hostprototype ? (new CTableColumn())->addClass('table-col-arrow') : null,
$is_hostprototype ? (new CTableColumn(_('Parent host value')))->addClass('table-col-parent-value') : null,
(new CTableColumn())->addClass('table-col-arrow'),
(new CTableColumn(_('Template value')))->addClass('table-col-template-value'),
(new CTableColumn())->addClass('table-col-arrow'),
(new CTableColumn([_('Global value'), $link]))->addClass('table-col-global-value')
foreach ($data['macros'] as $i => $macro) {
$macro_value = (new CMacroValue($macro['type'], 'macros['.$i.']', null, false))
->setReadonly($data['readonly']
|| !($macro['discovery_state'] & CControllerHostMacrosList::DISCOVERY_STATE_CONVERTING)
|| !($macro['inherited_type'] & ZBX_PROPERTY_OWN)
(new CTextAreaFlexible('macros['.$i.'][macro]', $macro['macro']))