本文整理匯總了PHP中CMap::AddItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMap::AddItem方法的具體用法?PHP CMap::AddItem怎麽用?PHP CMap::AddItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CMap
的用法示例。
在下文中一共展示了CMap::AddItem方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_action_map_by_sysmapid
function get_action_map_by_sysmapid($sysmapid)
{
$action_map = new CMap("links{$sysmapid}");
$db_elements = DBselect('SELECT * FROM sysmaps_elements WHERE sysmapid=' . $sysmapid);
while ($db_element = DBfetch($db_elements)) {
$url = $db_element["url"];
$alt = "Label: " . $db_element["label"];
$scripts_by_hosts = null;
if ($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_HOST) {
$host = get_host_by_hostid($db_element["elementid"]);
if ($host["status"] != HOST_STATUS_MONITORED) {
continue;
}
$scripts_by_hosts = get_accessible_scripts_by_hosts(array($db_element["elementid"]));
if (empty($url)) {
$url = 'tr_status.php?hostid=' . $db_element['elementid'] . '&noactions=true&onlytrue=true&compact=true';
}
$alt = "Host: " . $host["host"] . " " . $alt;
} else {
if ($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_MAP) {
$map = get_sysmap_by_sysmapid($db_element["elementid"]);
if (empty($url)) {
$url = "maps.php?sysmapid=" . $db_element["elementid"];
}
$alt = "Host: " . $map["name"] . " " . $alt;
} elseif ($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_TRIGGER) {
if (empty($url) && $db_element["elementid"] != 0) {
$url = "events.php?triggerid=" . $db_element["elementid"];
}
} else {
if ($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_HOST_GROUP) {
if (empty($url) && $db_element["elementid"] != 0) {
$url = "events.php?hostid=0&groupid=" . $db_element["elementid"];
}
}
}
}
if (empty($url)) {
continue;
}
$back = get_png_by_selementid($db_element["selementid"]);
if (!$back) {
continue;
}
$x1_ = $db_element["x"];
$y1_ = $db_element["y"];
$x2_ = $db_element["x"] + imagesx($back);
$y2_ = $db_element["y"] + imagesy($back);
$r_area = new CArea(array($x1_, $y1_, $x2_, $y2_), $url, $alt, 'rect');
if (!empty($scripts_by_hosts)) {
$menus = '';
$host_nodeid = id2nodeid($db_element["elementid"]);
foreach ($scripts_by_hosts[$db_element["elementid"]] as $id => $script) {
$script_nodeid = id2nodeid($script['scriptid']);
if (bccomp($host_nodeid, $script_nodeid) == 0) {
$menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $db_element["elementid"] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
}
}
$menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
$menus .= "['" . S_STATUS_OF_TRIGGERS . "',\"javascript: redirect('tr_status.php?hostid=" . $db_element['elementid'] . "&noactions=true&onlytrue=true&compact=true')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
if (!empty($db_element["url"])) {
$menus .= "['" . S_MAP . SPACE . S_URL . "',\"javascript: redirect('" . $url . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
}
$menus = trim($menus, ',');
$menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180); cancelEvent(event);";
$r_area->AddAction('onclick', 'javascript: ' . $menus);
}
$action_map->AddItem($r_area);
//AddRectArea($x1_,$y1_,$x2_,$y2_, $url, $alt);
}
$jsmenu = new CPUMenu(null, 170);
$jsmenu->InsertJavaScript();
return $action_map;
}