當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CMacrosResolverHelper::resolveFunctionParameters方法代碼示例

本文整理匯總了PHP中CMacrosResolverHelper::resolveFunctionParameters方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMacrosResolverHelper::resolveFunctionParameters方法的具體用法?PHP CMacrosResolverHelper::resolveFunctionParameters怎麽用?PHP CMacrosResolverHelper::resolveFunctionParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CMacrosResolverHelper的用法示例。


在下文中一共展示了CMacrosResolverHelper::resolveFunctionParameters方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: explode_exp

function explode_exp($expressionCompressed, $html = false, $resolveMacro = false, $sourceHost = null, $destinationHost = null)
{
    $expressionExpanded = $html ? array() : '';
    $trigger = array();
    for ($i = 0, $state = '', $max = zbx_strlen($expressionCompressed); $i < $max; $i++) {
        if ($expressionCompressed[$i] == '{') {
            if ($expressionCompressed[$i + 1] == '$') {
                $state = 'USERMACRO';
                $userMacro = '';
            } elseif ($expressionCompressed[$i + 1] == '#') {
                $state = 'LLDMACRO';
                $lldMacro = '';
            } else {
                $state = 'FUNCTIONID';
                $functionId = '';
                continue;
            }
        } elseif ($expressionCompressed[$i] == '}') {
            if ($state == 'USERMACRO') {
                $state = '';
                $userMacro .= '}';
                if ($resolveMacro) {
                    $functionData['expression'] = $userMacro;
                    $userMacro = CMacrosResolverHelper::resolveTriggerExpressionUserMacro($functionData);
                }
                if ($html) {
                    $expressionExpanded[] = $userMacro;
                } else {
                    $expressionExpanded .= $userMacro;
                }
                continue;
            } elseif ($state == 'LLDMACRO') {
                $state = '';
                $lldMacro .= '}';
                if ($html) {
                    $expressionExpanded[] = $lldMacro;
                } else {
                    $expressionExpanded .= $lldMacro;
                }
                continue;
            } elseif ($functionId == 'TRIGGER.VALUE') {
                $state = '';
                if ($html) {
                    $expressionExpanded[] = '{' . $functionId . '}';
                } else {
                    $expressionExpanded .= '{' . $functionId . '}';
                }
                continue;
            }
            $state = '';
            $error = true;
            if (is_numeric($functionId)) {
                $functionData = DBfetch(DBselect('SELECT h.host,h.hostid,i.itemid,i.key_,f.function,f.triggerid,f.parameter,i.itemid,i.status,i.type,i.flags' . ' FROM items i,functions f,hosts h' . ' WHERE f.functionid=' . zbx_dbstr($functionId) . ' AND i.itemid=f.itemid' . ' AND h.hostid=i.hostid'));
                if ($functionData) {
                    $error = false;
                    if ($resolveMacro) {
                        $trigger = $functionData;
                        // expand macros in item key
                        $items = CMacrosResolverHelper::resolveItemKeys(array($functionData));
                        $item = reset($items);
                        $functionData['key_'] = $item['key_expanded'];
                        // expand macros in function parameter
                        $functionParameters = CMacrosResolverHelper::resolveFunctionParameters(array($functionData));
                        $functionParameter = reset($functionParameters);
                        $functionData['parameter'] = $functionParameter['parameter_expanded'];
                    }
                    if ($sourceHost !== null && $destinationHost !== null && $sourceHost === $functionData['host']) {
                        $functionData['host'] = $destinationHost;
                    }
                    if ($html) {
                        if ($functionData['status'] == ITEM_STATUS_DISABLED) {
                            $style = 'disabled';
                        } elseif ($functionData['status'] == ITEM_STATUS_ACTIVE) {
                            $style = 'enabled';
                        } else {
                            $style = 'unknown';
                        }
                        if ($functionData['flags'] == ZBX_FLAG_DISCOVERY_CREATED || $functionData['type'] == ITEM_TYPE_HTTPTEST) {
                            $link = new CSpan($functionData['host'] . ':' . $functionData['key_'], $style);
                        } elseif ($functionData['flags'] == ZBX_FLAG_DISCOVERY_PROTOTYPE) {
                            $link = new CLink($functionData['host'] . ':' . $functionData['key_'], 'disc_prototypes.php?form=update&itemid=' . $functionData['itemid'] . '&parent_discoveryid=' . $trigger['discoveryRuleid'] . '&switch_node=' . id2nodeid($functionData['itemid']), $style);
                        } else {
                            $link = new CLink($functionData['host'] . ':' . $functionData['key_'], 'items.php?form=update&itemid=' . $functionData['itemid'] . '&switch_node=' . id2nodeid($functionData['itemid']), $style);
                        }
                        $expressionExpanded[] = array('{', $link, '.', bold($functionData['function'] . '('), $functionData['parameter'], bold(')'), '}');
                    } else {
                        $expressionExpanded .= '{' . $functionData['host'] . ':' . $functionData['key_'] . '.' . $functionData['function'] . '(' . $functionData['parameter'] . ')}';
                    }
                }
            }
            if ($error) {
                if ($html) {
                    $expressionExpanded[] = new CSpan('*ERROR*', 'on');
                } else {
                    $expressionExpanded .= '*ERROR*';
                }
            }
            continue;
        }
        switch ($state) {
//.........這裏部分代碼省略.........
開發者ID:itnihao,項目名稱:zatree-2.2,代碼行數:101,代碼來源:triggers.inc.php


注:本文中的CMacrosResolverHelper::resolveFunctionParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。