Code Duplication    Length = 27-29 lines in 2 locations

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

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