Location: PHPKode > projects > OpenCabling > opencabling/show_connection.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
<link rel="stylesheet" href="css/opencabling.css" type="text/css"></link>
<?php
require_once 'js/functions.js';
require_once 'primitives/getobject.php';
require_once 'primitives/getconnection.php';

$DEBUG=0;

?>
</head>
<body>
<?php

$object=$_REQUEST['object'];
$item=$_REQUEST['item'];
$wide=$_REQUEST['wide'];

if ($wide=='')
     $wide=1;

$itemreload=$item;
$objectreload=$object;
$widereload=$wide+1;

print "<!-- Object: [ $object ] Item: [ $item ] Wide: [ $wide ] -->";

include "opendb.php";

// Show parent objects

$depth=0;	

while (($object<>0) and ($result=getobject($object))) {
    $history_obj[$depth]=$result['id_object'];
    $history_name[$depth]=$result['name'];
    $history_small[$depth]=str_replace("@@HEIGHT@@"," height=50 ",$result['html_small']);
    $history_description[$depth]=$result['brand']." - ".$result['type'];
    $history_pos[$depth]=$result['position'];
    $history_outnames[$depth]=$result['out_names'];
    $object=$result['parent_obj'];
    $depth++;
}

print "<table border=0 cellspacing=0 cellpadding=0><tr>";
for ($i=$depth-1;$i>=0;$i--) {
  print "<td align='center' valign='middle' title='".$history_description[$i]."'><a href='javascript:select_obj(".$history_obj[$i].")'>".$history_small[$i]."</a></td>";
  if ($i>0) {
    print "<td align='center' valign='middle'><img src='images/lesser.png' title='".$history_pos[$i-1]."'></img></td>";
  }
}

$id_object=$history_obj[0];
$obj_outnames=$history_outnames[0];

$cdepth=0;

if ($item<>'') {

  do {
    
    // Show cable

    print "<!-- SHOW CABLE for obj [[ $id_object ]] and item [[ $item ]] -->";

    $cable=getconnection($id_object,$item);

    if ($cable==NULL) {
      echo "<!-- No connection from object $id_object and item $item -->";
    } else {   
      $itembis=$cable['startfromitemspan']."bis";
      if (($cable['startspan']>1) && ($itembis!=$cable['starttoitemspan'])) {
	print "<td align=center title='".$cable['startitem']."' class='smalltext'>&nbsp;".$cable['startfromitemspan']."&nbsp;<br>&nbsp;".$cable['starttoitemspan']."&nbsp;</td>";
      } else {
	print "<td align=center class='smalltext'>&nbsp;".$cable['startfromitemspan']."&nbsp;</td>";
      }
      
      echo "<td title='".$cable['conndescription']."'><a target='right' href='edit_field_connection.php?id_conn=".$cable['id_connection']."'>".$cable['startconnectorhtml']."</a></td>";
      echo "<td title='".$cable['conndescription']."'><a target='right' href='edit_field_connection.php?id_conn=".$cable['id_connection']."'>".$cable['cablehtml']."</a></td>";
      echo "<td title='".$cable['conndescription']."'><a target='right' href='edit_field_connection.php?id_conn=".$cable['id_connection']."'>".$cable['endconnectorhtml']."</a></td>";
      
      $itembis=$cable['endfromitemspan']."bis";
      if (($cable['endspan']>1) && ($itembis!=$cable['endtoitemspan'])) {
	print "<td align=center title='".$cable['enditem']."' class='smalltext'>&nbsp;".$cable['endfromitemspan']."&nbsp;<br>&nbsp;".$cable['endtoitemspan']."&nbsp;</td>";
      } else {
	print "<td align=center class='smalltext'>&nbsp;".$cable['endfromitemspan']."&nbsp;</td>";
      }
      
      $intra_description[$cdepth++]="<td colspan=5></td>";
      
      $end_object=$cable['endobject'];
      
      // Show following objects
      if ($wide>0) {
	
	print "<!-- SHOW FOLLOWING OBJECTS for obj $end_object -->";
	
	$wide--; 
	$fdepth=0;
	
	while (($end_object<>0) and ($result=getobject($end_object))) {
	  $end_history_obj[$fdepth]=$result['id_object'];
	  $end_history_name[$fdepth]=$result['name'];
	  $end_history_small[$fdepth]=str_replace("@@HEIGHT@@"," height=50 ",$result['html_small']);
	  $end_history_description[$fdepth]=$result['brand']." - ".$result['type'];
	  $end_history_pos[$fdepth]=$result['position'];
	  $end_history_outnames[$fdepth]=$result['out_names'];
	  $end_history_options[$fdepth]=$result['options'];
	  $end_object=$result['parent_obj'];
	  $fdepth++;
	}
	
	print "<td align='center' valign='middle'><a href='show_detail.php?object=".$end_history_obj[0]."' target='right'>".$end_history_small[0]."</a></td>";
	
	$intra_description[$cdepth++]="<td align='center' valign='middle' class='smalltext'>".$end_history_name[0]."</td>";
	
	if (strpos($end_history_options[0],"frontbackconnection")===FALSE) {
	  echo "<!-- Object DO NOT HAVE frontbackconnection -->";
	  $wide=-1;
	}
	
	if ( $wide>0) {
	  
	  $obj_outnames=$end_history_outnames[0];
	  $id_object=$end_history_obj[0];
	  
	  print "<!-- Object has FRONTBACK, new object is $id_object -->";
	  
	  $item=$cable['enditem'];
	  $itemback=$item."b";
	  
	  if (strpos($end_history_outnames[0],$itemback)===FALSE)
	    $itemback=substr($item,0,strlen($item)-1);
	  
	  print "<!-- itemback: $itemback -->";
	  
	  $item=$itemback;
	  
	  print "<!-- Next turn looking for object [ $id_object ][ $item ] -->"; 
	} 
      }
    }
  } while ( ($wide>0) && ($cable!=NULL));
}

if ($item<>'') {

  print "<td align='center' valign='middle'>";

  if ($widereload>2) {
    $unwidereload=$widereload-2;
    print "<a href='show_connection.php?object=$objectreload&item=$itemreload&wide=$unwidereload'><img src='images/unfollowme.png' title='Back along with the connection'></img></a>";
  }

  if ( ($wide>=0) && ($cable<>NULL) ) {
    print "<a href='show_connection.php?object=$objectreload&item=$itemreload&wide=$widereload'><img src='images/followme.png' title='Follow the connection'></img></a>";
  }

  print "</td>";

  for ($i=1;$i<$fdepth;$i++) {
    print "<td align='center' valign='middle'><img src='images/greater.png' title='".$end_history_pos[$i-1]."'></img></td>";
    print "<td align='center' valign='middle'><a href='show_detail.php?object=".$end_history_obj[$i]."' target='right'>".$end_history_small[$i]."</a></td>";
  }
}

print "</tr><tr>";

// Show Description for previous objects

for ($i=$depth-1;$i>=0;$i--) {
  print "<td align='center' valign='top'><p class='smalltext'>".$history_name[$i]."</p></td>";
  if ($i>0) {
    print "<td></td>";
  }		
}

if ($item<>'') {
  
  for ($i=0;$i<=$cdepth-1;$i++) {
    print $intra_description[$i];
  }

  print "<td></td>";

  for ($i=1;$i<$fdepth;$i++) {
    print "<td></td>";
    print "<td align='center' valign='top'><p class='smalltext'>".$end_history_name[$i]."</p></td>";
  }
}

print "</tr></table>";

mysql_close($mysql_conn);
?>
</body>
</html>
Return current item: OpenCabling