From 818f43e7adc6731f08428592501038f0414759a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Nov 2017 22:04:24 +0100 Subject: [PATCH] Work on generic filemanager --- htdocs/core/ajax/ajaxdirtree.php | 2 +- htdocs/ecm/docdir.php | 1 + htdocs/ecm/docmine.php | 93 ++++++++++++++++++++------------ 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 0475dabbdfa..723a5dbfb2a 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -198,7 +198,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE print ''; // Edit link - print ''.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').''; + print ''.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').''; // Add link //print ''.img_edit_add().''; diff --git a/htdocs/ecm/docdir.php b/htdocs/ecm/docdir.php index 1d92d54d0ea..e5a1de61f51 100644 --- a/htdocs/ecm/docdir.php +++ b/htdocs/ecm/docdir.php @@ -43,6 +43,7 @@ $confirm = GETPOST('confirm','alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); +if (empty($module)) $module='ecm'; // Security check if ($user->societe_id > 0) diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index c722ba9a208..a68785dd09e 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -34,8 +34,15 @@ $langs->load("ecm"); $langs->load("companies"); $langs->load("other"); -$action=GETPOST('action','alpha'); -$confirm=GETPOST('confirm','alpha'); +$action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); +$confirm = GETPOST('confirm','alpha'); + +$module = GETPOST('module', 'alpha'); +$website = GETPOST('website', 'alpha'); +$pageid = GETPOST('pageid', 'int'); +if (empty($module)) $module='ecm'; // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -48,24 +55,33 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; -$section=GETPOST("section"); +$section=GETPOST("section", 'alpha')?GETPOST("section", 'alpha'):GETPOST("relativedir", 'alpha'); if (! $section) { dol_print_error('',"ErrorSectionParamNotDefined"); exit; } - // Load ecm object $ecmdir = new EcmDirectory($db); -$result=$ecmdir->fetch(GETPOST("section")); -if (! $result > 0) + +if ($module == 'ecm') { - dol_print_error($db,$ecmdir->error); - exit; + $result=$ecmdir->fetch($section); + if (! $result > 0) + { + dol_print_error($db, $ecmdir->error); + exit; + } + $relativepath=$ecmdir->getRelativePath(); + + $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; +} +else // For example $module == 'medias' +{ + $relativepath = $section; + $upload_dir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath; } -$relativepath=$ecmdir->getRelativePath(); -$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; @@ -256,27 +272,39 @@ dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref); print '
'; print '
'; -print ''; +print '
'; /*print '';*/ -print ''; + + print ''; +} +print ''; -print ''; -print ''; print '
'.$langs->trans("Ref").''; print img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '; print $s; print '
'.$langs->trans("Description").''; -if ($action == 'edit') +if ($module == 'ecm') { - print ''; + print '
'.$langs->trans("Description").''; + if ($action == 'edit') + { + print ''; + } + else print dol_nl2br($ecmdir->description); + print '
'.$langs->trans("ECMCreationUser").''; + $userecm=new User($db); + $userecm->fetch($ecmdir->fk_user_c); + print $userecm->getNomUrl(1); + print '
'.$langs->trans("ECMCreationDate").''; +if ($module == 'ecm') +{ + print dol_print_date($ecmdir->date_c,'dayhour'); +} +else +{ + //var_dump($upload_dir); + print dol_print_date(dol_filemtime($upload_dir), 'dayhour'); } -else print dol_nl2br($ecmdir->description); -print '
'.$langs->trans("ECMCreationUser").''; -$userecm=new User($db); -$userecm->fetch($ecmdir->fk_user_c); -print $userecm->getNomUrl(1); -print '
'.$langs->trans("ECMCreationDate").''; -print dol_print_date($ecmdir->date_c,'dayhour'); print '
'.$langs->trans("ECMDirectoryForFiles").''; print '/ecm/'.$relativepath; @@ -321,12 +349,12 @@ if ($action != 'edit' && $action != 'delete') if ($user->rights->ecm->setup) { - print ''.$langs->trans('Edit').''; + print ''.$langs->trans('Edit').''; } if ($user->rights->ecm->setup) { - print ''.$langs->trans('ECMAddSection').''; + print ''.$langs->trans('ECMAddSection').''; } else { @@ -337,7 +365,7 @@ if ($action != 'edit' && $action != 'delete') { if ($user->rights->ecm->setup) { - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } else { @@ -354,21 +382,20 @@ if ($action != 'edit' && $action != 'delete') // Confirm remove file if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile'); - + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST("section",'alpha').'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile'); } // Confirm remove file if ($action == 'delete_dir') { $relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath); - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1); - + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1); } -$formfile=new FormFile($db); /* +$formfile=new FormFile($db); + // Display upload form if ($user->rights->ecm->upload) {