dolibarr  9.0.0
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 <http://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" 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 }
81 else
82 {
83  print '<a href="#" class="inline-block valignmiddle toolbarbutton" title="'.$langs->trans("NotAllowed").'">';
84  print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
85  print '</a>';
86 }
87 if ($module == 'ecm')
88 {
89  $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:'')));
90  print '<a href="'.$tmpurl.'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ReSyncListOfDir')).'">';
91  print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
92  print '</a>';
93 }
94 
95 // Start "Add new file" area
96 $nameforformuserfile = 'formuserfileecm';
97 
98 print '<div class="inline-block valignmiddle floatright">';
99 
100 // To attach new file
101 if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
102 {
103  if ((empty($section) || $section == -1) && ($module != 'medias'))
104  {
105  ?>
106  <script type="text/javascript">
107  jQuery(document).ready(function() {
108  jQuery('#<?php echo $nameforformuserfile ?>').hide();
109  });
110  </script>
111  <?php
112  }
113 
114  $sectiondir=GETPOST('file','alpha')?GETPOST('file','alpha'):GETPOST('section_dir','alpha');
115  print '<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.' sectiondir='.$sectiondir.' -->'."\n";
116  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
117  $formfile=new FormFile($db);
118  $formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir);
119 }
120 else print '&nbsp;';
121 
122 print '</div>';
123 // End "Add new file" area
124 
125 
126 print '</div>';
127 // End top panel, toolbar
128 
129 ?>
130 </div>
131 <div id="ecm-layout-west" class="inline-block">
132 <?php
133 // Start left area
134 
135 
136 // Confirmation de la suppression d'une ligne categorie
137 if ($action == 'delete_section')
138 {
139  print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
140 }
141 // End confirm
142 
143 
144 if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
145 {
146  $langs->load("ecm");
147 
148  print '<table width="100%" class="liste noborderbottom">'."\n";
149 
150  print '<!-- Title for manual directories -->'."\n";
151  print '<tr class="liste_titre">'."\n";
152  print '<th class="liste_titre" align="left">';
153  print '&nbsp;'.$langs->trans("ECMSections");
154  print '</th></tr>';
155 
156  $showonrightsize='';
157 
158  // Manual section
159  $htmltooltip=$langs->trans("ECMAreaDesc2");
160 
161  if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
162  {
163  // Show the link to "Root"
164  if ($showroot)
165  {
166  print '<tr><td><div style="padding-left: 5px; padding-right: 5px;"><a href="'.$_SERVER["PHP_SELF"].'?file_manager=1&pageid='.$pageid.'">'.$langs->trans("Root").'</a></div></td></tr>';
167  }
168 
169 
170 
171  print '<tr><td>';
172 
173  // Show filemanager tree (will be filled by a call of ajax /ecm/tpl/enablefiletreeajax.tpl.php, later, that executes ajaxdirtree.php)
174  print '<div id="filetree" class="ecmfiletree"></div>';
175 
176  if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
177 
178  print '</td></tr>';
179  }
180  else // Show filtree when ajax is disabled (rare)
181  {
182  print '<tr><td style="padding-left: 20px">';
183 
184  $_POST['modulepart'] = $module;
185  $_POST['openeddir'] = GETPOST('openeddir');
186  $_POST['dir'] = empty($_POST['dir'])?'/':$_POST['dir'];
187 
188  // Show filemanager tree (will be filled by direct include of ajaxdirtree.php in mode noajax, this will return all dir - all levels - to show)
189  print '<div id="filetree" class="ecmfiletree">';
190 
191  // Variables that may be defined:
192  // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
193  // $_POST['dir']
194  $mode='noajax';
195  if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
196  include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirtree.php';
197 
198  print '</div>';
199  print '</td></tr>';
200  }
201 
202 
203  print "</table>";
204 }
205 
206 
207 // End left panel
208 ?>
209 </div>
210 <div id="ecm-layout-center" class="inline-block">
211 <div class="pane-in ecm-in-layout-center">
212 <div id="ecmfileview" class="ecmfileview">
213 <?php
214 // Start right panel
215 
216 
217 $mode='noajax';
218 if (empty($url)) $url=DOL_URL_ROOT.'/ecm/index.php';
219 include DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php'; // Show content of a directory on right side
220 
221 
222 // End right panel
223 ?>
224 </div>
225 </div>
226 
227 </div>
228 </div> <!-- End div id="containerlayout" -->
229 <?php
230 
231 
232 if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) // Show filtree when ajax is enabled
233 {
234  //var_dump($modulepart);
235  // Variables that may be defined:
236  // $_GET['modulepart'], $_GET['openeddir'], $_GET['sortfield'], $_GET['sortorder']
237  // $_POST['dir']
238  // $_POST['section_dir'], $_POST['section_id'], $_POST['token'], $_POST['max_file_size'], $_POST['sendit']
239  if (GETPOST('section_dir','alpha')) { $preopened=GETPOST('section_dir','alpha'); }
240 
241  include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
242 }
243 
244 ?>
245 <!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
type
Definition: viewcat.php:284
Class to offer components to list and upload files.