1 | <?php |
---|
2 | |
---|
3 | /* * ************************************************************************\ |
---|
4 | * -------------------------------------------------------------------------* |
---|
5 | * This library is free software; you can redistribute it and/or modify it * |
---|
6 | * under the terms of the GNU Lesser General Public License as published by * |
---|
7 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
8 | * or any later version. * |
---|
9 | * This library is distributed in the hope that it will be useful, but * |
---|
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
---|
12 | * See the GNU Lesser General Public License for more details. * |
---|
13 | * You should have received a copy of the GNU Lesser General Public License * |
---|
14 | * along with this library; if not, write to the Free Software Foundation, * |
---|
15 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
16 | \************************************************************************* */ |
---|
17 | |
---|
18 | /* $Id: class.uifilemanager.inc.php 17511 2004-12-12 06:35:24Z dawnlinux $ */ |
---|
19 | |
---|
20 | class uifilemanager { |
---|
21 | |
---|
22 | var $public_functions = array( |
---|
23 | 'index' => True, |
---|
24 | 'help' => True, |
---|
25 | 'view' => True, |
---|
26 | 'export' => True, |
---|
27 | 'touch' => True, |
---|
28 | 'history' => True, |
---|
29 | 'edit' => True, |
---|
30 | 'fileModels' => True, |
---|
31 | 'getReturnExecuteForm' => True, |
---|
32 | 'dir_ls' => True, |
---|
33 | 'search' => True, |
---|
34 | 'setFileMaxSize' => True, |
---|
35 | 'get_folders_list' => True, |
---|
36 | 'showUploadboxes' => True, |
---|
37 | 'createdir' => True, |
---|
38 | 'removedir' => True, |
---|
39 | 'uploadModel' => True |
---|
40 | ); |
---|
41 | //keep |
---|
42 | var $bo; |
---|
43 | var $vfs_functions; |
---|
44 | var $t; //template object |
---|
45 | var $dispath; |
---|
46 | var $cwd; |
---|
47 | var $lesspath; |
---|
48 | var $readable_groups; |
---|
49 | var $files_array; |
---|
50 | var $numoffiles; |
---|
51 | var $dispsep; |
---|
52 | var $target; |
---|
53 | var $prefs; //array |
---|
54 | var $groups_applications; |
---|
55 | var $current_config; |
---|
56 | var $dirs; |
---|
57 | var $to; |
---|
58 | var $changedir; // for switching dir. |
---|
59 | var $cdtodir; // for switching dir. |
---|
60 | var $newfile_or_dir; |
---|
61 | var $newfile_x; |
---|
62 | var $createfile_var; |
---|
63 | var $move_to_x; |
---|
64 | var $copy_to_x; |
---|
65 | var $edit_x; |
---|
66 | var $edit_file; |
---|
67 | var $edit_preview_x; |
---|
68 | var $edit_save_x; |
---|
69 | var $edit_save_done_x; |
---|
70 | var $edit_cancel_x; |
---|
71 | // this ones must be checked thorougly; |
---|
72 | var $fileman = Array(); |
---|
73 | //var $fileman; |
---|
74 | var $path; |
---|
75 | var $file; // FIXME WHERE IS THIS FILLED? |
---|
76 | var $sortby; |
---|
77 | var $messages; |
---|
78 | var $limit; //for paging (paginacao) |
---|
79 | var $offset; //for paging (paginacao) |
---|
80 | var $now; |
---|
81 | |
---|
82 | function uifilemanager() { |
---|
83 | $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages']; |
---|
84 | |
---|
85 | $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser'); |
---|
86 | |
---|
87 | $this->now = date('Y-m-d'); |
---|
88 | |
---|
89 | $this->bo = CreateObject('filemanager.bofilemanager'); |
---|
90 | |
---|
91 | $this->vfs_functions = CreateObject('filemanager.vfs_functions'); |
---|
92 | |
---|
93 | $this->t = $GLOBALS['phpgw']->template; |
---|
94 | $c = CreateObject('phpgwapi.config', 'filemanager'); |
---|
95 | $c->read_repository(); |
---|
96 | |
---|
97 | $this->current_config = $c->config_data; |
---|
98 | |
---|
99 | // here local vars are created from the HTTP vars |
---|
100 | @reset($GLOBALS['HTTP_POST_VARS']); |
---|
101 | while (list($name, ) = @each($GLOBALS['HTTP_POST_VARS'])) { |
---|
102 | $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; |
---|
103 | } |
---|
104 | |
---|
105 | @reset($GLOBALS['HTTP_GET_VARS']); |
---|
106 | while (list($name, ) = @each($GLOBALS['HTTP_GET_VARS'])) { |
---|
107 | $$name = $GLOBALS['HTTP_GET_VARS'][$name]; |
---|
108 | $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; |
---|
109 | } |
---|
110 | |
---|
111 | $to_decode = array |
---|
112 | ( |
---|
113 | 'op' => array('op' => ''), |
---|
114 | 'path' => array('path' => ''), |
---|
115 | 'filename' => array('filename' => ''), |
---|
116 | 'file' => array('file' => ''), |
---|
117 | 'sortby' => array('sortby' => ''), |
---|
118 | 'messages' => array('messages' => ''), |
---|
119 | 'show_upload_boxes' => array('show_upload_boxes' => ''), |
---|
120 | 'from' => array('from' => ''), |
---|
121 | 'to' => array('to' => '') |
---|
122 | ); |
---|
123 | |
---|
124 | reset($to_decode); |
---|
125 | while (list($var, $conditions) = each($to_decode)) { |
---|
126 | while (list($condvar, $condvalue) = each($conditions)) { |
---|
127 | if (isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) { |
---|
128 | $this->$var = stripslashes(base64_decode($$var)); |
---|
129 | } |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | // get appl. and user prefs |
---|
134 | $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']); |
---|
135 | $pref->read_repository(); |
---|
136 | //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']); |
---|
137 | $pref->save_repository(True); |
---|
138 | $pref_array = $pref->read_repository(); |
---|
139 | $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array |
---|
140 | //always show name |
---|
141 | |
---|
142 | $this->prefs[name] = 1; |
---|
143 | |
---|
144 | |
---|
145 | if ($this->prefs['viewinnewwin']) { |
---|
146 | $this->target = '_blank'; |
---|
147 | } |
---|
148 | |
---|
149 | |
---|
150 | /* |
---|
151 | Check for essential directories |
---|
152 | admin must be able to disable these tests |
---|
153 | */ |
---|
154 | |
---|
155 | // check if basedir exist |
---|
156 | $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
157 | if ($test[mime_type] != 'Directory') { |
---|
158 | die('Base directory does not exist, Ask adminstrator to check the global configuration.'); |
---|
159 | } |
---|
160 | |
---|
161 | $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
162 | if ($test[mime_type] != 'Directory') { |
---|
163 | $this->bo->vfs->override_acl = 1; |
---|
164 | |
---|
165 | $this->bo->vfs->mkdir(array( |
---|
166 | 'string' => $this->bo->fakebase, |
---|
167 | 'relatives' => array(RELATIVE_NONE) |
---|
168 | )); |
---|
169 | |
---|
170 | $this->bo->vfs->override_acl = 0; |
---|
171 | |
---|
172 | //test one more time |
---|
173 | $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
174 | |
---|
175 | if ($test[mime_type] != 'Directory') { |
---|
176 | die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); |
---|
177 | } else { |
---|
178 | $this->messages[] = lang('Fake Base Dir did not exist, created a new one.'); |
---|
179 | } |
---|
180 | } |
---|
181 | |
---|
182 | $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
183 | if ($test[mime_type] != 'Directory') { |
---|
184 | |
---|
185 | $c_admin = CreateObject('phpgwapi.config', 'expressoAdmin1_2'); |
---|
186 | $c_admin->read_repository(); |
---|
187 | if($c_admin->config_data['expressoAdmin_cotasOu']) |
---|
188 | $this->generate_error(lang("You have access to the application, but you have no quota. Please contact your administrator")); |
---|
189 | |
---|
190 | $this->bo->vfs->override_acl = 1; |
---|
191 | |
---|
192 | $this->bo->vfs->mkdir(array( |
---|
193 | 'string' => $this->bo->homedir, |
---|
194 | 'relatives' => array(RELATIVE_NONE) |
---|
195 | )); |
---|
196 | $this->bo->vfs->set_quota(array( |
---|
197 | 'string' => $this->bo->homedir, |
---|
198 | 'relatives' => array(RELATIVE_NONE), |
---|
199 | 'new_quota' => $this->current_config['filemanager_quota_size']?$this->current_config['filemanager_quota_size']:0 |
---|
200 | )); |
---|
201 | |
---|
202 | $this->bo->vfs->override_acl = 0; |
---|
203 | |
---|
204 | //test one more time |
---|
205 | $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
206 | |
---|
207 | if ($test[mime_type] != 'Directory') { |
---|
208 | die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); |
---|
209 | } else { |
---|
210 | $this->messages[] = lang('Your Home Dir did not exist, eGroupWare created a new one.'); |
---|
211 | // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content |
---|
212 | } |
---|
213 | } |
---|
214 | |
---|
215 | } |
---|
216 | |
---|
217 | function generate_error($error) { |
---|
218 | $template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/filemanager/templates/'.$GLOBALS['phpgw_info']['server']['template_set']); |
---|
219 | $template->set_file( |
---|
220 | Array( |
---|
221 | 'error_model' => 'errors.tpl' |
---|
222 | ) |
---|
223 | ); |
---|
224 | $template->set_block('error_model','error_page'); |
---|
225 | $template->set_var("errors",$error); |
---|
226 | $GLOBALS['phpgw_info']['flags'] = array |
---|
227 | ( |
---|
228 | 'currentapp' => 'filemanager', |
---|
229 | 'noheader' => False, |
---|
230 | 'nonavbar' => False, |
---|
231 | 'nofooter' => False, |
---|
232 | 'noappheader' => False, |
---|
233 | 'enable_browser_class' => True |
---|
234 | ); |
---|
235 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
236 | $template->pfp('out','error_page'); |
---|
237 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
238 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
239 | } |
---|
240 | |
---|
241 | function fileModels() { |
---|
242 | $GLOBALS['phpgw_info']['flags'] = array |
---|
243 | ( |
---|
244 | 'currentapp' => 'filemanager', |
---|
245 | 'noheader' => False, |
---|
246 | 'nonavbar' => False, |
---|
247 | 'nofooter' => False, |
---|
248 | 'noappheader' => False, |
---|
249 | 'enable_browser_class' => True |
---|
250 | ); |
---|
251 | |
---|
252 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
253 | $this->t->set_file(array('models' => 'fileModels.tpl')); |
---|
254 | $this->t->set_block('models', 'header', 'header'); |
---|
255 | $this->t->set_block('models', 'body', 'body'); |
---|
256 | $this->t->set_block('models', 'footer', 'footer'); |
---|
257 | $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); |
---|
258 | $this->t->set_var('model_1', 'article'); |
---|
259 | $this->t->set_var('lang_1', lang('article')); |
---|
260 | |
---|
261 | $this->t->set_var('url_2', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); |
---|
262 | $this->t->set_var('model_2', 'calendar'); |
---|
263 | $this->t->set_var('lang_2', lang('calendar')); |
---|
264 | |
---|
265 | $this->t->set_var('url_3', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); |
---|
266 | $this->t->set_var('model_3', 'todo'); |
---|
267 | $this->t->set_var('lang_3', lang('todo')); |
---|
268 | |
---|
269 | $this->t->set_var('url_4', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); |
---|
270 | $this->t->set_var('model_4', 'slide'); |
---|
271 | $this->t->set_var('lang_4', lang('slide')); |
---|
272 | |
---|
273 | $this->t->set_var('url_5', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); |
---|
274 | $this->t->set_var('model_5', 'cards'); |
---|
275 | $this->t->set_var('lang_5', lang('cards')); |
---|
276 | |
---|
277 | $this->t->set_var('url_6', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); |
---|
278 | $this->t->set_var('model_6', 'resume'); |
---|
279 | $this->t->set_var('lang_6', lang('resume')); |
---|
280 | |
---|
281 | |
---|
282 | $this->t->pparse('out', 'models'); |
---|
283 | } |
---|
284 | |
---|
285 | function uploadModel() { |
---|
286 | $GLOBALS['phpgw_info']['flags'] = array |
---|
287 | ( |
---|
288 | 'currentapp' => 'filemanager', |
---|
289 | 'noheader' => False, |
---|
290 | 'nonavbar' => False, |
---|
291 | 'nofooter' => False, |
---|
292 | 'noappheader' => False, |
---|
293 | 'enable_browser_class' => True |
---|
294 | ); |
---|
295 | |
---|
296 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
297 | |
---|
298 | $filename = lang('new') . "_" . lang($this->model) . rand(0, 1000) . ".html"; |
---|
299 | $this->bo->vfs->cp(array( |
---|
300 | 'from' => PHPGW_SERVER_ROOT . '/filemanager/templates/default/' . $this->model . '.html', |
---|
301 | 'to' => $filename, |
---|
302 | 'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL) |
---|
303 | )); |
---|
304 | |
---|
305 | $this->bo->vfs->set_attributes(array( |
---|
306 | 'string' => $filename, |
---|
307 | 'relatives' => array(RELATIVE_ALL), |
---|
308 | 'attributes' => array( |
---|
309 | 'mime_type' => "text/html", |
---|
310 | 'comment' => "" |
---|
311 | ) |
---|
312 | )); |
---|
313 | $this->filename = $filename; |
---|
314 | $this->edit(); |
---|
315 | } |
---|
316 | |
---|
317 | function index() { |
---|
318 | $GLOBALS['phpgw_info']['flags'] = array |
---|
319 | ( |
---|
320 | 'currentapp' => 'filemanager', |
---|
321 | 'noheader' => False, |
---|
322 | 'nonavbar' => False, |
---|
323 | 'nofooter' => False, |
---|
324 | 'noappheader' => False, |
---|
325 | 'enable_browser_class' => True |
---|
326 | ); |
---|
327 | |
---|
328 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
329 | |
---|
330 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/inc/load_lang.php'></script>"; |
---|
331 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/global.js'></script>"; |
---|
332 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/main.js'></script>"; |
---|
333 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/common_functions.js'></script>"; |
---|
334 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/connector.js'></script>"; |
---|
335 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/draw_api.js'></script>"; |
---|
336 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/drag_area.js'></script>"; |
---|
337 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/handler.js'></script>"; |
---|
338 | |
---|
339 | //echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/NewHandler.js'></script>"; |
---|
340 | |
---|
341 | |
---|
342 | // Temas Expresso |
---|
343 | $theme = "window_" . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . ".css"; |
---|
344 | |
---|
345 | if (!file_exists('filemanager/tp/expressowindow/css/' . $theme)) |
---|
346 | $theme = "window_default.css"; |
---|
347 | |
---|
348 | // Path FileManager |
---|
349 | $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; |
---|
350 | $webserver_url = (!empty($webserver_url) ) ? $webserver_url : '/'; |
---|
351 | |
---|
352 | if (strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url) - 1)) |
---|
353 | $webserver_url .= '/'; |
---|
354 | |
---|
355 | $webserver_url = $webserver_url . 'filemanager/'; |
---|
356 | |
---|
357 | $js = "var path_filemanager = '" . $webserver_url . "';"; |
---|
358 | $js .= "var my_home_filemanager = '" . trim($GLOBALS['uifilemanager']->bo->vfs->my_home) . "';"; |
---|
359 | |
---|
360 | echo "<script type='text/javascript'>" . $js . "</script>"; |
---|
361 | |
---|
362 | // Expresso Window - CSS |
---|
363 | print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/' . $theme . '" >'; |
---|
364 | |
---|
365 | // Expresso Window - JS |
---|
366 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/xtools.js'></script>"; |
---|
367 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/jsloader.js'></script>"; |
---|
368 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/makeW.js'></script>"; |
---|
369 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/dragdrop.js'></script>"; |
---|
370 | echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/show_hidden.js'></script>"; |
---|
371 | |
---|
372 | echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>"; |
---|
373 | |
---|
374 | # Page to process users |
---|
375 | # Code is fairly hackish at the beginning, but it gets better |
---|
376 | # Highly suggest turning wrapping off due to long SQL queries |
---|
377 | ### |
---|
378 | # Some hacks to set and display directory paths correctly |
---|
379 | ### |
---|
380 | // new method for switching to a new dir. |
---|
381 | if ($this->changedir == 'true' && $this->cdtodir || $this->goto_x) { |
---|
382 | $this->path = $this->cdtodir; |
---|
383 | } |
---|
384 | |
---|
385 | if (!$this->path) { |
---|
386 | $this->path = $this->bo->vfs->pwd(); |
---|
387 | |
---|
388 | if (!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') { |
---|
389 | $this->path = $this->bo->homedir; |
---|
390 | } |
---|
391 | } |
---|
392 | |
---|
393 | $this->bo->vfs->cd(array('string' => False, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
394 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
395 | |
---|
396 | $pwd = $this->bo->vfs->pwd(); |
---|
397 | |
---|
398 | if (!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) { |
---|
399 | $this->cwd = '/'; |
---|
400 | } else { |
---|
401 | $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); |
---|
402 | } |
---|
403 | |
---|
404 | $this->disppath = $this->path; |
---|
405 | |
---|
406 | /* This just prevents // in some cases */ |
---|
407 | if ($this->path == '/') { |
---|
408 | $this->dispsep = ''; |
---|
409 | } else { |
---|
410 | $this->dispsep = '/'; |
---|
411 | } |
---|
412 | |
---|
413 | if (!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) { |
---|
414 | $this->lesspath = '/'; |
---|
415 | } |
---|
416 | |
---|
417 | /* Check permission */ |
---|
418 | if ($this->bo->vfs->acl_check(array( |
---|
419 | 'string' => $this->path, |
---|
420 | 'relatives' => array(RELATIVE_NONE), |
---|
421 | 'operation' => PHPGW_ACL_READ |
---|
422 | ))) { |
---|
423 | $this->can_read = True; |
---|
424 | } |
---|
425 | |
---|
426 | |
---|
427 | if ( $_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed' ) { |
---|
428 | /* Flush journal-deleted */ |
---|
429 | $this->bo->vfs->flush_journal(array( |
---|
430 | 'string' => $this->path, |
---|
431 | 'relatives' => array(RELATIVE_NONE), |
---|
432 | 'deleteall' => True |
---|
433 | )); |
---|
434 | $_SESSION['phpgw_info']['user']['filemanager']['flush'] = 'flushed'; |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | |
---|
439 | # if is different path than home and no permission allowed |
---|
440 | if ($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) { |
---|
441 | $this->messages[] = lang('You do not have access to %1', $this->path); |
---|
442 | $this->path = $this->homedir; |
---|
443 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
444 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
445 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
446 | } |
---|
447 | |
---|
448 | $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id; |
---|
449 | $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']); |
---|
450 | |
---|
451 | # Verify path is real |
---|
452 | if ($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) { |
---|
453 | if (!$this->bo->vfs->file_exists(array( |
---|
454 | 'string' => $this->path, |
---|
455 | 'relatives' => array(RELATIVE_NONE) |
---|
456 | ))) { |
---|
457 | $this->messages[] = lang('Error:') . lang('Directory %1 does not exist', $this->path); |
---|
458 | $this->path = $this->homedir; |
---|
459 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
460 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
461 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
462 | } |
---|
463 | } |
---|
464 | |
---|
465 | |
---|
466 | # Default is to sort by name |
---|
467 | if (!$this->sortby) { |
---|
468 | $this->sortby = 'name'; |
---|
469 | } |
---|
470 | if ($this->update_x == 1) { |
---|
471 | $this->bo->vfs->update_real(array( |
---|
472 | 'string' => $this->path, |
---|
473 | 'relatives' => array(RELATIVE_NONE) |
---|
474 | )); |
---|
475 | header('Location:' . $this->encode_href('index.php?menuaction=filemanager.uifilemanager.index', '&path=' . base64_encode($this->bo->homedir))); |
---|
476 | } elseif ($this->newfile_x && $this->newfile_or_dir) { // create new textfile |
---|
477 | $this->createfile(); |
---|
478 | } elseif ($this->edit_cancel_x) { |
---|
479 | $this->readFilesInfo(); |
---|
480 | $this->fileListing(); |
---|
481 | } elseif ($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) { |
---|
482 | $this->edit(); |
---|
483 | } else { |
---|
484 | //$this->readFilesInfo(); |
---|
485 | $this->fileListing(); |
---|
486 | } |
---|
487 | } |
---|
488 | |
---|
489 | function setFileMaxSize() |
---|
490 | { |
---|
491 | $maxSize = $_POST['maxFileSize']; |
---|
492 | $file = "setFileMaxSize.php"; |
---|
493 | $writeFile = "<?php $"."SET_FILE_MAX_SIZE="."\"".base64_encode(serialize($maxSize))."\""." ?>"; |
---|
494 | $filename = dirname(__FILE__).'/'.$file; |
---|
495 | $content = $writeFile; |
---|
496 | |
---|
497 | if ( !$handle = fopen($filename, 'w+') ) |
---|
498 | return false; |
---|
499 | |
---|
500 | if (fwrite($handle, $content) === FALSE) |
---|
501 | return false; |
---|
502 | |
---|
503 | fclose($handle); |
---|
504 | |
---|
505 | return true; |
---|
506 | } |
---|
507 | |
---|
508 | function get_permissions() { |
---|
509 | /* get permissions */ |
---|
510 | if ((preg_match('+^' . $this->bo->fakebase . '\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) { //FIXME matches not defined |
---|
511 | $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); //FIXME matches not defined |
---|
512 | } else { |
---|
513 | $this->bo->vfs->working_id = $this->bo->userinfo['username']; |
---|
514 | } |
---|
515 | |
---|
516 | # Check available permissions for $this->path, so we can disable unusable operations in user interface |
---|
517 | $path = explode('/', $this->path); |
---|
518 | $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase, $path[2]); |
---|
519 | $user_id = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
520 | if ($owner_id == $user_id) { |
---|
521 | $rights = 31; |
---|
522 | } else { |
---|
523 | $acl = CreateObject('phpgwapi.acl', $owner_id); |
---|
524 | $acl->account_id = $owner_id; |
---|
525 | $acl->read_repository(); |
---|
526 | $rights = $acl->get_rights($user_id); |
---|
527 | } |
---|
528 | return $rights; |
---|
529 | } |
---|
530 | |
---|
531 | function dir_ls() { |
---|
532 | // change dir to this->path |
---|
533 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
534 | $return['permissions'] = $this->get_permissions(); |
---|
535 | $return['quota']['usedSpace'] = $this->bo->vfs->get_size(array( |
---|
536 | 'string' => $this->path, |
---|
537 | 'relatives' => array(RELATIVE_NONE) |
---|
538 | )); |
---|
539 | $return['files_count'] = $this->bo->vfs->count_files(array( |
---|
540 | 'string' => $this->path, |
---|
541 | )); |
---|
542 | $quota = $this->bo->vfs->get_quota(array( |
---|
543 | 'string' => $this->path |
---|
544 | )); |
---|
545 | reset($this->files_array); |
---|
546 | $this->readFilesInfo(); |
---|
547 | |
---|
548 | for ($i = 0; $i != $this->numoffiles; $i++) { |
---|
549 | $files = $this->files_array[$i]; |
---|
550 | |
---|
551 | if ($files['mime_type'] == "Directory") { |
---|
552 | continue; |
---|
553 | } |
---|
554 | /* small keys to safe bandwidth */ |
---|
555 | $tuple['name'] = htmlentities($files['name']); |
---|
556 | if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1) { |
---|
557 | if ($files['mime_type'] == 'image/png' || |
---|
558 | $files['mime_type'] == 'image/gif' || |
---|
559 | $files['mime_type'] == 'image/jpg') { |
---|
560 | $filename = str_replace('=', '', base64_encode($tuple['name'])); |
---|
561 | $pathname = str_replace('=', '', base64_encode($this->path)); |
---|
562 | $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file=' . $filename . '&path=' . $pathname; |
---|
563 | } |
---|
564 | else |
---|
565 | $tuple['icon'] = $this->mime_icon($files['mime_type'], 64); |
---|
566 | } |
---|
567 | else |
---|
568 | $tuple['icon'] = $this->mime_icon($files['mime_type']); |
---|
569 | $tuple['type'] = $files['type']; |
---|
570 | $tuple['created'] = $this->vfs_functions->dateString2timeStamp($files['created']); |
---|
571 | $tuple['modified'] = $this->vfs_functions->dateString2timeStamp($files['modified']); |
---|
572 | $tuple['size'] = $files['size']; |
---|
573 | $tuple['mime_type'] = $files['mime_type']; |
---|
574 | $tuple['pub'] = $files['type']; |
---|
575 | $tuple['createdby_id'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); |
---|
576 | $tuple['modifiedby_id'] = $files['modifiedby_id'] ? $GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']) : ''; |
---|
577 | $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); |
---|
578 | $tuple['comment'] = $files['comment']; |
---|
579 | $tuple['version'] = $files['version']; |
---|
580 | $output[] = $tuple; |
---|
581 | } |
---|
582 | $return['files'] = $output; |
---|
583 | $return['quota']['quotaSize'] = ($quota * 1024 * 1024); |
---|
584 | echo serialize($return); |
---|
585 | } |
---|
586 | |
---|
587 | function get_folders_list() { |
---|
588 | $this->update_groups(); |
---|
589 | $this->groups_applications = array(); |
---|
590 | |
---|
591 | $user_groups = $GLOBALS['phpgw']->accounts->membership(); |
---|
592 | foreach ($user_groups as $val) { |
---|
593 | $account_name = $GLOBALS['phpgw']->accounts->id2name($val['account_id']); |
---|
594 | $this->readable_groups[$account_name] = array( |
---|
595 | 'account_id' => $val['account_id'], |
---|
596 | 'account_name' => $account_name |
---|
597 | ); |
---|
598 | } |
---|
599 | |
---|
600 | foreach ($this->readable_groups as $value) { |
---|
601 | $applications = CreateObject('phpgwapi.applications', $value['account_id']); |
---|
602 | $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); |
---|
603 | } |
---|
604 | |
---|
605 | |
---|
606 | // selectbox for change/move/and copy to |
---|
607 | $this->dirs = $this->all_other_directories(); |
---|
608 | foreach ($this->dirs as $dir) |
---|
609 | $return[] = $dir['directory'] . $dir['name']; |
---|
610 | sort(&$return, SORT_STRING); |
---|
611 | echo serialize($return); |
---|
612 | } |
---|
613 | |
---|
614 | function fileListing() { |
---|
615 | $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); |
---|
616 | $this->t->set_block('filemanager_list_t', 'filemanager_header', 'filemanager_header'); |
---|
617 | $this->t->set_block('filemanager_list_t', 'filemanager_footer', 'filemanager_footer'); |
---|
618 | |
---|
619 | if ($this->numoffiles || $this->cwd) { |
---|
620 | $vars[path] = '<input type="hidden" id="currentPath" value="' . $this->path . '">'; |
---|
621 | $vars[css] = '<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; |
---|
622 | $vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">'; |
---|
623 | $_SESSION['phpgw_info']['user']['preferences']['filemanager']['lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; |
---|
624 | $vars[preferences] = '<input type="hidden" id="userPreferences" value=\'' . serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']) . '\'>'; |
---|
625 | // Used for important operations that needs security |
---|
626 | for ($key = ""; strlen($key) < 150; $key .= chr(rand(48, 95))) |
---|
627 | ; |
---|
628 | $_SESSION['phpgw_info']['filemanager']['user']['sec_key'] = $key; |
---|
629 | $vars[sec_key] = '<input type="hidden" id="userKey" value=\'' . $key . '\'>'; |
---|
630 | $vars[script] = '<script>initDrawApi();</script>'; |
---|
631 | |
---|
632 | $vars[new_button] = $this->toolButton('new', 'createfile', lang('New...')); |
---|
633 | $vars[new_button].='<input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" />'; |
---|
634 | |
---|
635 | // reload button with this url |
---|
636 | $vars[refresh_button] = $this->toolButton('reload', 'reload', lang('reload')); |
---|
637 | |
---|
638 | // go up icon when we're not at the top, dont allow to go outside /home = fakebase |
---|
639 | if ($this->path != '/' && $this->path != $this->bo->fakebase) { |
---|
640 | $vars[tools_button] = $this->toolButton('tools', 'tools', lang('tools')); |
---|
641 | } |
---|
642 | else |
---|
643 | $vars[tools_button] = ""; |
---|
644 | |
---|
645 | $vars[toolbar1] = $toolbar; |
---|
646 | |
---|
647 | if (count($this->messages) > 0) { |
---|
648 | foreach ($this->messages as $msg) { |
---|
649 | $messages.='<span>' . $msg . '</span>'; |
---|
650 | } |
---|
651 | } |
---|
652 | $this->messages = NULL; |
---|
653 | |
---|
654 | $vars[messages] = $messages; |
---|
655 | |
---|
656 | $this->t->set_var($vars); |
---|
657 | $this->t->pparse('out', 'filemanager_header'); |
---|
658 | } |
---|
659 | |
---|
660 | $this->t->set_var($vars); |
---|
661 | $this->t->pparse('out', 'filemanager_footer'); |
---|
662 | |
---|
663 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
664 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
665 | } |
---|
666 | |
---|
667 | function readFilesInfo() { |
---|
668 | // start files info |
---|
669 | # Read in file info from database to use in the rest of the script |
---|
670 | # $fakebase is a special directory. In that directory, we list the user's |
---|
671 | # home directory and the directories for the groups they're in |
---|
672 | $this->numoffiles = 0; |
---|
673 | if ($this->path == $this->bo->fakebase) { |
---|
674 | // FIXME this test can be removed |
---|
675 | if (!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) { |
---|
676 | $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); |
---|
677 | } |
---|
678 | |
---|
679 | $ls_array = $this->bo->vfs->ls(array( |
---|
680 | 'string' => $this->bo->homedir, |
---|
681 | 'relatives' => array(RELATIVE_NONE), |
---|
682 | 'checksubdirs' => False, |
---|
683 | 'nofiles' => True |
---|
684 | )); |
---|
685 | |
---|
686 | $this->files_array[] = $ls_array[0]; |
---|
687 | $this->numoffiles++; |
---|
688 | |
---|
689 | reset($this->readable_groups); |
---|
690 | while (list($num, $group_array) = each($this->readable_groups)) { |
---|
691 | # If the group doesn't have access to this app, we don't show it |
---|
692 | /* if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) |
---|
693 | { |
---|
694 | continue; |
---|
695 | } |
---|
696 | */ |
---|
697 | |
---|
698 | |
---|
699 | if (!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE)))) { |
---|
700 | $this->bo->vfs->override_acl = 1; |
---|
701 | $this->bo->vfs->mkdir(array( |
---|
702 | 'string' => $this->bo->fakebase . '/' . $group_array['account_name'], |
---|
703 | 'relatives' => array(RELATIVE_NONE) |
---|
704 | )); |
---|
705 | |
---|
706 | // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content |
---|
707 | |
---|
708 | |
---|
709 | $this->bo->vfs->override_acl = 0; |
---|
710 | |
---|
711 | $this->bo->vfs->set_attributes(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE), 'attributes' => array('owner_id' => $group_array['account_id'], 'createdby_id' => $group_array['account_id']))); |
---|
712 | } |
---|
713 | |
---|
714 | $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True)); |
---|
715 | |
---|
716 | $this->files_array[] = $ls_array[0]; |
---|
717 | |
---|
718 | $this->numoffiles++; |
---|
719 | } |
---|
720 | } else { |
---|
721 | $ls_array = $this->bo->vfs->ls(array( |
---|
722 | 'string' => $this->path, |
---|
723 | 'relatives' => array(RELATIVE_NONE), |
---|
724 | 'checksubdirs' => False, |
---|
725 | 'nofiles' => False, |
---|
726 | 'orderby' => $this->criteria, |
---|
727 | 'otype' => $this->otype, |
---|
728 | 'limit' => $this->limit, |
---|
729 | 'offset' => $this->offset |
---|
730 | )); |
---|
731 | |
---|
732 | while (list($num, $file_array) = each($ls_array)) { |
---|
733 | $this->numoffiles++; |
---|
734 | $this->files_array[] = $file_array; |
---|
735 | } |
---|
736 | } |
---|
737 | |
---|
738 | if (!is_array($this->files_array)) { |
---|
739 | $this->files_array = array(); |
---|
740 | } |
---|
741 | // end file count |
---|
742 | } |
---|
743 | |
---|
744 | function removedir() { |
---|
745 | //$toRemove = $this->path ^ $_SESSION['phpgw_info']['filemanager']['user']['sec_key']; |
---|
746 | $toRemove = $this->path; |
---|
747 | |
---|
748 | if ($this->bo->vfs->rm(array('string' => $toRemove, 'relatives' => array(RELATIVE_NONE)))) |
---|
749 | echo "True"; |
---|
750 | else |
---|
751 | echo "False"; |
---|
752 | } |
---|
753 | |
---|
754 | function createdir() { |
---|
755 | if ($this->bo->badchar = $this->bo->bad_chars($this->filename, True, True)) { |
---|
756 | echo lang('Error:') . $this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); |
---|
757 | return; |
---|
758 | } |
---|
759 | /* TODO is this right or should it be a single $ ? */ |
---|
760 | if ($this->filename[strlen($this->filename) - 1] == ' ' || $this->filename[0] == ' ') { |
---|
761 | echo lang('Error:') . lang('Cannot create directory because it begins or ends in a space'); |
---|
762 | } |
---|
763 | |
---|
764 | $ls_array = $this->bo->vfs->ls(array( |
---|
765 | 'string' => $this->path . '/' . $this->filename, |
---|
766 | 'relatives' => array(RELATIVE_NONE), |
---|
767 | 'checksubdirs' => False, |
---|
768 | 'nofiles' => True |
---|
769 | )); |
---|
770 | |
---|
771 | $fileinfo = $ls_array[0]; |
---|
772 | |
---|
773 | if ($fileinfo['name']) { |
---|
774 | if ($fileinfo['mime_type'] != 'Directory') { |
---|
775 | echo lang('Error:') . lang('%1 already exists as a file', $fileinfo['name']); |
---|
776 | } else { |
---|
777 | echo lang('Error:') . lang('Directory %1 already exists', $fileinfo['name']); |
---|
778 | } |
---|
779 | } else { |
---|
780 | $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
781 | |
---|
782 | if ($this->bo->vfs->mkdir(array('string' => $this->filename))) { |
---|
783 | echo lang('Created directory %1', $this->disppath . '/' . $this->filename); |
---|
784 | } else { |
---|
785 | echo lang('Error:') . lang('Could not create %1', $this->disppath . '/' . $this->filename); |
---|
786 | } |
---|
787 | } |
---|
788 | echo lang('Directory created'); |
---|
789 | } |
---|
790 | |
---|
791 | function getReturnExecuteForm() { |
---|
792 | $response = $_SESSION['response']; |
---|
793 | |
---|
794 | unset($_SESSION['response']); |
---|
795 | |
---|
796 | echo $response; |
---|
797 | } |
---|
798 | |
---|
799 | function showUploadboxes() |
---|
800 | { |
---|
801 | $notify = CreateObject('filemanager.notifications'); |
---|
802 | |
---|
803 | $var = array( |
---|
804 | 'change_upload_boxes' => lang('Show'), |
---|
805 | 'form_action' => $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'), |
---|
806 | 'emails_to' => $notify->EmailsToSend($GLOBALS['phpgw']->preferences->values['email']), |
---|
807 | 'lang_file' => lang('File(s)'), |
---|
808 | 'lang_comment' => lang('Comment(s)'), |
---|
809 | 'lang_advanced_upload' => lang('Advanced Upload'), |
---|
810 | 'lang_delete' => lang('delete'), |
---|
811 | 'lang_upload' => lang('Upload files'), |
---|
812 | 'max_size' => lang('The maximum size for each file is %1MB', ($this->current_config['filemanager_Max_file_size'])), |
---|
813 | 'path' => $this->path |
---|
814 | ); |
---|
815 | |
---|
816 | print( serialize($var)); |
---|
817 | } |
---|
818 | |
---|
819 | /* create textfile */ |
---|
820 | function createfile() |
---|
821 | { |
---|
822 | $this->filename = $this->newfile_or_dir; |
---|
823 | if ($this->filename) { |
---|
824 | if ($badchar = $this->bo->bad_chars($this->filename, True, True)) { |
---|
825 | $this->messages[] = lang('Error:') . lang('File names cannot contain "%1"', $badchar); |
---|
826 | |
---|
827 | $this->fileListing(); |
---|
828 | } |
---|
829 | |
---|
830 | if ($this->bo->vfs->file_exists(array( |
---|
831 | 'string' => $this->filename, |
---|
832 | 'relatives' => array(RELATIVE_ALL) |
---|
833 | ))) { |
---|
834 | $this->messages[] = lang('Error:') . lang('File %1 already exists. Please edit it or delete it first.', $this->filename); |
---|
835 | $this->fileListing(); |
---|
836 | } |
---|
837 | |
---|
838 | if ($this->bo->vfs->touch(array( |
---|
839 | 'string' => $this->filename, |
---|
840 | 'relatives' => array(RELATIVE_ALL) |
---|
841 | ))) { |
---|
842 | $this->edit = 1; |
---|
843 | $this->numoffiles++; |
---|
844 | $this->edit(); |
---|
845 | } else { |
---|
846 | $this->messages[] = lang('Error:') . lang('File %1 could not be created.', $this->filename); |
---|
847 | $this->fileListing(); |
---|
848 | } |
---|
849 | } |
---|
850 | } |
---|
851 | |
---|
852 | # Handle Editing files |
---|
853 | |
---|
854 | function edit() { |
---|
855 | if ($this->filename) { |
---|
856 | if (!$this->vfs_functions->verifyLock($this->path . '/' . $this->filename, RELATIVE_NONE)) { |
---|
857 | $GLOBALS['phpgw']->redirect('/index.php'); |
---|
858 | } |
---|
859 | $ls_array = $this->bo->vfs->ls(array( |
---|
860 | 'string' => $this->path . '/' . $this->filename, |
---|
861 | 'relatives' => array(RELATIVE_NONE), |
---|
862 | 'checksubdirs' => False, |
---|
863 | 'nofiles' => True |
---|
864 | )); |
---|
865 | $this->bo->vfs->touch(array( |
---|
866 | 'string' => $this->path . '/' . $this->filename, |
---|
867 | 'relatives' => array(RELATIVE_NONE) |
---|
868 | )); |
---|
869 | |
---|
870 | |
---|
871 | if ($ls_array[0]['mime_type']) { |
---|
872 | $mime_type = $ls_array[0]['mime_type']; |
---|
873 | } elseif ($this->prefs['viewtextplain']) { |
---|
874 | $mime_type = 'text/plain'; |
---|
875 | } |
---|
876 | $editable = array('', 'text/plain', 'text/csv', 'text/html', 'text/text', 'message/rfc822'); |
---|
877 | |
---|
878 | if (!in_array($mime_type, $editable)) { |
---|
879 | $this->messages[] = lang('Error:') . lang('Impossible to edit this file'); |
---|
880 | $this->readFilesInfo(); |
---|
881 | $this->fileListing(); |
---|
882 | return; |
---|
883 | } |
---|
884 | } |
---|
885 | |
---|
886 | $this->readFilesInfo(); |
---|
887 | |
---|
888 | if ($mime_type == 'text/html') |
---|
889 | $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl')); |
---|
890 | else |
---|
891 | $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); |
---|
892 | |
---|
893 | $this->t->set_block('filemanager_edit', 'row', 'row'); |
---|
894 | |
---|
895 | |
---|
896 | $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; |
---|
897 | |
---|
898 | $vars[preview_content] = ''; |
---|
899 | if ($this->edit_file) { |
---|
900 | $this->edit_file_content = stripslashes($this->edit_file_content); |
---|
901 | } |
---|
902 | |
---|
903 | if ($this->edit_preview_x) { |
---|
904 | $content = $this->edit_file_content; |
---|
905 | |
---|
906 | $vars[lang_preview_of] = lang('Preview of %1', $this->path . '/' . $edit_file); |
---|
907 | |
---|
908 | $vars[preview_content] = nl2br($content); |
---|
909 | } elseif ($this->edit_save_x || $this->edit_save_done_x) { |
---|
910 | $content = $this->edit_file_content; |
---|
911 | //die( $content); |
---|
912 | if ($this->bo->vfs->write(array( |
---|
913 | 'string' => $this->path . '/' . $this->edit_file, |
---|
914 | 'relatives' => array(RELATIVE_NONE), |
---|
915 | 'content' => $content |
---|
916 | ))) { |
---|
917 | $this->messages[] = lang('Saved %1', $this->path . '/' . $this->edit_file); |
---|
918 | |
---|
919 | if ($this->edit_save_done_x) { |
---|
920 | $this->readFilesInfo(); |
---|
921 | $this->fileListing(); |
---|
922 | exit; |
---|
923 | } |
---|
924 | } else { |
---|
925 | $this->messages[] = lang('Could not save %1', $this->path . '/' . $this->edit_file); |
---|
926 | } |
---|
927 | } |
---|
928 | |
---|
929 | # If we're in preview or save mode, we only show the file |
---|
930 | # being previewed or saved |
---|
931 | if ($this->edit_file && ($this->filename != $this->edit_file)) { |
---|
932 | continue; |
---|
933 | } |
---|
934 | |
---|
935 | if ($this->filename && $this->bo->vfs->file_exists(array( |
---|
936 | 'string' => $this->filename, |
---|
937 | 'relatives' => array(RELATIVE_ALL) |
---|
938 | ))) { |
---|
939 | if ($this->edit_file) { |
---|
940 | $content = stripslashes($this->edit_file_content); |
---|
941 | } else { |
---|
942 | $content = $this->bo->vfs->read(array('string' => $this->filename)); |
---|
943 | } |
---|
944 | $vars[form_action] = $GLOBALS['phpgw']->link('/index.php', 'menuaction=filemanager.uifilemanager.index', 'path=' . $this->path); |
---|
945 | $vars[edit_file] = $this->filename; |
---|
946 | # We need to include all of the fileman entries for each file's form, |
---|
947 | # so we loop through again |
---|
948 | for ($i = 0; $i != $this->numoffiles; $i++) { |
---|
949 | if ($this->filename) |
---|
950 | $value = 'value="' . $this->filename . '"'; |
---|
951 | $vars[filemans_hidden] = '<input type="hidden" name="filename" ' . $value . ' />'; |
---|
952 | } |
---|
953 | $vars[file_content] = $content; |
---|
954 | |
---|
955 | $vars[buttonPreview] = $this->inputButton('edit_preview', 'edit_preview', lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1))); |
---|
956 | $vars[buttonSave] = $this->inputButton('edit_save', 'save', lang('Save %1', $this->bo->html_encode($this->filename, 1))); |
---|
957 | $vars[buttonDone] = $this->inputButton('edit_save_done', 'ok', lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); |
---|
958 | $vars[buttonCancel] = $this->inputButton('edit_cancel', 'cancel', lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); |
---|
959 | |
---|
960 | if ($mime_type == 'text/html') { |
---|
961 | $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> |
---|
962 | <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">' . $content . '</textarea> |
---|
963 | <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{ |
---|
964 | removePlugins : \'elementspath\', |
---|
965 | skin : \'office2003\', |
---|
966 | toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print", |
---|
967 | "Undo","Redo","-","Find","Replace","-","SelectAll" ], |
---|
968 | ["Table","HorizontalRule","Smiley","SpecialChar","PageBreak","-","Bold", |
---|
969 | "Italic","Underline","Strike","-","Subscript","Superscript", |
---|
970 | "NumberedList","BulletedList","-","Outdent","Indent","Blockquote", |
---|
971 | "JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock", |
---|
972 | "Link", "TextColor","BGColor","Maximize"], |
---|
973 | ["Styles","Format","Font","FontSize"]] |
---|
974 | });</script>'; |
---|
975 | } |
---|
976 | |
---|
977 | |
---|
978 | $this->t->set_var($vars); |
---|
979 | $this->t->parse('rows', 'row'); |
---|
980 | $this->t->pparse('out', 'row'); |
---|
981 | } |
---|
982 | } |
---|
983 | |
---|
984 | function history() |
---|
985 | { |
---|
986 | if ( $this->file) |
---|
987 | { |
---|
988 | // FIXME this-file is never defined |
---|
989 | $journal_array = $this->bo->vfs->get_journal(array( |
---|
990 | 'string' => $this->file, //FIXME |
---|
991 | 'relatives' => array(RELATIVE_ALL) |
---|
992 | |
---|
993 | )); |
---|
994 | |
---|
995 | if ( is_array($journal_array) ) |
---|
996 | { |
---|
997 | $historyFile = array(); |
---|
998 | |
---|
999 | while ( list($num, $journal_entry) = each($journal_array) ) |
---|
1000 | { |
---|
1001 | $historyFile[] = array( |
---|
1002 | "created" => $journal_entry['created'], |
---|
1003 | "version" => $journal_entry['version'], |
---|
1004 | "who" => $GLOBALS['phpgw']->accounts->id2name($journal_entry['owner_id']), |
---|
1005 | "operation" => $journal_entry['comment'] |
---|
1006 | ); |
---|
1007 | } |
---|
1008 | |
---|
1009 | echo serialize( $historyFile ); |
---|
1010 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
1011 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1012 | } |
---|
1013 | else |
---|
1014 | { |
---|
1015 | echo lang('No version history for this file/directory'); |
---|
1016 | } |
---|
1017 | } |
---|
1018 | } |
---|
1019 | |
---|
1020 | function view() { |
---|
1021 | if (!$this->bo->vfs->acl_check(array( |
---|
1022 | 'string' => $this->path, |
---|
1023 | 'relatives' => array(RELATIVE_NONE), |
---|
1024 | 'operation' => PHPGW_ACL_READ |
---|
1025 | ))) { |
---|
1026 | $this->messages[] = lang("You have no permission to access this file"); |
---|
1027 | header('Location:' . $this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index', '&path=' . base64_encode($this->bo->homedir))); |
---|
1028 | |
---|
1029 | return; |
---|
1030 | } |
---|
1031 | if ($this->file) { //FIXME |
---|
1032 | $ls_array = $this->bo->vfs->ls(array( |
---|
1033 | 'string' => $this->path . '/' . $this->file, //FIXME |
---|
1034 | 'relatives' => array(RELATIVE_NONE), |
---|
1035 | 'checksubdirs' => False, |
---|
1036 | 'nofiles' => True |
---|
1037 | )); |
---|
1038 | if ($ls_array[0]['mime_type']) { |
---|
1039 | $mime_type = $ls_array[0]['mime_type']; |
---|
1040 | } elseif ($this->prefs['viewtextplain']) { |
---|
1041 | $mime_type = 'text/plain'; |
---|
1042 | } |
---|
1043 | $viewable = array('text/plain', 'text/csv', 'text/html', |
---|
1044 | 'text/text', 'image/jpeg', 'image/png', 'image/gif', |
---|
1045 | 'audio/mpeg', 'video/mpeg'); |
---|
1046 | |
---|
1047 | if (in_array($mime_type, $viewable)) { |
---|
1048 | /* Note: if you put application/octet-stream you force download */ |
---|
1049 | header('Content-type: ' . $mime_type); |
---|
1050 | header('Content-disposition: filename="' . addslashes($this->file) . '"'); |
---|
1051 | Header("Pragma: public"); |
---|
1052 | } else { |
---|
1053 | $GLOBALS['phpgw']->browser->content_header($this->file, $mime_type, $ls_array[0]['size']); |
---|
1054 | } |
---|
1055 | if ($ls_array[0]['size'] < 10240) { |
---|
1056 | echo $this->bo->vfs->read(array( |
---|
1057 | 'string' => $this->path . '/' . $this->file, //FIXME |
---|
1058 | 'relatives' => array(RELATIVE_NONE) |
---|
1059 | )); |
---|
1060 | } else { |
---|
1061 | $this->bo->vfs->print_content(array( |
---|
1062 | 'string' => $this->path . '/' . $this->file, |
---|
1063 | 'relatives' => array(RELATIVE_NONE) |
---|
1064 | ) |
---|
1065 | ); |
---|
1066 | } |
---|
1067 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1068 | } |
---|
1069 | } |
---|
1070 | |
---|
1071 | function export() |
---|
1072 | { |
---|
1073 | if ($this->file) |
---|
1074 | { |
---|
1075 | $ls_array = $this->bo->vfs->ls(array( |
---|
1076 | 'string' => $this->path . '/' . $this->file, |
---|
1077 | 'relatives' => array(RELATIVE_NONE), |
---|
1078 | 'checksubdirs' => False, |
---|
1079 | 'nofiles' => True |
---|
1080 | )); |
---|
1081 | |
---|
1082 | $mime_type = $ls_array[0]['mime_type']; |
---|
1083 | |
---|
1084 | $formats = array('text/html'); |
---|
1085 | |
---|
1086 | if (!in_array($mime_type, $formats)) |
---|
1087 | { |
---|
1088 | echo lang('Impossible to export this file'); |
---|
1089 | return False; |
---|
1090 | } |
---|
1091 | |
---|
1092 | $content = $this->bo->vfs->read(array('string' => $this->path . '/' . $this->file, |
---|
1093 | 'relatives' => array(RELATIVE_NONE) |
---|
1094 | )); |
---|
1095 | |
---|
1096 | include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); |
---|
1097 | |
---|
1098 | $dompdf = new DOMPDF(); |
---|
1099 | $dompdf->load_html($content); |
---|
1100 | $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']); |
---|
1101 | /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate' */ |
---|
1102 | $dompdf->render(); |
---|
1103 | $dompdf->stream(strtok($this->file, '.') . ".pdf"); |
---|
1104 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
1105 | } |
---|
1106 | } |
---|
1107 | |
---|
1108 | //give back an array with all directories except current and dirs that are not accessable |
---|
1109 | function all_other_directories() { |
---|
1110 | # First we get the directories in their home directory |
---|
1111 | $dirs = array(); |
---|
1112 | $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); |
---|
1113 | |
---|
1114 | $tmp_arr = array( |
---|
1115 | 'string' => $this->bo->homedir, |
---|
1116 | 'relatives' => array(RELATIVE_NONE), |
---|
1117 | 'checksubdirs' => True, |
---|
1118 | 'mime_type' => 'Directory' |
---|
1119 | ); |
---|
1120 | |
---|
1121 | $ls_array = $this->bo->vfs->ls($tmp_arr, True); |
---|
1122 | |
---|
1123 | while (list($num, $dir) = each($ls_array)) { |
---|
1124 | $dirs[] = $dir; |
---|
1125 | } |
---|
1126 | |
---|
1127 | |
---|
1128 | # Then we get the directories in their readable groups' home directories |
---|
1129 | reset($this->readable_groups); |
---|
1130 | while (list($num, $group_array) = each($this->readable_groups)) { |
---|
1131 | // Don't list directories for groups that don't exists |
---|
1132 | $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], |
---|
1133 | 'relatives' => array(RELATIVE_NONE), 'relative' => False)); |
---|
1134 | if ($test[mime_type] != 'Directory') { |
---|
1135 | continue; |
---|
1136 | } |
---|
1137 | |
---|
1138 | $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); |
---|
1139 | |
---|
1140 | $tmp_arr = array( |
---|
1141 | 'string' => $this->bo->fakebase . '/' . $group_array['account_name'], |
---|
1142 | 'relatives' => array(RELATIVE_NONE), |
---|
1143 | 'checksubdirs' => True, |
---|
1144 | 'mime_type' => 'Directory' |
---|
1145 | ); |
---|
1146 | |
---|
1147 | $ls_array = $this->bo->vfs->ls($tmp_arr, True); |
---|
1148 | while (list($num, $dir) = each($ls_array)) { |
---|
1149 | $dirs[] = $dir; |
---|
1150 | } |
---|
1151 | } |
---|
1152 | reset($dirs); |
---|
1153 | while (list($num, $dir) = each($dirs)) { |
---|
1154 | if (!$dir['directory']) { |
---|
1155 | continue; |
---|
1156 | } |
---|
1157 | |
---|
1158 | # So we don't display // |
---|
1159 | if ($dir['directory'] != '/') { |
---|
1160 | $dir['directory'] .= '/'; |
---|
1161 | } |
---|
1162 | $return[] = $dir; |
---|
1163 | } |
---|
1164 | return $return; |
---|
1165 | } |
---|
1166 | |
---|
1167 | function update_groups() { |
---|
1168 | # Get their readable groups to be used throughout the script |
---|
1169 | $acl = array(); |
---|
1170 | $groups = array(); |
---|
1171 | $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'], 1, 'filemanager'); |
---|
1172 | if (is_array($acl)) |
---|
1173 | foreach ($acl as $key => $value) { |
---|
1174 | $info = array(); |
---|
1175 | $info = $GLOBALS['phpgw']->accounts->get_account_data($value); |
---|
1176 | $groups[$key]['account_id'] = $value; |
---|
1177 | $groups[$key]['account_lid'] = $info[$value]['lid']; |
---|
1178 | $groups[$key]['account_name'] = $info[$value]['firstname']; |
---|
1179 | $groups[$key]['account_lastname'] = $info[$value]['lastname']; |
---|
1180 | $groups[$key]['account_fullname'] = $info[$value]['fullname']; |
---|
1181 | } |
---|
1182 | $this->readable_groups = array(); |
---|
1183 | while (list($num, $account) = each($groups)) { |
---|
1184 | if ($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'], 'operation' => PHPGW_ACL_READ))) { |
---|
1185 | $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); |
---|
1186 | } |
---|
1187 | } |
---|
1188 | } |
---|
1189 | |
---|
1190 | function search() { |
---|
1191 | /* TODO this is a primitive search */ |
---|
1192 | $this->update_groups(); |
---|
1193 | $this->dirs = $this->all_other_directories(); |
---|
1194 | $path = $this->path; |
---|
1195 | if (strlen($this->text) > 3) { |
---|
1196 | $this->text = strtoupper($this->text); |
---|
1197 | foreach ($this->dirs as $elem) { |
---|
1198 | $this->path = $elem['directory'] . $elem['name']; |
---|
1199 | reset($this->files_array); |
---|
1200 | $this->readFilesInfo(); |
---|
1201 | for ($i = 0; $i < count($this->files_array); $i++) { |
---|
1202 | $comment = strtoupper($this->files_array[$i]['comment']); |
---|
1203 | $name = strtoupper($this->files_array[$i]['name']); |
---|
1204 | if (strstr($name, $this->text) || |
---|
1205 | strstr($comment, $this->text)) { |
---|
1206 | $return[$this->files_array[$i]['directory'] . $name] = $this->files_array[$i]; |
---|
1207 | $return[$this->files_array[$i]['directory'] . $name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']); |
---|
1208 | } |
---|
1209 | } |
---|
1210 | if (count($return) > 50) { |
---|
1211 | $return = array_slice($return, 0, 50); |
---|
1212 | break; |
---|
1213 | } |
---|
1214 | } |
---|
1215 | } |
---|
1216 | echo serialize(array_values($return)); |
---|
1217 | } |
---|
1218 | |
---|
1219 | /* seek icon for mimetype else return an unknown icon */ |
---|
1220 | |
---|
1221 | function mime_icon($mime_type, $size=16) { |
---|
1222 | if (!$mime_type) |
---|
1223 | $mime_type = 'unknown'; |
---|
1224 | |
---|
1225 | $mime_type = str_replace('/', '_', $mime_type); |
---|
1226 | |
---|
1227 | $img = $GLOBALS['phpgw']->common->image('filemanager', 'mime' . $size . '_' . strtolower($mime_type)); |
---|
1228 | if (!$img) |
---|
1229 | $img = $GLOBALS['phpgw']->common->image('filemanager', 'mime' . $size . '_unknown'); |
---|
1230 | |
---|
1231 | return $img; |
---|
1232 | } |
---|
1233 | |
---|
1234 | function toolButton($link, $img='', $description='') { |
---|
1235 | $image = $GLOBALS['phpgw']->common->image('filemanager', 'button_' . strtolower($img)); |
---|
1236 | |
---|
1237 | if ($img) { |
---|
1238 | return '<div name="' . $link . '" class="toolButton" onclick="toolbar.control(\'' . $link . '\',this);" title="' . $description . '"><img src="' . $image . '" alt="' . $description . '"/><small>' . $description . '</small></div>'; |
---|
1239 | } |
---|
1240 | } |
---|
1241 | |
---|
1242 | function inputButton($name, $img='', $description='') { |
---|
1243 | $image = $GLOBALS['phpgw']->common->image('filemanager', 'button_' . strtolower($img)); |
---|
1244 | |
---|
1245 | if ($img) { |
---|
1246 | return '<td class="" align="center" valign="middle" height="28" width="70"> |
---|
1247 | <input title="' . $description . '" name="' . $name . '" type="image" alt="' . $name . '" src="' . $image . '" value="clicked" /><br><small>' . $description . '</small> |
---|
1248 | </td>'; |
---|
1249 | } |
---|
1250 | } |
---|
1251 | |
---|
1252 | function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) { |
---|
1253 | $text = ' '; |
---|
1254 | if ($type != NULL && $type) { |
---|
1255 | if ($type == 'checkbox') { |
---|
1256 | $value = $this->bo->string_encode($value, 1); |
---|
1257 | } |
---|
1258 | $text .= 'type="' . $type . '" '; |
---|
1259 | } |
---|
1260 | if ($name != NULL && $name) { |
---|
1261 | $text .= 'name="' . $name . '" '; |
---|
1262 | } |
---|
1263 | if ($value != NULL && $value) { |
---|
1264 | $text .= 'value="' . $value . '" '; |
---|
1265 | } |
---|
1266 | if (is_int($maxlength) && $maxlength >= 0) { |
---|
1267 | $text .= 'maxlength="' . $maxlength . '" '; |
---|
1268 | } |
---|
1269 | if (is_int($size) && $size >= 0) { |
---|
1270 | $text .= 'size="' . $size . '" '; |
---|
1271 | } |
---|
1272 | if ($checked != NULL && $checked) { |
---|
1273 | $text .= 'checked '; |
---|
1274 | } |
---|
1275 | |
---|
1276 | return '<input' . $text . $string . '>'; |
---|
1277 | } |
---|
1278 | |
---|
1279 | function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) { |
---|
1280 | $text = ' '; |
---|
1281 | if ($value != NULL && $value) { |
---|
1282 | $text .= ' value="' . $value . '" '; |
---|
1283 | } |
---|
1284 | if ($selected != NULL && $selected) { |
---|
1285 | $text .= ' selected'; |
---|
1286 | } |
---|
1287 | return '<option' . $text . '>' . $displayed . '</option>'; |
---|
1288 | } |
---|
1289 | |
---|
1290 | function encode_href($href = NULL, $args = NULL, $extra_args) { |
---|
1291 | $href = $this->bo->string_encode($href, 1); |
---|
1292 | $all_args = $args . '&' . $this->bo->string_encode($extra_args, 1); |
---|
1293 | |
---|
1294 | $address = $GLOBALS['phpgw']->link($href, $all_args); |
---|
1295 | |
---|
1296 | return $address; |
---|
1297 | } |
---|
1298 | |
---|
1299 | function html_link($href = NULL, $args = NULL, $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) { |
---|
1300 | // unset($encode); |
---|
1301 | if ($encode) { |
---|
1302 | $href = $this->bo->string_encode($href, 1); |
---|
1303 | $all_args = $args . '&' . $this->bo->string_encode($extra_args, 1); |
---|
1304 | } else { |
---|
1305 | // $href = $this->bo->string_encode($href, 1); |
---|
1306 | $all_args = $args . '&' . $extra_args; |
---|
1307 | } |
---|
1308 | ### |
---|
1309 | # This decodes / back to normal |
---|
1310 | ### |
---|
1311 | // $all_args = preg_replace("/%2F/", "/", $all_args); |
---|
1312 | // $href = preg_replace("/%2F/", "/", $href); |
---|
1313 | |
---|
1314 | /* Auto-detect and don't disturb absolute links */ |
---|
1315 | if (!preg_match("|^http(.{0,1})://|", $href)) { |
---|
1316 | //Only add an extra / if there isn't already one there |
---|
1317 | // die(SEP); |
---|
1318 | if (!($href[0] == SEP)) { |
---|
1319 | $href = SEP . $href; |
---|
1320 | } |
---|
1321 | |
---|
1322 | /* $phpgw->link requires that the extra vars be passed separately */ |
---|
1323 | // $link_parts = explode("?", $href); |
---|
1324 | $address = $GLOBALS['phpgw']->link($href, $all_args); |
---|
1325 | // $address = $GLOBALS['phpgw']->link($href); |
---|
1326 | } else { |
---|
1327 | $address = $href; |
---|
1328 | } |
---|
1329 | |
---|
1330 | /* If $linkonly is set, don't add any HTML */ |
---|
1331 | if ($linkonly) { |
---|
1332 | $rstring = $address; |
---|
1333 | } else { |
---|
1334 | if ($target) { |
---|
1335 | $target = 'target=' . $target; |
---|
1336 | } |
---|
1337 | |
---|
1338 | $text = trim($text); |
---|
1339 | $rstring = '<a href="' . $address . '" ' . $target . '>' . $text . '</a>'; |
---|
1340 | } |
---|
1341 | |
---|
1342 | return($this->bo->eor($rstring, $return)); |
---|
1343 | } |
---|
1344 | |
---|
1345 | function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) { |
---|
1346 | if ($width != NULL && $width) { |
---|
1347 | $width = "width=$width"; |
---|
1348 | } |
---|
1349 | if (is_int($border) && $border >= 0) { |
---|
1350 | $border = "border=$border"; |
---|
1351 | } |
---|
1352 | if (is_int($cellspacing) && $cellspacing >= 0) { |
---|
1353 | $cellspacing = "cellspacing=$cellspacing"; |
---|
1354 | } |
---|
1355 | if (is_int($cellpadding) && $cellpadding >= 0) { |
---|
1356 | $cellpadding = "cellpadding=$cellpadding"; |
---|
1357 | } |
---|
1358 | if ($rules != NULL && $rules) { |
---|
1359 | $rules = "rules=$rules"; |
---|
1360 | } |
---|
1361 | |
---|
1362 | $rstring = "<table $width $border $cellspacing $cellpadding $rules $string>"; |
---|
1363 | return($this->bo->eor($rstring, $return)); |
---|
1364 | } |
---|
1365 | |
---|
1366 | function html_table_end($return = 0) { |
---|
1367 | $rstring = "</table>"; |
---|
1368 | return($this->bo->eor($rstring, $return)); |
---|
1369 | } |
---|
1370 | |
---|
1371 | function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) { |
---|
1372 | if ($align != NULL && $align) { |
---|
1373 | $align = "align=$align"; |
---|
1374 | } |
---|
1375 | if ($halign != NULL && $halign) { |
---|
1376 | $halign = "halign=$halign"; |
---|
1377 | } |
---|
1378 | if ($valign != NULL && $valign) { |
---|
1379 | $valign = "valign=$valign"; |
---|
1380 | } |
---|
1381 | if ($bgcolor != NULL && $bgcolor) { |
---|
1382 | $bgcolor = "bgcolor=$bgcolor"; |
---|
1383 | } |
---|
1384 | $rstring = "<tr $align $halign $valign $bgcolor $string>"; |
---|
1385 | return($this->bo->eor($rstring, $return)); |
---|
1386 | } |
---|
1387 | |
---|
1388 | function html_table_row_end($return = 0) { |
---|
1389 | $rstring = "</tr>"; |
---|
1390 | return($this->bo->eor($rstring, $return)); |
---|
1391 | } |
---|
1392 | |
---|
1393 | function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) { |
---|
1394 | if ($align != NULL && $align) { |
---|
1395 | $align = "align=$align"; |
---|
1396 | } |
---|
1397 | if ($halign != NULL && $halign) { |
---|
1398 | $halign = "halign=$halign"; |
---|
1399 | } |
---|
1400 | if ($valign != NULL && $valign) { |
---|
1401 | $valign = "valign=$valign"; |
---|
1402 | } |
---|
1403 | if (is_int($rowspan) && $rowspan >= 0) { |
---|
1404 | $rowspan = "rowspan=$rowspan"; |
---|
1405 | } |
---|
1406 | if (is_int($colspan) && $colspan >= 0) { |
---|
1407 | $colspan = "colspan=$colspan"; |
---|
1408 | } |
---|
1409 | |
---|
1410 | $rstring = "<td $align $halign $valign $rowspan $colspan $string>"; |
---|
1411 | return($this->bo->eor($rstring, $return)); |
---|
1412 | } |
---|
1413 | |
---|
1414 | function html_table_col_end($return = 0) { |
---|
1415 | $rstring = "</td>"; |
---|
1416 | return($this->bo->eor($rstring, $return)); |
---|
1417 | } |
---|
1418 | |
---|
1419 | } |
---|