From 8152a728a866c568baf769db56ff09ef36b8a9e3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 22 Mar 2022 11:42:15 +0100 Subject: [PATCH 1/4] Fix : filemanagement in ecm and medias --- htdocs/core/class/html.formfile.class.php | 8 ++++---- htdocs/core/tpl/filemanager.tpl.php | 18 ++++++++++++++++-- htdocs/ecm/class/htmlecm.form.class.php | 4 ++-- htdocs/ecm/dir_add_card.php | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6c4ff6e30f1..7117b2b8a2a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1328,7 +1328,7 @@ class FormFile if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\.meta$/i', $file['name'])) { - if ($filearray[$key]['rowid'] > 0) { + if (!empty($filearray[$key]['rowid']) && $filearray[$key]['rowid'] > 0) { $lastrowid = $filearray[$key]['rowid']; } $filepath = $relativepath.$file['name']; @@ -1337,8 +1337,8 @@ class FormFile $nboflines++; print ''."\n"; // Do we have entry into database ? - print ''."\n"; - print ''; + print ''."\n"; + print ''; // File name print ''; @@ -1481,7 +1481,7 @@ class FormFile if ($permtoeditline) { // Link to resize $moreparaminurl = ''; - if ($object->id > 0) { + if (!empty($object->id) && $object->id > 0) { $moreparaminurl = '&id='.$object->id; } elseif (GETPOST('website', 'alpha')) { $moreparaminurl = '&website='.GETPOST('website', 'alpha'); diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index e776388ac53..5c40e56ff10 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -51,7 +51,7 @@ if ($module == 'medias') { $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $showroot = 1; } - +$section = 0; // Confirm remove file (for non javascript users) @@ -102,12 +102,26 @@ $('#acreatedir').on('click', function() { try{ section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel; section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2]; + catParent = "; +if ($module == 'ecm') { + print "section;"; +} else { + print "section_dir.substring(0, section_dir.length - 1);"; +} +print " } catch{ section_dir = '/'; section = 0; + catParent = "; +if ($module == 'ecm') { + print "section;"; +} else { + print "section_dir;"; +} +print " } console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir'); - $('#acreatedir').attr('href', $('#acreatedir').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section)); + $('#acreatedir').attr('href', $('#acreatedir').attr('href')+'%26section_dir%3D'+encodeURI(section_dir)+'%26section%3D'+encodeURI(section)+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section)+'&catParent='+encodeURI(catParent)); console.log($('#acreatedir').attr('href')); }); $('#agenerateimgwebp').on('click', function() { diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 623d626935d..b93d3d563fb 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -80,7 +80,7 @@ class FormEcm $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); } - $output = ''; if (is_array($cate_arbo)) { if (!count($cate_arbo)) { $output .= ''; @@ -100,7 +100,7 @@ class FormEcm } } $output .= ''; - $output .= ajax_combobox($select_name); + //$output .= ajax_combobox($select_name); $output .= "\n"; return $output; } diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index d7de6acc727..a6c980e5908 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -230,7 +230,7 @@ if ($action == 'create') { print ''; // Label - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("AddIn").''; print $formecm->selectAllSections((GETPOST("catParent", 'alpha') ? GETPOST("catParent", 'alpha') : $ecmdir->fk_parent), 'catParent', $module); From b18eac6c75708e6d1e2869cd3c99936440225932 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 22 Mar 2022 14:44:11 +0100 Subject: [PATCH 2/4] remove tests lines --- htdocs/ecm/class/htmlecm.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index b93d3d563fb..623d626935d 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -80,7 +80,7 @@ class FormEcm $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); } - $output = ''; if (is_array($cate_arbo)) { if (!count($cate_arbo)) { $output .= ''; @@ -100,7 +100,7 @@ class FormEcm } } $output .= ''; - //$output .= ajax_combobox($select_name); + $output .= ajax_combobox($select_name); $output .= "\n"; return $output; } From 63cca2c7cfe0cfc664299a2b9948107e1dc46250 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 22 Jun 2022 10:16:27 +0000 Subject: [PATCH 3/4] Fixing style errors. --- htdocs/core/class/html.formfile.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 0b87823c38d..69c349616f5 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1282,7 +1282,6 @@ class FormFile if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\.meta$/i', $file['name'])) { - if (array_key_exists('rowid', $filearray[$key]) && $filearray[$key]['rowid'] > 0) { $lastrowid = $filearray[$key]['rowid']; } From fd0bbf8ebc94c27ba44f213e5c88ae8c6e5447af Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 22 Jun 2022 12:25:59 +0200 Subject: [PATCH 4/4] fix coments --- htdocs/core/tpl/filemanager.tpl.php | 4 +++- htdocs/ecm/dir_add_card.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 2290e9093d8..2c4b2f5dea8 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -53,8 +53,10 @@ if ($module == 'medias') { $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $showroot = 1; } -$section = 0; +if (!isset($section)) { + $section = 0; +} // Confirm remove file (for non javascript users) if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax)) { diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index a6c980e5908..e5df264e377 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -230,7 +230,7 @@ if ($action == 'create') { print ''; // Label - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'label).'" autofocus>
'.$langs->trans("AddIn").''; print $formecm->selectAllSections((GETPOST("catParent", 'alpha') ? GETPOST("catParent", 'alpha') : $ecmdir->fk_parent), 'catParent', $module);