";
} else {
// set two classes, one eneraic to all foreign, and one based on the peer's shortname for finer grain tuning
printf ('
\n";
}
//// standard peerscope syntax
function plc_peer_info ($api,$peerscope) {
switch ($_GET['peerscope']) {
case '':
$peer_filter=array();
$peer_label="all peers";
break;
case 'local':
$peer_filter=array("peer_id"=>NULL);
$peer_label=PLC_SHORTNAME;
break;
case 'foreign':
$peer_filter=array("~peer_id"=>NULL);
$peer_label="foreign peers";
break;
default:
$peer_id=intval($_GET['peerscope']);
$peer_filter=array("peer_id"=>$peer_id);
$peer=$api->GetPeers(array("peer_id"=>$peer_id));
$peer_label='peer "' . $peer[0]['peername'] . '"';
break;
}
return array ($peer_filter,$peer_label);
}
//////////////////////////////////////////////////////////// links
function href ($url,$text) { return "
" . $text . ""; }
function l_nodes () { return "/db/nodes/newindex.php"; }
function l_node_u ($node_id) { return "/db/nodes/node.php?id=" . $node_id; }
function l_node ($node_id) { return href (l_node_u($node_id),$node_id); }
function l_node2 ($node_id,$text) { return href (l_node_u($node_id),$text); }
function l_interface_u ($interface_id) { return "/db/nodes/interfaces.php?id=" . $interface_id; }
function l_interface_add_u($node_id) { return "/db/nodes/interfaces.php?node_id=" . $node_id; }
function l_interface ($interface_id) { return href (l_interface_u($interface_id),$interface_id); }
function l_interface2 ($interface_id,$text) { return href (l_interface_u($interface_id),$text); }
function l_nodegroup_u ($nodegroup_id) { return "/db/nodes/node_groups.php?id=" . $nodegroup_id; }
function l_nodegroup2 ($nodegroup_id,$text) { return href(l_nodegroup_u($nodegroup_id),$text); }
function l_sites () { return "/db/sites/index.php"; }
function l_site_u ($site_id) { return "/db/persons/index.php?id=" . $site_id; }
function l_site ($site_id) { return href (l_site_u($site_id),$site_id); }
function l_site2 ($site_id,$text) { return href (l_site_u($site_id),$text); }
function l_slices () { return "/db/slices/index.php"; }
function l_slice_u ($slice_id) { return "/db/slices/index.php?id=" . $slice_id; }
function l_slice ($slice_id) { return href (l_slice_u($slice_id),$slice_id); }
function l_slice2 ($slice_id,$text) { return href (l_slice_u($slice_id),$text); }
function l_sliver_u ($node_id,$slice_id) { return "/db/nodes/slivers.php?node_id=" . $node_id. "&slice_id=" . $slice_id; }
function l_sliver3 ($node_id,$slice_id,$text) { return href (l_sliver_u($node_id,$slice_id),$text) ; }
function l_persons () { return "/db/persons/index.php"; }
function l_person_u ($person_id) { return "/db/persons/index.php?id=" . $person_id; }
function l_person ($person_id) { return href (l_person_u($person_id),$person_id); }
function l_person2 ($person_id,$text) { return href (l_person_u($person_id),$text); }
function l_event ($type,$param,$id) { return '/db/events/index.php?type=' . $type . '&' . $param . '=' . $id; }
function l_comon($id_name,$id_value) { return '/db/nodes/comon.php?' . $id_name . "=" . $id_value; }
//////////////////////////////////////////////////////////// titles
function t_site($site) { return " on site " . $site['name'] . " (" . $site['login_base'] .")"; }
function t_slice ($slice) { return " running slice " . $slice['name'] . " (" . $slice['slice_id'] . ")"; }
//////////////////////////////////////////////////////////// nav tabs
function tabs_node($node) { return array('Node ' . $node['hostname']=>l_node_u($node_id)); }
function tabs_site($site) { return array('Site ' . $site['name']=>l_site_u($site_id)); }
function tabs_slice($slice) { return array('Slice ' . $slice['name']=>l_slice_u($slice_id)); }
//////////////////////////////////////////////////////////// presentation
// builds a table from an array of strings, with the given class
// attempt to normalize the delete buttons and confirmations
function plc_delete_button($width=15) {
return '
';
}
function plc_js_confirm($message) {
return "onclick=\"javascript:return confirm('Are you sure you want to delete " . $message . " ?')\"";
}
function plc_delete_link($url,$delete_message,$visible) {
return "
" . $visible . "";
}
function plc_delete_link_button($url,$delete_message,$width=15) {
return "
" . plc_delete_button($width) . "";
}
function plc_event_button($type,$param,$id) {
return '
';
}
function plc_comon_button ($id_name, $id_value,$target="") {
$result='
';
$result.=' ';
return $result;
}
function plc_make_table ($class, $messages) {
// pretty print the cell
$formatted = "";
if (! empty ($messages)) {
$formatted="
";
foreach ($messages as $message) {
$formatted .= "" . $message . " |
";
}
$formatted .= "
";
}
return $formatted;
}
////////////////////////////////////////////////////////////
function plc_error ($text) {
// should use the same channel as the php errors..
print "
Error " . $text . "
";
}
function plc_warning ($text) {
print "
Warning " . $text . "
";
}
// shows a php variable verbatim with a heading message
function plc_debug ($message,$object) {
print "
" . $message . "
";
print_r ($object);
print "
";
}
?>