34 print
"Error, template page filemanager.tpl.php can't be called as URL";
39@phan-var-force Website $website
40@phan-var-force string $filepathnoext
41@phan-var-force string $pageid
42@phan-var-force EcmDirectory $ecmdir
43@phan-var-force int $section
48<!-- BEGIN PHP TEMPLATE core/tpl/filemanager.tpl.php -->
49<!-- Doc of fileTree plugin at https:
53require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
66if ($module ==
'ecm') {
67 $permtoadd = $user->hasRight(
"ecm",
"setup");
68 $permtoupload = $user->hasRight(
"ecm",
"upload");
71if ($module ==
'medias') {
72 $permtoadd = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
73 $permtoupload = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
77if (!isset($section)) {
82if (($action ==
'delete' || $action ==
'file_manager_delete') && empty(
$conf->use_javascript_ajax)) {
84 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section.
'&urlfile='.urlencode(
GETPOST(
"urlfile")), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'', 1);
89<!-- Begin div
id=
"containerlayout" -->
90<div
id=
"containerlayout">
91<div
id=
"ecm-layout-north" class=
"toolbar largebutton">
95print
'<div class="inline-block toolbarbutton centpercent">';
99 $websitekeyandpageid = (!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').(!empty($pageid) ?
'&pageid='.urlencode((
string) $pageid) :
'');
100 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')).
'">';
101 print
img_picto(
'',
'folder-plus',
'', 0, 0, 0,
'',
'size15x marginrightonly');
104 print
'<a id="acreatedir" href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans(
"NotAllowed").
'">';
105 print
img_picto(
'',
'folder-plus',
'disabled', 0, 0, 0,
'',
'size15x marginrightonly');
108if ($module ==
'ecm') {
109 $tmpurl = ((!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_ECM_DISABLE_JS')) ?
'#' : ($_SERVER[
"PHP_SELF"].
'?action=refreshmanual'.($module ?
'&module='.$module :
'').($section ?
'&section='.$section :
'')));
110 print
'<a id="arefreshbutton" href="'.$tmpurl.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ReSyncListOfDir')).
'">';
111 print
img_picto(
'',
'refresh',
'id="refreshbutton"', 0, 0, 0,
'',
'size15x marginrightonly');
114if ($permtoadd && GETPOSTISSET(
'website')) {
116 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")).
'">';
117 print
img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
119} elseif ($permtoadd && $module ==
'ecm') {
121 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")).
'">';
122 print
img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
128$('#acreatedir').on('click', function() {
130 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
131 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
133if ($module ==
'ecm') {
136 print
"section_dir.substring(0, section_dir.length - 1);";
143if ($module ==
'ecm') {
146 print
"section_dir;";
150 console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
151 $('#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));
152 console.log($('#acreatedir').attr('href'));
154$('#agenerateimgwebp').on('click', function() {
156 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
157 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
162 console.log('We click to generate webp image, we set current section_dir='+section_dir+' into href url of button agenerateimgwebp');
163 $('#agenerateimgwebp').attr('href', $('#agenerateimgwebp').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
164 console.log($('#agenerateimgwebp').attr('href'));
169$nameforformuserfile =
'formuserfileecm';
171print
'<div class="inline-block valignmiddle floatright">';
175 if ((empty($section) || $section == -1) && ($module !=
'medias')) {
178 jQuery(document).ready(
function() {
179 jQuery(
'#<?php echo $nameforformuserfile ?>').hide();
187 print
'<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.
' sectiondir='.$sectiondir.
' -->'.
"\n";
188 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
190 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);
204<div
id=
"ecm-layout-west" class=
"inline-block">
210if ($action ==
'delete_section') {
211 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
216if ($action ==
'confirmconvertimgwebp') {
219 $section_dir =
GETPOST(
'section_dir',
'alpha');
220 $section =
GETPOST(
'section',
'alpha');
221 $file =
GETPOST(
'filetoregenerate',
'alpha');
222 $form =
new Form($db);
223 $formquestion = array();
224 $formquestion[
'section_dir'] = array(
'type' =>
'hidden',
'value' => $section_dir,
'name' =>
'section_dir');
225 $formquestion[
'section'] = array(
'type' =>
'hidden',
'value' => $section,
'name' =>
'section');
226 $formquestion[
'filetoregenerate'] = array(
'type' =>
'hidden',
'value' => $file,
'name' =>
'filetoregenerate');
227 if ($module ==
'medias') {
228 $formquestion[
'website'] = array(
'type' =>
'hidden',
'value' => $website->ref,
'name' =>
'website');
231 if (!empty($sortfield)) {
232 $param .=
'&sortfield='.urlencode($sortfield);
234 if (!empty($sortorder)) {
235 $param .=
'&sortorder='.urlencode($sortorder);
237 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);
238 $action =
'file_manager';
242if ($action ==
'convertimgwebp' && $permtoadd) {
243 $file =
GETPOST(
'filetoregenerate',
'alpha');
245 if ($module ==
'medias') {
251 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
255 $filelist[][
"fullname"] =
dol_osencode($imagefolder.
'/'.$file);
259 $filelist =
dol_dir_list($imagefolder,
"files", 0, $regeximgext);
264 foreach ($filelist as $filename) {
265 $filepath = $filename[
'fullname'];
266 if (!(substr_compare($filepath,
'webp', -strlen(
'webp')) === 0)) {
267 if (!empty($file) || !
dol_is_file($filepathnoext.
'.webp')) {
269 $filepathnoext = preg_replace(
"/\.[a-z0-9]+$/i",
"", $filepath);
291 $action =
'file_manager';
295if (empty($action) || $action ==
'editfile' || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete') {
298 print
'<table class="liste centpercent noborder">'.
"\n";
300 print
'<!-- Title for manual directories -->'.
"\n";
301 print
'<tr class="liste_titre">'.
"\n";
302 print
'<th class="liste_titre left">';
303 print
'<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans(
"ECMSections").
'</span>';
306 $showonrightsize =
'';
309 $htmltooltip = $langs->trans(
"ECMAreaDesc2a");
310 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
315 print
'<tr class="oddeven nohover"><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.$_SERVER[
"PHP_SELF"].
'?file_manager=1'.(!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').
'&pageid='.urlencode((
string) $pageid).
'">';
316 if ($module ==
'medias') {
317 print $langs->trans(
"RootOfMedias");
319 print $langs->trans(
"Root");
321 print
'</a></div></td></tr>';
324 print
'<tr class="oddeven nohover"><td>';
327 print
'<div id="filetree" class="ecmfiletree"></div>';
329 if ($action ==
'deletefile') {
330 print $form->formconfirm(
'eeeee', $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'',
'deletefile');
336 print
'<tr><td style="padding-left: 20px">';
338 $_POST[
'modulepart'] = $module;
339 $_POST[
'openeddir'] =
GETPOST(
'openeddir');
340 $_POST[
'dir'] = empty($_POST[
'dir']) ?
'/' :
GETPOST(
'dir');
343 print
'<div id="filetree" class="ecmfiletree">';
350 $url = DOL_URL_ROOT.
'/ecm/index.php';
352 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirtree.php';
366<div
id=
"ecm-layout-center" class=
"inline-block">
367<div
class=
"pane-in ecm-in-layout-center">
368<div
id=
"ecmfileview" class=
"ecmfileview">
374 if (!empty($module) && $module ==
'medias' && !
GETPOST(
'website')) {
375 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
376 } elseif (GETPOSTISSET(
'website')) {
377 $url = DOL_URL_ROOT.
'/website/index.php';
379 $url = DOL_URL_ROOT.
'/ecm/index.php';
382include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
391</div> <!-- End div
id=
"containerlayout" -->
401 if (
GETPOST(
'section_dir',
'alpha')) {
402 $preopened =
GETPOST(
'section_dir',
'alpha');
405 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
409<!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...