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

Revision 1693, 57.6 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - melhorias no modulo gerenciador de arquivos para arquivos grandes

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