function guifi_device_print($device = NULL)
{
    if ($device == NULL) {
        print theme('page', t('Not found'), FALSE);
        return;
    }
    $output = '<div id="guifi">';
    $node = node_load(array('nid' => $device[nid]));
    $title = t('Node:') . ' <a href="' . url('node/' . $node->nid) . '">' . $node->nick . '</a> &middot; ' . t('Device:') . '&nbsp;' . $device[nick];
    drupal_set_breadcrumb(guifi_node_ariadna($node));
    switch (arg(4)) {
        case 'all':
        case 'data':
        default:
            $table = theme_table(null, guifi_device_print_data($device), array('class' => 'device-data'));
            $output .= theme('box', $title, $table);
            if (arg(4) == 'data') {
                break;
            }
        case 'comment':
            if (!empty($device['comment'])) {
                $output .= theme('box', t('Comments'), $device['comment']);
            }
            if (arg(4) == 'comment') {
                break;
            }
        case 'graphs':
            if (empty($device['interfaces'])) {
                break;
            }
            // device graphs
            $table = theme('table', array(t('traffic overview')), guifi_device_graph_overview($device));
            $output .= theme('box', t('device graphs'), $table);
            if (arg(4) == 'graphs') {
                break;
            }
        case 'links':
            // links
            $output .= theme('box', NULL, guifi_device_links_print($device));
            if (arg(4) == 'links') {
                break;
            }
        case 'interfaces':
            if (empty($device['interfaces'])) {
                break;
            }
            $header = array(t('id'), t('connects with'), t('connector'), t('comments'), t('mac'), t('ip address'), t('netmask'));
            $tables = theme_table($header, guifi_device_print_interfaces($device), array('class' => 'device-data'));
            $output .= theme('box', t('physical ports & connections'), $tables);
            foreach (array('vlans', 'aggregations', 'tunnels') as $iClass) {
                $rows = guifi_device_print_iclass($iClass, $device);
                if (empty($rows)) {
                    continue;
                }
                if ($iClass == 'vlans') {
                    $header = array(t('type'), t('name'), t('parent'), t('vlan'), t('comments'), t('mac'), t('ip address'), t('netmask'));
                } else {
                    $header = array(t('type'), t('name'), t('parent'), t('comments'), t('mac'), t('ip address'), t('netmask'));
                }
                $tables = theme_table($header, $rows, array('class' => 'device-data'));
                $output .= theme('box', t($iClass), $tables);
            }
            break;
        case 'services':
            $output .= theme('box', t('services information'), theme_guifi_services_list($device['id']));
            $output .= '</div>';
            return;
    }
    $output .= '</div>';
    drupal_set_title(t('View device %dname', array('%dname' => $device['nick'])));
    $output .= theme_links(module_invoke_all('link', 'node', $node, FALSE));
    print theme('page', $output, FALSE);
    return;
}
Example #2
0
/**
 * guifi_node_graph_overview
 * outputs an overiew graph of the node
**/
function theme_guifi_node_graphs_overview($node, $links = FALSE)
{
    $gs = guifi_service_load(guifi_graphs_get_server($node->id, 'node'));
    $radios = array();
    $query = db_query("SELECT * FROM {guifi_radios} WHERE nid=%d", $node->id);
    while ($radio = db_fetch_array($query)) {
        $radios[] = $radio;
    }
    // print "Count radios: ".count($radios)."\n<br />";
    if (count($radios) > 1) {
        if (substr($gs->var['url'], 0, 3) == "fot") {
            //  graph all devices.about a node. Ferran Ot
            while ($radio = db_fetch_object($query)) {
                $ssid = get_SSID_radio($radio->id);
                $ssid = strtolower($ssid);
                $mrtg_url = substr($gs->var['url'], 3);
                $rows[] = array('<a href="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_6&cfg=mrtg.cfg" target="_blank"> <img src="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_6&cfg=mrtg.cfg&png=weekly"></a>');
                $rows[] = array('<a href="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_ping&cfg=mrtg.cfg" target="_blank"> <img src="' . $mrtg_url . '/14all.cgi?log=' . $ssid . '_ping&cfg=mrtg.cfg&png=weekly"></a>');
            }
            $ret = array_merge($rows);
        } else {
            $args = array('type' => 'supernode', 'node' => $node->id);
            //      $args = sprintf('type=supernode&node=%d&direction=',$node->id);
            $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args, 'direction=in') . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, 'direction=in') . '"></a>', 'align' => 'center'));
            $rows[] = array(array('data' => '<a href=' . base_path() . 'guifi/graph_detail?' . guifi_cnml_args($args, 'direction=out') . '><img src="' . guifi_cnml_call_service($gs->var['url'], 'graph', $args, 'direction=out') . '"></a>', 'align' => 'center'));
            //      $rows[] = array(
            //      guifi_cnml_call_service($gs->var['url'],'graph',$args,'direction=in'sprintf('<a href="'.base_path().'guifi/graph_detail?'.$args.'in"><img src="'.$gs->var['url'].'?'.$args.'in"></a>',$node->id));
            //      $rows[] = array(sprintf('<a href="'.base_path().'guifi/graph_detail?'.$args.'out"><img src="'.$gs->var['url'].'?'.$args.'out"></a>',$node->id));
            $ret = array_merge($rows);
        }
    } else {
        if (count($radios) == 1) {
            $ret = guifi_device_graph_overview($radios[0]);
        }
    }
    $output = theme('table', NULL, $ret);
    if ($links) {
        $node = node_load(array('nid' => $node->id));
        drupal_set_title(t('graph overview @ %node', array('%node' => $node->title)));
        drupal_set_breadcrumb(guifi_node_ariadna($node));
        $output .= theme_links(module_invoke_all('link', 'node', $node, FALSE));
        print theme('page', $output, FALSE);
        return;
    }
    return $output;
}