function guifi_device_print_data($device)
{
    $radios = db_query('SELECT *
       FROM {guifi_radios}
       WHERE id=%d
       ORDER BY id', $device['id']);
    $rows[] = array(t($device[type]), '<b>' . $device[nick] . '</b>');
    if (count($device['funders'])) {
        $rows[] = array(count($device['funders']) == 1 ? t('Funder') : t('Funders'), implode(', ', guifi_funders_links($device['funders'])));
    }
    if (count($device['maintainers'])) {
        $rows[] = array(t('Maintenance & SLAs'), implode(', ', guifi_maintainers_links($device['maintainers'])));
    }
    // If radio, print model & firmware
    if ($device['type'] == 'radio') {
        $rows[] = array($device[manufacturer] . '-' . $device[model], $device[variable][firmware]);
        // going to list all device radios
        if (count($device['radios'])) {
            foreach ($device['radios'] as $radio_id => $radio) {
                if ($radio['fund_required'] == '') {
                    $policy = t('n/d, ask to node contacts');
                } else {
                    if ($radio['fund_required'] == 'yes') {
                        $policy = t('Fund: :fund :curr', array(':fund' => $radio['fund_amount'], ':curr' => $radio['fund_currency']));
                    } else {
                        $policy = t($radio['fund_required']);
                    }
                }
                $rowsr[] = array($radio['ssid'], $radio['mode'], $radio['protocol'], $radio['channel'], $radio['mac'], t($radio['clients_accepted']), $policy);
            }
            $rows[] = array(array('data' => theme('table', array(t('ssid'), t('mode'), t('protocol'), t('ch'), t('wireless mac'), t('clients'), t('connection policy')), $rowsr), 'colspan' => 2));
        }
    }
    // If ADSL, print characteristics
    if ($device['type'] == 'ADSL' and $device['variable'] != '') {
        $bandwidth = guifi_bandwidth_types();
        $rows[] = array(t('bandwidth'), $bandwidth[$device['variable']['download']] . '/' . $bandwidth[$device['variable']['upload']]);
        $rows[] = array(t('SNMP index to graph'), $device['variable']['mrtg_index']);
    }
    // Others with modelDescr set
    if (isset($device['variable']['modelDescr'])) {
        switch ($device['type']) {
            case 'ups':
                $vDescr = t('Power: %power', array('%power' => $device['variable']['specs']));
                break;
            case 'generator':
                $vDescr = t('Max Power: %power Watts', array('%power' => $device['variable']['specs']));
                break;
            case 'battery':
                $vDescr = t('Power: %power/Ah, Quantity: %quantity', array('%power' => $device['variable']['specs'], '%quantity' => $device['variable']['units']));
                break;
            case 'rack':
                $vDescr = t('Height: %height Us, Width: %width inches, Depth: %depth mm', array('%height' => $device['variable']['height'], '%width' => $device['variable']['width'], '%depth' => $device['variable']['depth']));
                break;
            case 'breaker':
                $vDescr = t('Protection: %cbtype, Auto-reclose: %recloser', array('%cbtype' => $device['variable']['cbtype'], '%recloser' => $device['variable']['recloser'] ? t('Yes') : t('No')));
                break;
        }
        $rows[] = array($device['variable']['modelDescr'], $vDescr);
    }
    // generic
    if ($device['type'] == 'generic' || 'confine' and !empty($device['variable']['mrtg_index'])) {
        $rows[] = array(t('SNMP index to graph'), $device['variable']['mrtg_index']);
    }
    if ($device['graph_server'] > 0) {
        $gs = node_load(array('nid' => $device['graph_server']));
    } else {
        $gs = node_load(array('nid' => guifi_graphs_get_server($device['id'], 'device')));
    }
    $rows[] = array(t('graphs provided from'), array('data' => l(guifi_service_str($device['graph_server']), $gs->l, array('attributes' => array('title' => $gs->nick . ' - ' . $gs->title))), 'colspan' => 2));
    $ip = guifi_main_ip($device[id]);
    $rows[] = array(t('IP address & MAC'), $ip[ipv4] . '/' . $ip[maskbits] . ' ' . $device[mac]);
    $status_url = guifi_cnml_availability(array('device' => $device['id'], 'format' => 'long'), $gs);
    if (!empty($ip[ipv4])) {
        $rows[] = array(t('status &#038; availability'), array('data' => t($device[flag]) . $status_url, 'class' => $device['flag']));
    }
    $rows[] = array(array('data' => theme_guifi_contacts($device), 'colspan' => 2));
    return array_merge($rows);
}
Example #2
0
function theme_guifi_node_data($node, $links = FALSE)
{
    guifi_log(GUIFILOG_TRACE, 'function guifi_node_data(node)', $node);
    /*  $zone = db_fetch_object(db_query('SELECT id, title, master, zone_mode FROM {guifi_zone} WHERE id = %d',
        $node->zone_id));*/
    $zone = db_fetch_object(db_query('SELECT id, title, master FROM {guifi_zone} WHERE id = %d', $node->zone_id));
    $rows[] = array(t('node'), $node->nid . ' ' . $node->nick, '<b>' . $node->title . '</b>');
    //  $rows[] = array(t('zone (mode)'),l($zone->title,'node/'.$zone->id).' ('.t($zone->zone_mode).')',$node->zone_description);
    $rows[] = array(t('zone'), l($zone->title, 'node/' . $zone->id), $node->zone_description);
    $rows[] = array(t('position (lat/lon)'), sprintf('<a href="http://maps.guifi.net/world.phtml?Lat=%f&Lon=%f&Layers=all" target="_blank">Lat:%f<br />Lon:%f</a>', $node->lat, $node->lon, $node->lat, $node->lon), $node->elevation . '&nbsp;' . t('meters above the ground'));
    $rows[] = array(t('available for mesh &#038; status'), $node->stable, array('data' => t($node->status_flag), 'class' => $node->status_flag));
    if (count($node->funders)) {
        $rows[] = array(count($node->funders) == 1 ? t('Funder') : t('Funders'), array('data' => implode(', ', guifi_funders_links($node->funders)), 'colspan' => 2));
    }
    if (count($node->maintainers)) {
        $rows[] = array(t('Maintenance & SLAs'), array('data' => implode(', ', guifi_maintainers_links($node->maintainers)), 'colspan' => 2));
    } else {
        $radios = db_fetch_object(db_query('SELECT count(id) c FROM {guifi_radios} WHERE nid=%d', $node->id));
        if ($radios->c > 1) {
            $pmaintainers = guifi_maintainers_parents($node->zone_id);
            if (!empty($pmaintainers)) {
                $rows[] = array(t('Maintenance & SLAs') . ' ' . t('(from parents)'), implode(', ', guifi_maintainers_links($pmaintainers)));
            }
        }
    }
    if ($node->graph_server > 0) {
        $gs = node_load(array('nid' => $node->graph_server));
    } else {
        $gs = node_load(array('nid' => guifi_graphs_get_server($node->id, 'node')));
    }
    $rows[] = array(t('graphs provided from'), array('data' => l(guifi_service_str($node->graph_server), $gs->l, array('attributes' => array('title' => $gs->nick . ' - ' . $gs->title))), 'colspan' => 2));
    $output = theme('table', NULL, array_merge($rows));
    $output .= theme_guifi_contacts($node);
    if ($links) {
        $node = node_load(array('nid' => $node->id));
        drupal_set_title(t('%node data', 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 theme('box', NULL, $output);
}