Code Duplication    Length = 25-25 lines in 2 locations

main/lp/learnpath.class.php 2 locations

@@ 10209-10233 (lines=25) @@
10206
                                        $file_path = str_replace('\\', '/', $file_path);
10207
                                        $my_dep_file->setAttribute('href', 'document/'.$file_path);
10208
                                        $my_dep->setAttribute('xml:base', '');
10209
                                        if (strstr($file_path, $main_path) !== false) {
10210
                                            // The calculated real path is really inside the chamilo root path.
10211
                                            // Reduce file path to what's under the DocumentRoot.
10212
                                            $file_path = substr($file_path, strlen($root_path));
10213
                                            $zip_files_abs[] = $file_path;
10214
                                            $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/'.$file_path);
10215
                                            $my_dep_file->setAttribute('href', 'document/'.$file_path);
10216
                                            $my_dep->setAttribute('xml:base', '');
10217
                                        } elseif (empty($file_path)) {
10218
                                            /*$document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH)));
10219
                                            if (strpos($document_root,-1) == '/') {
10220
                                                $document_root = substr(0, -1, $document_root);
10221
                                            }*/
10222
                                            $file_path = $_SERVER['DOCUMENT_ROOT'].$abs_path;
10223
                                            $file_path = str_replace('//', '/', $file_path);
10224
                                            if (file_exists($file_path)) {
10225
                                                $file_path = substr($file_path, strlen($current_dir)); // We get the relative path.
10226
                                                $zip_files[] = $my_sub_dir.'/'.$file_path;
10227
                                                $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/'.$file_path);
10228
                                                $my_dep_file->setAttribute('href', 'document/'.$file_path);
10229
                                                $my_dep->setAttribute('xml:base', '');
10230
                                            }
10231
                                        }
10232
                                        break;
10233
                                    case 'abs': // Absolute path from DocumentRoot. Save file and leave path as is in the zip.
10234
                                        $current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/';
10235
                                        $current_dir = str_replace('\\', '/', $current_dir);
10236
                                        $file_path = realpath($doc_info[0]);
@@ 10241-10265 (lines=25) @@
10238
                                        $my_dep_file->setAttribute('href', $file_path);
10239
                                        $my_dep->setAttribute('xml:base', '');
10240
10241
                                        if (strstr($file_path, $main_path) !== false) {
10242
                                            // The calculated real path is really inside the chamilo root path.
10243
                                            // Reduce file path to what's under the DocumentRoot.
10244
                                            $file_path = substr($file_path, strlen($root_path));
10245
                                            //echo $file_path;echo '<br /><br />';
10246
                                            //error_log('Reduced path: '.$file_path, 0);
10247
                                            $zip_files_abs[] = $file_path;
10248
                                            $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path);
10249
                                            $my_dep_file->setAttribute('href', 'document/'.$file_path);
10250
                                            $my_dep->setAttribute('xml:base', '');
10251
                                        } elseif (empty($file_path)) {
10252
                                            /*$document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH), api_get_path(REL_PATH)));
10253
                                            if (strpos($document_root,-1) == '/') {
10254
                                                $document_root = substr(0, -1, $document_root);
10255
                                            }*/
10256
                                            $file_path = $_SERVER['DOCUMENT_ROOT'].$doc_info[0];
10257
                                            $file_path = str_replace('//', '/', $file_path);
10258
                                            if (file_exists($file_path)) {
10259
                                                $file_path = substr($file_path, strlen($current_dir)); // We get the relative path.
10260
                                                $zip_files[] = $my_sub_dir.'/'.$file_path;
10261
                                                $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path);
10262
                                                $my_dep_file->setAttribute('href', 'document/'.$file_path);
10263
                                                $my_dep->setAttribute('xml:base', '');
10264
                                            }
10265
                                        }
10266
                                        break;
10267
                                    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
10268
                                        if (substr($doc_info[0], 0, 2) == '..') {