diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index e394196e03..d218e5e7f6 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -5399,7 +5399,7 @@ div#chat-remote-video video { width: 420px; } .tab-wrapper .tab-content{ - padding: 25px; + padding: 25px 0px 25px 0px; } .description-upload{ margin-bottom: 10px; diff --git a/main/document/upload.php b/main/document/upload.php index 4269d90cbf..4c6adf74d0 100755 --- a/main/document/upload.php +++ b/main/document/upload.php @@ -315,7 +315,7 @@ if ($is_certificate_mode) { // Link to create a folder -echo $toolbar = Display::toolbarAction('toolbar-upload', array( 0 => $actions), 1); +echo $toolbar = Display::toolbarAction('toolbar-upload', array(0 => $actions), 1); // Form to select directory $folders = DocumentManager::get_all_document_folders($_course, $groupId, $is_allowed_to_edit); if (!$is_certificate_mode) { diff --git a/main/inc/ajax/document.ajax.php b/main/inc/ajax/document.ajax.php index 524a1944d2..f99780e785 100755 --- a/main/inc/ajax/document.ajax.php +++ b/main/inc/ajax/document.ajax.php @@ -26,13 +26,29 @@ switch ($action) { exit; } - $fileExistsOption = api_get_setting('document_if_file_exists_option'); - $defaultFileExistsOption = 'rename'; - if (!empty($fileExistsOption)) { - $defaultFileExistsOption = $fileExistsOption; + $directoryParentId = isset($_POST['directory_parent_id']) ? $_POST['directory_parent_id'] : 0; + $currentDirectory = ''; + if (empty($directoryParentId)) { + $currentDirectory = isset($_REQUEST['curdirpath']) ? $_REQUEST['curdirpath'] : ''; + } else { + $documentData = DocumentManager::get_document_data_by_id($directoryParentId, api_get_course_id()); + if ($documentData) { + $currentDirectory = $documentData['path']; + } } - //$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : $defaultFileExistsOption; + $ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : ''; + $unzip = isset($_POST['unzip']) ? 1 : 0; + + if (empty($ifExists)) { + $fileExistsOption = api_get_setting('document_if_file_exists_option'); + $defaultFileExistsOption = 'rename'; + if (!empty($fileExistsOption)) { + $defaultFileExistsOption = $fileExistsOption; + } + } else { + $defaultFileExistsOption = $ifExists; + } if (!empty($_FILES)) { $files = $_FILES['files']; @@ -51,10 +67,10 @@ switch ($action) { $globalFile['files'] = $file; $result = DocumentManager::upload_document( $globalFile, - $_REQUEST['curdirpath'], + $currentDirectory, $file['name'], '', // comment - 0, + $unzip, $defaultFileExistsOption, false, false, diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index f04a4590cb..0b37bd1c18 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -2789,6 +2789,8 @@ class DocumentManager * @param string $if_exists overwrite, rename or warn (default) * @param bool $index_document index document (search xapian module) * @param bool $show_output print html messages + * @param string $fileKey + * * @return array|bool */ public static function upload_document( @@ -2829,6 +2831,21 @@ class DocumentManager $sessionId ); + // Showing message when sending zip files + if ($new_path === true && $unzip == 1) { + if ($show_output) { + Display::display_confirmation_message( + get_lang('UplUploadSucceeded').'
', + false + ); + } + + return [ + 'title' => $path, + 'url' => $path, + ]; + } + if ($new_path) { $documentId = DocumentManager::get_document_id( $course_info, @@ -2875,13 +2892,6 @@ class DocumentManager ); } - // Showing message when sending zip files - if ($new_path === true && $unzip == 1 && $show_output) { - Display::display_confirmation_message( - get_lang('UplUploadSucceeded') . '
', - false - ); - } if ($index_document) { self::index_document( @@ -3403,13 +3413,13 @@ class DocumentManager $return = ''; if ($lp_id) { if ($folderId === false) { - $return .= '
'; + /*$return .= '
'; $return .= Display::return_icon('new_doc.gif', '', array(), ICON_SIZE_SMALL); $return .= Display::url( get_lang('NewDocument'), api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_DOCUMENT.'&lp_id='.$_SESSION['oLP']->lp_id ); - $return .= '
'; + $return .= '
';*/ } } else { $return .= Display::div( @@ -5034,8 +5044,14 @@ class DocumentManager * @return string html form */ - public static function build_directory_selector($folders, $document_id, $group_dir = '', $change_renderer = false, & $form = null, $selectName = 'id') - { + public static function build_directory_selector( + $folders, + $document_id, + $group_dir = '', + $change_renderer = false, + & $form = null, + $selectName = 'id' + ) { $doc_table = Database::get_course_table(TABLE_DOCUMENT); $course_id = api_get_course_int_id(); $folder_titles = array(); diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index fe6314b8bb..8c58748b54 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -8672,7 +8672,7 @@ class learnpath $course_info = api_get_course_info(); $sessionId = api_get_session_id(); - $document_tree = DocumentManager::get_document_preview( + $documentTree = DocumentManager::get_document_preview( $course_info, $this->lp_id, null, @@ -8684,7 +8684,69 @@ class learnpath true ); - return $document_tree; + $headers = array( + get_lang('Files'), + get_lang('NewDocument'), + get_lang('Upload'), + ); + + $multipleForm = ''; + + $form = new FormValidator('form_upload', 'POST', api_get_self() . '?' .$_SERVER['QUERY_STRING'], '', array('enctype'=> "multipart/form-data")); + + $folders = DocumentManager::get_all_document_folders( + api_get_course_info(), + 0, + true + ); + + DocumentManager::build_directory_selector( + $folders, + '', + array(), + true, + $form, + 'directory_parent_id' + ); + + $form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing'); + $form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite'); + $form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename'); + $form->setDefaults(['if_exists' => 'rename']); + + + // Check box options + $form->addElement( + 'checkbox', + 'unzip', + get_lang('Options'), + get_lang('Uncompress') + ); + + $form->addHtml(' + + + '.get_lang('AddFiles').' + + + + +
+
+ +
+
+
+
+ ' + ); + + + $new = $this->display_document_form('add', 0); + + $tabs = Display::tabs($headers, array($documentTree, $new, $form->returnForm()), 'subtab'); + + return $tabs; } /** diff --git a/main/newscorm/lp_add_item.php b/main/newscorm/lp_add_item.php index e12b7ce218..0bc5a233f2 100755 --- a/main/newscorm/lp_add_item.php +++ b/main/newscorm/lp_add_item.php @@ -93,20 +93,136 @@ if (!empty($gradebook) && $gradebook == 'view') { ); } -$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); -$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $learnPath->get_name()); +$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-upload')); + +$url = api_get_path(WEB_AJAX_PATH).'document.ajax.php?'.api_get_cidreq().'&a=upload_file&curdirpath='; + +$htmlHeadXtra[] = " +"; + +$interbreadcrumb[] = array( + 'url' => 'lp_controller.php?action=list?'.api_get_cidreq(), + 'name' => get_lang('LearningPaths'), +); +$interbreadcrumb[] = array( + 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), + 'name' => $learnPath->get_name(), +); switch ($type) { case 'chapter': $interbreadcrumb[] = array( - 'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), + 'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id().'&'.api_get_cidreq(), 'name' => get_lang('NewStep'), ); $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('NewChapter')); break; case 'document': $interbreadcrumb[] = array( - 'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), + 'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id().'&'.api_get_cidreq(), 'name' => get_lang('NewStep'), ); break; @@ -115,7 +231,7 @@ switch ($type) { break; } -if ($action == 'add_item' && $type == 'document' ) { +if ($action == 'add_item' && $type == 'document') { $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewDocumentCreated')); } @@ -164,10 +280,9 @@ jQuery(document).ready(function(){ $(document).ready(function() { $("#doc_form").removeClass( "col-md-8" ).addClass( "col-md-7" ); - $("#hide_bar_template").click(function() { $("#lp_sidebar").toggleClass("hide"); - + if ($('#doc_form').is('.col-md-7')) { $('#doc_form').removeClass('col-md-7'); $('#doc_form').addClass('col-md-11'); @@ -175,7 +290,7 @@ $(document).ready(function() { $('#doc_form').removeClass('col-md-11'); $('#doc_form').addClass('col-md-7'); } - + $("#hide_bar_template").toggleClass("hide_bar_template_not_hide"); });