source: sandbox/filemanager/inc/class.uifilemanager.inc.php @ 1694

Revision 1694, 57.7 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Melhorias no módulo gerenciados de arquivos

  • Property svn:executable set to *
Line 
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                        'uploadModel'=>True
32                );
33
34                //keep
35                var $bo;
36                var $vfs_functions;
37                var $t; //template object
38                var $dispath;
39                var $cwd;
40                var $lesspath;
41                var $readable_groups;
42                var $files_array;
43                var $numoffiles;
44                var $dispsep;
45
46                var $target;
47
48                var $prefs;//array
49
50                var $groups_applications;
51
52                //originally post_vars
53                //              var $goto;
54                var $current_config;
55                var $goto_x;
56                var $to;
57                var $changedir; // for switching dir.
58                var $cdtodir; // for switching dir.
59//              var $createdir;
60                var $newfile_or_dir;
61                var $newdir_x;
62                var $newfile_x;
63                var $createfile_var;
64                var $move_to_x;
65//              var $copy_to;
66                var $copy_to_x;
67                var $edit_x;
68                var $edit_file;
69                var $edit_preview_x;
70                var $edit_save_x;
71                var $edit_save_done_x;
72                var $edit_cancel_x;
73                var $upload_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 $show_upload_boxes;
83
84                var $now;
85
86                function uifilemanager()
87                {
88                        $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages'];
89
90                        $GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser');
91
92                        $this->now = date('Y-m-d');
93
94                        $this->bo = CreateObject('filemanager.bofilemanager');
95
96                        $this->vfs_functions = CreateObject('filemanager.vfs_functions');
97
98                        $this->t = $GLOBALS['phpgw']->template;
99                        $c = CreateObject('phpgwapi.config','filemanager');
100                        $c->read_repository();
101                        $this->current_config = $c->config_data;
102
103
104                        // here local vars are created from the HTTP vars
105                        @reset($GLOBALS['HTTP_POST_VARS']);
106                        while(list($name,) = @each($GLOBALS['HTTP_POST_VARS']))
107                        {
108                                $this->$name = $GLOBALS['HTTP_POST_VARS'][$name];
109                        }
110
111                        @reset($GLOBALS['HTTP_GET_VARS']);
112                        while(list($name,) = @each($GLOBALS['HTTP_GET_VARS']))
113                        {
114                                $$name = $GLOBALS['HTTP_GET_VARS'][$name];
115                                $this->$name = $GLOBALS['HTTP_GET_VARS'][$name];
116
117                        }
118
119                        $to_decode = array
120                        (
121                                'op'    => array('op' => ''),
122                                'path'  => array('path' => ''),
123                                'filename' => array('filename' => ''),
124                                'file'  => array('file' => ''),
125                                'sortby'        => array('sortby' => ''),
126                                'messages'      => array('messages'     => ''),
127                                'show_upload_boxes'     => array('show_upload_boxes' => ''),
128                                'to' => array('to' => '')
129
130                        );
131
132                        reset($to_decode);
133                        while(list($var, $conditions) = each($to_decode))
134                        {
135                                while(list($condvar, $condvalue) = each($conditions))
136                                {
137                                        if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue))
138                                        {
139                                                if(is_array($$var))
140                                                {
141                                                        $temp = array();
142                                                        while(list($varkey, $varvalue) = each($$var))
143                                                        {
144                                                                if(is_int($varkey))
145                                                                {
146                                                                        $temp[$varkey] = stripslashes(base64_decode(urldecode(($varvalue))));
147                                                                }
148                                                                else
149                                                                {
150                                                                        $temp[stripslashes(base64_decode(urldecode(($varkey))))] = $varvalue;
151                                                                }
152                                                        }
153                                                        $this->$var = $temp;
154                                                }
155                                                elseif(isset($$var))
156                                                {
157                                                        $this->$var = stripslashes(base64_decode(urldecode($$var)));
158                                                }
159                                        }
160                                }
161                        }
162
163                        // get appl. and user prefs
164                        $pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']);
165                        $pref->read_repository();
166                        //$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']);
167                        $pref->save_repository(True);
168                        $pref_array = $pref->read_repository();
169                        $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array
170
171                        //always show name
172
173                        $this->prefs[name] =1;
174
175
176                        if($this->prefs['viewinnewwin'])
177                        {
178                                $this->target = '_blank';
179                        }
180
181
182                        /*
183                                Check for essential directories
184                                admin must be able to disable these tests
185                        */
186                       
187                        // check if basedir exist
188                        $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
189                        if($test[mime_type]!='Directory')
190                        {
191                                die('Base directory does not exist, Ask adminstrator to check the global configuration.');
192                        }
193
194                        $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
195                        if($test[mime_type]!='Directory')
196                        {
197
198                                $this->bo->vfs->override_acl = 1;
199
200                                $this->bo->vfs->mkdir(array(
201                                        'string' => $this->bo->fakebase,
202                                        'relatives' => array(RELATIVE_NONE)
203                                ));
204                               
205                                $this->bo->vfs->override_acl = 0;
206
207                                //test one more time
208                                $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
209
210                                if($test[mime_type]!='Directory')
211                                {
212                                        die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.');
213                                }
214                                else
215                                {
216                                        $this->messages[]= lang('Fake Base Dir did not exist, eGroupWare created a new one.');
217                                }
218                        }
219
220                        $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
221                        if($test[mime_type]!='Directory')
222                        {
223                                $this->bo->vfs->override_acl = 1;
224
225                                $this->bo->vfs->mkdir(array(
226                                        'string' => $this->bo->homedir,
227                                        'relatives' => array(RELATIVE_NONE)
228                                ));
229                                $this->bo->vfs->set_quota(array(
230                                        'string' => $this->bo->homedir,
231                                        'relatives' => array(RELATIVE_NONE),
232                                        'new_quota' => $this->current_config['filemanager_quota_size']
233                                ));
234       
235                                $this->bo->vfs->override_acl = 0;
236
237                                //test one more time
238                                $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
239
240                                if($test[mime_type]!='Directory')
241                                {
242                                        die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.');
243                                }
244                                else
245                                {
246                                        $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.');
247                                        // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content
248                                }
249
250
251                        }
252                       
253                }
254                function fileModels()
255                {
256                        $GLOBALS['phpgw_info']['flags'] = array
257                                (
258                                        'currentapp'    => 'filemanager',
259                                        'noheader'      => False,
260                                        'nonavbar' => False,
261                                        'nofooter'      => False,
262                                        'noappheader'   => False,
263                                        'enable_browser_class'  => True
264                                );
265
266                        $GLOBALS['phpgw']->common->phpgw_header();
267                        $this->t->set_file(array('models' => 'fileModels.tpl'));
268                        $this->t->set_block('models','header','header');
269                        $this->t->set_block('models','body','body');
270                        $this->t->set_block('models','footer','footer');
271                        $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article');
272                        $this->t->set_var('model_1','article');
273                        $this->t->set_var('lang_1',lang('article'));
274
275                        $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar');
276                        $this->t->set_var('model_2','calendar');
277                        $this->t->set_var('lang_2',lang('calendar'));
278
279                        $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo');
280                        $this->t->set_var('model_3','todo');
281                        $this->t->set_var('lang_3',lang('todo'));
282
283                        $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide');
284                        $this->t->set_var('model_4','slide');
285                        $this->t->set_var('lang_4',lang('slide'));
286
287                        $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards');
288                        $this->t->set_var('model_5','cards');
289                        $this->t->set_var('lang_5',lang('cards'));
290
291                        $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume');
292                        $this->t->set_var('model_6','resume');
293                        $this->t->set_var('lang_6',lang('resume'));
294
295
296                        $this->t->pparse('out','models');
297
298
299                }
300                function uploadModel(){
301                        $GLOBALS['phpgw_info']['flags'] = array
302                                (
303                                        'currentapp'    => 'filemanager',
304                                        'noheader'      => False,
305                                        'nonavbar' => False,
306                                        'nofooter'      => False,
307                                        'noappheader'   => False,
308                                        'enable_browser_class'  => True
309                                );
310
311                        $GLOBALS['phpgw']->common->phpgw_header();
312
313                        $filename = lang('new')."_".lang($this->model).rand(0,1000).".html";
314                        $this->bo->vfs->cp(array(
315                                'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html',
316                                'to'=> $filename,
317                                'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
318                        ));
319
320                        $this->bo->vfs->set_attributes(array(
321                                'string'=> $filename,
322                                'relatives'     => array(RELATIVE_ALL),
323                                'attributes'=> array(
324                                        'mime_type' => "text/html",
325                                        'comment' => ""
326                                )
327                        ));
328                        $this->filename = $filename;
329                        $this->edit();
330
331                }
332                function index()
333                {
334                        $GLOBALS['phpgw_info']['flags'] = array
335                        (
336                                'currentapp'    => 'filemanager',
337                                'noheader'      => False,
338                                'nonavbar' => False,
339                                'nofooter'      => False,
340                                'noappheader'   => False,
341                                'enable_browser_class'  => True
342                        );
343
344                        $GLOBALS['phpgw']->common->phpgw_header();
345
346                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/global.js'></script>";
347                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>";
348                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>";
349                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>";
350                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>";
351                        include('load_lang.php');
352
353                        # Page to process users
354                        # Code is fairly hackish at the beginning, but it gets better
355                        # Highly suggest turning wrapping off due to long SQL queries
356
357                        ###
358                        # Some hacks to set and display directory paths correctly
359                        ###
360                        // new method for switching to a new dir.
361                        if($this->changedir=='true' && $this->cdtodir || $this->goto_x)
362                        {
363                                $this->path = $this->cdtodir;
364                        }
365
366                        if(!$this->path)
367                        {
368                                $this->path = $this->bo->vfs->pwd();
369
370                                if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '')
371                                {
372                                        $this->path = $this->bo->homedir;
373                                }
374                        }
375
376                        $this->bo->vfs->cd(array('string' => False, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
377                        $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False));
378
379                        $pwd = $this->bo->vfs->pwd();
380
381                        if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) 
382                        {
383                                $this->cwd = '/';
384                        }
385                        else
386                        {
387                                $this->cwd = substr($pwd, strrpos($pwd, '/') + 1);
388                        }
389
390                        $this->disppath = $this->path;
391
392                        /* This just prevents // in some cases */
393                        if($this->path == '/')
394                        {
395                                $this->dispsep = '';
396                        }
397                        else
398                        {
399                                $this->dispsep = '/';
400                        }
401
402                        if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/'))))
403                        {
404                                $this->lesspath = '/';
405                        }
406
407                        # Get their readable groups to be used throughout the script
408                        $acl = array();
409                        $groups = array();
410                        $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'],1,'filemanager');
411                        if (is_array($acl))
412                                foreach($acl as $key => $value){
413                                        $info = array();
414                                        $info = $GLOBALS['phpgw']->accounts->get_account_data($value);
415                                        $groups[$key]['account_id'] = $value;
416                                        $groups[$key]['account_lid'] = $info[$value]['lid'];
417                                        $groups[$key]['account_name'] = $info[$value]['firstname'];
418                                        $groups[$key]['account_lastname'] = $info[$value]['lastname'];
419                                        $groups[$key]['account_fullname'] = $info[$value]['fullname'];
420                                }
421                        $this->readable_groups = array();
422                        while(list($num, $account) = each($groups))
423                        {
424                                if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ)))
425                                {
426                                        $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']);
427                                }
428                        }
429
430                        $this->groups_applications = array();
431
432                        foreach ($this->readable_groups as $value)
433                        {
434                                $applications = CreateObject('phpgwapi.applications', $value['account_id']);
435                                $this->groups_applications[$value['account_name']] = $applications->read_account_specific();
436                        }
437
438                        # We determine if they're in their home directory or a group's directory,
439                        # and set the VFS working_id appropriately
440                        if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined
441
442                        {
443                                $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined
444
445                        }
446                        else
447                        {
448                                $this->bo->vfs->working_id = $this->bo->userinfo['username'];
449                        }
450
451                        # Check available permissions for $this->path, so we can disable unusable operations in user interface
452                        $path = explode('/',$this->path);
453                        $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]);
454                        $user_id = $GLOBALS['phpgw_info']['user']['account_id'];
455                        if ($owner_id == $user_id)
456                        {
457                                $this->can_read = True;
458                                $this->can_add = True;
459                                $this->can_edit = True;
460                                $this->can_delete = True;
461                                $this->can_private = True;
462                        }else
463                        {
464                                $acl = CreateObject ('phpgwapi.acl', $owner_id);
465                                $acl->account_id = $owner_id;
466                                $acl->read_repository();
467                                $rights = $acl->get_rights($user_id);
468                                $this->can_read = $rights & PHPGW_ACL_READ;
469                                $this->can_add = $rights & PHPGW_ACL_ADD;
470                                $this->can_edit = $rights & PHPGW_ACL_EDIT;
471                                $this->can_delete = $rights & PHPGW_ACL_DELETE;
472                                $this->can_private = $rights & PHPGW_ACL_PRIVATE;
473                        }
474       
475                        # if is different path than home and no permission allowed
476                        if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read)
477                        {
478                                echo lang('You do not have access to %1', $this->path);
479                                $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->homedir, lang('Go to your home directory'));
480
481                                $GLOBALS['phpgw']->common->phpgw_footer();
482                                $GLOBALS['phpgw']->common->phpgw_exit();
483                        }
484
485                        $this->bo->userinfo['working_id'] = $this->bo->vfs->working_id;
486                        $this->bo->userinfo['working_lid'] = $GLOBALS['phpgw']->accounts->id2name($this->bo->userinfo['working_id']);
487
488                        # Verify path is real
489                        if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase)
490                        {
491                                if(!$this->bo->vfs->file_exists(array(
492                                        'string' => $this->path,
493                                        'relatives' => array(RELATIVE_NONE)
494                                )))
495                                {
496                                        $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path);
497                                        $this->html_link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir, lang('Go to your home directory'));
498
499                                        $GLOBALS['phpgw']->common->phpgw_footer();
500                                        $GLOBALS['phpgw']->common->phpgw_exit();
501                                }
502                        }
503
504
505                        /* Update the vfs */
506                        if ($this->update_x == 'True')
507                        {
508                                $this->bo->vfs->update_real(array(
509                                        'string' => $this->path,
510                                        'relatives' => array(RELATIVE_ALL)
511                                ));
512                        }
513
514                        # Default is to sort by name
515                        if(!$this->sortby)
516                        {
517                                $this->sortby = 'name';
518                        }
519
520                        # main action switch
521                        // FIXME this will become a switch
522                        if($this->newfile_x && $this->newfile_or_dir) // create new textfile
523                        {
524                                $this->createfile();
525                        }
526                        elseif($this->newfile_or_dir && $this->newdir_x)
527                        {
528                                $this->createdir();
529                        }
530                        elseif($this->upload_x || $this->show_upload_boxes)
531                        {
532                                $this->showUploadboxes();
533                        }
534                        elseif($this->copy_to_x)
535                        {
536                                $this->copyTo();
537                        }
538                        elseif($this->move_to_x)
539                        {
540                                $this->moveTo();
541                        }
542                        elseif($this->edit_cancel_x)
543                        {
544                                $this->readFilesInfo();
545                                $this->fileListing();
546                        }
547                        elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x)
548                        {
549                                $this->edit();
550                        }
551                        else
552                        {
553                                $this->readFilesInfo();
554                                $this->fileListing();
555                        }
556                }
557                function fileListing()
558                {
559                        $this->t->set_file(array('filemanager_list_t' => 'filelisting.tpl'));
560                        $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header');
561                        $this->t->set_block('filemanager_list_t','column','column');
562                        $this->t->set_block('filemanager_list_t','row','row');
563                        $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer');
564
565                        $vars['form_action']=$this->encode_href('/index.php', 'menuaction=filemanager.uifilemanager.index','path='.$this->path);
566                        if($this->numoffiles || $this->cwd)
567                        {
568                                while(list($num, $name) = each($this->prefs))
569                                {
570                                        if($name)
571                                        {
572                                                $columns++;
573                                        }
574                                }
575                                $columns++;
576                                $usedSpace = $this->bo->vfs->get_size(array(
577                                        'string'        => $this->path,
578                                        'relatives'     => array(RELATIVE_NONE)
579                                ));
580                                $quota = $this->bo->vfs->get_quota(array(
581                                        'string'        => $this->path
582                                ));
583
584                                $vars[usedSpace]='<input type="hidden" id="usedSpace" value="'.$usedSpace.'">';
585                                $vars[quotaSize]='<input type="hidden" id="quotaSize" value="'.($quota*1024*1024).'">';
586                                $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">';
587                                $vars[css]='<script>initDrawApi();</script>
588                                        <link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">';
589                                $vars[toolbar0]=$this->toolbar('location');
590                                $vars[toolbar1]=$this->toolbar('list_nav');
591
592                                if(count($this->messages)>0)
593                                {
594                                        foreach($this->messages as $msg)
595                                        {
596                                                $messages.='<span>'.$msg.'</span>';
597                                        }
598                                }
599                                $this->messages = NULL;
600                               
601                                $vars[messages]=$messages;
602
603                                $this->t->set_var($vars);
604                                $this->t->pparse('out','filemanager_header');
605
606                                ###
607                                # Start File Table Column Headers
608                                # Reads values from $file_attributes array and preferences
609                                ###
610                                $this->t->set_var('actions',lang('select'));
611                                $this->t->set_var('mini_bar','&nbsp;');
612
613
614                                reset($this->bo->file_attributes);
615
616                                if($this->numoffiles>0)
617                                {
618                                        while(list($internal, $displayed) = each($this->bo->file_attributes))
619                                        {
620                                                if($this->prefs[$internal])
621                                                {
622                                                        if ($internal != 'owner')
623                                                                $col_data='<span><a href="'.$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.'&sortby='.$internal).'">'.$displayed.'</a></span>';
624                                                        else
625                                                                $col_data='<span>'.$displayed.'</span>';
626                                                        $this->t->set_var('col_data',$col_data);
627                                                        $this->t->parse('columns','column',True);
628                                                }
629                                        }
630
631                                        $this->t->set_var('row_tr_color','#dedede');
632                                       
633                                        $this->t->parse('rows','row');
634                                       
635                                        $this->t->pparse('out','row');
636                                }
637                                else
638                                {
639                                        $lang_nofiles=lang('No files in this directory.');
640                                }
641                                $vars[lang_no_files]=$lang_nofiles;
642
643
644                                if($this->prefs['dotdot'] && $this->prefs['name'] && $this->path != '/')
645                                {
646                                        $this->t->set_var('actions','');
647
648                                        $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath);
649
650                                        $col_data='<a href="'.$link.'"><img src="'.$GLOBALS['phpgw']->common->image('filemanager','mime16up').' "alt="'.lang('Folder Up').'" /></a>';
651                                        $col_data.='&nbsp;<a href="'.$link.'">..</a>';
652
653                                        $this->t->set_var('col_data',$col_data);
654                                        $this->t->parse('columns','column');
655
656                                        if($this->prefs['mime_type'])
657                                        {
658                                                $col_data=lang('Directory');
659                                                $this->t->set_var('col_data',$col_data);
660                                                $this->t->parse('columns','column',True);
661                                        }
662
663                                        $this->t->set_var('row_tr_color',$tr_color);
664                                        $this->t->parse('rows','row');
665                                        $this->t->pparse('out','row');
666                                }
667
668                                # List all of the files, with their attributes
669                                @reset($this->files_array);
670                                for($i = 0; $i != $this->numoffiles; $i++)
671                                {
672                                        $files = $this->files_array[$i];
673                                       
674
675                                        if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name']))
676                                        {
677                                                continue;
678                                        }
679
680                                        # Checkboxes
681                                        if($this->path != $this->bo->fakebase && $this->path != '/')
682                                        {
683                                                $cbox='<input type="checkbox" name="fileman" value="'.$files['name'].'">';
684                                                $this->t->set_var('actions',$cbox);
685                                        }
686                                        else
687                                        {
688                                                $this->t->set_var('actions','');
689                                        }
690                                        $minibar_data="";
691                                        if($this->can_private)
692                                        {
693                                                if ($files['type'] == "1")
694                                                {
695                                                        $image = $GLOBALS['phpgw']->common->image('filemanager','button_lock');
696                                                }
697                                                else
698                                                {
699                                                        $image = $GLOBALS['phpgw']->common->image('filemanager','button_unlock');
700                                                }
701                                                $link=$this->encode_href('/index.php','menuaction=filemanager.vfs_functions.setRestricted','file='.$files['name'].'&path='.$this->path);
702                                                $minibar_data = '<img id="restrict_'.$files['name'].'" onClick="setRestricted(\''.$link.'\')" alt="'.lang("mark as restricted").'" title="'.lang("mark as restricted").'" src="'.$image.'">';
703                                        }
704
705
706                                        if ($files['mime_type'] == "text/html")
707                                        {
708                                                $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.export','file='.$files['name'].'&path='.$this->path);
709                                                $image=$GLOBALS['phpgw']->common->image('filemanager','button_export');
710                                                $minibar_data.='<a href="'.$link.'"><img alt="'.lang("export").'" title="'.lang("export").'" src="'.$image.'"></a>';
711                                        }
712                                        else
713                                                $minibar_data.= "<a>&nbsp;</a>";
714                                        $this->t->set_var('mini_bar',$minibar_data);
715
716
717                                        # File name and icon
718                                        if($files['mime_type'] == 'Directory')
719                                        {
720                                                $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.$this->dispsep.$files['name']);
721
722                                                $icon=$this->mime_icon($files['mime_type']);
723
724                                                $col_data='<a href="'.$link.'">'.$icon.'</a>&nbsp;';
725                                                $col_data.='<a href="'.$link.'">'.$files['name'].'</a>&nbsp;';
726                                        }
727                                        else
728                                        {
729
730                                                if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory'])
731                                                {
732                                                        #FIXME
733                                                        $clickview = $this->filesdir.$pwd.'/'.$files['name'];
734
735                                                }
736                                                else
737                                                {
738                                                        $icon=$this->mime_icon($files['mime_type']);
739                                                        $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path);
740                                                        //$link=$this->encode_href('inc/download.php','file='.base64_encode($files['name']).'&path='.base64_encode($this->path));
741
742                                                        $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;'.
743                                                        '<a id="name_'.$files['name'].'" href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>';
744                                                }
745                                        }
746
747
748                                        $this->t->set_var('col_data',$col_data);
749                                        $this->t->parse('columns','column');
750
751                                        # MIME type
752                                        if($this->prefs['mime_type'])
753                                        {
754                                                $col_data=$files['mime_type'];
755                                                $this->t->set_var('col_data',$col_data);
756                                                $this->t->parse('columns','column',True);
757                                        }
758
759                                        # File size
760                                        if($this->prefs['size'])
761                                        {
762                                                $tmp_arr=array(
763                                                        'string'        => $files['directory'] . '/' . $files['name'],
764                                                        'relatives'     => array(RELATIVE_NONE)
765                                                );
766                                                if($files['mime_type'] != 'Directory') $tmp_arr['checksubdirs'] = false;
767
768                                                $size = $this->bo->vfs->get_size($tmp_arr);
769
770                                                $col_data=$this->bo->borkb($size);
771
772                                                $this->t->set_var('col_data',$col_data);
773                                                $this->t->parse('columns','column',True);
774                                        }
775
776                                        # Date created
777                                        if($this->prefs['created'])
778                                        {
779                                                $timestamp = $this->vfs_functions->dateString2timeStamp($files['created']);
780                                                if (time() - $timestamp > 86400) // Older than yesterday
781                                                        $col_data=date("Y-m-d",$timestamp);
782                                                else
783                                                        $col_data=date("H:i",$timestamp);
784                                                $this->t->set_var('col_data',$col_data);
785                                                $this->t->parse('columns','column',True);
786                                        }
787
788                                        # Date modified
789                                        if($this->prefs['modified'])
790                                        {
791                                                if ($files['modified'] != ''){
792                                                        $timestamp = $this->vfs_functions->dateString2timeStamp($files['modified']);
793                                                        if (time() - $timestamp > 86400) // Older than yesterday
794                                                                $col_data=date("Y-m-d",$timestamp);
795                                                        else
796                                                                $col_data=date("H:i",$timestamp);
797                                                }
798                                                else
799                                                        $col_data='';
800                                                $this->t->set_var('col_data',$col_data);
801                                                $this->t->parse('columns','column',True);
802                                        }
803
804                                        # Owner name
805                                        if($this->prefs['owner'])
806                                        {
807                                                $this->t->set_var('col_data',$GLOBALS['phpgw']->accounts->id2name($files['owner_id']));
808                                                $this->t->parse('columns','column',True);
809                                        }
810
811                                        # Creator name
812                                        if($this->prefs['createdby_id'])
813                                        {
814                                                $this->html_table_col_begin();
815                                                if($files['createdby_id'])
816                                                {
817                                                        $col_data=$GLOBALS['phpgw']->accounts->id2name($files['createdby_id']);
818                                                }
819                                                else $col_data='';
820
821                                                $this->t->set_var('col_data',$col_data);
822                                                $this->t->parse('columns','column',True);
823                                        }
824
825                                        # Modified by name
826                                        if($this->prefs['modifiedby_id'])
827                                        {
828                                                if($files['modifiedby_id'])
829                                                {
830                                                        $col_data=$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']);
831                                                }
832                                                else $col_data='';
833                                                $this->t->set_var('col_data',$col_data);
834                                                $this->t->parse('columns','column',True);
835                                        }
836
837                                        # Application
838                                        if($this->prefs['app'])
839                                        {
840                                                $col_data=$files['app'];
841                                                $this->t->set_var('col_data',$col_data);
842                                                $this->t->parse('columns','column',True);
843                                        }
844
845                                        # Comment
846                                        if($this->prefs['comment'])
847                                        {
848                                                if (strlen($files['comment']) == 0 )
849                                                        $files['comment'] = "&lt;".lang("no comments")."&gt;";
850                                                $col_data='<span id="'.$files['name'].'" onClick="setComments(this)">'.$files['comment'].'</span>';
851                                                $this->t->set_var('col_data',$col_data);
852                                                $this->t->parse('columns','column',True);
853                                        }
854
855                                        # Version
856                                        if($this->prefs['version'])
857                                        {
858                                                $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.history','file='.$files['name'].'&path='.$this->path);
859                                                $col_data='<a href="'.$link.'" target="_blank">'.$files['version'].'</a>';
860                                                $this->t->set_var('col_data',$col_data);
861                                                $this->t->parse('columns','column',True);
862                                        }
863
864                                        $usedspace += $files['size'];
865
866                                        $this->t->set_var('row_tr_color','');
867                                        $this->t->parse('rows','row');
868                                        $this->t->pparse('out','row');
869                                }
870                        }
871
872                        // The file and directory information
873                        $vars[lang_files_in_this_dir]=lang('Files in this directory');
874                        $vars[files_in_this_dir]=$this->numoffiles;
875
876                        $vars[lang_used_space]=lang('Used space');
877                        $vars[used_space]=$this->bo->borkb($usedspace, NULL, 1);
878
879                        if($this->path == $this->bo->homedir || $this->path == $this->bo->fakebase)
880                        {
881                                $vars[lang_unused_space]=lang('Unused space');
882                                $vars[unused_space]=$this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace, NULL, 1);
883
884                                $tmp_arr=array(
885                                        'string'        => $this->path,
886                                        'relatives'     => array(RELATIVE_NONE)
887                                );
888
889                                $ls_array = $this->bo->vfs->ls($tmp_arr);
890
891                                $vars[lang_total_files]=lang('Total Files');
892                                $vars[total_files]=     count($ls_array);
893                        }
894
895                        $this->t->set_var($vars);
896                        $this->t->pparse('out','filemanager_footer');
897
898                        $GLOBALS['phpgw']->common->phpgw_footer();
899                        $GLOBALS['phpgw']->common->phpgw_exit();
900                }
901
902                function readFilesInfo()
903                {
904                        // start files info
905
906                        # Read in file info from database to use in the rest of the script
907                        # $fakebase is a special directory.  In that directory, we list the user's
908                        # home directory and the directories for the groups they're in
909                        $this->numoffiles = 0;
910                        if($this->path == $this->bo->fakebase)
911                        {
912                                // FIXME this test can be removed
913                                if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))))
914                                {
915                                        $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)));
916                                }
917
918                                $ls_array = $this->bo->vfs->ls(array(
919                                        'string' => $this->bo->homedir,
920                                        'relatives' => array(RELATIVE_NONE),
921                                        'checksubdirs' => False,
922                                        'nofiles' => True
923                                ));
924
925                                $this->files_array[] = $ls_array[0];
926                                $this->numoffiles++;
927
928                                reset($this->readable_groups);
929                                while(list($num, $group_array) = each($this->readable_groups))
930                                {
931                                        # If the group doesn't have access to this app, we don't show it
932                                        /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled'])
933                                        {
934                                                continue;
935                                        }
936                                        */
937
938
939                                        if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'      => array(RELATIVE_NONE))))
940                                        {
941                                                $this->bo->vfs->override_acl = 1;
942                                                $this->bo->vfs->mkdir(array(
943                                                        'string' => $this->bo->fakebase.'/'.$group_array['account_name'],
944                                                        'relatives' => array(RELATIVE_NONE)
945                                                ));
946
947                                                // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content
948                                               
949                                               
950                                                $this->bo->vfs->override_acl = 0;
951
952                                                $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'])));
953                                        }
954
955                                        $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'       => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True));
956
957                                        $this->files_array[] = $ls_array[0];
958
959                                        $this->numoffiles++;
960                                }
961                        }
962                        else
963                        {
964                                $ls_array = $this->bo->vfs->ls(array(
965                                        'string' => $this->path,
966                                        'relatives'     => array(RELATIVE_NONE),
967                                        'checksubdirs' => False,
968                                        'nofiles'       => False,
969                                        'orderby'       => $this->sortby
970                                ));
971
972                                while(list($num, $file_array) = each($ls_array))
973                                {
974                                        $this->numoffiles++;
975                                        $this->files_array[] = $file_array;
976                                }
977                        }
978
979                        if(!is_array($this->files_array))
980                        {
981                                $this->files_array = array();
982                        }
983                        // end file count
984                }
985
986                function toolbar($type)
987                {
988                        switch($type)
989                        {
990                                case 'location':
991                                        $toolbar='
992                                        <div id="fmLocation">
993                                        <table cellspacing="10" cellpadding="0" border="0">
994                                        <tr>
995                                        ';
996//                                      $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('phpgwapi','buttonseparator').'" height="27" width="8"></td>';
997//                                      $toolbar.='<td><img alt="spacer" src="'.$GLOBALS['phpgw']->common->image('filemanager','spacer').'" height="27" width="1"></td>';
998
999                                        // go up icon when we're not at the top, dont allow to go outside /home = fakebase
1000                                        if($this->path != '/' && $this->path != $this->bo->fakebase)
1001                                        {
1002                                                $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath);
1003                                                $toolbar.=$this->linkButton($link,'up',lang('go up'));
1004                                        }
1005
1006                                        // go home icon when we're not home already
1007                                        if($this->path != $this->bo->homedir)
1008                                        {
1009                                                $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir);
1010                                                $toolbar.=$this->linkButton($link,'home',lang('go home'));
1011                                        }
1012
1013                                        // reload button with this url
1014                                        $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path);
1015                                        $toolbar.=$this->linkButton($link,'reload',lang('reload'));
1016
1017                                        $toolbar.='<td>'.lang('Location').':&nbsp;';
1018                                        //$toolbar.='<input id="fmInputLocation" type="text" size="20" disabled="disabled" name="location" value="'.$this->disppath.'"/>&nbsp;';
1019                                        $current_option='<option>'.$this->disppath.'</option>';
1020                                        // selectbox for change/move/and copy to
1021                                        $dirs_options=$this->all_other_directories_options();
1022                                        $toolbar.='<select id="cdtodir" name="cdtodir" onChange="document.formfm.changedir.value=\'true\';document.formfm.submit()">'.$current_option.$dirs_options.'</select>
1023                                        <input type="hidden" name="changedir" value="false"></td>
1024                                        ';
1025                                        //$toolbar.=$this->inputImage('goto','goto',lang('Quick jump to'));
1026                                        // upload button
1027                                        /*if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add)
1028                                        {
1029                                                // upload button
1030                                                $toolbar.=$this->inputImage('upload','upload',lang('Upload'));
1031                                               
1032
1033                                        }*/
1034                                        $toolbar.='</tr></table>';
1035                                        $toolbar.='</div><br><br>';
1036                                        break;
1037                                case 'list_nav':
1038                                        $toolbar='
1039                                        <table cellspacing="10" cellpadding="0" border="0">
1040                                        <tr>';
1041                                        // selectbox for change/move/and copy to
1042                                        // submit buttons for
1043                                        if($this->path != '/' && $this->path != $this->bo->fakebase)
1044                                        {
1045                                                // create dir and file button
1046                                                if($this->can_add)
1047                                                {
1048                                                        $toolbar.='<td><input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" /></td>';
1049                                                        //TODO : create folder with problems
1050                                                        //$toolbar3.=$this->inputImage('newdir','createdir',lang('Create Folder'));
1051                                                        $toolbar.=$this->inputImage('new','createfile',lang('New...'));
1052                                                }
1053
1054                                                if($this->can_edit)
1055                                                {
1056                                                        // edit text file button
1057                                                        $toolbar.=$this->inputImage('edit','edit',lang('edit'));
1058                                                }
1059
1060                                                if($this->can_edit)
1061                                                {
1062                                                        $toolbar.=$this->inputImage('rename','rename',lang('Rename'));
1063                                                }
1064
1065                                                if($this->can_delete)
1066                                                {
1067                                                        $toolbar.=$this->inputImage('delete','delete',lang('Delete'));
1068                                                }
1069
1070                                        }
1071
1072                                                // copy and move buttons
1073                                                if($this->path != '/' && $this->path != $this->bo->fakebase)
1074                                                {
1075                                                        $dirs_options=$this->all_other_directories_options();
1076                                                        if (strlen($dirs_options) > 0){
1077                                                                $toolbar3.=$this->inputImage('copy_to','copy_to',lang('Copy to'));
1078                                                                if ($this->can_delete)
1079                                                                        $toolbar3.=$this->inputImage('move_to','move_to',lang('Move to'));
1080                                                        }
1081                                                        $toolbar3.='<td><select name="todir" style="visibility:hidden">'.$dirs_options.'</select></td>';
1082
1083                                                }
1084
1085                                                if($toolbar3)
1086                                                {
1087                                                        $toolbar.=$toolbar3;
1088                                                /*      $toolbar.='
1089                                                        <table cellspacing="1" cellpadding="0" border="0">
1090                                                        <tr>'.$toolbar3;*/
1091                                                }
1092                                        $toolbar.='</tr></table>';
1093
1094                                        break;
1095                                default:$x='';
1096                        }
1097
1098                        if($toolbar)
1099                        {
1100                                return $toolbar;
1101                        }
1102                }
1103
1104
1105                # Handle Moving Files and Directories
1106                function moveTo()
1107                {
1108                        if(!$this->to)
1109                        {
1110                                $this->messages[] = lang('Error:').lang('Could not move file because no destination directory is given ', $this->disppath.'/'.$file);
1111
1112                        }
1113                        else
1114                        {
1115
1116                                while(list($num, $file) = each($this->fileman))
1117                                {
1118                                        if($this->bo->vfs->mv(array(
1119                                                'from'  => $file,
1120                                                'to'    => $this->to . '/' . $file,
1121                                                'relatives'     => array(RELATIVE_ALL, RELATIVE_NONE)
1122                                        )))
1123                                        {
1124                                                $moved++;
1125                                                $this->messages[]=lang('Moved %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file);
1126                                        }
1127                                        else
1128                                        {
1129                                                $this->messages[] = lang('Error:').lang('Could not move %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file);
1130                                        }
1131                                }
1132                        }
1133
1134                        if($moved)
1135                        {
1136                                $x=0;
1137                        }
1138
1139                        $this->readFilesInfo();
1140                        $this->filelisting();
1141                }
1142
1143                // Handle Copying of Files and Directories
1144                function copyTo()
1145                {
1146                        if(!$this->to)
1147                        {
1148                                $this->messages[] = lang('Error:').lang('Could not copy file because no destination directory is given ', $this->disppath.'/'.$file);
1149
1150                        }
1151                        else
1152                        {
1153                                while(list($num, $file) = each($this->fileman))
1154                                {
1155                                        if($this->bo->vfs->cp(array(
1156                                                'from'  => $file,
1157                                                'to'    => $this->to . '/' . $file,
1158                                                'relatives'     => array(RELATIVE_ALL, RELATIVE_NONE)
1159                                        )))
1160                                        {
1161                                                $copied++;
1162                                                $this->messages[] = lang('Copied %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file);
1163                                        }
1164                                        else
1165                                        {
1166                                                $this->messages[] = lang('Error:').lang('Could not copy %1 to %2', $this->disppath.'/'.$file, $this->to.'/'.$file);
1167                                        }
1168                                }
1169                        }
1170                        if($copied)
1171                       
1172                        {
1173                                $x=0;
1174                        }
1175
1176                        $this->readFilesInfo();
1177                        $this->filelisting();
1178                }
1179
1180                function createdir()
1181                {
1182                        if($this->newdir_x && $this->newfile_or_dir)
1183                        {
1184                                if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True))
1185                                {
1186                                        $this->messages[]= lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1);
1187                                }
1188
1189                                /* TODO is this right or should it be a single $ ? */
1190                                if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ')
1191                                {
1192                                        $this->messages[]= lang('Error:').lang('Cannot create directory because it begins or ends in a space');
1193                                }
1194
1195                                $ls_array = $this->bo->vfs->ls(array(
1196                                        'string'        => $this->path . '/' . $this->newfile_or_dir,
1197                                        'relatives'     => array(RELATIVE_NONE),
1198                                        'checksubdirs'  => False,
1199                                        'nofiles'       => True
1200                                ));
1201
1202                                $fileinfo = $ls_array[0];
1203
1204                                if($fileinfo['name'])
1205                                {
1206                                        if($fileinfo['mime_type'] != 'Directory')
1207                                        {
1208                                                $this->messages[]= lang('Error:').lang('%1 already exists as a file',$fileinfo['name']);
1209                                        }
1210                                        else
1211                                        {
1212                                                $this->messages[]= lang('Error:').lang('Directory %1 already exists', $fileinfo['name']);
1213                                        }
1214                                }
1215                                else
1216                                {
1217                                        if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir)))
1218                                        {
1219                                                $this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir);
1220                                        }
1221                                        else
1222                                        {
1223                                                $this->messages[]=lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir);
1224                                        }
1225                                }
1226
1227                                $this->readFilesInfo();
1228                                $this->filelisting();
1229                        }
1230                }
1231                function getReturnExecuteForm(){
1232                        $response = $_SESSION['response'];
1233                        $_SESSION['response'] = null;
1234                        echo $response;
1235                        return;
1236                }
1237                function showUploadboxes()
1238                {
1239                        $this->t->set_file(array('upload' => 'upload.tpl'));
1240                        $this->t->set_block('upload','upload_header','upload_header');
1241                        $this->t->set_block('upload','row','row');
1242                        $this->t->set_block('upload','upload_footer','upload_footer');
1243
1244                        if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add)
1245                        {
1246                                $vars[max_size]=lang('Note: Uploaded is limited to %1MB',($this->current_config['filemanager_Max_file_size']));
1247                                $vars[form_action]=$GLOBALS[phpgw]->link('/filemanager/inc/upload.php');
1248                                //$vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index');
1249                                $vars[path]=$this->path;
1250                                $vars[lang_file]=lang('File');
1251                                $vars[lang_comment]=lang('Comment');
1252                                $vars[num_upload_boxes]=1;
1253                                $this->t->set_var($vars);
1254                                $this->t->pparse('out','upload_header');
1255
1256                                $this->t->set_var('row_tr_color',$tr_color);
1257                                $this->t->parse('rows','row');
1258                                $this->t->pparse('out','row');
1259
1260                                $vars[lang_upload]=lang('Upload files');
1261                                $vars[change_upload_boxes].=lang('Show') . '&nbsp;';
1262                                $this->t->set_var($vars);
1263                                $this->t->pparse('out','upload_footer');
1264                        }
1265                }
1266
1267                /* create textfile */
1268                function createfile()
1269                {
1270                        $this->filename=$this->newfile_or_dir;
1271                        if($this->filename)
1272                        {
1273                                if($badchar = $this->bo->bad_chars($this->filename, True, True))
1274                                {
1275                                        $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar);
1276
1277                                        $this->fileListing();
1278                                }
1279
1280                                if($this->bo->vfs->file_exists(array(
1281                                        'string'=> $this->filename,
1282                                        'relatives'     => array(RELATIVE_ALL)
1283                                )))
1284                                {
1285                                        $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename);
1286                                        $this->fileListing();
1287                                }
1288
1289                                if($this->bo->vfs->touch(array(
1290                                        'string'        => $this->filename,
1291                                        'relatives'     => array(RELATIVE_ALL)
1292                                )))
1293                                {
1294                                        $this->edit = 1;
1295                                        $this->numoffiles++;
1296                                        $this->edit();
1297                                }
1298                                else
1299                                {
1300                                        $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename);
1301                                        $this->fileListing();
1302                                }
1303                        }
1304                }
1305
1306                # Handle Editing files
1307                function edit()
1308                {
1309                        if($this->filename)
1310                        {
1311                                if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){
1312                                        echo $this->messages['0'];
1313                                        $GLOBALS['phpgw']->redirect('/index.php');
1314
1315                                        //$GLOBALS['phpgw']->common->phpgw_exit();
1316                                }
1317                                $ls_array = $this->bo->vfs->ls(array(
1318                                        'string'        => $this->path.'/'.$this->filename,
1319                                        'relatives'     => array(RELATIVE_NONE),
1320                                        'checksubdirs'  => False,
1321                                        'nofiles'       => True
1322                                ));
1323                                $this->bo->vfs->touch(array(
1324                                        'string'=> $this->path.'/'.$this->filename,
1325                                        'relatives'     => array(RELATIVE_NONE)
1326                                ));
1327
1328
1329                                if($ls_array[0]['mime_type'])
1330                                {
1331                                        $mime_type = $ls_array[0]['mime_type'];
1332                                }
1333                                elseif($this->prefs['viewtextplain'])
1334                                {
1335                                        $mime_type = 'text/plain';
1336                                }
1337                                $editable = array('','text/plain','text/csv','text/html','text/text','message/rfc822');
1338
1339                                if(!in_array($mime_type,$editable)){
1340                                        echo lang('Impossbile to edit this file');
1341                                        return False;
1342                                }
1343                        }
1344
1345                        $this->readFilesInfo();
1346
1347                        if ($mime_type == 'text/html')
1348                                $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl'));
1349                        else
1350                                $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl'));
1351
1352                        $this->t->set_block('filemanager_edit','row','row');
1353
1354
1355                        $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>";
1356
1357                        $vars[preview_content]='';
1358                        if($this->edit_file)
1359                        {
1360                                $this->edit_file_content = stripslashes($this->edit_file_content);
1361                        }
1362
1363                        if($this->edit_preview_x)
1364                        {
1365                                $content = $this->edit_file_content;
1366
1367                                $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file);
1368
1369                                $vars[preview_content]=nl2br($content);
1370                        }
1371                        elseif($this->edit_save_x || $this->edit_save_done_x)
1372                        {
1373                                $content = $this->edit_file_content;
1374                                //die( $content);
1375                                if($this->bo->vfs->write(array(
1376                                        'string'        => $this->path.'/'.$this->edit_file,
1377                                        'relatives'     => array(RELATIVE_NONE),
1378                                        'content'       => $content
1379                                )))
1380                                {
1381                                        $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file);
1382
1383                                        if($this->edit_save_done_x)
1384                                        {
1385                                                $this->readFilesInfo();
1386                                                $this->fileListing();
1387                                                exit;
1388                                        }
1389                                }
1390                                else
1391                                {
1392                                        echo lang('Could not save %1', $this->path.'/'.$this->edit_file);
1393                                        $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file);
1394                                }
1395                        }
1396
1397                        # If we're in preview or save mode, we only show the file
1398                        # being previewed or saved
1399                        if($this->edit_file &&($this->filename != $this->edit_file))
1400                        {
1401                                continue;
1402                        }
1403
1404                        if($this->filename && $this->bo->vfs->file_exists(array(
1405                                'string'        => $this->filename,
1406                                'relatives'     => array(RELATIVE_ALL)
1407                        )))
1408                        {
1409                                if($this->edit_file)
1410                                {
1411                                        $content = stripslashes($this->edit_file_content);
1412                                }
1413                                else
1414                                {
1415                                        $content = $this->bo->vfs->read(array('string' => $this->filename));
1416                                }
1417                                $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path);
1418                                $vars[edit_file]=$this->filename;
1419                                # We need to include all of the fileman entries for each file's form,
1420                                # so we loop through again
1421                                for($i = 0; $i != $this->numoffiles; $i++)
1422                                {
1423                                        if($this->filename) $value='value="'.$this->filename.'"';
1424                                        $vars[filemans_hidden]='<input type="hidden" name="filename" '.$value.' />';
1425                                }
1426                                $vars[file_content]=$content;
1427
1428                                $vars[buttonPreview]=$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[$j], 1)));
1429                                $vars[buttonSave]=$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1)));
1430                                $vars[buttonDone]=$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1)));
1431                                $vars[buttonCancel]=$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1)));
1432
1433                                if ($mime_type == 'text/html'){
1434                                        $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script>
1435                                                <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea>
1436                                                <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{
1437removePlugins : \'elementspath\',
1438skin : \'office2003\',
1439toolbar : [["Source","Preview","-","Cut","Copy","Paste","-","Print",
1440"Undo","Redo","-","Find","Replace","-","SelectAll" ],
1441["Table","HorizontalRule","Smiley","SpecialChar","PageBreak","-","Bold",
1442"Italic","Underline","Strike","-","Subscript","Superscript",
1443"NumberedList","BulletedList","-","Outdent","Indent","Blockquote",
1444"JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock",
1445"Link", "TextColor","BGColor","Maximize"],
1446["Styles","Format","Font","FontSize"]]
1447                                });</script>';
1448
1449                                }
1450
1451
1452                                $this->t->set_var($vars);
1453                                $this->t->parse('rows','row');
1454                                $this->t->pparse('out','row');
1455
1456                        }
1457
1458                }
1459
1460                function history()
1461                {
1462                        if($this->file) // FIXME this-file is never defined
1463                        {
1464                                $journal_array = $this->bo->vfs->get_journal(array(
1465                                        'string'        => $this->file,//FIXME
1466                                        'relatives'     => array(RELATIVE_ALL)
1467                                ));
1468
1469                                if(is_array($journal_array))
1470                                {
1471                                        $this->html_table_begin();
1472                                        $this->html_table_row_begin();
1473                                        $this->html_table_col_begin();
1474                                        echo lang('Date');
1475                                        $this->html_table_col_end();
1476                                        $this->html_table_col_begin();
1477                                        echo lang('Version');
1478                                        $this->html_table_col_end();
1479                                        $this->html_table_col_begin();
1480                                        echo lang('Who');
1481                                        $this->html_table_col_end();
1482                                        $this->html_table_col_begin();
1483                                        echo lang('Operation');
1484                                        $this->html_table_col_end();
1485                                        $this->html_table_row_end();
1486
1487                                        while(list($num, $journal_entry) = each($journal_array))
1488                                        {
1489                                                $this->html_table_row_begin();
1490                                                $this->html_table_col_begin();
1491                                                $this->bo->html_text($journal_entry['created'] . '&nbsp;&nbsp;&nbsp;');
1492                                                $this->html_table_col_end();
1493                                                $this->html_table_col_begin();
1494                                                $this->bo->html_text($journal_entry['version'] . '&nbsp;&nbsp;&nbsp;' );
1495                                                $this->html_table_col_end();
1496                                                $this->html_table_col_begin();
1497                                                $this->bo->html_text($GLOBALS['phpgw']->accounts->id2name($journal_entry['owner_id']) . '&nbsp;&nbsp;&nbsp;');
1498                                                $this->html_table_col_end();
1499                                                $this->html_table_col_begin();
1500                                                $this->bo->html_text($journal_entry['comment']);
1501                                                $this->html_table_col_end();
1502                                        }
1503
1504                                        $this->html_table_end();
1505                                        $GLOBALS['phpgw']->common->phpgw_footer();
1506                                        $GLOBALS['phpgw']->common->phpgw_exit();
1507                                }
1508                                else
1509                                {
1510                                        echo lang('No version history for this file/directory');
1511                                }
1512                        }
1513                }
1514                function view()
1515                {
1516                        if (!$this->bo->vfs->acl_check(array(
1517                                'string'        => $this->path,
1518                                'relatives'     => array(RELATIVE_NONE),
1519                                'operation'     => PHPGW_ACL_READ
1520                        )))
1521                        {
1522                                echo lang("You have no permission to access this file");
1523                                return false;
1524                        }
1525                        if($this->file) //FIXME
1526                        {
1527                                $ls_array = $this->bo->vfs->ls(array(
1528                                        'string'        => $this->path.'/'.$this->file,//FIXME
1529                                        'relatives'     => array(RELATIVE_NONE),
1530                                        'checksubdirs'  => False,
1531                                        'nofiles'       => True
1532                                ));
1533                                if ($ls_array[0]['size'] > 4194304){
1534                                        header('Location:'.$this->encode_href('inc/download.php','file='.base64_encode($this->file).'&path='.base64_encode($this->path)));
1535                                        return;
1536                                }
1537                                if($ls_array[0]['mime_type'])
1538                                {
1539                                        $mime_type = $ls_array[0]['mime_type'];
1540                                }
1541                                elseif($this->prefs['viewtextplain'])
1542                                {
1543                                        $mime_type = 'text/plain';
1544                                }
1545                                $viewable = array('','text/plain','text/csv','text/html','text/text');
1546
1547                                if(in_array($mime_type,$viewable))
1548                                {
1549                                        /*Note: if you put application/octet-stream you force download */
1550                                        header('Content-type: ' . $mime_type);
1551                                        header('Content-disposition: filename="' . $this->file . '"');//FIXME
1552                                        Header("Pragma: public");
1553                                }
1554                                else
1555                                {
1556                                        $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME
1557                                }
1558 
1559
1560                                echo $this->bo->vfs->read(array(
1561                                        'string'        => $this->path.'/'.$this->file,//FIXME
1562                                        'relatives'     => array(RELATIVE_NONE)
1563                                ));
1564                                $GLOBALS['phpgw']->common->phpgw_exit();
1565                        }
1566                }
1567
1568                function export(){
1569                        if($this->file)
1570                        {
1571                                $ls_array = $this->bo->vfs->ls(array(
1572                                        'string'        => $this->path.'/'.$this->file,
1573                                        'relatives'     => array(RELATIVE_NONE),
1574                                        'checksubdirs'  => False,
1575                                        'nofiles'       => True
1576                                ));
1577                                /*$timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']);
1578                                if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']);
1579                                {
1580                                        // recently than last minute: someone is editing
1581                                }*/
1582                                $mime_type = $ls_array[0]['mime_type'];
1583                                $formats = array('text/html');
1584                                if(!in_array($mime_type,$formats)){
1585                                        echo lang('Impossbile to export this file');
1586                                        return False;
1587                                }
1588                                $content = $this->bo->vfs->read(array('string' => $this->path.'/'.$this->file,
1589                                               'relatives'     => array(RELATIVE_NONE)
1590                                       ));
1591
1592                                include_once('filemanager/tp/dompdf/dompdf_config.inc.php');
1593                                $dompdf = new DOMPDF();
1594                                $dompdf->load_html($content);
1595                                $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']);
1596                                /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate'*/
1597                                $dompdf->render();
1598                                $dompdf->stream(strtok($this->file,'.').".pdf");
1599                                $GLOBALS['phpgw']->common->phpgw_exit();
1600                        }
1601                }
1602
1603                //give back an array with all directories except current and dirs that are not accessable
1604                function all_other_directories_options()
1605                {
1606                        # First we get the directories in their home directory
1607                        $dirs = array();
1608                        $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']);
1609
1610                        $tmp_arr=array(
1611                                'string'        => $this->bo->homedir,
1612                                'relatives'     => array(RELATIVE_NONE),
1613                                'checksubdirs'  => True,
1614                                'mime_type'     => 'Directory'
1615                        );
1616
1617                        $ls_array = $this->bo->vfs->ls($tmp_arr);
1618
1619                        while(list($num, $dir) = each($ls_array))
1620                        {
1621                                $dirs[] = $dir;
1622                        }
1623
1624
1625                        # Then we get the directories in their readable groups' home directories
1626                        reset($this->readable_groups);
1627                        while(list($num, $group_array) = each($this->readable_groups))
1628                        {
1629                                /* Don't list directories for groups that don't have access
1630                                if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled'])
1631                                {
1632]                                       continue;
1633                                }*/
1634
1635                                $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']);
1636
1637                                $tmp_arr=array(
1638                                        'string'        => $this->bo->fakebase.'/'.$group_array['account_name'],
1639                                        'relatives'     => array(RELATIVE_NONE),
1640                                        'checksubdirs'  => True,
1641                                        'mime_type'     => 'Directory'
1642                                );
1643
1644                                $ls_array = $this->bo->vfs->ls($tmp_arr);
1645                                while(list($num, $dir) = each($ls_array))
1646                                {
1647                                        $dirs[] = $dir;
1648                                }
1649                        }
1650
1651                        reset($dirs);
1652                        while(list($num, $dir) = each($dirs))
1653                        {
1654                                if(!$dir['directory'])
1655                                {
1656                                        continue;
1657                                }
1658
1659                                # So we don't display //
1660                                if($dir['directory'] != '/')
1661                                {
1662                                        $dir['directory'] .= '/';
1663                                }
1664
1665                                # No point in displaying the current directory, or a directory that doesn't exist
1666                                if((($dir['directory'] . $dir['name']) != $this->path) && $this->bo->vfs->file_exists(array('string' => $dir['directory'] . $dir['name'],'relatives' => array(RELATIVE_NONE))))
1667                                {
1668                                        //FIXME replace the html_form_option function
1669                                        $options .= $this->html_form_option($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']);
1670                                }
1671                        }
1672
1673                        return $options;
1674                }
1675
1676                /* seek icon for mimetype else return an unknown icon */
1677                function mime_icon($mime_type, $size=16)
1678                {
1679                        if(!$mime_type) $mime_type='unknown';
1680
1681                        $mime_type=str_replace  ('/','_',$mime_type);
1682
1683                        $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type));
1684                        if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown');
1685
1686                        $icon='<img src="'.$img.' "alt="'.lang($mime_type).'" />';
1687                        return $icon;
1688                }
1689
1690                function linkButton($link,$img='',$description='')
1691                {
1692                        $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img));
1693
1694                        if($img)
1695                        {
1696                                return '<td class="" align="center" valign="middle" height="28" width="70">
1697                                <a href="'.$link.'" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/></a><br><small>'.$description.'</small>
1698                                </td>';
1699                        }
1700                }
1701
1702                function inputButton($name,$img='',$description='')
1703                {
1704                        $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img));
1705
1706                        if($img)
1707                        {
1708                                return '<td class="" align="center" valign="middle" height="28" width="70">
1709                                <input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small>
1710                                </td>';
1711                        }
1712                }
1713                function inputImage($name,$img='',$description='')
1714                {
1715                        $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img));
1716
1717                        if($img)
1718                        {
1719                                return '<td class="" align="center" valign="middle" height="28" width="70">
1720                                <img onClick="toolbar_control(\''.$name.'\')" title="'.$description.'" name="'.$name.'" alt="'.$name.'" src="'.$image.'" /><br><small>'.$description.'</small>
1721                                </td>';
1722                        }
1723                }
1724
1725
1726
1727                function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1)
1728                {
1729                        $text = ' ';
1730                        if($type != NULL && $type)
1731                        {
1732                                if($type == 'checkbox')
1733                                {
1734                                        $value = $this->bo->string_encode($value, 1);
1735                                }
1736                                $text .= 'type="'.$type.'" ';
1737                        }
1738                        if($name != NULL && $name)
1739                        {
1740                                $text .= 'name="'.$name.'" ';
1741                        }
1742                        if($value != NULL && $value)
1743                        {
1744                                $text .= 'value="'.$value.'" ';
1745                        }
1746                        if(is_int($maxlength) && $maxlength >= 0)
1747                        {
1748                                $text .= 'maxlength="'.$maxlength.'" ';
1749                        }
1750                        if(is_int($size) && $size >= 0)
1751                        {
1752                                $text .= 'size="'.$size.'" ';
1753                        }
1754                        if($checked != NULL && $checked)
1755                        {
1756                                $text .= 'checked ';
1757                        }
1758
1759                        return '<input'.$text.$string.'>';
1760                }
1761
1762                function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0)
1763                {
1764                        $text = ' ';
1765                        if($value != NULL && $value)
1766                        {
1767                                $text .= ' value="'.$value.'" ';
1768                        }
1769                        if($selected != NULL && $selected)
1770                        {
1771                                $text .= ' selected';
1772                        }
1773                        return  '<option'.$text.'>'.$displayed.'</option>';
1774                }
1775
1776                function encode_href($href = NULL, $args = NULL , $extra_args)
1777                {
1778                        $href = $this->bo->string_encode($href, 1);
1779                        $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1);
1780
1781                        $address = $GLOBALS['phpgw']->link($href, $all_args);
1782
1783                        return $address;
1784                }
1785
1786                function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL)
1787                {
1788                        //      unset($encode);
1789                        if($encode)
1790                        {
1791                                $href = $this->bo->string_encode($href, 1);
1792                                $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1);
1793                        }
1794                        else
1795                        {
1796                                //                              $href = $this->bo->string_encode($href, 1);
1797                                $all_args = $args.'&'.$extra_args;
1798                        }
1799                        ###
1800                        # This decodes / back to normal
1801                        ###
1802                        //                      $all_args = preg_replace("/%2F/", "/", $all_args);
1803                        //                      $href = preg_replace("/%2F/", "/", $href);
1804
1805                        /* Auto-detect and don't disturb absolute links */
1806                        if(!preg_match("|^http(.{0,1})://|", $href))
1807                        {
1808                                //Only add an extra / if there isn't already one there
1809
1810                                // die(SEP);
1811                                if(!($href[0] == SEP))
1812                                {
1813                                        $href = SEP . $href;
1814                                }
1815
1816                                /* $phpgw->link requires that the extra vars be passed separately */
1817                                //                              $link_parts = explode("?", $href);
1818                                $address = $GLOBALS['phpgw']->link($href, $all_args);
1819                                //                              $address = $GLOBALS['phpgw']->link($href);
1820                        }
1821                        else
1822                        {
1823                                $address = $href;
1824                        }
1825
1826                        /* If $linkonly is set, don't add any HTML */
1827                        if($linkonly)
1828                        {
1829                                $rstring = $address;
1830                        }
1831                        else
1832                        {
1833                                if($target)
1834                                {
1835                                        $target = 'target='.$target;
1836                                }
1837
1838                                $text = trim($text);
1839                                $rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>';
1840                        }
1841
1842                        return($this->bo->eor($rstring, $return));
1843                }
1844
1845                function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0)
1846                {
1847                        if($width != NULL && $width)
1848                        {
1849                                $width = "width=$width";
1850                        }
1851                        if(is_int($border) && $border >= 0)
1852                        {
1853                                $border = "border=$border";
1854                        }
1855                        if(is_int($cellspacing) && $cellspacing >= 0)
1856                        {
1857                                $cellspacing = "cellspacing=$cellspacing";
1858                        }
1859                        if(is_int($cellpadding) && $cellpadding >= 0)
1860                        {
1861                                $cellpadding = "cellpadding=$cellpadding";
1862                        }
1863                        if($rules != NULL && $rules)
1864                        {
1865                                $rules = "rules=$rules";
1866                        }
1867
1868                        $rstring = "<table $width $border $cellspacing $cellpadding $rules $string>";
1869                        return($this->bo->eor($rstring, $return));
1870                }
1871
1872                function html_table_end($return = 0)
1873                {
1874                        $rstring = "</table>";
1875                        return($this->bo->eor($rstring, $return));
1876                }
1877
1878                function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0)
1879                {
1880                        if($align != NULL && $align)
1881                        {
1882                                $align = "align=$align";
1883                        }
1884                        if($halign != NULL && $halign)
1885                        {
1886                                $halign = "halign=$halign";
1887                        }
1888                        if($valign != NULL && $valign)
1889                        {
1890                                $valign = "valign=$valign";
1891                        }
1892                        if($bgcolor != NULL && $bgcolor)
1893                        {
1894                                $bgcolor = "bgcolor=$bgcolor";
1895                        }
1896                        $rstring = "<tr $align $halign $valign $bgcolor $string>";
1897                        return($this->bo->eor($rstring, $return));
1898                }
1899
1900                function html_table_row_end($return = 0)
1901                {
1902                        $rstring = "</tr>";
1903                        return($this->bo->eor($rstring, $return));
1904                }
1905
1906                function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0)
1907                {
1908                        if($align != NULL && $align)
1909                        {
1910                                $align = "align=$align";
1911                        }
1912                        if($halign != NULL && $halign)
1913                        {
1914                                $halign = "halign=$halign";
1915                        }
1916                        if($valign != NULL && $valign)
1917                        {
1918                                $valign = "valign=$valign";
1919                        }
1920                        if(is_int($rowspan) && $rowspan >= 0)
1921                        {
1922                                $rowspan = "rowspan=$rowspan";
1923                        }
1924                        if(is_int($colspan) && $colspan >= 0)
1925                        {
1926                                $colspan = "colspan=$colspan";
1927                        }
1928
1929                        $rstring = "<td $align $halign $valign $rowspan $colspan $string>";
1930                        return($this->bo->eor($rstring, $return));
1931                }
1932
1933                function html_table_col_end($return = 0)
1934                {
1935                        $rstring = "</td>";
1936                        return($this->bo->eor($rstring, $return));
1937                }
1938        }
Note: See TracBrowser for help on using the repository browser.