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