| @@ 1418-1441 (lines=24) @@ | ||
| 1415 | * @param array $settings |
|
| 1416 | * @return array |
|
| 1417 | */ |
|
| 1418 | public function ext_depthKeys($arr, $settings) |
|
| 1419 | { |
|
| 1420 | $tsbrArray = []; |
|
| 1421 | foreach ($arr as $theK => $theV) { |
|
| 1422 | $theKeyParts = explode('.', $theK); |
|
| 1423 | $depth = ''; |
|
| 1424 | $c = count($theKeyParts); |
|
| 1425 | $a = 0; |
|
| 1426 | foreach ($theKeyParts as $p) { |
|
| 1427 | $a++; |
|
| 1428 | $depth .= ($depth ? '.' : '') . $p; |
|
| 1429 | $tsbrArray[$depth] = $c == $a ? $theV : 1; |
|
| 1430 | } |
|
| 1431 | } |
|
| 1432 | // Modify settings |
|
| 1433 | foreach ($tsbrArray as $theK => $theV) { |
|
| 1434 | if ($theV) { |
|
| 1435 | $settings[$theK] = 1; |
|
| 1436 | } else { |
|
| 1437 | unset($settings[$theK]); |
|
| 1438 | } |
|
| 1439 | } |
|
| 1440 | return $settings; |
|
| 1441 | } |
|
| 1442 | ||
| 1443 | /** |
|
| 1444 | * Process input |
|
| @@ 212-235 (lines=24) @@ | ||
| 209 | * @param array $settings Input depth_key array |
|
| 210 | * @return array Output depth_key array with entries added/removed based on $arr |
|
| 211 | */ |
|
| 212 | public function depthKeys($arr, $settings) |
|
| 213 | { |
|
| 214 | $tsbrArray = []; |
|
| 215 | foreach ($arr as $theK => $theV) { |
|
| 216 | $theKeyParts = explode('.', $theK); |
|
| 217 | $depth = ''; |
|
| 218 | $c = count($theKeyParts); |
|
| 219 | $a = 0; |
|
| 220 | foreach ($theKeyParts as $p) { |
|
| 221 | $a++; |
|
| 222 | $depth .= ($depth ? '.' : '') . $p; |
|
| 223 | $tsbrArray[$depth] = $c == $a ? $theV : 1; |
|
| 224 | } |
|
| 225 | } |
|
| 226 | // Modify settings |
|
| 227 | foreach ($tsbrArray as $theK => $theV) { |
|
| 228 | if ($theV) { |
|
| 229 | $settings[$theK] = 1; |
|
| 230 | } else { |
|
| 231 | unset($settings[$theK]); |
|
| 232 | } |
|
| 233 | } |
|
| 234 | return $settings; |
|
| 235 | } |
|
| 236 | } |
|
| 237 | ||