+//////////////////////////////////////////////////////////// interfaces
+if ( $local_peer ) {
+ $toggle=new PlekitToggle ('interfaces',count_english_warning($interfaces,'interface'),
+ array('bubble'=>'Inspect and tune interfaces on that node',
+ 'visible'=>get_arg('show_interfaces',false)));
+ $toggle->start();
+ // display interfaces
+ if( ! $interfaces ) {
+ echo '<p>';
+ plc_warning_html("This node has no interface");
+ echo "Please add an interface to make this a usable PLC node.</p>\n";
+ } // else { // show this unconditionnally as otherwise there's no mean to create one..
+
+ // display a hostname column iff at least one interface has a hostname
+ $need_hostname=false;
+ if ($interfaces) foreach ($interfaces as $interface) if ($interface['hostname']) $need_hostname=true;
+
+ $headers=array();
+
+ $sort_column=0;
+ if (plc_is_admin()) { $headers['I']='int'; $sort_column +=1;}
+ $headers["IP"]="sortIPAddress";
+ if ($need_hostname) $headers['hostname']='string';
+ $headers["Method"]="string";
+ $headers["Type"]="string";
+ $headers["MAC"]="string";
+ $headers["bw limit"]="sortBandwidth";
+ $headers["tags"]=array('type'=>'int',
+ 'title'=>"number of tags set on interface");
+ // a single symbol, marking 'p' for primary and a delete button for non-primary
+ if ( $privileges ) $headers[plc_delete_icon()]='string';
+
+ $table_options=array('search_area'=>false,"pagesize_area"=>false,'notes_area'=>false);
+ $table=new PlekitTable("node_interfaces",$headers,$sort_column,$table_options);
+ $table->start();
+
+ if ($interfaces) foreach ( $interfaces as $interface ) {
+ $interface_id= $interface['interface_id'];
+ $interface_ip= $interface['ip'];
+
+ $table->row_start();
+ if (plc_is_admin()) $table->cell(l_interface_t($interface_id,$interface_id));
+ $table->cell(l_interface_t($interface_id,$interface_ip));
+ if ($need_hostname) $table->cell($interface['hostname']);
+ $table->cell($interface['method']);
+ $table->cell($interface['type']);
+ $table->cell($interface['mac']);
+ $table->cell(pretty_bandwidth($interface['bwlimit']));
+ $table->cell(href(l_interface_tags($interface_id),
+ count($interface['interface_tag_ids'])));
+ if ( $privileges ) {
+ if ($interface['is_primary']) {
+ $table->cell(plc_bubble("p","Cannot delete a primary interface"));
+ } else {
+ $table->cell ($form->checkbox_html('interface_ids[]',$interface_id));
+ }
+ }
+ $table->row_end();
+ }
+ if ($privileges) {
+ $table->tfoot_start();
+ $table->row_start();
+ // we should have 6 cols, use 3 for the left (new) and the rest for the right (remove)
+ //$add_button=new PlekitFormButton (l_interface_add($node_id),"add","Add Interface","GET");
+ //$table->cell($add_button->html(),array('columns'=> 3,'align'=>'left'));
+ $table->cell($form->submit_html("new-interface","Add Interface"),
+ array('columns'=> 3,'align'=>'left'));
+ $table->cell($form->submit_html("delete-interfaces","Remove Interfaces"),
+ array('columns'=>$table->columns()-3,'align'=>'right'));
+ $table->row_end();
+ }
+ $table->end();
+ // }
+ $toggle->end();
+ }
+
+$form->end();
+
+////////////////////////////////////////////////////////////
+$peers->block_end($peer_id);
+
+//plekit_linetabs ($tabs,"bottom");
+