Code Duplication    Length = 27-29 lines in 2 locations

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

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