* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Output code for the filemanager * $module must be defined ('ecm', 'medias', ...) * $formalreadyopen can be set to 1 to avoid to open the
to submit files a second time */ // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page filemanager.tpl.php can't be called as URL"; exit; } ?> load("ecm"); if (empty($module)) { $module = 'ecm'; } $permtoadd = 0; $permtoupload = 0; $showroot = 0; if ($module == 'ecm') { $permtoadd = $user->hasRight("ecm", "setup"); $permtoupload = $user->hasRight("ecm", "upload"); $showroot = 0; } if ($module == 'medias') { $permtoadd = ($user->hasRight("mailing", "creer") || $user->hasRight("website", "write")); $permtoupload = ($user->hasRight("mailing", "creer") || $user->hasRight("website", "write")); $showroot = 1; } if (!isset($section)) { $section = 0; } // Confirm remove file (for non javascript users) if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax)) { // TODO Add website, pageid, filemanager if defined print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1); } // Start container of all panels ?>
'; // Toolbar if ($permtoadd) { $websitekeyandpageid = (!empty($websitekey) ? '&website='.urlencode($websitekey) : '').(!empty($pageid) ? '&pageid='.urlencode($pageid) : ''); print ''; print img_picto('', 'folder-plus', '', false, 0, 0, '', 'size15x marginrightonly'); print ''; } else { print ''; print img_picto('', 'folder-plus', 'disabled', false, 0, 0, '', 'size15x marginrightonly'); print ''; } if ($module == 'ecm') { $tmpurl = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&module='.$module : '').($section ? '&section='.$section : ''))); print ''; print img_picto('', 'refresh', 'id="refreshbutton"', false, 0, 0, '', 'size15x marginrightonly'); print ''; } if ($permtoadd && GETPOSTISSET('website')) { // If on file manager to manage medias of a web site print 'ref.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans("GenerateImgWebp")).'">'; print img_picto('', 'images', '', false, 0, 0, '', 'size15x flip marginrightonly'); print ''; } elseif ($permtoadd && $module == 'ecm') { // If on file manager medias in ecm if (getDolGlobalInt('ECM_SHOW_GENERATE_WEBP_BUTTON')) { print ''; print img_picto('', 'images', '', false, 0, 0, '', 'size15x flip marginrightonly'); print ''; } } print ""; // Start "Add new file" area $nameforformuserfile = 'formuserfileecm'; print '
'; // For to attach a new file if ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || !empty($section)) { if ((empty($section) || $section == -1) && ($module != 'medias')) { ?> '."\n"; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); print $formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section ? $section : -1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir, empty($formalreadyopen) ? 0 : $formalreadyopen, 0, 0, 1); } else { print ' '; } print '
'; // End "Add new file" area print '
'; // End top panel, toolbar ?>
formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1); } // End confirm // Ask confirmation to build webp images if ($action == 'confirmconvertimgwebp') { $langs->load("ecm"); $section_dir=GETPOST('section_dir', 'alpha'); $section=GETPOST('section', 'alpha'); $form = new Form($db); $formquestion['section_dir']=array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); $formquestion['section']=array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); if ($module == 'medias') { $formquestion['website']=array('type'=>'hidden', 'value'=>$website->ref, 'name'=>'website'); } print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('ConfirmImgWebpCreation'), $langs->trans('ConfirmGenerateImgWebp', $object->ref), 'convertimgwebp', $formquestion, "yes", 1); $action = 'file_manager'; } // Duplicate images into .webp if ($action == 'convertimgwebp' && $permtoadd) { if ($module == 'medias') { $imagefolder = $conf->website->dir_output.'/'.$websitekey.'/medias/'.dol_sanitizePathName(GETPOST('section_dir', 'alpha')); } else { $imagefolder = $conf->ecm->dir_output.'/'.dol_sanitizePathName(GETPOST('section_dir', 'alpha')); } include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $regeximgext = getListOfPossibleImageExt(); $filelist = dol_dir_list($imagefolder, "files", 0, $regeximgext); $nbconverted = 0; foreach ($filelist as $filename) { $filepath = $filename['fullname']; if (!(substr_compare($filepath, 'webp', -strlen('webp')) === 0)) { if (image_format_supported($filepath) == 1) { $filepathnoext = preg_replace("/\.[a-z0-9]+$/i", "", $filepath); if (! dol_is_file($filepathnoext.'.webp')) { // If file does not exists yet $result = dol_imageResizeOrCrop($filepath, 0, 0, 0, 0, 0, $filepathnoext.'.webp', 90); if (!dol_is_file($result)) { $error++; setEventMessages($result, null, 'errors'); } else { $nbconverted++; } } } } if ($error) { break; } } if (!$error) { setEventMessages($langs->trans('SucessConvertImgWebp'), null); } $action = 'file_manager'; } if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete') { $langs->load("ecm"); print ''."\n"; print ''."\n"; print ''."\n"; print ''; $showonrightsize = ''; // Manual section $htmltooltip = $langs->trans("ECMAreaDesc2a"); $htmltooltip .= '
'.$langs->trans("ECMAreaDesc2b"); if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { // Show the link to "Root" if ($showroot) { print ''; } print ''; } else { // Show filtree when ajax is disabled (rare) print ''; } print "
'; print ''.$langs->trans("ECMSections").''; print '
'; // Show filemanager tree (will be filled by a call of ajax /ecm/tpl/enablefiletreeajax.tpl.php, later, that executes ajaxdirtree.php) print '
'; if ($action == 'deletefile') { print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile'); } print '
'; $_POST['modulepart'] = $module; $_POST['openeddir'] = GETPOST('openeddir'); $_POST['dir'] = empty($_POST['dir']) ? '/' : $_POST['dir']; // Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show) print '
'; // Variables that may be defined: // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder'] // $_POST['dir'] $mode = 'noajax'; if (empty($url)) { $url = DOL_URL_ROOT.'/ecm/index.php'; } include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php'; print '
'; print '
"; } // End left panel ?>
use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { // Show filtree when ajax is enabled //var_dump($modulepart); // Variables that may be defined: // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder'] // $_POST['dir'] // $_POST['section_dir'], $_POST['section_id'], $_POST['token'], $_POST['max_file_size'], $_POST['sendit'] if (GETPOST('section_dir', 'alpha')) { $preopened = GETPOST('section_dir', 'alpha'); } include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php'; } ?>