Exemplo n.º 1
0
function createTree(&$smarty, $interface_name)
{
    $req = new GetTree($interface_name);
    $resp = $req->sendAndRecv();
    if (!$resp->isSuccessful()) {
        $resp->setErrorInSmarty($smarty);
        return "";
    }
    $root_node = $resp->getResult();
    return createSubTree($smarty, $root_node, "nothing");
}
Exemplo n.º 2
0
function createSubTree(&$smarty, &$node, $line)
{
    $req = new GetNodeInfo($node[0]);
    $resp = $req->sendAndRecv();
    if ($resp->isSuccessful()) {
        $node_info = $resp->getResult();
    } else {
        $resp->setErrorInSmarty($smarty);
        return "";
    }
    $rate_kbits = price($node_info["rate_kbits"]);
    $ceil_kbits = price($node_info["ceil_kbits"]);
    $n_table = "<table align=center cellspacing=0 cellpadding=0 border=0 width=100%>";
    $n_table .= "<tr>\n\t\t    <td align=center>" . getLine($line) . "</td>\n\t       </tr>";
    if ($line != "nothing") {
        $n_table .= "<tr><td align=center>" . verticalLineImage() . "</td>";
    }
    $n_table .= "<tr>\n\t\t<td align=center>";
    $color = "aqua";
    $n_table .= <<<END
\t\t<table border="0" cellspacing="0" cellpadding="0" >
\t\t\t<tr>
\t\t\t\t<td class="Form_Title_Begin"><img border="0" src="/IBSng/images/form/begin_form_title_{$color}.gif"></td>
\t\t\t\t<td class="Form_Title_{$color}">
\t\t\t\t    <a href="#" id='{$node_info["node_id"]}_node_link' onClick="showReportLayer('{$node_info["node_id"]}_node_id',this,'right'); return false;" class="bw_node">
\t\t\t\t\tR:{$rate_kbits}|C:{$ceil_kbits}&nbsp;kbits
\t\t\t\t    </a>
\t\t\t\t</td>
\t\t\t\t<td class="Form_Title_End"><img border="0" src="/IBSng/images/form/end_form_title_{$color}.gif"></td>
\t\t\t</tr>
\t\t</table>
END;
    $n_table .= createNodeLayer($smarty, $node_info);
    $n_table .= "</td></tr>";
    if (sizeof($node[2]) != 0 or sizeof($node[1]) != 0) {
        //if node has no children
        $n_table .= "<tr><td align=center>" . verticalLineImage() . "</td>";
    }
    $n_table .= "<tr><td><table cellspacing='0' cellpadding='0' width=100% border=0 bordercolor=blue align=center><tr>";
    for ($i = 0; $i < sizeof($node[1]); $i++) {
        $n_table .= "<td valign=top>";
        if (sizeof($node[1]) == 1 and sizeof($node[2]) == 0) {
            $nline = "up";
        } else {
            if ($i == 0) {
                $nline = "left";
            } else {
                if (sizeof($node[2]) == 0 and $i == sizeof($node[1]) - 1) {
                    $nline = "right";
                } else {
                    $nline = "all";
                }
            }
        }
        $n_table .= createSubTree($smarty, $node[1][$i], $nline);
        $n_table .= "</td>";
    }
    for ($j = 0; $j < sizeof($node[2]); $j++) {
        $n_table .= "<td valign=top>";
        if (sizeof($node[1]) == 0 and sizeof($node[2]) == 1) {
            $nline = "up";
        } else {
            if (sizeof($node[1]) == 0 and $j == 0) {
                $nline = "left";
            } else {
                if ($j == sizeof($node[2]) - 1) {
                    $nline = "right";
                } else {
                    $nline = "all";
                }
            }
        }
        $n_table .= createLeafTable($smarty, $node[2][$j], $nline);
        $n_table .= "</td>";
    }
    $n_table .= "</tr></table></td></tr></table>";
    return $n_table;
}
Exemplo n.º 3
0
function createSubTree($parent, $termTree, $parentname)
{
    global $dtTerms, $ind_label, $datatype;
    if (!is_array($termTree) || count($termTree) < 1) {
        return 0;
    }
    $termLookup = $dtTerms['termsByDomainLookup'][$datatype];
    $ind_label = $dtTerms['fieldNamesToIndex']['trm_Label'];
    $ind_descr = $dtTerms['fieldNamesToIndex']['trm_Description'];
    $ind_ccode = $dtTerms['fieldNamesToIndex']['trm_ConceptID'];
    $ind_tcode = $dtTerms['fieldNamesToIndex']['trm_Code'];
    $is_all_codes_numeric = true;
    $cnt_withcodes = 0;
    //first loop need to order by code (numeric or alphanumeric)  or by name (alphanumeric)
    foreach ($termTree as $termid => $child_terms) {
        $termName = @$termLookup[$termid][$ind_label];
        if ($termName) {
            $termCode = @$termLookup[$termid][$ind_tcode];
            if ($termCode) {
                $is_all_codes_numeric = $is_all_codes_numeric && is_numeric($termCode);
                $cnt_withcodes++;
            } else {
                $is_all_codes_numeric = false;
            }
        }
    }
    $fsort = 'sortByName';
    if ($cnt_withcodes > count($termTree) * 0.89) {
        if ($is_all_codes_numeric) {
            $fsort = 'sortByCodeNum';
        } else {
            $fsort = 'sortByCodeAlpha';
        }
    }
    uksort($termTree, $fsort);
    $cnt = 0;
    foreach ($termTree as $termid => $child_terms) {
        $termName = @$termLookup[$termid][$ind_label];
        if ($termName) {
            $termDescr = @$termLookup[$termid][$ind_descr];
            $termCcode = @$termLookup[$termid][$ind_ccode];
            //concept code
            $termCode = @$termLookup[$termid][$ind_tcode];
            if ($termCode) {
                //$termCode = "[".$termCode."]";
            } else {
                $termCode = "";
            }
            if (strpos($termCcode, '-') === false) {
                $termCcode = '0-' . $termid;
            }
            $term = $parent->addChild('term', getResStrA16n(prepareText($termName)));
            $term->addAttribute('HeuristID', $termCcode);
            $term->addAttribute('StandardCode', $termCode);
            //$term->addAttribute('pictureURL', '');
            //$term->addAttribute('semanticMapURL', '');
            $term->addChild('description', $termDescr ? prepareText($termDescr) : "");
            $cnt++;
            $cnt = $cnt + createSubTree($term, $child_terms, $parentname . $termName . "-");
        }
    }
    return $cnt;
}