23if (empty($conf) || !is_object($conf)) {
24 print
"Error, template page filemanager.tpl.php can't be called as URL";
30<!-- BEGIN PHP TEMPLATE core/tpl/filemanager.tpl.php -->
31<!-- Doc of fileTree plugin at https:
35require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
46if ($module ==
'ecm') {
47 $permtoadd = $user->hasRight(
"ecm",
"setup");
48 $permtoupload = $user->hasRight(
"ecm",
"upload");
51if ($module ==
'medias') {
52 $permtoadd = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
53 $permtoupload = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
57if (!isset($section)) {
62if (($action ==
'delete' || $action ==
'file_manager_delete') && empty($conf->use_javascript_ajax)) {
64 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section.
'&urlfile='.urlencode($_GET[
"urlfile"]), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'', 1);
69<!-- Begin div
id=
"containerlayout" -->
70<div
id=
"containerlayout">
71<div
id=
"ecm-layout-north" class=
"toolbar largebutton">
75print
'<div class="inline-block toolbarbutton centpercent">';
79 $websitekeyandpageid = (!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').(!empty($pageid) ?
'&pageid='.urlencode($pageid) :
'');
80 print
'<a id="acreatedir" href="'.DOL_URL_ROOT.
'/ecm/dir_add_card.php?action=create&module='.urlencode($module).$websitekeyandpageid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?file_manager=1'.$websitekeyandpageid).
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ECMAddSection')).
'">';
81 print
img_picto(
'',
'folder-plus',
'',
false, 0, 0,
'',
'size15x marginrightonly');
84 print
'<a id="acreatedir" href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans(
"NotAllowed").
'">';
85 print
img_picto(
'',
'folder-plus',
'disabled',
false, 0, 0,
'',
'size15x marginrightonly');
88if ($module ==
'ecm') {
89 $tmpurl = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ?
'#' : ($_SERVER[
"PHP_SELF"].
'?action=refreshmanual'.($module ?
'&module='.$module :
'').($section ?
'&section='.$section :
'')));
90 print
'<a id="arefreshbutton" href="'.$tmpurl.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ReSyncListOfDir')).
'">';
91 print
img_picto(
'',
'refresh',
'id="refreshbutton"',
false, 0, 0,
'',
'size15x marginrightonly');
94if ($permtoadd && GETPOSTISSET(
'website')) {
95 print
'<a id="agenerateimgwebp" href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmconvertimgwebp&token='.newToken().
'&website='.urlencode($website->ref).
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
"GenerateImgWebp")).
'">';
96 print
img_picto(
'',
'images',
'',
false, 0, 0,
'',
'size15x flip marginrightonly');
98} elseif ($permtoadd && $module ==
'ecm') {
100 print
'<a id="agenerateimgwebp" href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmconvertimgwebp&token='.newToken().
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
"GenerateImgWebp")).
'">';
101 print
img_picto(
'',
'images',
'',
false, 0, 0,
'',
'size15x flip marginrightonly');
107$('#acreatedir').on('click', function() {
109 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
110 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
112if ($module ==
'ecm') {
115 print
"section_dir.substring(0, section_dir.length - 1);";
122if ($module ==
'ecm') {
125 print
"section_dir;";
129 console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
130 $('#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));
131 console.log($('#acreatedir').attr('href'));
133$('#agenerateimgwebp').on('click', function() {
135 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
136 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
141 console.log('We click to generate webp image, we set current section_dir='+section_dir+' into href url of button agenerateimgwebp');
142 $('#agenerateimgwebp').attr('href', $('#agenerateimgwebp').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
143 console.log($('#agenerateimgwebp').attr('href'));
148$nameforformuserfile =
'formuserfileecm';
150print
'<div class="inline-block valignmiddle floatright">';
153if ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || !empty($section)) {
154 if ((empty($section) || $section == -1) && ($module !=
'medias')) {
157 jQuery(document).ready(
function() {
158 jQuery(
'#<?php echo $nameforformuserfile ?>').hide();
166 print
'<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.
' sectiondir='.$sectiondir.
' -->'.
"\n";
167 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
169 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);
183<div
id=
"ecm-layout-west" class=
"inline-block">
189if ($action ==
'delete_section') {
190 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
195if ($action ==
'confirmconvertimgwebp') {
198 $section_dir=
GETPOST(
'section_dir',
'alpha');
199 $section=
GETPOST(
'section',
'alpha');
200 $file=
GETPOST(
'filetoregenerate',
'alpha');
201 $form =
new Form($db);
202 $formquestion[
'section_dir']=array(
'type'=>
'hidden',
'value'=>$section_dir,
'name'=>
'section_dir');
203 $formquestion[
'section']=array(
'type'=>
'hidden',
'value'=>$section,
'name'=>
'section');
204 $formquestion[
'filetoregenerate']=array(
'type'=>
'hidden',
'value'=>$file,
'name'=>
'filetoregenerate');
205 if ($module ==
'medias') {
206 $formquestion[
'website']=array(
'type'=>
'hidden',
'value'=>$website->ref,
'name'=>
'website');
209 if (!empty($sortfield)) $param .=
'&sortfield='.urlencode($sortfield);
210 if (!empty($sortorder)) $param .=
'&sortorder='.urlencode($sortorder);
211 print $form->formconfirm($_SERVER[
"PHP_SELF"].($param ?
'?'.$param :
''), empty($file) ? $langs->trans(
'ConfirmImgWebpCreation') : $langs->trans(
'ConfirmChosenImgWebpCreation'), empty($file) ? $langs->trans(
'ConfirmGenerateImgWebp') : $langs->trans(
'ConfirmGenerateChosenImgWebp', basename($file)),
'convertimgwebp', $formquestion,
"yes", 1);
212 $action =
'file_manager';
216if ($action ==
'convertimgwebp' && $permtoadd) {
217 $file =
GETPOST(
'filetoregenerate',
'alpha');
219 if ($module ==
'medias') {
225 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
229 $filelist[][
"fullname"] =
dol_osencode($imagefolder.
'/'.$file);
233 $filelist =
dol_dir_list($imagefolder,
"files", 0, $regeximgext);
238 foreach ($filelist as $filename) {
239 $filepath = $filename[
'fullname'];
240 if (!(substr_compare($filepath,
'webp', -strlen(
'webp')) === 0)) {
241 if (!empty($file) || !
dol_is_file($filepathnoext.
'.webp')) {
243 $filepathnoext = preg_replace(
"/\.[a-z0-9]+$/i",
"", $filepath);
265 $action =
'file_manager';
268if (empty($action) || $action ==
'editfile' || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete') {
271 print
'<table class="liste centpercent">'.
"\n";
273 print
'<!-- Title for manual directories -->'.
"\n";
274 print
'<tr class="liste_titre">'.
"\n";
275 print
'<th class="liste_titre left">';
276 print
'<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans(
"ECMSections").
'</span>';
279 $showonrightsize =
'';
282 $htmltooltip = $langs->trans(
"ECMAreaDesc2a");
283 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
285 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
288 print
'<tr class="nooddeven"><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.$_SERVER[
"PHP_SELF"].
'?file_manager=1'.(!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').
'&pageid='.urlencode($pageid).
'">';
289 if ($module ==
'medias') {
290 print $langs->trans(
"RootOfMedias");
292 print $langs->trans(
"Root");
294 print
'</a></div></td></tr>';
297 print
'<tr class="nooddeven"><td>';
300 print
'<div id="filetree" class="ecmfiletree"></div>';
302 if ($action ==
'deletefile') {
303 print $form->formconfirm(
'eeeee', $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'',
'deletefile');
309 print
'<tr><td style="padding-left: 20px">';
311 $_POST[
'modulepart'] = $module;
312 $_POST[
'openeddir'] =
GETPOST(
'openeddir');
313 $_POST[
'dir'] = empty($_POST[
'dir']) ?
'/' : $_POST[
'dir'];
316 print
'<div id="filetree" class="ecmfiletree">';
323 $url = DOL_URL_ROOT.
'/ecm/index.php';
325 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirtree.php';
339<div
id=
"ecm-layout-center" class=
"inline-block">
340<div
class=
"pane-in ecm-in-layout-center">
341<div
id=
"ecmfileview" class=
"ecmfileview">
347 if (!empty($module) && $module ==
'medias' && !
GETPOST(
'website')) {
348 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
349 } elseif (GETPOSTISSET(
'website')) {
350 $url = DOL_URL_ROOT.
'/website/index.php';
352 $url = DOL_URL_ROOT.
'/ecm/index.php';
355include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
364</div> <!-- End div
id=
"containerlayout" -->
368if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
374 if (
GETPOST(
'section_dir',
'alpha')) {
375 $preopened =
GETPOST(
'section_dir',
'alpha');
378 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
382<!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizePathName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a path name.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getListOfPossibleImageExt($acceptsvg=0)
Return if a filename is file name of a supported image format.
dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0, $filetowrite='', $newquality=0)
Resize or crop an image file (Supported extensions are gif, jpg, png, bmp and webp)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.