Merge branch 'fronkdev'
This commit is contained in:
@@ -219,62 +219,60 @@ class Termination extends mfBaseModel {
|
|||||||
|
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLineworkportPairs() {
|
public function getLineworkportPairs() {
|
||||||
$ports = $this->getProperty("workflowitems")["ports"]->value->value_string;
|
$ports = $this->getProperty("workflowitems")["ports"]->value->value_string;
|
||||||
$ist_port = $this->getProperty("workflowitems")["ist_ports"]->value->value_string;
|
$ist_port = $this->getProperty("workflowitems")["ist_ports"]->value->value_string;
|
||||||
if(strlen($ist_port)) {
|
if(strlen($ist_port)) {
|
||||||
$ports = $ist_port;
|
$ports = $ist_port;
|
||||||
}
|
|
||||||
|
|
||||||
if(!$ports) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$return = [];
|
|
||||||
$return["range"] = [];
|
|
||||||
$return["pairs"] = [];
|
|
||||||
|
|
||||||
$ports = preg_replace('/[^0-9-]+/', "", $ports);
|
|
||||||
if(strpos($ports, "-") !== false) {
|
|
||||||
// port range
|
|
||||||
$this->log->debug("is range");
|
|
||||||
$port_parts = explode("-", $ports);
|
|
||||||
if(is_array($port_parts) && count($port_parts) == 2) {
|
|
||||||
$from = intval($port_parts[0]);
|
|
||||||
$to = intval($port_parts[1]);
|
|
||||||
|
|
||||||
if($from > $to) {
|
|
||||||
$tmp = $from;
|
|
||||||
$from = $to;
|
|
||||||
$to = $tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$range = [];
|
if(!$ports) {
|
||||||
$pairs = [];
|
return [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for($i = $from; $i <= $to; $i++) {
|
|
||||||
$range[] = intval($i);
|
|
||||||
if($i + 1 <= $to) {
|
|
||||||
$pairs[] = $i."-".($i+1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$return["range"] = $range;
|
$return = [];
|
||||||
$return["pairs"] = $pairs;
|
$return["range"] = [];
|
||||||
}
|
$return["pairs"] = [];
|
||||||
} else {
|
|
||||||
// single port
|
$ports = preg_replace('/[^0-9-]+/', "", $ports);
|
||||||
$this->log->debug("not a range");
|
|
||||||
$return["range"][] = $ports;
|
$port_parts = false;
|
||||||
|
if(preg_match('/^(\d+)-(\d+)$/', $ports, $m)) {
|
||||||
|
$port_parts = [$m[1], $m[2]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_array($port_parts) || count($port_parts) < 2) {
|
||||||
|
// not a valid port range, treat as single port
|
||||||
|
$return["range"][] = $ports;
|
||||||
|
} else {
|
||||||
|
// valid port range
|
||||||
|
$from = $port_parts[0];
|
||||||
|
$to = $port_parts[1];
|
||||||
|
|
||||||
|
if($port_parts[0] > $port_parts[1]) {
|
||||||
|
$from = $port_parts[1];
|
||||||
|
$to = $port_parts[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
$range = [];
|
||||||
|
$pairs = [];
|
||||||
|
|
||||||
|
for($i = $from; $i <= $to; $i++) {
|
||||||
|
$range[] = intval($i);
|
||||||
|
if($i + 1 <= $to) {
|
||||||
|
$pairs[] = $i."-".($i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$return["range"] = $range;
|
||||||
|
$return["pairs"] = $pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
//var_dump($return);exit;
|
||||||
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//var_dump($return);exit;
|
|
||||||
return $return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resetProperties() {
|
public function resetProperties() {
|
||||||
$this->building = null;
|
$this->building = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user