Code Duplication    Length = 27-29 lines in 2 locations

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

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