本文整理匯總了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;
//.........這裏部分代碼省略.........