本文整理汇总了PHP中CMacrosResolverHelper::resolveMapLabelMacros方法的典型用法代码示例。如果您正苦于以下问题:PHP CMacrosResolverHelper::resolveMapLabelMacros方法的具体用法?PHP CMacrosResolverHelper::resolveMapLabelMacros怎么用?PHP CMacrosResolverHelper::resolveMapLabelMacros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMacrosResolverHelper
的用法示例。
在下文中一共展示了CMacrosResolverHelper::resolveMapLabelMacros方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawMapLinkLabels
function drawMapLinkLabels(&$im, $map, $mapInfo, $resolveMacros = true)
{
global $colors;
$links = $map['links'];
$selements = $map['selements'];
foreach ($links as $link) {
if (empty($link['label'])) {
continue;
}
$selement1 = $selements[$link['selementid1']];
list($x1, $y1) = get_icon_center_by_selement($selement1, $mapInfo[$link['selementid1']], $map);
$selement2 = $selements[$link['selementid2']];
list($x2, $y2) = get_icon_center_by_selement($selement2, $mapInfo[$link['selementid2']], $map);
if (isset($selement1['elementsubtype']) && $selement1['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
if ($selement1['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
$w = $selement1['width'];
$h = $selement1['height'];
} else {
$w = $map['width'];
$h = $map['height'];
}
list($x1, $y1) = calculateMapAreaLinkCoord($x1, $y1, $w, $h, $x2, $y2);
}
if (isset($selement2['elementsubtype']) && $selement2['elementsubtype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
if ($selement2['areatype'] == SYSMAP_ELEMENT_AREA_TYPE_CUSTOM) {
$w = $selement2['width'];
$h = $selement2['height'];
} else {
$w = $map['width'];
$h = $map['height'];
}
list($x2, $y2) = calculateMapAreaLinkCoord($x2, $y2, $w, $h, $x1, $y1);
}
$drawtype = $link['drawtype'];
$color = convertColor($im, $link['color']);
$linktriggers = $link['linktriggers'];
order_result($linktriggers, 'triggerid');
if (!empty($linktriggers)) {
$max_severity = 0;
$triggers = array();
foreach ($linktriggers as $link_trigger) {
if ($link_trigger['triggerid'] == 0) {
continue;
}
$id = $link_trigger['linktriggerid'];
$triggers[$id] = zbx_array_merge($link_trigger, get_trigger_by_triggerid($link_trigger['triggerid']));
if ($triggers[$id]['status'] == TRIGGER_STATUS_ENABLED && $triggers[$id]['value'] == TRIGGER_VALUE_TRUE) {
if ($triggers[$id]['priority'] >= $max_severity) {
$drawtype = $triggers[$id]['drawtype'];
$color = convertColor($im, $triggers[$id]['color']);
$max_severity = $triggers[$id]['priority'];
}
}
}
}
$label = $link['label'];
$label = str_replace("\r", '', $label);
$strings = explode("\n", $label);
$box_width = 0;
$box_height = 0;
foreach ($strings as $snum => $str) {
$strings[$snum] = $resolveMacros ? CMacrosResolverHelper::resolveMapLabelMacros($str) : $str;
}
foreach ($strings as $str) {
$dims = imageTextSize(8, 0, $str);
$box_width = $box_width > $dims['width'] ? $box_width : $dims['width'];
$box_height += $dims['height'] + 2;
}
$boxX_left = round(($x1 + $x2) / 2 - $box_width / 2 - 6);
$boxX_right = round(($x1 + $x2) / 2 + $box_width / 2 + 6);
$boxY_top = round(($y1 + $y2) / 2 - $box_height / 2 - 4);
$boxY_bottom = round(($y1 + $y2) / 2 + $box_height / 2 + 2);
switch ($drawtype) {
case MAP_LINK_DRAWTYPE_DASHED_LINE:
case MAP_LINK_DRAWTYPE_DOT:
dashedRectangle($im, $boxX_left, $boxY_top, $boxX_right, $boxY_bottom, $color);
break;
case MAP_LINK_DRAWTYPE_BOLD_LINE:
imagerectangle($im, $boxX_left - 1, $boxY_top - 1, $boxX_right + 1, $boxY_bottom + 1, $color);
// break; is not ne
// break; is not ne
case MAP_LINK_DRAWTYPE_LINE:
default:
imagerectangle($im, $boxX_left, $boxY_top, $boxX_right, $boxY_bottom, $color);
}
imagefilledrectangle($im, $boxX_left + 1, $boxY_top + 1, $boxX_right - 1, $boxY_bottom - 1, $colors['White']);
$increasey = 4;
foreach ($strings as $str) {
$dims = imageTextSize(8, 0, $str);
$labelx = ($x1 + $x2) / 2 - $dims['width'] / 2;
$labely = $boxY_top + $increasey;
imagetext($im, 8, 0, $labelx, $labely + $dims['height'], $colors['Black'], $str);
$increasey += $dims['height'] + 2;
}
}
}