Code Duplication    Length = 25-25 lines in 2 locations

main/newscorm/learnpath.class.php 2 locations

@@ 9529-9553 (lines=25) @@
9526
                                        $file_path = str_replace('\\', '/', $file_path);
9527
                                        $my_dep_file->setAttribute('href', 'document/'.$file_path);
9528
                                        $my_dep->setAttribute('xml:base', '');
9529
                                        if (strstr($file_path, $main_path) !== false) {
9530
                                            // The calculated real path is really inside the chamilo root path.
9531
                                            // Reduce file path to what's under the DocumentRoot.
9532
                                            $file_path = substr($file_path, strlen($root_path));
9533
                                            //echo $file_path;echo '<br /><br />';
9534
                                            //error_log('Reduced path: '.$file_path, 0);
9535
                                            $zip_files_abs[] = $file_path;
9536
                                            $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/'.$file_path);
9537
                                            $my_dep_file->setAttribute('href', 'document/'.$file_path);
9538
                                            $my_dep->setAttribute('xml:base', '');
9539
                                        } elseif (empty($file_path)) {
9540
                                            /*$document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH)));
9541
                                            if (strpos($document_root,-1) == '/') {
9542
                                                $document_root = substr(0, -1, $document_root);
9543
                                            }*/
9544
                                            $file_path = $_SERVER['DOCUMENT_ROOT'].$abs_path;
9545
                                            $file_path = str_replace('//', '/', $file_path);
9546
                                            if (file_exists($file_path)) {
9547
                                                $file_path = substr($file_path, strlen($current_dir)); // We get the relative path.
9548
                                                $zip_files[] = $my_sub_dir.'/'.$file_path;
9549
                                                $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/'.$file_path);
9550
                                                $my_dep_file->setAttribute('href', 'document/'.$file_path);
9551
                                                $my_dep->setAttribute('xml:base', '');
9552
                                            }
9553
                                        }
9554
                                        break;
9555
                                    case 'abs': // Absolute path from DocumentRoot. Save file and leave path as is in the zip.
9556
                                        $current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/';
@@ 9563-9587 (lines=25) @@
9560
                                        $my_dep_file->setAttribute('href', $file_path);
9561
                                        $my_dep->setAttribute('xml:base', '');
9562
9563
                                        if (strstr($file_path,$main_path) !== false) {
9564
                                            // The calculated real path is really inside the chamilo root path.
9565
                                            // Reduce file path to what's under the DocumentRoot.
9566
                                            $file_path = substr($file_path, strlen($root_path));
9567
                                            //echo $file_path;echo '<br /><br />';
9568
                                            //error_log('Reduced path: '.$file_path, 0);
9569
                                            $zip_files_abs[] = $file_path;
9570
                                            $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path);
9571
                                            $my_dep_file->setAttribute('href', 'document/'.$file_path);
9572
                                            $my_dep->setAttribute('xml:base', '');
9573
                                        } elseif (empty($file_path)) {
9574
                                            /*$document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH), api_get_path(REL_PATH)));
9575
                                            if (strpos($document_root,-1) == '/') {
9576
                                                $document_root = substr(0, -1, $document_root);
9577
                                            }*/
9578
                                            $file_path = $_SERVER['DOCUMENT_ROOT'].$doc_info[0];
9579
                                            $file_path = str_replace('//', '/', $file_path);
9580
                                            if (file_exists($file_path)) {
9581
                                                $file_path = substr($file_path,strlen($current_dir)); // We get the relative path.
9582
                                                $zip_files[] = $my_sub_dir.'/'.$file_path;
9583
                                                $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path);
9584
                                                $my_dep_file->setAttribute('href', 'document/'.$file_path);
9585
                                                $my_dep->setAttribute('xml:base', '');
9586
                                            }
9587
                                        }
9588
                                        break;
9589
                                    case 'rel': // Path relative to the current document. Save xml:base as current document's directory and save file in zip as subdir.file_path
9590
                                        if (substr($doc_info[0], 0, 2) == '..') {