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">
110$paramspopuparray = array();
111foreach (array(
'dol_hide_topmenu',
'dol_hide_leftmenu') as $tmpparam) {
113 $paramspopuparray[$tmpparam] =
GETPOSTINT($tmpparam);
116if (
GETPOST(
'dol_openinpopup',
'aZ09')) {
117 $paramspopuparray[
'dol_openinpopup'] =
GETPOST(
'dol_openinpopup',
'aZ09');
119$paramspopup = (empty($paramspopuparray) ?
'' :
'&'.http_build_query($paramspopuparray));
122print
'<div class="inline-block toolbarbutton centpercent">';
126 $websitekeyandpageid = (!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').(!empty($pageid) ?
'&pageid='.urlencode((
string) $pageid) :
'');
127 $paramscreatedir = array(
'action' =>
'create',
'module' =>
$module);
128 if (!empty($websitekey)) {
129 $paramscreatedir[
'website'] = $websitekey;
131 if (!empty($pageid)) {
132 $paramscreatedir[
'pageid'] = $pageid;
134 $paramscreatedir = array_merge($paramscreatedir, $paramspopuparray);
135 $paramscreatedir[
'backtopage'] = $_SERVER[
"PHP_SELF"].
'?file_manager=1'.$websitekeyandpageid.$paramspopup;
136 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')).
'">';
137 print img_picto(
'',
'folder-plus',
'', 0, 0, 0,
'',
'size15x marginrightonly');
140 print
'<a id="acreatedir" href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans(
"NotAllowed").
'">';
141 print img_picto(
'',
'folder-plus',
'disabled', 0, 0, 0,
'',
'size15x marginrightonly');
148 $paramsrefresh = array(
'action' =>
'refreshmanual',
'module' =>
$module);
150 $paramsrefresh[
'section'] = $section;
152 $tmpurl =
dolBuildUrl($_SERVER[
"PHP_SELF"], $paramsrefresh);
154 print
'<a id="arefreshbutton" href="'.$tmpurl.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ReSyncListOfDir')).
'">';
155 print img_picto(
'',
'refresh',
'id="refreshbutton"', 0, 0, 0,
'',
'size15x marginrightonly');
160 print
'<a id="agenerateimgwebp" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], array_merge(array(
'action' =>
'confirmconvertimgwebp',
'website' => $website->ref), $paramspopuparray),
true).
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
"GenerateImgWebp")).
'">';
161 print img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
163} elseif ($permtoadd &&
$module ==
'ecm') {
165 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")).
'">';
166 print img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
172$('#acreatedir').on('click', function() {
174 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
175 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
180 print
"section_dir.substring(0, section_dir.length - 1);";
190 print
"section_dir;";
194 console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
195 $('#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));
196 console.log($('#acreatedir').attr('href'));
198$('#agenerateimgwebp').on('click', function() {
200 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
201 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
206 console.log('We click to generate webp image, we set current section_dir='+section_dir+' into href url of button agenerateimgwebp');
207 $('#agenerateimgwebp').attr('href', $('#agenerateimgwebp').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
208 console.log($('#agenerateimgwebp').attr('href'));
213$nameforformuserfile =
'formuserfileecm';
215print
'<div class="inline-block valignmiddle floatright">';
219 if ((empty($section) || $section == -1) && (
$module !=
'medias')) {
222 jQuery(document).ready(
function() {
223 jQuery(
'#<?php echo $nameforformuserfile ?>').hide();
231 print
'<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.
' sectiondir='.$sectiondir.
' -->'.
"\n";
232 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
234 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);
248<div
id=
"ecm-layout-west" class=
"inline-block">
254if ($action ==
'delete_section') {
255 print $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], array(
'section' => $section)), $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
260if ($action ==
'confirmconvertimgwebp') {
263 $section_dir =
GETPOST(
'section_dir',
'alpha');
264 $section =
GETPOST(
'section',
'alpha');
265 $file =
GETPOST(
'filetoregenerate',
'alpha');
266 $form =
new Form($db);
267 $formquestion = array();
268 $formquestion[
'section_dir'] = array(
'type' =>
'hidden',
'value' => $section_dir,
'name' =>
'section_dir');
269 $formquestion[
'section'] = array(
'type' =>
'hidden',
'value' => $section,
'name' =>
'section');
270 $formquestion[
'filetoregenerate'] = array(
'type' =>
'hidden',
'value' => $file,
'name' =>
'filetoregenerate');
272 $formquestion[
'website'] = array(
'type' =>
'hidden',
'value' => $website->ref,
'name' =>
'website');
274 $paramsconvertimgwebp = $paramspopuparray;
275 if (!empty($sortfield)) {
276 $paramsconvertimgwebp[
'sortfield'] = $sortfield;
278 if (!empty($sortorder)) {
279 $paramsconvertimgwebp[
'sortorder'] = $sortorder;
281 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);
282 $action =
'file_manager';
286if ($action ==
'convertimgwebp' && $permtoadd) {
287 $file =
GETPOST(
'filetoregenerate',
'alpha');
295 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
299 $filelist[][
"fullname"] =
dol_osencode($imagefolder.
'/'.$file);
303 $filelist =
dol_dir_list($imagefolder,
"files", 0, $regeximgext);
308 foreach ($filelist as $filename) {
309 $filepath = $filename[
'fullname'];
310 if (!(substr_compare($filepath,
'webp', -strlen(
'webp')) === 0)) {
311 if (!empty($file) || !
dol_is_file($filepathnoext.
'.webp')) {
313 $filepathnoext = preg_replace(
"/\.[a-z0-9]+$/i",
"", $filepath);
317 setEventMessages($result,
null,
'errors');
330 setEventMessages($langs->trans(
'SucessConvertChosenImgWebp'),
null);
332 setEventMessages($langs->trans(
'SucessConvertImgWebp'),
null);
335 $action =
'file_manager';
339if (empty($action) || $action ==
'editfile' || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete') {
342 print
'<table class="liste centpercent noborder">'.
"\n";
344 print
'<!-- Title for manual directories -->'.
"\n";
345 print
'<tr class="liste_titre">'.
"\n";
346 print
'<th class="liste_titre left">';
347 print
'<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans(
"ECMSections").
'</span>';
350 $showonrightsize =
'';
353 $htmltooltip = $langs->trans(
"ECMAreaDesc2a");
354 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
359 $paramsroot = array(
'file_manager' => 1);
360 if (!empty($websitekey)) {
361 $paramsroot[
'website'] = $websitekey;
363 $paramsroot[
'pageid'] = $pageid;
364 print
'<tr class="oddeven nohover"><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], $paramsroot).
'">';
366 print $langs->trans(
"RootOfMedias");
368 print $langs->trans(
"Root");
370 print
'</a></div></td></tr>';
373 print
'<tr class="oddeven nohover"><td>';
376 print
'<div id="filetree" class="ecmfiletree"></div>';
378 if ($action ==
'deletefile') {
379 print $form->formconfirm(
'eeeee', $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'',
'deletefile');
385 print
'<tr><td style="padding-left: 20px">';
387 $_POST[
'modulepart'] =
$module;
388 $_POST[
'openeddir'] =
GETPOST(
'openeddir');
389 $_POST[
'dir'] = empty($_POST[
'dir']) ?
'/' :
GETPOST(
'dir');
392 print
'<div id="filetree" class="ecmfiletree">';
399 $url = DOL_URL_ROOT.
'/ecm/index.php';
401 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirtree.php';
415<div
id=
"ecm-layout-center" class=
"inline-block">
416<div
class=
"pane-in ecm-in-layout-center">
417<div
id=
"ecmfileview" class=
"ecmfileview">
424 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
426 $url = DOL_URL_ROOT.
'/website/index.php';
428 $url = DOL_URL_ROOT.
'/ecm/index.php';
431include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
440</div> <!-- End div
id=
"containerlayout" -->
450 if (
GETPOST(
'section_dir',
'alpha')) {
451 $preopened =
GETPOST(
'section_dir',
'alpha');
454 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
458<!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.