Code Duplication    Length = 27-29 lines in 2 locations

manager/includes/document.parser.class.inc.php 2 locations

@@ 1434-1460 (lines=27) @@
1431
                $str = trim($str, '()"\'');
1432
                $docid = $this->getIdFromAlias($str);
1433
                break;
1434
            case 'prev':
1435
                if (!$option) {
1436
                    $option = 'menuindex,ASC';
1437
                } elseif (strpos($option, ',') === false) {
1438
                    $option .= ',ASC';
1439
                }
1440
                list($by, $dir) = explode(',', $option, 2);
1441
                $children = $this->getActiveChildren($parent, $by, $dir);
1442
                $find = false;
1443
                $prev = false;
1444
                foreach ($children as $row) {
1445
                    if ($row['id'] == $this->documentIdentifier) {
1446
                        $find = true;
1447
                        break;
1448
                    }
1449
                    $prev = $row;
1450
                }
1451
                if ($find) {
1452
                    if (isset($prev[$key])) {
1453
                        return $prev[$key];
1454
                    } else {
1455
                        $docid = $prev['id'];
1456
                    }
1457
                } else {
1458
                    $docid = '';
1459
                }
1460
                break;
1461
            case 'next':
1462
                if (!$option) {
1463
                    $option = 'menuindex,ASC';
@@ 1461-1489 (lines=29) @@
1458
                    $docid = '';
1459
                }
1460
                break;
1461
            case 'next':
1462
                if (!$option) {
1463
                    $option = 'menuindex,ASC';
1464
                } elseif (strpos($option, ',') === false) {
1465
                    $option .= ',ASC';
1466
                }
1467
                list($by, $dir) = explode(',', $option, 2);
1468
                $children = $this->getActiveChildren($parent, $by, $dir);
1469
                $find = false;
1470
                $next = false;
1471
                foreach ($children as $row) {
1472
                    if ($find) {
1473
                        $next = $row;
1474
                        break;
1475
                    }
1476
                    if ($row['id'] == $this->documentIdentifier) {
1477
                        $find = true;
1478
                    }
1479
                }
1480
                if ($find) {
1481
                    if (isset($next[$key])) {
1482
                        return $next[$key];
1483
                    } else {
1484
                        $docid = $next['id'];
1485
                    }
1486
                } else {
1487
                    $docid = '';
1488
                }
1489
                break;
1490
            default:
1491
                $docid = $str;
1492
        }