예제 #1
0
파일: interface.php 프로젝트: xtha/salt
function renderEntityTags($entity_id)
{
    global $tagtree, $taglist, $target_given_tags, $pageno, $etype_by_pageno;
    echo '<table border=0 width="100%"><tr>';
    if (count($taglist) > getConfigVar('TAGS_QUICKLIST_THRESHOLD')) {
        $minilist = getTagChart(getConfigVar('TAGS_QUICKLIST_SIZE'), $etype_by_pageno[$pageno], $target_given_tags);
        // It could happen, that none of existing tags have been used in the current realm.
        if (count($minilist)) {
            $js_code = "tag_cb.setTagShortList ({";
            $is_first = TRUE;
            foreach ($minilist as $tag) {
                if (!$is_first) {
                    $js_code .= ",";
                }
                $is_first = FALSE;
                $js_code .= "\n\t{$tag['id']} : 1";
            }
            $js_code .= "\n});\n\$(document).ready(tag_cb.compactTreeMode);";
            addJS('js/tag-cb.js');
            addJS($js_code, TRUE);
        }
    }
    // do not do anything about empty tree, trigger function ought to work this out
    echo '<td class=pcright>';
    renderEntityTagsPortlet('Tag tree', $tagtree, $target_given_tags, $etype_by_pageno[$pageno]);
    echo '</td>';
    echo '</tr></table>';
}
function renderTagStats()
{
    global $taglist;
    echo '<table border=1><tr><th>tag</th><th>total</th><th>objects</th><th>IPv4 nets</th><th>IPv6 nets</th>';
    echo '<th>racks</th><th>IPv4 VS</th><th>IPv4 RS pools</th><th>users</th><th>files</th></tr>';
    $pagebyrealm = array('file' => 'files&tab=default', 'ipv4net' => 'ipv4space&tab=default', 'ipv6net' => 'ipv6space&tab=default', 'ipv4vs' => 'ipv4slb&tab=default', 'ipv4rspool' => 'ipv4slb&tab=rspools', 'object' => 'depot&tab=default', 'rack' => 'rackspace&tab=default', 'user' => 'userlist&tab=default');
    foreach (getTagChart(getConfigVar('TAGS_TOPLIST_SIZE')) as $taginfo) {
        echo "<tr><td>{$taginfo['tag']}</td><td>" . $taginfo['refcnt']['total'] . "</td>";
        foreach (array('object', 'ipv4net', 'ipv6net', 'rack', 'ipv4vs', 'ipv4rspool', 'user', 'file') as $realm) {
            echo '<td>';
            if (!isset($taginfo['refcnt'][$realm])) {
                echo '&nbsp;';
            } else {
                echo "<a href='index.php?page=" . $pagebyrealm[$realm] . "&cft[]={$taginfo['id']}'>";
                echo $taginfo['refcnt'][$realm] . '</a>';
            }
            echo '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
}