Code Duplication    Length = 11-35 lines in 6 locations

main/lp/learnpathItem.class.php 3 locations

@@ 1227-1261 (lines=35) @@
1224
                                                        $pos1 + 1,
1225
                                                        $pos2 - ($pos1 + 1)
1226
                                                    );
1227
                                                    if (strpos(
1228
                                                            $second_part,
1229
                                                            api_get_path(
1230
                                                                WEB_PATH
1231
                                                            )
1232
                                                        ) !== false
1233
                                                    ) {
1234
                                                        // We found the current portal url.
1235
                                                        $files_list[] = array(
1236
                                                            $second_part,
1237
                                                            'local',
1238
                                                            'url'
1239
                                                        );
1240
                                                        $in_files_list[] = learnpathItem::get_resources_from_source(
1241
                                                            TOOL_DOCUMENT,
1242
                                                            $second_part,
1243
                                                            $recursivity + 1
1244
                                                        );
1245
                                                        if (count(
1246
                                                                $in_files_list
1247
                                                            ) > 0
1248
                                                        ) {
1249
                                                            $files_list = array_merge(
1250
                                                                $files_list,
1251
                                                                $in_files_list
1252
                                                            );
1253
                                                        }
1254
                                                    } else {
1255
                                                        // We didn't find any trace of current portal.
1256
                                                        $files_list[] = array(
1257
                                                            $second_part,
1258
                                                            'remote',
1259
                                                            'url'
1260
                                                        );
1261
                                                    }
1262
                                                } elseif (strpos(
1263
                                                        $second_part,
1264
                                                        '='
@@ 1375-1409 (lines=35) @@
1372
                                                        '://'
1373
                                                    ) > 0
1374
                                                ) {
1375
                                                    if (strpos(
1376
                                                            $source,
1377
                                                            api_get_path(
1378
                                                                WEB_PATH
1379
                                                            )
1380
                                                        ) !== false
1381
                                                    ) {
1382
                                                        // We found the current portal url.
1383
                                                        $files_list[] = array(
1384
                                                            $source,
1385
                                                            'local',
1386
                                                            'url'
1387
                                                        );
1388
                                                        $in_files_list[] = learnpathItem::get_resources_from_source(
1389
                                                            TOOL_DOCUMENT,
1390
                                                            $source,
1391
                                                            $recursivity + 1
1392
                                                        );
1393
                                                        if (count(
1394
                                                                $in_files_list
1395
                                                            ) > 0
1396
                                                        ) {
1397
                                                            $files_list = array_merge(
1398
                                                                $files_list,
1399
                                                                $in_files_list
1400
                                                            );
1401
                                                        }
1402
                                                    } else {
1403
                                                        // We didn't find any trace of current portal.
1404
                                                        $files_list[] = array(
1405
                                                            $source,
1406
                                                            'remote',
1407
                                                            'url'
1408
                                                        );
1409
                                                    }
1410
                                                } else {
1411
                                                    // No protocol found, make link local.
1412
                                                    if (substr(
@@ 1512-1541 (lines=30) @@
1509
                                            }
1510
1511
                                            // Found some protocol there.
1512
                                            if (strpos(
1513
                                                    $source,
1514
                                                    api_get_path(WEB_PATH)
1515
                                                ) !== false
1516
                                            ) {
1517
                                                // We found the current portal url.
1518
                                                $files_list[] = array(
1519
                                                    $source,
1520
                                                    'local',
1521
                                                    'url'
1522
                                                );
1523
                                                $in_files_list[] = learnpathItem::get_resources_from_source(
1524
                                                    TOOL_DOCUMENT,
1525
                                                    $source,
1526
                                                    $recursivity + 1
1527
                                                );
1528
                                                if (count($in_files_list) > 0) {
1529
                                                    $files_list = array_merge(
1530
                                                        $files_list,
1531
                                                        $in_files_list
1532
                                                    );
1533
                                                }
1534
                                            } else {
1535
                                                // We didn't find any trace of current portal.
1536
                                                $files_list[] = array(
1537
                                                    $source,
1538
                                                    'remote',
1539
                                                    'url'
1540
                                                );
1541
                                            }
1542
                                        } else {
1543
                                            // No protocol found, make link local.
1544
                                            if (substr($source, 0, 1) === '/') {

main/inc/lib/document.lib.php 3 locations

@@ 2266-2276 (lines=11) @@
2263
                                        $pos1 = strpos($second_part, '=');
2264
                                        $pos2 = strpos($second_part, '&');
2265
                                        $second_part = substr($second_part, $pos1 + 1, $pos2 - ($pos1 + 1));
2266
                                        if (strpos($second_part, api_get_path(WEB_PATH)) !== false) {
2267
                                            //we found the current portal url
2268
                                            $files_list[] = array($second_part, 'local', 'url');
2269
                                            $in_files_list[] = self::get_resources_from_source_html($second_part, true, TOOL_DOCUMENT, $recursivity + 1);
2270
                                            if (count($in_files_list) > 0) {
2271
                                                $files_list = array_merge($files_list, $in_files_list);
2272
                                            }
2273
                                        } else {
2274
                                            //we didn't find any trace of current portal
2275
                                            $files_list[] = array($second_part, 'remote', 'url');
2276
                                        }
2277
                                    } elseif (strpos($second_part, '=') > 0) {
2278
                                        if (substr($second_part, 0, 1) === '/') {
2279
                                            //link starts with a /, making it absolute (relative to DocumentRoot)
@@ 2319-2329 (lines=11) @@
2316
                                    //leave that second part behind now
2317
                                    $source = substr($source, 0, strpos($source, '?'));
2318
                                    if (strpos($source, '://') > 0) {
2319
                                        if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2320
                                            //we found the current portal url
2321
                                            $files_list[] = array($source, 'local', 'url');
2322
                                            $in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
2323
                                            if (count($in_files_list) > 0) {
2324
                                                $files_list = array_merge($files_list, $in_files_list);
2325
                                            }
2326
                                        } else {
2327
                                            //we didn't find any trace of current portal
2328
                                            $files_list[] = array($source, 'remote', 'url');
2329
                                        }
2330
                                    } else {
2331
                                        //no protocol found, make link local
2332
                                        if (substr($source, 0, 1) === '/') {
@@ 2369-2379 (lines=11) @@
2366
                                    }
2367
                                }
2368
                                //found some protocol there
2369
                                if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2370
                                    //we found the current portal url
2371
                                    $files_list[] = array($source, 'local', 'url');
2372
                                    $in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
2373
                                    if (count($in_files_list) > 0) {
2374
                                        $files_list = array_merge($files_list, $in_files_list);
2375
                                    }
2376
                                } else {
2377
                                    //we didn't find any trace of current portal
2378
                                    $files_list[] = array($source, 'remote', 'url');
2379
                                }
2380
                            } else {
2381
                                //no protocol found, make link local
2382
                                if (substr($source, 0, 1) === '/') {