Code Duplication    Length = 11-35 lines in 6 locations

main/newscorm/learnpathItem.class.php 3 locations

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

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

@@ 2210-2220 (lines=11) @@
2207
                                        $pos1 = strpos($second_part, '=');
2208
                                        $pos2 = strpos($second_part, '&');
2209
                                        $second_part = substr($second_part, $pos1 + 1, $pos2 - ($pos1 + 1));
2210
                                        if (strpos($second_part, api_get_path(WEB_PATH)) !== false) {
2211
                                            //we found the current portal url
2212
                                            $files_list[] = array($second_part, 'local', 'url');
2213
                                            $in_files_list[] = self::get_resources_from_source_html($second_part, true, TOOL_DOCUMENT, $recursivity + 1);
2214
                                            if (count($in_files_list) > 0) {
2215
                                                $files_list = array_merge($files_list, $in_files_list);
2216
                                            }
2217
                                        } else {
2218
                                            //we didn't find any trace of current portal
2219
                                            $files_list[] = array($second_part, 'remote', 'url');
2220
                                        }
2221
                                    } elseif (strpos($second_part, '=') > 0) {
2222
                                        if (substr($second_part, 0, 1) === '/') {
2223
                                            //link starts with a /, making it absolute (relative to DocumentRoot)
@@ 2263-2273 (lines=11) @@
2260
                                    //leave that second part behind now
2261
                                    $source = substr($source, 0, strpos($source, '?'));
2262
                                    if (strpos($source, '://') > 0) {
2263
                                        if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2264
                                            //we found the current portal url
2265
                                            $files_list[] = array($source, 'local', 'url');
2266
                                            $in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
2267
                                            if (count($in_files_list) > 0) {
2268
                                                $files_list = array_merge($files_list, $in_files_list);
2269
                                            }
2270
                                        } else {
2271
                                            //we didn't find any trace of current portal
2272
                                            $files_list[] = array($source, 'remote', 'url');
2273
                                        }
2274
                                    } else {
2275
                                        //no protocol found, make link local
2276
                                        if (substr($source, 0, 1) === '/') {
@@ 2313-2323 (lines=11) @@
2310
                                    }
2311
                                }
2312
                                //found some protocol there
2313
                                if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2314
                                    //we found the current portal url
2315
                                    $files_list[] = array($source, 'local', 'url');
2316
                                    $in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
2317
                                    if (count($in_files_list) > 0) {
2318
                                        $files_list = array_merge($files_list, $in_files_list);
2319
                                    }
2320
                                } else {
2321
                                    //we didn't find any trace of current portal
2322
                                    $files_list[] = array($source, 'remote', 'url');
2323
                                }
2324
                            } else {
2325
                                //no protocol found, make link local
2326
                                if (substr($source, 0, 1) === '/') {