23 if (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:
35 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
46 if ($module ==
'ecm') {
47 $permtoadd = $user->rights->ecm->setup;
48 $permtoupload = $user->rights->ecm->upload;
51 if ($module ==
'medias') {
52 $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
53 $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
60 if (($action ==
'delete' || $action ==
'file_manager_delete') && empty($conf->use_javascript_ajax)) {
62 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section.
'&urlfile='.urlencode($_GET[
"urlfile"]), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'', 1);
67 <!-- Begin div
id=
"containerlayout" -->
68 <div
id=
"containerlayout">
69 <div
id=
"ecm-layout-north" class=
"toolbar largebutton">
73 print
'<div class="inline-block toolbarbutton centpercent">';
77 $websitekeyandpageid = (!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').(!empty($pageid) ?
'&pageid='.urlencode($pageid) :
'');
78 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')).
'">';
79 print
img_picto(
'',
'folder-plus',
'',
false, 0, 0,
'',
'size15x marginrightonly');
82 print
'<a id="acreatedir" href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans(
"NotAllowed").
'">';
83 print
img_picto(
'',
'folder-plus',
'disabled',
false, 0, 0,
'',
'size15x marginrightonly');
86 if ($module ==
'ecm') {
87 $tmpurl = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ?
'#' : ($_SERVER[
"PHP_SELF"].
'?action=refreshmanual'.($module ?
'&module='.$module :
'').($section ?
'&section='.$section :
'')));
88 print
'<a id="arefreshbutton" href="'.$tmpurl.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ReSyncListOfDir')).
'">';
89 print
img_picto(
'',
'refresh',
'id="refreshbutton"',
false, 0, 0,
'',
'size15x marginrightonly');
93 print
'<a id="agenerateimgwebp" href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmconvertimgwebp&token='.
newToken().
'&website='.$website->ref.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
"GenerateImgWebp")).
'">';
94 print
img_picto(
'',
'images',
'',
false, 0, 0,
'',
'size15x flip marginrightonly');
96 } elseif ($permtoadd && $module ==
'ecm') {
98 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")).
'">';
99 print
img_picto(
'',
'images',
'',
false, 0, 0,
'',
'size15x flip marginrightonly');
105 $('#acreatedir').on('click', function() {
107 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
108 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
113 console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
114 $('#acreatedir').attr('href', $('#acreatedir').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
115 console.log($('#acreatedir').attr('href'));
117 $('#agenerateimgwebp').on('click', function() {
119 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
120 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
125 console.log('We click to generate webp image, we set current section_dir='+section_dir+' into href url of button agenerateimgwebp');
126 $('#agenerateimgwebp').attr('href', $('#agenerateimgwebp').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
127 console.log($('#agenerateimgwebp').attr('href'));
132 $nameforformuserfile =
'formuserfileecm';
134 print
'<div class="inline-block valignmiddle floatright">';
137 if ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || !empty($section)) {
138 if ((empty($section) || $section == -1) && ($module !=
'medias')) {
141 jQuery(document).ready(
function() {
142 jQuery(
'#<?php echo $nameforformuserfile ?>').hide();
150 print
'<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.
' sectiondir='.$sectiondir.
' -->'.
"\n";
151 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
153 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);
167 <div
id=
"ecm-layout-west" class=
"inline-block">
173 if ($action ==
'delete_section') {
174 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
179 if ($action ==
'confirmconvertimgwebp') {
182 $section_dir=
GETPOST(
'section_dir',
'alpha');
183 $section=
GETPOST(
'section',
'alpha');
185 $formquestion[
'section_dir']=array(
'type'=>
'hidden',
'value'=>$section_dir,
'name'=>
'section_dir');
186 $formquestion[
'section']=array(
'type'=>
'hidden',
'value'=>$section,
'name'=>
'section');
187 if ($module ==
'medias') {
188 $formquestion[
'website']=array(
'type'=>
'hidden',
'value'=>$website->ref,
'name'=>
'website');
190 print
$form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'ConfirmImgWebpCreation'), $langs->trans(
'ConfirmGenerateImgWebp', $object->ref),
'convertimgwebp', $formquestion,
"yes", 1);
191 $action =
'file_manager';
195 if ($action ==
'convertimgwebp' && $permtoadd) {
196 if ($module ==
'medias') {
202 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
206 $filelist =
dol_dir_list($imagefolder,
"files", 0, $regeximgext);
210 foreach ($filelist as $filename) {
211 $filepath = $filename[
'fullname'];
212 if (!(substr_compare($filepath,
'webp', -strlen(
'webp')) === 0)) {
214 $filepathnoext = preg_replace(
"/\.[a-z0-9]+$/i",
"", $filepath);
234 $action =
'file_manager';
237 if (empty($action) || $action ==
'editfile' || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete') {
240 print
'<table class="liste centpercent">'.
"\n";
242 print
'<!-- Title for manual directories -->'.
"\n";
243 print
'<tr class="liste_titre">'.
"\n";
244 print
'<th class="liste_titre left">';
245 print
'<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans(
"ECMSections").
'</span>';
248 $showonrightsize =
'';
251 $htmltooltip = $langs->trans(
"ECMAreaDesc2");
253 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
256 print
'<tr><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).
'">';
257 if ($module ==
'medias') {
258 print $langs->trans(
"RootOfMedias");
260 print $langs->trans(
"Root");
262 print
'</a></div></td></tr>';
268 print
'<div id="filetree" class="ecmfiletree"></div>';
270 if ($action ==
'deletefile') {
271 print
$form->formconfirm(
'eeeee', $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'',
'deletefile');
276 print
'<tr><td style="padding-left: 20px">';
278 $_POST[
'modulepart'] = $module;
279 $_POST[
'openeddir'] =
GETPOST(
'openeddir');
280 $_POST[
'dir'] = empty($_POST[
'dir']) ?
'/' : $_POST[
'dir'];
283 print
'<div id="filetree" class="ecmfiletree">';
290 $url = DOL_URL_ROOT.
'/ecm/index.php';
292 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirtree.php';
306 <div
id=
"ecm-layout-center" class=
"inline-block">
307 <div
class=
"pane-in ecm-in-layout-center">
308 <div
id=
"ecmfileview" class=
"ecmfileview">
315 $url = DOL_URL_ROOT.
'/ecm/index.php';
317 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
326 </div> <!-- End div
id=
"containerlayout" -->
330 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
336 if (
GETPOST(
'section_dir',
'alpha')) {
337 $preopened =
GETPOST(
'section_dir',
'alpha');
340 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
344 <!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->