From fa0703870aee573b5013e894b8c5fa66198b1b9a Mon Sep 17 00:00:00 2001 From: Garrett K Date: Sun, 28 Feb 2021 05:53:12 +0000 Subject: [PATCH] 0.3.14 --- backend/retrieve_path_full.php | 3 +- includes/App.class.php | 78 ++++++++++++++++++++++++++++++++++ includes/content-path2.php | 47 ++++++++++++++------ 3 files changed, 114 insertions(+), 14 deletions(-) diff --git a/backend/retrieve_path_full.php b/backend/retrieve_path_full.php index 880b89d..bf0005b 100755 --- a/backend/retrieve_path_full.php +++ b/backend/retrieve_path_full.php @@ -26,7 +26,8 @@ if($_SERVER['REQUEST_METHOD'] == 'POST'){ // Create $path include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path2.php'; include_once $_SERVER['DOCUMENT_ROOT'].'/includes/content-path.php'; - $validate->returnData['success'] = $qls->App->buildPathFull($path, $connectorCode39); + $validate->returnData['success'] = $qls->App->buildPathFull2($pathArray); + //$validate->returnData['success'] = $qls->App->buildPathFull($path, $connectorCode39); } echo json_encode($validate->returnData); } diff --git a/includes/App.class.php b/includes/App.class.php index 9373bcf..98e91a8 100755 --- a/includes/App.class.php +++ b/includes/App.class.php @@ -1955,6 +1955,84 @@ var $qls; $this->qls->SQL->insert('app_history', $columns, $values); } + function buildPathFull2($pathArray){ + + $pathOrientation = $this->qls->user_info['pathOrientation']; + $trunkPairID = 0; + + $htmlPathFull = ''; + $htmlPathFull .= ''; + + // Cable Adjacent + if($pathOrientation == 0) { + + foreach($pathArray as $pathArrayIndex => $connection) { + + // Set connectionPairID so connection can be drawn + $connectionPairID = $pathArrayIndex; + + foreach($connection as $connectionIndex => $connectionSide) { + + if(count($connectionSide)) { + + // Set trunkPairID so trunk can be drawn + if($connectionIndex == 1) { + $trunkPairID++; + } + + // Generate port name(s) + $objName = ''; + $selected = false; + foreach($connectionSide as $port) { + + $objID = $port['objID']; + $objFace = $port['objFace']; + $objDepth = $port['objDepth']; + $objPort = $port['objPort']; + $selected = ($port['selected'] == true) ? true : $selected; + + $objName .= $this->generateObjectPortName($objID, $objFace, $objDepth, $objPort).'
'; + } + + // Compile port name(s) in an object box + $htmlPort = $this->wrapObject($objID, $objName, $selected, $trunkPairID); + + // Gather connector data + $obj = $this->objectArray[$objID]; + $objTemplateID = $obj['template_id']; + $objCompatibility = $this->compatibilityArray[$objTemplateID][$objFace][$objDepth]; + $portTypeID = $objCompatibility['portType']; + $portTypeName = $this->portTypeValueArray[$portTypeID]['name']; + + // Compile connector div + $htmlConnector = '
'; + + $mediaTypeID = $objCompatibility['mediaType']; + $mediaTypeName = $this->mediaTypeValueArray[$mediaTypeID]['name']; + $cableLength = 0; + + $htmlCable = '
'.$cableLength.'
'.$mediaTypeName.'
'; + + $htmlPathFull .= ''; + $htmlPathFull .= ''; + $htmlPathFull .= ''; + if($connectionIndex == 0) { + $htmlPathFull .= ''; + } + $htmlPathFull .= ''; + } + } + } + + // Cable inline + } else { + + } + + $htmlPathFull .= '
'.$htmlPort.''.$htmlConnector.''.$htmlCable.'
'; + return $htmlPathFull; + } + function buildPathFull($path, $connectorCode39){ $htmlPathFull = ''; diff --git a/includes/content-path2.php b/includes/content-path2.php index 71c4081..14f968a 100755 --- a/includes/content-path2.php +++ b/includes/content-path2.php @@ -19,20 +19,26 @@ $selectedObjDepth2 = $objDepth; $selectedObjPort2 = $objPort; // Retrieve initial connection set -$connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); +$selected = true; +$connSet = crawlConn($qls, $selected, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); detectDivergence($connSet[0]); detectDivergence($connSet[1]); +//$connSet[0]['selected'] = true; array_push($pathArray, $connSet); for($direction=0; $direction<2; $direction++) { - $trunkFound = true; - while($trunkFound){ + do { // Set path array pointer // 0 for up, -1 for down $pathArrayPointer = ($direction == 0) ? 0 : count($pathArray)-1; + error_log('Debug (pathArray): '.json_encode($pathArray)); + error_log('Debug (pathArrayPointer): '.$pathArrayPointer); + error_log('Debug (direction): '.$direction); + error_log('Debug (crawlTrunk data): '.json_encode($pathArray[$pathArrayPointer][$direction])); + // Get port trunk peer $trunkSet = crawlTrunk($qls, $pathArray[$pathArrayPointer][$direction]); detectDivergence($trunkSet); @@ -49,16 +55,27 @@ for($direction=0; $direction<2; $direction++) { $selectedObjPort2 = $port['objPort']; // Find connections - $connSet = crawlConn($qls, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); + $selected = false; + $connSet = crawlConn($qls, $selected, $selectedObjID2, $selectedObjFace2, $selectedObjDepth2, $selectedObjPort2); detectDivergence($connSet[0]); detectDivergence($connSet[1]); // Add ports to workingConnSet - foreach($connSet[0] as $port) { - array_push($workingConnSet[0], $port); - } - foreach($connSet[1] as $port) { - array_push($workingConnSet[1], $port); + if($direction == 0) { + foreach($connSet[0] as $port) { + array_push($workingConnSet[1], $port); + } + foreach($connSet[1] as $port) { + array_push($workingConnSet[0], $port); + } + } else { + foreach($connSet[0] as $port) { + array_push($workingConnSet[0], $port); + } + foreach($connSet[1] as $port) { + array_push($workingConnSet[1], $port); + } + } } @@ -70,9 +87,11 @@ for($direction=0; $direction<2; $direction++) { array_push($pathArray, $workingConnSet); } } - } + } while($trunkFound); } +error_log('Debug (FINAL pathArray): '.json_encode($pathArray)); + function crawlTrunk(&$qls, $portSet) { $trunkSet = array(); @@ -114,14 +133,15 @@ function crawlTrunk(&$qls, $portSet) { return $trunkSet; } -function crawlConn(&$qls, $objID, $objFace, $objDepth, $objPort, &$connSet=array(array(),array()), $connSetID=0) { +function crawlConn(&$qls, $selected, $objID, $objFace, $objDepth, $objPort, &$connSet=array(array(),array()), $connSetID=0) { // Store port details $workingArray = array( 'objID' => $objID, 'objFace' => $objFace, 'objDepth' => $objDepth, - 'objPort' => $objPort + 'objPort' => $objPort, + 'selected' => $selected ); // Add port info to connection set @@ -154,7 +174,8 @@ function crawlConn(&$qls, $objID, $objFace, $objDepth, $objPort, &$connSet=array } if(!$alreadySeen) { - crawlConn($qls, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSet, $connSetID); + $selected = false; + crawlConn($qls, $selected, $remoteObjID, $remoteObjFace, $remoteObjDepth, $remoteObjPort, $connSet, $connSetID); } } }