34 print
"Error, template page filemanager.tpl.php can't be called as URL";
40<!-- BEGIN PHP TEMPLATE core/tpl/filemanager.tpl.php -->
41<!-- Doc of fileTree plugin at https:
45require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
53'@phan-var-force Website $website';
60if ($module ==
'ecm') {
61 $permtoadd = $user->hasRight(
"ecm",
"setup");
62 $permtoupload = $user->hasRight(
"ecm",
"upload");
65if ($module ==
'medias') {
66 $permtoadd = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
67 $permtoupload = ($user->hasRight(
"mailing",
"creer") || $user->hasRight(
"website",
"write"));
71if (!isset($section)) {
76if (($action ==
'delete' || $action ==
'file_manager_delete') && empty(
$conf->use_javascript_ajax)) {
78 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section.
'&urlfile='.urlencode(
GETPOST(
"urlfile")), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'', 1);
83<!-- Begin div
id=
"containerlayout" -->
84<div
id=
"containerlayout">
85<div
id=
"ecm-layout-north" class=
"toolbar largebutton">
89print
'<div class="inline-block toolbarbutton centpercent">';
93 $websitekeyandpageid = (!empty($websitekey) ?
'&website='.urlencode($websitekey) :
'').(!empty($pageid) ?
'&pageid='.urlencode((
string) $pageid) :
'');
94 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')).
'">';
95 print
img_picto(
'',
'folder-plus',
'', 0, 0, 0,
'',
'size15x marginrightonly');
98 print
'<a id="acreatedir" href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans(
"NotAllowed").
'">';
99 print
img_picto(
'',
'folder-plus',
'disabled', 0, 0, 0,
'',
'size15x marginrightonly');
102if ($module ==
'ecm') {
103 $tmpurl = ((!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_ECM_DISABLE_JS')) ?
'#' : ($_SERVER[
"PHP_SELF"].
'?action=refreshmanual'.($module ?
'&module='.$module :
'').($section ?
'&section='.$section :
'')));
104 print
'<a id="arefreshbutton" href="'.$tmpurl.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'ReSyncListOfDir')).
'">';
105 print
img_picto(
'',
'refresh',
'id="refreshbutton"', 0, 0, 0,
'',
'size15x marginrightonly');
108if ($permtoadd && GETPOSTISSET(
'website')) {
109 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")).
'">';
110 print
img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
112} elseif ($permtoadd && $module ==
'ecm') {
114 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")).
'">';
115 print
img_picto(
'',
'images',
'', 0, 0, 0,
'',
'size15x flip marginrightonly');
121$('#acreatedir').on('click', function() {
123 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
124 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
126if ($module ==
'ecm') {
129 print
"section_dir.substring(0, section_dir.length - 1);";
136if ($module ==
'ecm') {
139 print
"section_dir;";
143 console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir');
144 $('#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));
145 console.log($('#acreatedir').attr('href'));
147$('#agenerateimgwebp').on('click', function() {
149 section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel;
150 section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2];
155 console.log('We click to generate webp image, we set current section_dir='+section_dir+' into href url of button agenerateimgwebp');
156 $('#agenerateimgwebp').attr('href', $('#agenerateimgwebp').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section));
157 console.log($('#agenerateimgwebp').attr('href'));
162$nameforformuserfile =
'formuserfileecm';
164print
'<div class="inline-block valignmiddle floatright">';
168 if ((empty($section) || $section == -1) && ($module !=
'medias')) {
171 jQuery(document).ready(
function() {
172 jQuery(
'#<?php echo $nameforformuserfile ?>').hide();
180 print
'<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.
' sectiondir='.$sectiondir.
' -->'.
"\n";
181 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
183 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);
197<div
id=
"ecm-layout-west" class=
"inline-block">
203if ($action ==
'delete_section') {
204 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
209if ($action ==
'confirmconvertimgwebp') {
212 $section_dir =
GETPOST(
'section_dir',
'alpha');
213 $section =
GETPOST(
'section',
'alpha');
214 $file =
GETPOST(
'filetoregenerate',
'alpha');
215 $form =
new Form($db);
216 $formquestion = array();
217 $formquestion[
'section_dir'] = array(
'type' =>
'hidden',
'value' => $section_dir,
'name' =>
'section_dir');
218 $formquestion[
'section'] = array(
'type' =>
'hidden',
'value' => $section,
'name' =>
'section');
219 $formquestion[
'filetoregenerate'] = array(
'type' =>
'hidden',
'value' => $file,
'name' =>
'filetoregenerate');
220 if ($module ==
'medias') {
221 $formquestion[
'website'] = array(
'type' =>
'hidden',
'value' => $website->ref,
'name' =>
'website');
224 if (!empty($sortfield)) {
225 $param .=
'&sortfield='.urlencode($sortfield);
227 if (!empty($sortorder)) {
228 $param .=
'&sortorder='.urlencode($sortorder);
230 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);
231 $action =
'file_manager';
235if ($action ==
'convertimgwebp' && $permtoadd) {
236 $file =
GETPOST(
'filetoregenerate',
'alpha');
238 if ($module ==
'medias') {
244 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
248 $filelist[][
"fullname"] =
dol_osencode($imagefolder.
'/'.$file);
252 $filelist =
dol_dir_list($imagefolder,
"files", 0, $regeximgext);
257 foreach ($filelist as $filename) {
258 $filepath = $filename[
'fullname'];
259 if (!(substr_compare($filepath,
'webp', -strlen(
'webp')) === 0)) {
260 if (!empty($file) || !
dol_is_file($filepathnoext.
'.webp')) {
262 $filepathnoext = preg_replace(
"/\.[a-z0-9]+$/i",
"", $filepath);
284 $action =
'file_manager';
288if (empty($action) || $action ==
'editfile' || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete') {
291 print
'<table class="liste centpercent noborder">'.
"\n";
293 print
'<!-- Title for manual directories -->'.
"\n";
294 print
'<tr class="liste_titre">'.
"\n";
295 print
'<th class="liste_titre left">';
296 print
'<span style="padding-left: 5px; padding-right: 5px;">'.$langs->trans(
"ECMSections").
'</span>';
299 $showonrightsize =
'';
302 $htmltooltip = $langs->trans(
"ECMAreaDesc2a");
303 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
308 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).
'">';
309 if ($module ==
'medias') {
310 print $langs->trans(
"RootOfMedias");
312 print $langs->trans(
"Root");
314 print
'</a></div></td></tr>';
317 print
'<tr class="oddeven nohover"><td>';
320 print
'<div id="filetree" class="ecmfiletree"></div>';
322 if ($action ==
'deletefile') {
323 print $form->formconfirm(
'eeeee', $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'',
'deletefile');
329 print
'<tr><td style="padding-left: 20px">';
331 $_POST[
'modulepart'] = $module;
332 $_POST[
'openeddir'] =
GETPOST(
'openeddir');
333 $_POST[
'dir'] = empty($_POST[
'dir']) ?
'/' :
GETPOST(
'dir');
336 print
'<div id="filetree" class="ecmfiletree">';
343 $url = DOL_URL_ROOT.
'/ecm/index.php';
345 include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirtree.php';
359<div
id=
"ecm-layout-center" class=
"inline-block">
360<div
class=
"pane-in ecm-in-layout-center">
361<div
id=
"ecmfileview" class=
"ecmfileview">
367 if (!empty($module) && $module ==
'medias' && !
GETPOST(
'website')) {
368 $url = DOL_URL_ROOT.
'/ecm/index_medias.php';
369 } elseif (GETPOSTISSET(
'website')) {
370 $url = DOL_URL_ROOT.
'/website/index.php';
372 $url = DOL_URL_ROOT.
'/ecm/index.php';
375include DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
384</div> <!-- End div
id=
"containerlayout" -->
394 if (
GETPOST(
'section_dir',
'alpha')) {
395 $preopened =
GETPOST(
'section_dir',
'alpha');
398 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
402<!-- 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)
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...