Changeset 873 for trunk/Modules/NetworkTopology/topologie2.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkTopology/topologie2.php
r858 r873 29 29 $Hosts = array(); 30 30 $DbResult = $Database->select('hosts', 'id, name, ip, parent, online', 'used=1'); 31 while ($DbRow = $DbResult->fetch_array())31 while ($DbRow = $DbResult->fetch_array()) 32 32 { 33 if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array());33 if (!array_key_exists($DbRow['id'], $Hosts)) $Hosts[$DbRow['id']] = array('subitems' => array()); 34 34 $Hosts[$DbRow['id']] = array('id' => $DbRow['id'], 'name' => $DbRow['name'], 'parent' => $DbRow['parent'], 'online' => $DbRow['online'], 'subitems' => $Hosts[$DbRow['id']]['subitems']); 35 if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array());35 if (!array_key_exists($DbRow['parent'], $Hosts)) $Hosts[$DbRow['parent']] = array('subitems' => array()); 36 36 $Hosts[$DbRow['parent']]['subitems'][] = &$Hosts[$DbRow['id']]; 37 37 $Hosts[$DbRow['id']]['parent_node'] = &$Hosts[$DbRow['parent']]; … … 44 44 { 45 45 $Result = array('min' => $Host['displacement'], 'max' => $Host['displacement']); 46 foreach ($Host['subitems'] as $Index => $SubHost)46 foreach ($Host['subitems'] as $Index => $SubHost) 47 47 { 48 48 $SubitemResult = $this->CalculateDimension($Host['subitems'][$Index]); … … 50 50 $Result['max'] = max($SubitemResult['max'], $Result['max']); 51 51 } 52 return ($Result);52 return ($Result); 53 53 } 54 54 55 55 function CalculateDisplacement(&$Host, $Level = 0) 56 56 { 57 if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0;57 if (!array_key_exists('displacement', $Host)) $Host['displacement'] = 0; 58 58 $Host['level'] = $Level; 59 foreach ($Host['subitems'] as $Index => $SubHost)59 foreach ($Host['subitems'] as $Index => $SubHost) 60 60 { 61 61 $Host['subitems'][$Index]['rel_displacement'] = (-(count($Host['subitems']) - 1) * 0.5 + $Index) * $this->HostWidth; … … 68 68 { 69 69 $Host['displacement'] = $Host['displacement'] + $Displacement; 70 foreach ($Host['subitems'] as $Index => $SubHost)70 foreach ($Host['subitems'] as $Index => $SubHost) 71 71 { 72 72 $this->MoveNode($Host['subitems'][$Index], $Displacement); … … 76 76 function CheckColision() 77 77 { 78 foreach ($this->Levels as $Index => $Level)78 foreach ($this->Levels as $Index => $Level) 79 79 { 80 for ($I = 0; $I < count($Level) - 1; $I++)81 if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement'])80 for ($I = 0; $I < count($Level) - 1; $I++) 81 if ($Level[$I]['displacement'] >= $Level[$I + 1]['displacement']) 82 82 { 83 83 // Search for common parent 84 84 $LeftHost = $Level[$I]; 85 85 $RightHost = $Level[$I + 1]; 86 while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent']))86 while (($LeftHost['level'] > 0) and ($LeftHost['parent'] != $RightHost['parent'])) 87 87 { 88 88 $LeftHost = $LeftHost['parent_node']; … … 91 91 $Host = $RightHost['parent_node']['subitems'][0]; 92 92 $II = 0; 93 while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++;94 while ($II < count($RightHost['parent_node']['subitems']))93 while ($RightHost['parent_node']['subitems'][$II]['id'] != $RightHost['id']) $II++; 94 while ($II < count($RightHost['parent_node']['subitems'])) 95 95 { 96 96 $this->MoveNode($RightHost['parent_node']['subitems'][$II], $Level[$I]['displacement'] - $Level[$I + 1]['displacement']); … … 104 104 { 105 105 $this->Levels[$Host['level']][] = &$Host; 106 foreach ($Host['subitems'] as $Index => $SubHost)106 foreach ($Host['subitems'] as $Index => $SubHost) 107 107 { 108 108 $this->BuildLevels($Host['subitems'][$Index]); … … 113 113 { 114 114 $ParentHostPos = array('x' => -$this->RelPos['min'] + $Host['displacement'], 'y' => $Host['level'] * $this->HostHeight); 115 foreach ($Host['subitems'] as $Index => $SubHost)115 foreach ($Host['subitems'] as $Index => $SubHost) 116 116 { 117 117 $HostPos = array('x' => -$this->RelPos['min'] + $SubHost['displacement'], 'y' => $SubHost['level'] * $this->HostHeight);
Note:
See TracChangeset
for help on using the changeset viewer.