本文整理汇总了PHP中CMacrosResolverHelper::resolveMapLabelMacrosAll方法的典型用法代码示例。如果您正苦于以下问题:PHP CMacrosResolverHelper::resolveMapLabelMacrosAll方法的具体用法?PHP CMacrosResolverHelper::resolveMapLabelMacrosAll怎么用?PHP CMacrosResolverHelper::resolveMapLabelMacrosAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMacrosResolverHelper
的用法示例。
在下文中一共展示了CMacrosResolverHelper::resolveMapLabelMacrosAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawMapLabels
function drawMapLabels(&$im, $map, $mapInfo, $resolveMacros = true)
{
global $colors;
if ($map['label_type'] == MAP_LABEL_TYPE_NOTHING && $map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) {
return;
}
$selements = $map['selements'];
$allStrings = '';
$labelLines = array();
$statusLines = array();
foreach ($selements as $sid => $selement) {
if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) {
unset($selements[$sid]);
}
}
// set label type and custom label text for all selements
foreach ($selements as $selementId => $selement) {
$selements[$selementId]['label_type'] = $map['label_type'];
if ($map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) {
continue;
}
switch ($selement['elementtype']) {
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$selements[$selementId]['label_type'] = $map['label_type_hostgroup'];
if ($map['label_type_hostgroup'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_hostgroup'];
}
break;
case SYSMAP_ELEMENT_TYPE_HOST:
$selements[$selementId]['label_type'] = $map['label_type_host'];
if ($map['label_type_host'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_host'];
}
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$selements[$selementId]['label_type'] = $map['label_type_trigger'];
if ($map['label_type_trigger'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_trigger'];
}
break;
case SYSMAP_ELEMENT_TYPE_MAP:
$selements[$selementId]['label_type'] = $map['label_type_map'];
if ($map['label_type_map'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_map'];
}
break;
case SYSMAP_ELEMENT_TYPE_IMAGE:
$selements[$selementId]['label_type'] = $map['label_type_image'];
if ($map['label_type_image'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_image'];
}
break;
}
}
foreach ($selements as $selementId => $selement) {
if (!isset($labelLines[$selementId])) {
$labelLines[$selementId] = array();
}
if (!isset($statusLines[$selementId])) {
$statusLines[$selementId] = array();
}
$msg = $resolveMacros ? CMacrosResolverHelper::resolveMapLabelMacrosAll($selement) : $selement['label'];
$allStrings .= $msg;
$msgs = explode("\n", $msg);
foreach ($msgs as $msg) {
$labelLines[$selementId][] = array('msg' => $msg);
}
$elementInfo = $mapInfo[$selementId];
foreach (array('problem', 'unack', 'maintenance', 'ok', 'status') as $caption) {
if (!isset($elementInfo['info'][$caption]) || zbx_empty($elementInfo['info'][$caption]['msg'])) {
continue;
}
$statusLines[$selementId][] = array('msg' => $elementInfo['info'][$caption]['msg'], 'color' => $elementInfo['info'][$caption]['color']);
$allStrings .= $elementInfo['info'][$caption]['msg'];
}
}
$allLabelsSize = imageTextSize(8, 0, str_replace("\r", '', str_replace("\n", '', $allStrings)));
$labelFontHeight = $allLabelsSize['height'];
$labelFontBaseline = $allLabelsSize['baseline'];
$elementsHostIds = array();
foreach ($selements as $selement) {
if ($selement['label_type'] != MAP_LABEL_TYPE_IP) {
continue;
}
if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) {
$elementsHostIds[] = $selement['elementid'];
}
}
if (!empty($elementsHostIds)) {
$mapHosts = API::Host()->get(array('hostids' => $elementsHostIds, 'output' => array('hostid'), 'selectInterfaces' => API_OUTPUT_EXTEND));
$mapHosts = zbx_toHash($mapHosts, 'hostid');
}
// draw
foreach ($selements as $selementId => $selement) {
if (empty($selement) || $selement['label_type'] == MAP_LABEL_TYPE_NOTHING) {
continue;
}
$elementInfo = $mapInfo[$selementId];
$hl_color = null;
$st_color = null;
//.........这里部分代码省略.........