Code Duplication    Length = 25-25 lines in 2 locations

main/newscorm/learnpath.class.php 2 locations

@@ 9568-9592 (lines=25) @@
9565
                                        $file_path = str_replace('\\', '/', $file_path);
9566
                                        $my_dep_file->setAttribute('href', 'document/'.$file_path);
9567
                                        $my_dep->setAttribute('xml:base', '');
9568
                                        if (strstr($file_path, $main_path) !== false) {
9569
                                            // The calculated real path is really inside the chamilo root path.
9570
                                            // Reduce file path to what's under the DocumentRoot.
9571
                                            $file_path = substr($file_path, strlen($root_path));
9572
                                            //echo $file_path;echo '<br /><br />';
9573
                                            //error_log('Reduced path: '.$file_path, 0);
9574
                                            $zip_files_abs[] = $file_path;
9575
                                            $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/'.$file_path);
9576
                                            $my_dep_file->setAttribute('href', 'document/'.$file_path);
9577
                                            $my_dep->setAttribute('xml:base', '');
9578
                                        } elseif (empty($file_path)) {
9579
                                            /*$document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH)));
9580
                                            if (strpos($document_root,-1) == '/') {
9581
                                                $document_root = substr(0, -1, $document_root);
9582
                                            }*/
9583
                                            $file_path = $_SERVER['DOCUMENT_ROOT'].$abs_path;
9584
                                            $file_path = str_replace('//', '/', $file_path);
9585
                                            if (file_exists($file_path)) {
9586
                                                $file_path = substr($file_path, strlen($current_dir)); // We get the relative path.
9587
                                                $zip_files[] = $my_sub_dir.'/'.$file_path;
9588
                                                $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/'.$file_path);
9589
                                                $my_dep_file->setAttribute('href', 'document/'.$file_path);
9590
                                                $my_dep->setAttribute('xml:base', '');
9591
                                            }
9592
                                        }
9593
                                        break;
9594
                                    case 'abs': // Absolute path from DocumentRoot. Save file and leave path as is in the zip.
9595
                                        $current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/';
@@ 9602-9626 (lines=25) @@
9599
                                        $my_dep_file->setAttribute('href', $file_path);
9600
                                        $my_dep->setAttribute('xml:base', '');
9601
9602
                                        if (strstr($file_path,$main_path) !== false) {
9603
                                            // The calculated real path is really inside the chamilo root path.
9604
                                            // Reduce file path to what's under the DocumentRoot.
9605
                                            $file_path = substr($file_path, strlen($root_path));
9606
                                            //echo $file_path;echo '<br /><br />';
9607
                                            //error_log('Reduced path: '.$file_path, 0);
9608
                                            $zip_files_abs[] = $file_path;
9609
                                            $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path);
9610
                                            $my_dep_file->setAttribute('href', 'document/'.$file_path);
9611
                                            $my_dep->setAttribute('xml:base', '');
9612
                                        } elseif (empty($file_path)) {
9613
                                            /*$document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH), api_get_path(REL_PATH)));
9614
                                            if (strpos($document_root,-1) == '/') {
9615
                                                $document_root = substr(0, -1, $document_root);
9616
                                            }*/
9617
                                            $file_path = $_SERVER['DOCUMENT_ROOT'].$doc_info[0];
9618
                                            $file_path = str_replace('//', '/', $file_path);
9619
                                            if (file_exists($file_path)) {
9620
                                                $file_path = substr($file_path,strlen($current_dir)); // We get the relative path.
9621
                                                $zip_files[] = $my_sub_dir.'/'.$file_path;
9622
                                                $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path);
9623
                                                $my_dep_file->setAttribute('href', 'document/'.$file_path);
9624
                                                $my_dep->setAttribute('xml:base', '');
9625
                                            }
9626
                                        }
9627
                                        break;
9628
                                    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
9629
                                        if (substr($doc_info[0], 0, 2) == '..') {