dolibarr  13.0.2
filemanager.tpl.php
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  *
17  * Output code for the filemanager
18  * $module must be defined ('ecm', 'medias', ...)
19  */
20 
21 // Protection to avoid direct call of template
22 if (empty($conf) || !is_object($conf))
23 {
24  print "Error, template page filemanager.tpl.php can't be called as URL";
25  exit;
26 }
27 
28 ?>
29 
30 <!-- BEGIN PHP TEMPLATE core/tpl/filemanager.tpl.php -->
31 <!-- Doc of fileTree plugin at https://www.abeautifulsite.net/jquery-file-tree -->
32 
33 <?php
34 
35 require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
36 
37 if (empty($module)) $module = 'ecm';
38 
39 $permtoadd = 0;
40 $permtoupload = 0;
41 $showroot = 0;
42 if ($module == 'ecm')
43 {
44  $permtoadd = $user->rights->ecm->setup;
45  $permtoupload = $user->rights->ecm->upload;
46  $showroot = 0;
47 }
48 if ($module == 'medias')
49 {
50  $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write);
51  $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write);
52  $showroot = 1;
53 }
54 
55 
56 
57 // Confirm remove file (for non javascript users)
58 if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax))
59 {
60  // TODO Add website, pageid, filemanager if defined
61  print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
62 }
63 
64 // Start container of all panels
65 ?>
66 <!-- Begin div id="containerlayout" -->
67 <div id="containerlayout">
68 <div id="ecm-layout-north" class="toolbar largebutton">
69 <?php
70 
71 // Start top panel, toolbar
72 print '<div class="inline-block toolbarbutton centpercent">';
73 
74 // Toolbar
75 if ($permtoadd)
76 {
77  print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&module='.urlencode($module).($websitekey ? '&website='.$websitekey : '').($pageid ? '&pageid='.$pageid : '').'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid).'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
78  print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
79  print '</a>';
80 } else {
81  print '<a href="#" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.$langs->trans("NotAllowed").'">';
82  print '<img class="toolbarbutton disabled" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
83  print '</a>';
84 }
85 if ($module == 'ecm')
86 {
87  $tmpurl = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&amp;module='.$module : '').($section ? '&amp;section='.$section : '')));
88  print '<a href="'.$tmpurl.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
89  print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
90  print '</a>';
91 }
92 
93 // Start "Add new file" area
94 $nameforformuserfile = 'formuserfileecm';
95 
96 print '<div class="inline-block valignmiddle floatright">';
97 
98 // To attach new file
99 if ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || !empty($section))
100 {
101  if ((empty($section) || $section == -1) && ($module != 'medias'))
102  {
103  ?>
104  <script>
105  jQuery(document).ready(function() {
106  jQuery('#<?php echo $nameforformuserfile ?>').hide();
107  });
108  </script>
109  <?php
110  }
111 
112  $sectiondir = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
113  print '<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.' sectiondir='.$sectiondir.' -->'."\n";
114  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
115  $formfile = new FormFile($db);
116  $formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section ? $section : -1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir);
117 } else print '&nbsp;';
118 
119 print '</div>';
120 // End "Add new file" area
121 
122 
123 print '</div>';
124 // End top panel, toolbar
125 
126 ?>
127 </div>
128 <div id="ecm-layout-west" class="inline-block">
129 <?php
130 // Start left area
131 
132 
133 // Ask confirmation of deletion of directory
134 if ($action == 'delete_section')
135 {
136  print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
137 }
138 // End confirm
139 
140 
141 if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'delete')
142 {
143  $langs->load("ecm");
144 
145  print '<table width="100%" class="liste noborderbottom">'."\n";
146 
147  print '<!-- Title for manual directories -->'."\n";
148  print '<tr class="liste_titre">'."\n";
149  print '<th class="liste_titre left">';
150  print '&nbsp;'.$langs->trans("ECMSections");
151  print '</th></tr>';
152 
153  $showonrightsize = '';
154 
155  // Manual section
156  $htmltooltip = $langs->trans("ECMAreaDesc2");
157 
158  if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
159  {
160  // Show the link to "Root"
161  if ($showroot)
162  {
163  print '<tr><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.$_SERVER["PHP_SELF"].'?file_manager=1&pageid='.$pageid.'">';
164  if ($module == 'medias') print $langs->trans("RootOfMedias");
165  else print $langs->trans("Root");
166  print '</a></div></td></tr>';
167  }
168 
169  print '<tr><td>';
170 
171  // Show filemanager tree (will be filled by a call of ajax /ecm/tpl/enablefiletreeajax.tpl.php, later, that executes ajaxdirtree.php)
172  print '<div id="filetree" class="ecmfiletree"></div>';
173 
174  if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
175 
176  print '</td></tr>';
177  } else { // Show filtree when ajax is disabled (rare)
178  print '<tr><td style="padding-left: 20px">';
179 
180  $_POST['modulepart'] = $module;
181  $_POST['openeddir'] = GETPOST('openeddir');
182  $_POST['dir'] = empty($_POST['dir']) ? '/' : $_POST['dir'];
183 
184  // Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show)
185  print '<div id="filetree" class="ecmfiletree">';
186 
187  // Variables that may be defined:
188  // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
189  // $_POST['dir']
190  $mode = 'noajax';
191  if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php';
192  include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
193 
194  print '</div>';
195  print '</td></tr>';
196  }
197 
198 
199  print "</table>";
200 }
201 
202 
203 // End left panel
204 ?>
205 </div>
206 <div id="ecm-layout-center" class="inline-block">
207 <div class="pane-in ecm-in-layout-center">
208 <div id="ecmfileview" class="ecmfileview">
209 <?php
210 // Start right panel - List of content of a directory
211 
212 
213 $mode = 'noajax';
214 if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php';
215 include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; // Show content of a directory on right side
216 
217 
218 // End right panel
219 ?>
220 </div>
221 </div>
222 
223 </div>
224 </div> <!-- End div id="containerlayout" -->
225 <?php
226 
227 
228 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) // Show filtree when ajax is enabled
229 {
230  //var_dump($modulepart);
231  // Variables that may be defined:
232  // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
233  // $_POST['dir']
234  // $_POST['section_dir'], $_POST['section_id'], $_POST['token'], $_POST['max_file_size'], $_POST['sendit']
235  if (GETPOST('section_dir', 'alpha')) { $preopened = GETPOST('section_dir', 'alpha'); }
236 
237  include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
238 }
239 
240 ?>
241 <!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...