Code Duplication    Length = 27-29 lines in 2 locations

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

@@ 1398-1424 (lines=27) @@
1395
                $str = trim($str, '()"\'');
1396
                $docid = $this->getIdFromAlias($str);
1397
                break;
1398
            case 'prev':
1399
                if (!$option) {
1400
                    $option = 'menuindex,ASC';
1401
                } elseif (strpos($option, ',') === false) {
1402
                    $option .= ',ASC';
1403
                }
1404
                list($by, $dir) = explode(',', $option, 2);
1405
                $children = $this->getActiveChildren($parent, $by, $dir);
1406
                $find = false;
1407
                $prev = false;
1408
                foreach ($children as $row) {
1409
                    if ($row['id'] == $this->documentIdentifier) {
1410
                        $find = true;
1411
                        break;
1412
                    }
1413
                    $prev = $row;
1414
                }
1415
                if ($find) {
1416
                    if (isset($prev[$key])) {
1417
                        return $prev[$key];
1418
                    } else {
1419
                        $docid = $prev['id'];
1420
                    }
1421
                } else {
1422
                    $docid = '';
1423
                }
1424
                break;
1425
            case 'next':
1426
                if (!$option) {
1427
                    $option = 'menuindex,ASC';
@@ 1425-1453 (lines=29) @@
1422
                    $docid = '';
1423
                }
1424
                break;
1425
            case 'next':
1426
                if (!$option) {
1427
                    $option = 'menuindex,ASC';
1428
                } elseif (strpos($option, ',') === false) {
1429
                    $option .= ',ASC';
1430
                }
1431
                list($by, $dir) = explode(',', $option, 2);
1432
                $children = $this->getActiveChildren($parent, $by, $dir);
1433
                $find = false;
1434
                $next = false;
1435
                foreach ($children as $row) {
1436
                    if ($find) {
1437
                        $next = $row;
1438
                        break;
1439
                    }
1440
                    if ($row['id'] == $this->documentIdentifier) {
1441
                        $find = true;
1442
                    }
1443
                }
1444
                if ($find) {
1445
                    if (isset($next[$key])) {
1446
                        return $next[$key];
1447
                    } else {
1448
                        $docid = $next['id'];
1449
                    }
1450
                } else {
1451
                    $docid = '';
1452
                }
1453
                break;
1454
            default:
1455
                $docid = $str;
1456
        }