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

@@ 2227-2237 (lines=11) @@
2224
                                        $pos1 = strpos($second_part, '=');
2225
                                        $pos2 = strpos($second_part, '&');
2226
                                        $second_part = substr($second_part, $pos1 + 1, $pos2 - ($pos1 + 1));
2227
                                        if (strpos($second_part, api_get_path(WEB_PATH)) !== false) {
2228
                                            //we found the current portal url
2229
                                            $files_list[] = array($second_part, 'local', 'url');
2230
                                            $in_files_list[] = self::get_resources_from_source_html($second_part, true, TOOL_DOCUMENT, $recursivity + 1);
2231
                                            if (count($in_files_list) > 0) {
2232
                                                $files_list = array_merge($files_list, $in_files_list);
2233
                                            }
2234
                                        } else {
2235
                                            //we didn't find any trace of current portal
2236
                                            $files_list[] = array($second_part, 'remote', 'url');
2237
                                        }
2238
                                    } elseif (strpos($second_part, '=') > 0) {
2239
                                        if (substr($second_part, 0, 1) === '/') {
2240
                                            //link starts with a /, making it absolute (relative to DocumentRoot)
@@ 2280-2290 (lines=11) @@
2277
                                    //leave that second part behind now
2278
                                    $source = substr($source, 0, strpos($source, '?'));
2279
                                    if (strpos($source, '://') > 0) {
2280
                                        if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2281
                                            //we found the current portal url
2282
                                            $files_list[] = array($source, 'local', 'url');
2283
                                            $in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
2284
                                            if (count($in_files_list) > 0) {
2285
                                                $files_list = array_merge($files_list, $in_files_list);
2286
                                            }
2287
                                        } else {
2288
                                            //we didn't find any trace of current portal
2289
                                            $files_list[] = array($source, 'remote', 'url');
2290
                                        }
2291
                                    } else {
2292
                                        //no protocol found, make link local
2293
                                        if (substr($source, 0, 1) === '/') {
@@ 2330-2340 (lines=11) @@
2327
                                    }
2328
                                }
2329
                                //found some protocol there
2330
                                if (strpos($source, api_get_path(WEB_PATH)) !== false) {
2331
                                    //we found the current portal url
2332
                                    $files_list[] = array($source, 'local', 'url');
2333
                                    $in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
2334
                                    if (count($in_files_list) > 0) {
2335
                                        $files_list = array_merge($files_list, $in_files_list);
2336
                                    }
2337
                                } else {
2338
                                    //we didn't find any trace of current portal
2339
                                    $files_list[] = array($source, 'remote', 'url');
2340
                                }
2341
                            } else {
2342
                                //no protocol found, make link local
2343
                                if (substr($source, 0, 1) === '/') {