";
return true;
} else {
// set two classes, one eneraic to all foreign, and one based on the peer's shortname for finer grain tuning
printf ('
\n";
}
// interpret standard syntax for peerscope
function plc_peer_info ($api,$peerscope) {
switch ($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:
if (is_int ($peerscope)) {
$peer_id=intval($peerscope);
$peers=$api->GetPeers(array("peer_id"=>$peer_id));
} else {
$peers=$api->GetPeers(array("shortname"=>$peerscope));
}
if ($peers) {
$peer=$peers[0];
$peer_id=$peer['peer_id'];
$peer_filter=array("peer_id"=>$peer_id);
$peer_label='peer "' . $peer['shortname'] . '"';
} else {
$peer_filter=array();
$peer_label="[no such peer " . $peerscope . "]";
}
break;
}
return array ($peer_filter,$peer_label);
}
//////////////////////////////////////////////////////////// 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($node_id)); }
function tabs_site($site) { return array('Site ' . $site['name']=>l_site($site_id)); }
function tabs_slice($slice) { return array('Slice ' . $slice['name']=>l_slice($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_vertical_table ($messages, $class="") {
// pretty print the cell
if ( empty( $messages) ) return "";
$formatted = "";
$formatted .= "
";
return $formatted;
}
////////////////////////////////////////////////////////////
function plc_error ($text) {
// should use the same channel as the php errors..
print "
Error " . $text . "
";
}
function plc_errors ($list) {
print( "
" );
print( "
The following errors occured:
" );
print("
");
foreach( $errors as $err ) {
print( "- $err
\n" );
}
print( "
\n" );
}
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 "
";
}
?>