47 print
"Error, template page filemanager.tpl.php can't be called as URL";
52@phan-var-force Website $website
53@phan-var-force string $filepathnoext
54@phan-var-force string $pageid
55@phan-var-force EcmDirectory $ecmdir
56@phan-var-force ?string $module
57@phan-var-force int $section
58@phan-var-force string $websitekey
63<!-- BEGIN PHP TEMPLATE core/tpl/filemanager.tpl.php -->
64<!-- Doc of fileTree plugin at https:
68require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
82 $permtoadd = $user->hasRight(
"ecm",
"setup");
83 $permtoupload = $user->hasRight(
"ecm",
"upload");
87 $permtoadd = $user->hasRight(
"website",
"write");
88 $permtoupload = $user->hasRight(
"website",
"write");
92if (!isset($section)) {
97if (($action ==
'delete' || $action ==
'file_manager_delete') && empty(
$conf->use_javascript_ajax)) {
99 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'section' => $section,
'urlfile' =>
GETPOST(
"urlfile"))), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'', 1);
104<!-- Begin div
id=
"containerlayout" -->
105<div
id=
"containerlayout">
106<div
id=
"ecm-layout-north" class=
"toolbar largebutton">
110print
'<div class="inline-block toolbarbutton centpercent">';
114 $websitekeyandpageid = (!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').(!empty($pageid) ?
'&pageid='.urlencode((
string) $pageid) :
'');
115 $paramscreatedir = array(
'action' =>
'create',
'module' =>
$module);
116 if (!empty($websitekey)) {
117 $paramscreatedir[
'website'] = $websitekey;
119 if (!empty($pageid)) {
120 $paramscreatedir[
'pageid'] = $pageid;
122 $paramscreatedir[
'backtopage'] = $_SERVER[
"PHP_SELF"].
'?file_manager=1'.$websitekeyandpageid;
123 print
'<a id="acreatedir" href="'.dolBuildUrl(DOL_URL_ROOT.
'/ecm/dir_add_card.php', $paramscreatedir).
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ECMAddSection')).
'">';
124 print img_picto(
'',
'folder-plus',
'', 0, 0, 0,
'',
'size15x marginrightonly');
127 print
'<a id="acreatedir" href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans(
"NotAllowed").
'">';
128 print img_picto(
'',
'folder-plus',
'disabled', 0, 0, 0,
'',
'size15x marginrightonly');
135 $paramsrefresh = array(
'action' =>
'refreshmanual',
'module' =>
$module);
137 $paramsrefresh[
'section'] = $section;
139 $tmpurl =
dolBuildUrl($_SERVER[
"PHP_SELF"], $paramsrefresh);
141 print
'<a id="arefreshbutton" href="'.$tmpurl.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ReSyncListOfDir')).
'">';
142 print img_picto(
'',
'refresh',
'id="refreshbutton"', 0, 0, 0,
'',
'size15x marginrightonly');
147 print
'<a id="agenerateimgwebp" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'action' =>
'confirmconvertimgwebp',
'website' => $website->ref),
true).
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
"GenerateImgWebp")).
'">';
148 print img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
150} elseif ($permtoadd &&
$module ==
'ecm') {
152 print
'<a id="agenerateimgwebp" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'action' =>
'confirmconvertimgwebp'),
true).
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
"GenerateImgWebp")).
'">';
153 print img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
159$('#acreatedir').on('click', function() {
161 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
162 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
167 print
"section_dir.substring(0, section_dir.length - 1);";
177 print
"section_dir;";
181 console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
182 $('#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));
183 console.log($('#acreatedir').attr('href'));
185$('#agenerateimgwebp').on('click', function() {
187 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
188 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
193 console.log('We click to generate webp image, we set current section_dir='+section_dir+' into href url of button agenerateimgwebp');
194 $('#agenerateimgwebp').attr('href', $('#agenerateimgwebp').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
195 console.log($('#agenerateimgwebp').attr('href'));
200$nameforformuserfile =
'formuserfileecm';
202print
'<div class="inline-block valignmiddle floatright">';
206 if ((empty($section) || $section == -1) && (
$module !=
'medias')) {
209 jQuery(document).ready(
function() {
210 jQuery(
'#<?php echo $nameforformuserfile ?>').hide();
218 print
'<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.
' sectiondir='.$sectiondir.
' -->'.
"\n";
219 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
221 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);
235<div
id=
"ecm-layout-west" class=
"inline-block">
241if ($action ==
'delete_section') {
242 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'section' => $section)), $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
247if ($action ==
'confirmconvertimgwebp') {
250 $section_dir =
GETPOST(
'section_dir',
'alpha');
251 $section =
GETPOST(
'section',
'alpha');
252 $file =
GETPOST(
'filetoregenerate',
'alpha');
253 $form =
new Form($db);
254 $formquestion = array();
255 $formquestion[
'section_dir'] = array(
'type' =>
'hidden',
'value' => $section_dir,
'name' =>
'section_dir');
256 $formquestion[
'section'] = array(
'type' =>
'hidden',
'value' => $section,
'name' =>
'section');
257 $formquestion[
'filetoregenerate'] = array(
'type' =>
'hidden',
'value' => $file,
'name' =>
'filetoregenerate');
259 $formquestion[
'website'] = array(
'type' =>
'hidden',
'value' => $website->ref,
'name' =>
'website');
261 $paramsconvertimgwebp = array();
262 if (!empty($sortfield)) {
263 $paramsconvertimgwebp[
'sortfield'] = $sortfield;
265 if (!empty($sortorder)) {
266 $paramsconvertimgwebp[
'sortorder'] = $sortorder;
268 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], $paramsconvertimgwebp), empty($file) ? $langs->trans(
'ConfirmImgWebpCreation') : $langs->trans(
'ConfirmChosenImgWebpCreation'), empty($file) ? $langs->trans(
'ConfirmGenerateImgWebp') : $langs->trans(
'ConfirmGenerateChosenImgWebp', basename($file)),
'convertimgwebp', $formquestion,
"yes", 1);
269 $action =
'file_manager';
273if ($action ==
'convertimgwebp' && $permtoadd) {
274 $file =
GETPOST(
'filetoregenerate',
'alpha');
282 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
286 $filelist[][
"fullname"] =
dol_osencode($imagefolder.
'/'.$file);
290 $filelist =
dol_dir_list($imagefolder,
"files", 0, $regeximgext);
295 foreach ($filelist as $filename) {
296 $filepath = $filename[
'fullname'];
297 if (!(substr_compare($filepath,
'webp', -strlen(
'webp')) === 0)) {
298 if (!empty($file) || !
dol_is_file($filepathnoext.
'.webp')) {
300 $filepathnoext = preg_replace(
"/\.[a-z0-9]+$/i",
"", $filepath);
304 setEventMessages($result,
null,
'errors');
317 setEventMessages($langs->trans(
'SucessConvertChosenImgWebp'),
null);
319 setEventMessages($langs->trans(
'SucessConvertImgWebp'),
null);
322 $action =
'file_manager';
326if (empty($action) || $action ==
'editfile' || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete') {
329 print
'<table class="liste centpercent noborder">'.
"\n";
331 print
'<!-- Title for manual directories -->'.
"\n";
332 print
'<tr class="liste_titre">'.
"\n";
333 print
'<th class="liste_titre left">';
334 print
'<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans(
"ECMSections").
'</span>';
337 $showonrightsize =
'';
340 $htmltooltip = $langs->trans(
"ECMAreaDesc2a");
341 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
346 $paramsroot = array(
'file_manager' => 1);
347 if (!empty($websitekey)) {
348 $paramsroot[
'website'] = $websitekey;
350 $paramsroot[
'pageid'] = $pageid;
351 print
'<tr class="oddeven nohover"><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], $paramsroot).
'">';
353 print $langs->trans(
"RootOfMedias");
355 print $langs->trans(
"Root");
357 print
'</a></div></td></tr>';
360 print
'<tr class="oddeven nohover"><td>';
363 print
'<div id="filetree" class="ecmfiletree"></div>';
365 if ($action ==
'deletefile') {
366 print $form->formconfirm(
'eeeee', $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'',
'deletefile');
372 print
'<tr><td style="padding-left: 20px">';
374 $_POST[
'modulepart'] =
$module;
375 $_POST[
'openeddir'] =
GETPOST(
'openeddir');
376 $_POST[
'dir'] = empty($_POST[
'dir']) ?
'/' :
GETPOST(
'dir');
379 print
'<div id="filetree" class="ecmfiletree">';
386 $url = DOL_URL_ROOT.
'/ecm/index.php';
388 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirtree.php';
402<div
id=
"ecm-layout-center" class=
"inline-block">
403<div
class=
"pane-in ecm-in-layout-center">
404<div
id=
"ecmfileview" class=
"ecmfileview">
411 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
413 $url = DOL_URL_ROOT.
'/website/index.php';
415 $url = DOL_URL_ROOT.
'/ecm/index.php';
418include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
427</div> <!-- End div
id=
"containerlayout" -->
437 if (
GETPOST(
'section_dir',
'alpha')) {
438 $preopened =
GETPOST(
'section_dir',
'alpha');
441 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
445<!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->
if(! $sortfield) if(! $sortorder) $module
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.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizePathName($str, $newstr='_', $unaccent=0, $allowdash=0)
Clean a string to use it as a path name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
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.