当前位置: 首页>>代码示例>>PHP>>正文


PHP CMap::AddItem方法代码示例

本文整理汇总了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;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:74,代码来源:maps.inc.php


注:本文中的CMap::AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。