Code Duplication    Length = 27-29 lines in 2 locations

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

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