Ignore:
Timestamp:
03/18/11 18:18:12 (13 years ago)
Author:
alexandrecorreia
Message:

Ticket #1648 - Correcao( codigo ) e melhoria( laytou/informacao ) no upload de arquivos para o servidor.

Location:
branches/2.2/filemanager
Files:
1 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/filemanager/inc/class.uifilemanager.inc.php

    r3873 r3879  
    11<?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 { 
     2 
     3/* * ************************************************************************\ 
     4 * -------------------------------------------------------------------------* 
     5 * This library is free software; you can redistribute it and/or modify it  * 
     6 * under the terms of the GNU Lesser General Public License as published by * 
     7 * the Free Software Foundation; either version 2.1 of the License,         * 
     8 * or any later version.                                                    * 
     9 * This library is distributed in the hope that it will be useful, but      * 
     10 * WITHOUT ANY WARRANTY; without even the implied warranty of               * 
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     * 
     12 * See the GNU Lesser General Public License for more details.              * 
     13 * You should have received a copy of the GNU Lesser General Public License * 
     14 * along with this library; if not, write to the Free Software Foundation,  * 
     15 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            * 
     16  \************************************************************************* */ 
     17 
     18/* $Id: class.uifilemanager.inc.php 17511 2004-12-12 06:35:24Z dawnlinux $ */ 
     19 
     20class uifilemanager { 
     21 
    2122        var $public_functions = array( 
    22                 'index'                                 => True, 
    23                 'help'                                  => True, 
    24                 'view'                                  => True, 
    25                 'export'                                => True, 
    26                 'touch'                                 => True, 
    27                 'history'                               => True, 
    28                 'edit'                                  => True, 
    29                 'fileModels'                    => True, 
    30                 'getReturnExecuteForm'  => True, 
    31                 'dir_ls'                                => True, 
    32                 'search'                                => True, 
    33                 'get_folders_list'              => True, 
    34                 'showUploadboxes'               => True, 
    35                 'createdir'                     => True, 
    36                 'removedir'                     => True, 
    37                 'uploadModel'                   => True 
     23                 'index' => True, 
     24                 'help' => True, 
     25                 'view' => True, 
     26                 'export' => True, 
     27                 'touch' => True, 
     28                 'history' => True, 
     29                 'edit' => True, 
     30                 'fileModels' => True, 
     31                 'getReturnExecuteForm' => True, 
     32                 'dir_ls' => True, 
     33                 'search' => True, 
     34                 'get_folders_list' => True, 
     35                 'showUploadboxes' => True, 
     36                 'createdir' => True, 
     37                 'removedir' => True, 
     38                 'uploadModel' => True 
    3839        ); 
    39  
    4040        //keep 
    4141        var $bo; 
     
    4949        var $numoffiles; 
    5050        var $dispsep; 
    51  
    5251        var $target; 
    53  
    54         var $prefs;//array 
    55  
     52        var $prefs; //array 
    5653        var $groups_applications; 
    57  
    5854        var $current_config; 
    5955        var $dirs; 
     
    7268        var $edit_save_done_x; 
    7369        var $edit_cancel_x; 
    74  
    7570        // this ones must be checked thorougly; 
    7671        var $fileman = Array(); 
     
    8277        var $limit; //for paging (paginacao) 
    8378        var $offset; //for paging (paginacao) 
    84  
    8579        var $now; 
    8680 
    87         function uifilemanager() 
    88         { 
     81        function uifilemanager() { 
    8982                $this->messages = &$_SESSION['phpgw_info']['filemanager']['user']['messages']; 
    9083 
     
    9891 
    9992                $this->t = $GLOBALS['phpgw']->template; 
    100                 $c = CreateObject('phpgwapi.config','filemanager'); 
     93                $c = CreateObject('phpgwapi.config', 'filemanager'); 
    10194                $c->read_repository(); 
     95 
    10296                $this->current_config = $c->config_data; 
    103  
    10497 
    10598                // here local vars are created from the HTTP vars 
    10699                @reset($GLOBALS['HTTP_POST_VARS']); 
    107                 while(list($name,) = @each($GLOBALS['HTTP_POST_VARS'])) 
    108                 { 
     100                while (list($name, ) = @each($GLOBALS['HTTP_POST_VARS'])) { 
    109101                        $this->$name = $GLOBALS['HTTP_POST_VARS'][$name]; 
    110102                } 
    111103 
    112104                @reset($GLOBALS['HTTP_GET_VARS']); 
    113                 while(list($name,) = @each($GLOBALS['HTTP_GET_VARS'])) 
    114                 { 
     105                while (list($name, ) = @each($GLOBALS['HTTP_GET_VARS'])) { 
    115106                        $$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
    116107                        $this->$name = $GLOBALS['HTTP_GET_VARS'][$name]; 
    117  
    118108                } 
    119109 
    120110                $to_decode = array 
    121                 ( 
    122                         'op'    => array('op' => ''), 
    123                         'path'  => array('path' => ''), 
    124                         'filename' => array('filename' => ''), 
    125                         'file'  => array('file' => ''), 
    126                         'sortby'        => array('sortby' => ''), 
    127                         'messages'      => array('messages'     => ''), 
    128                         'show_upload_boxes'     => array('show_upload_boxes' => ''), 
    129                         'from'  =>      array('from' => ''), 
    130                         'to' => array('to' => '') 
    131  
     111                         ( 
     112                         'op' => array('op' => ''), 
     113                         'path' => array('path' => ''), 
     114                         'filename' => array('filename' => ''), 
     115                         'file' => array('file' => ''), 
     116                         'sortby' => array('sortby' => ''), 
     117                         'messages' => array('messages' => ''), 
     118                         'show_upload_boxes' => array('show_upload_boxes' => ''), 
     119                         'from' => array('from' => ''), 
     120                         'to' => array('to' => '') 
    132121                ); 
    133122 
    134123                reset($to_decode); 
    135                 while(list($var, $conditions) = each($to_decode)) 
    136                 { 
    137                         while(list($condvar, $condvalue) = each($conditions)) 
    138                         { 
    139                                 if(isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) 
    140                                 { 
     124                while (list($var, $conditions) = each($to_decode)) { 
     125                        while (list($condvar, $condvalue) = each($conditions)) { 
     126                                if (isset($$condvar) && ($condvar == $var || $$condvar == $condvalue)) { 
    141127                                        $this->$var = stripslashes(base64_decode($$var)); 
    142128                                } 
     
    151137                $pref_array = $pref->read_repository(); 
    152138                $this->prefs = $pref_array[$this->bo->appname]; //FIXME check appname var in _debug_array 
    153  
    154139                //always show name 
    155140 
    156                 $this->prefs[name] =1; 
    157  
    158  
    159                 if($this->prefs['viewinnewwin']) 
    160                 { 
     141                $this->prefs[name] = 1; 
     142 
     143 
     144                if ($this->prefs['viewinnewwin']) { 
    161145                        $this->target = '_blank'; 
    162146                } 
     
    164148 
    165149                /* 
    166                         Check for essential directories 
    167                         admin must be able to disable these tests 
    168                 */ 
    169                  
     150                  Check for essential directories 
     151                  admin must be able to disable these tests 
     152                 */ 
     153 
    170154                // check if basedir exist  
    171                 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    172                 if($test[mime_type]!='Directory') 
    173                 { 
     155                $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     156                if ($test[mime_type] != 'Directory') { 
    174157                        die('Base directory does not exist, Ask adminstrator to check the global configuration.'); 
    175158                } 
    176159 
    177                 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    178                 if($test[mime_type]!='Directory') 
    179                 { 
     160                $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     161                if ($test[mime_type] != 'Directory') { 
    180162                        $this->bo->vfs->override_acl = 1; 
    181163 
    182164                        $this->bo->vfs->mkdir(array( 
    183                                 'string' => $this->bo->fakebase, 
    184                                 'relatives' => array(RELATIVE_NONE) 
     165                                 'string' => $this->bo->fakebase, 
     166                                 'relatives' => array(RELATIVE_NONE) 
    185167                        )); 
    186                          
     168 
    187169                        $this->bo->vfs->override_acl = 0; 
    188170 
    189171                        //test one more time 
    190                         $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    191  
    192                         if($test[mime_type]!='Directory') 
    193                         { 
     172                        $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->fakebase, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     173 
     174                        if ($test[mime_type] != 'Directory') { 
    194175                                die('Fake Base directory does not exist and could not be created, please ask the administrator to check the global configuration.'); 
    195                         } 
    196                         else 
    197                         { 
    198                                 $this->messages[]= lang('Fake Base Dir did not exist, created a new one.'); 
    199                         } 
    200                 } 
    201  
    202                 $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    203                 if($test[mime_type]!='Directory') 
    204                 { 
     176                        } else { 
     177                                $this->messages[] = lang('Fake Base Dir did not exist, created a new one.'); 
     178                        } 
     179                } 
     180 
     181                $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     182                if ($test[mime_type] != 'Directory') { 
    205183                        $this->bo->vfs->override_acl = 1; 
    206184 
    207185                        $this->bo->vfs->mkdir(array( 
    208                                 'string' => $this->bo->homedir, 
    209                                 'relatives' => array(RELATIVE_NONE) 
     186                                 'string' => $this->bo->homedir, 
     187                                 'relatives' => array(RELATIVE_NONE) 
    210188                        )); 
    211189                        $this->bo->vfs->set_quota(array( 
    212                                 'string' => $this->bo->homedir, 
    213                                 'relatives' => array(RELATIVE_NONE), 
    214                                 'new_quota' => $this->current_config['filemanager_quota_size']  
     190                                 'string' => $this->bo->homedir, 
     191                                 'relatives' => array(RELATIVE_NONE), 
     192                                 'new_quota' => $this->current_config['filemanager_quota_size'] 
    215193                        )); 
    216194 
     
    218196 
    219197                        //test one more time 
    220                         $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->basedir.$this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    221  
    222                         if($test[mime_type]!='Directory') 
    223                         { 
     198                        $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->basedir . $this->bo->homedir, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     199 
     200                        if ($test[mime_type] != 'Directory') { 
    224201                                die('Your Home Dir does not exist and could not be created, please ask the adminstrator to check the global configuration.'); 
    225                         } 
    226                         else 
    227                         { 
    228                                 $this->messages[]= lang('Your Home Dir did not exist, eGroupWare created a new one.'); 
     202                        } else { 
     203                                $this->messages[] = lang('Your Home Dir did not exist, eGroupWare created a new one.'); 
    229204                                // FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content 
    230205                        } 
    231  
    232  
    233                 } 
    234         } 
    235         function fileModels() 
    236         { 
     206                } 
     207        } 
     208 
     209        function fileModels() { 
    237210                $GLOBALS['phpgw_info']['flags'] = array 
    238                         ( 
    239                                 'currentapp'    => 'filemanager', 
    240                                 'noheader'      => False, 
    241                                 'nonavbar' => False, 
    242                                 'nofooter'      => False, 
    243                                 'noappheader'  => False, 
    244                                 'enable_browser_class' => True 
    245                         ); 
     211                         ( 
     212                         'currentapp' => 'filemanager', 
     213                         'noheader' => False, 
     214                         'nonavbar' => False, 
     215                         'nofooter' => False, 
     216                         'noappheader' => False, 
     217                         'enable_browser_class' => True 
     218                ); 
    246219 
    247220                $GLOBALS['phpgw']->common->phpgw_header(); 
    248221                $this->t->set_file(array('models' => 'fileModels.tpl')); 
    249                 $this->t->set_block('models','header','header'); 
    250                 $this->t->set_block('models','body','body'); 
    251                 $this->t->set_block('models','footer','footer'); 
     222                $this->t->set_block('models', 'header', 'header'); 
     223                $this->t->set_block('models', 'body', 'body'); 
     224                $this->t->set_block('models', 'footer', 'footer'); 
    252225                $this->t->set_var('url_1', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=article'); 
    253                 $this->t->set_var('model_1','article'); 
    254                 $this->t->set_var('lang_1',lang('article')); 
    255  
    256                 $this->t->set_var('url_2','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 
    257                 $this->t->set_var('model_2','calendar'); 
    258                 $this->t->set_var('lang_2',lang('calendar')); 
    259  
    260                 $this->t->set_var('url_3','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 
    261                 $this->t->set_var('model_3','todo'); 
    262                 $this->t->set_var('lang_3',lang('todo')); 
    263  
    264                 $this->t->set_var('url_4','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 
    265                 $this->t->set_var('model_4','slide'); 
    266                 $this->t->set_var('lang_4',lang('slide')); 
    267  
    268                 $this->t->set_var('url_5','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 
    269                 $this->t->set_var('model_5','cards'); 
    270                 $this->t->set_var('lang_5',lang('cards')); 
    271  
    272                 $this->t->set_var('url_6','./index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 
    273                 $this->t->set_var('model_6','resume'); 
    274                 $this->t->set_var('lang_6',lang('resume')); 
    275  
    276  
    277                 $this->t->pparse('out','models'); 
    278  
    279  
    280         } 
    281         function uploadModel(){ 
     226                $this->t->set_var('model_1', 'article'); 
     227                $this->t->set_var('lang_1', lang('article')); 
     228 
     229                $this->t->set_var('url_2', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=calendar'); 
     230                $this->t->set_var('model_2', 'calendar'); 
     231                $this->t->set_var('lang_2', lang('calendar')); 
     232 
     233                $this->t->set_var('url_3', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=todo'); 
     234                $this->t->set_var('model_3', 'todo'); 
     235                $this->t->set_var('lang_3', lang('todo')); 
     236 
     237                $this->t->set_var('url_4', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=slide'); 
     238                $this->t->set_var('model_4', 'slide'); 
     239                $this->t->set_var('lang_4', lang('slide')); 
     240 
     241                $this->t->set_var('url_5', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=cards'); 
     242                $this->t->set_var('model_5', 'cards'); 
     243                $this->t->set_var('lang_5', lang('cards')); 
     244 
     245                $this->t->set_var('url_6', './index.php?menuaction=filemanager.uifilemanager.uploadModel&model=resume'); 
     246                $this->t->set_var('model_6', 'resume'); 
     247                $this->t->set_var('lang_6', lang('resume')); 
     248 
     249 
     250                $this->t->pparse('out', 'models'); 
     251        } 
     252 
     253        function uploadModel() { 
    282254                $GLOBALS['phpgw_info']['flags'] = array 
    283                         ( 
    284                                 'currentapp'    => 'filemanager', 
    285                                 'noheader'      => False, 
    286                                 'nonavbar' => False, 
    287                                 'nofooter'      => False, 
    288                                 'noappheader'  => False, 
    289                                 'enable_browser_class' => True 
    290                         ); 
     255                         ( 
     256                         'currentapp' => 'filemanager', 
     257                         'noheader' => False, 
     258                         'nonavbar' => False, 
     259                         'nofooter' => False, 
     260                         'noappheader' => False, 
     261                         'enable_browser_class' => True 
     262                ); 
    291263 
    292264                $GLOBALS['phpgw']->common->phpgw_header(); 
    293265 
    294                 $filename = lang('new')."_".lang($this->model).rand(0,1000).".html"; 
     266                $filename = lang('new') . "_" . lang($this->model) . rand(0, 1000) . ".html"; 
    295267                $this->bo->vfs->cp(array( 
    296                         'from'=> PHPGW_SERVER_ROOT . '/filemanager/templates/default/'.$this->model.'.html', 
    297                         'to'=> $filename, 
    298                         'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
     268                         'from' => PHPGW_SERVER_ROOT . '/filemanager/templates/default/' . $this->model . '.html', 
     269                         'to' => $filename, 
     270                         'relatives' => array(RELATIVE_NONE | VFS_REAL, RELATIVE_ALL) 
    299271                )); 
    300272 
    301273                $this->bo->vfs->set_attributes(array( 
    302                         'string'=> $filename, 
    303                         'relatives'    => array(RELATIVE_ALL), 
    304                         'attributes'=> array( 
    305                                 'mime_type' => "text/html", 
    306                                 'comment' => "" 
    307                         ) 
     274                         'string' => $filename, 
     275                         'relatives' => array(RELATIVE_ALL), 
     276                         'attributes' => array( 
     277                                  'mime_type' => "text/html", 
     278                                  'comment' => "" 
     279                         ) 
    308280                )); 
    309281                $this->filename = $filename; 
    310282                $this->edit(); 
    311  
    312         } 
    313         function index() 
    314         { 
     283        } 
     284 
     285        function index() { 
    315286                $GLOBALS['phpgw_info']['flags'] = array 
    316                 ( 
    317                         'currentapp'    => 'filemanager', 
    318                         'noheader'      => False, 
    319                         'nonavbar' => False, 
    320                         'nofooter'      => False, 
    321                         'noappheader'   => False, 
    322                         'enable_browser_class'  => True 
     287                         ( 
     288                         'currentapp' => 'filemanager', 
     289                         'noheader' => False, 
     290                         'nonavbar' => False, 
     291                         'nofooter' => False, 
     292                         'noappheader' => False, 
     293                         'enable_browser_class' => True 
    323294                ); 
    324295 
    325296                $GLOBALS['phpgw']->common->phpgw_header(); 
     297 
     298                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/inc/load_lang.php'></script>"; 
     299                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/global.js'></script>"; 
     300                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/main.js'></script>"; 
     301                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/common_functions.js'></script>"; 
     302                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/connector.js'></script>"; 
     303                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/draw_api.js'></script>"; 
     304                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/drag_area.js'></script>"; 
     305                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/handler.js'></script>"; 
    326306                 
    327                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/inc/load_lang.php'></script>"; 
    328                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/global.js'></script>"; 
    329                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; 
    330                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; 
    331                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; 
    332                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/draw_api.js'></script>"; 
    333                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/drag_area.js'></script>"; 
    334                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/handler.js'></script>"; 
     307                //echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/js/NewHandler.js'></script>"; 
    335308 
    336309 
     
    338311                $theme = "window_" . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . ".css"; 
    339312 
    340                 if( !file_exists('filemanager/tp/expressowindow/css/'.$theme) ) 
     313                if (!file_exists('filemanager/tp/expressowindow/css/' . $theme)) 
    341314                        $theme = "window_default.css"; 
    342315 
    343316                // Path FileManager 
    344317                $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 
    345                 $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 
    346          
    347                 if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1)) 
     318                $webserver_url = (!empty($webserver_url) ) ? $webserver_url : '/'; 
     319 
     320                if (strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url) - 1)) 
    348321                        $webserver_url .= '/'; 
    349          
    350                 $webserver_url  = $webserver_url . 'filemanager/';  
    351                  
    352                 $js   = "var path_filemanager   = '".$webserver_url."';"; 
    353                 $js      .= "var my_home_filemanager    = '".trim($GLOBALS['uifilemanager']->bo->vfs->my_home)."';"; 
    354                  
    355                 echo "<script type='text/javascript'>".$js."</script>"; 
     322 
     323                $webserver_url = $webserver_url . 'filemanager/'; 
     324 
     325                $js = "var path_filemanager     = '" . $webserver_url . "';"; 
     326                $js .= "var my_home_filemanager = '" . trim($GLOBALS['uifilemanager']->bo->vfs->my_home) . "';"; 
     327 
     328                echo "<script type='text/javascript'>" . $js . "</script>"; 
    356329 
    357330                // Expresso Window - CSS 
    358                 print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/'.$theme.'" >'; 
     331                print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'tp/expressowindow/css/' . $theme . '" >'; 
    359332 
    360333                // Expresso Window - JS  
    361                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/xtools.js'></script>"; 
    362                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/jsloader.js'></script>"; 
    363                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/makeW.js'></script>"; 
    364                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/dragdrop.js'></script>"; 
    365                 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/tp/expressowindow/js/show_hidden.js'></script>"; 
     334                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/xtools.js'></script>"; 
     335                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/jsloader.js'></script>"; 
     336                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/makeW.js'></script>"; 
     337                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/dragdrop.js'></script>"; 
     338                echo "<script src='" . $GLOBALS['phpgw_info']['flags']['currentapp'] . "/tp/expressowindow/js/show_hidden.js'></script>"; 
    366339 
    367340                echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>"; 
     
    370343                # Code is fairly hackish at the beginning, but it gets better 
    371344                # Highly suggest turning wrapping off due to long SQL queries 
    372  
    373345                ### 
    374346                # Some hacks to set and display directory paths correctly 
    375347                ### 
    376348                // new method for switching to a new dir. 
    377                 if($this->changedir=='true' && $this->cdtodir || $this->goto_x) 
    378                 { 
     349                if ($this->changedir == 'true' && $this->cdtodir || $this->goto_x) { 
    379350                        $this->path = $this->cdtodir; 
    380351                } 
    381352 
    382                 if(!$this->path) 
    383                 { 
     353                if (!$this->path) { 
    384354                        $this->path = $this->bo->vfs->pwd(); 
    385355 
    386                         if(!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') 
    387                         { 
    388                                 $this->path = $this->bo->homedir;  
     356                        if (!$this->path || $this->bo->vfs->pwd(array('full' => False)) == '') { 
     357                                $this->path = $this->bo->homedir; 
    389358                        } 
    390359                } 
     
    395364                $pwd = $this->bo->vfs->pwd(); 
    396365 
    397                 if(!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1))   
    398                 { 
     366                if (!$this->cwd = substr($this->path, strlen($this->bo->homedir) + 1)) { 
    399367                        $this->cwd = '/'; 
    400                 } 
    401                 else 
    402                 { 
     368                } else { 
    403369                        $this->cwd = substr($pwd, strrpos($pwd, '/') + 1); 
    404370                } 
     
    407373 
    408374                /* This just prevents // in some cases */ 
    409                 if($this->path == '/') 
    410                 { 
     375                if ($this->path == '/') { 
    411376                        $this->dispsep = ''; 
    412                 } 
    413                 else 
    414                 { 
     377                } else { 
    415378                        $this->dispsep = '/'; 
    416379                } 
    417380 
    418                 if(!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) 
    419                 { 
     381                if (!($this->lesspath = substr($this->path, 0, strrpos($this->path, '/')))) { 
    420382                        $this->lesspath = '/'; 
    421383                } 
    422384 
    423                 /*Check permission*/ 
    424                 if($this->bo->vfs->acl_check(array( 
    425                         'string' => $this->path, 
    426                         'relatives' => array(RELATIVE_NONE), 
    427                         'operation' => PHPGW_ACL_READ 
    428                 ))) 
    429                 { 
     385                /* Check permission */ 
     386                if ($this->bo->vfs->acl_check(array( 
     387                                                'string' => $this->path, 
     388                                                'relatives' => array(RELATIVE_NONE), 
     389                                                'operation' => PHPGW_ACL_READ 
     390                                  ))) { 
    430391                        $this->can_read = True; 
    431392                } 
    432393 
    433394 
    434                 if ($_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed') 
    435                 { 
    436                         /*Flush journal-deleted*/ 
     395                if ($_SESSION['phpgw_info']['user']['filemanager']['flush'] != 'flushed') { 
     396                        /* Flush journal-deleted */ 
    437397                        $this->bo->vfs->flush_journal(array( 
    438                                 'string' => $this->path, 
    439                                 'relatives' => array(RELATIVE_NONE), 
    440                                 'deleteall' => True 
     398                                 'string' => $this->path, 
     399                                 'relatives' => array(RELATIVE_NONE), 
     400                                 'deleteall' => True 
    441401                        )); 
    442402                        $_SESSION['phpgw_info']['user']['filemanager']['flush'] = 'flushed'; 
     
    446406 
    447407                # if is different path than home and no permission allowed 
    448                 if($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) 
    449                 { 
     408                if ($this->path != $this->bo->homedir && $this->path != $this->bo->fakebase && $this->path != '/' && !$this->can_read) { 
    450409                        $this->messages[] = lang('You do not have access to %1', $this->path); 
    451410                        $this->path = $this->homedir; 
     
    459418 
    460419                # Verify path is real 
    461                 if($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) 
    462                 { 
    463                         if(!$this->bo->vfs->file_exists(array( 
    464                                 'string' => $this->path, 
    465                                 'relatives' => array(RELATIVE_NONE) 
    466                         ))) 
    467                         { 
    468                                 $this->messages[] = lang('Error:').lang('Directory %1 does not exist', $this->path); 
     420                if ($this->path != $this->bo->homedir && $this->path != '/' && $this->path != $this->bo->fakebase) { 
     421                        if (!$this->bo->vfs->file_exists(array( 
     422                                                        'string' => $this->path, 
     423                                                        'relatives' => array(RELATIVE_NONE) 
     424                                          ))) { 
     425                                $this->messages[] = lang('Error:') . lang('Directory %1 does not exist', $this->path); 
    469426                                $this->path = $this->homedir; 
    470427                                $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     
    476433 
    477434                # Default is to sort by name 
    478                 if(!$this->sortby) 
    479                 { 
     435                if (!$this->sortby) { 
    480436                        $this->sortby = 'name'; 
    481437                } 
    482                 if($this->update_x == 1){ 
     438                if ($this->update_x == 1) { 
    483439                        $this->bo->vfs->update_real(array( 
    484                                 'string'        => $this->path, 
    485                                 'relatives'    => array(RELATIVE_NONE) 
     440                                 'string' => $this->path, 
     441                                 'relatives' => array(RELATIVE_NONE) 
    486442                        )); 
    487                         header('Location:'.$this->encode_href('index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 
    488                 } 
    489                 elseif($this->newfile_x && $this->newfile_or_dir) // create new textfile 
    490                 { 
     443                        header('Location:' . $this->encode_href('index.php?menuaction=filemanager.uifilemanager.index', '&path=' . base64_encode($this->bo->homedir))); 
     444                } elseif ($this->newfile_x && $this->newfile_or_dir) { // create new textfile 
    491445                        $this->createfile(); 
    492                 } 
    493                 elseif($this->edit_cancel_x) 
    494                 { 
     446                } elseif ($this->edit_cancel_x) { 
    495447                        $this->readFilesInfo(); 
    496448                        $this->fileListing(); 
    497                 } 
    498                 elseif($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) 
    499                 { 
     449                } elseif ($this->edit_x || $this->edit_preview_x || $this->edit_save_x || $this->edit_save_done_x) { 
    500450                        $this->edit(); 
    501                 } 
    502                 else 
    503                 { 
     451                } else { 
    504452                        //$this->readFilesInfo(); 
    505453                        $this->fileListing(); 
    506454                } 
    507455        } 
    508         function get_permissions(){ 
     456 
     457        function get_permissions() { 
    509458                /* get permissions */ 
    510                 if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined 
    511  
    512                 { 
    513                         $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined 
    514  
    515                 } 
    516                 else 
    517                 { 
     459                if ((preg_match('+^' . $this->bo->fakebase . '\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) { //FIXME matches not defined 
     460                        $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); //FIXME matches not defined 
     461                } else { 
    518462                        $this->bo->vfs->working_id = $this->bo->userinfo['username']; 
    519463                } 
    520464 
    521465                # Check available permissions for $this->path, so we can disable unusable operations in user interface 
    522                 $path = explode('/',$this->path); 
    523                 $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]); 
     466                $path = explode('/', $this->path); 
     467                $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase, $path[2]); 
    524468                $user_id = $GLOBALS['phpgw_info']['user']['account_id']; 
    525                 if ($owner_id == $user_id) 
    526                 { 
     469                if ($owner_id == $user_id) { 
    527470                        $rights = 31; 
    528                 }else 
    529                 { 
    530                         $acl = CreateObject ('phpgwapi.acl', $owner_id); 
     471                } else { 
     472                        $acl = CreateObject('phpgwapi.acl', $owner_id); 
    531473                        $acl->account_id = $owner_id; 
    532474                        $acl->read_repository(); 
    533475                        $rights = $acl->get_rights($user_id); 
    534476                } 
    535                 return $rights;  
    536         } 
    537         function dir_ls() 
    538         { 
     477                return $rights; 
     478        } 
     479 
     480        function dir_ls() { 
    539481                // change dir to this->path 
    540482                $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    541483                $return['permissions'] = $this->get_permissions(); 
    542484                $return['quota']['usedSpace'] = $this->bo->vfs->get_size(array( 
    543                                 'string'        => $this->path, 
    544                                 'relatives'    => array(RELATIVE_NONE) 
    545                 )); 
     485                                                'string' => $this->path, 
     486                                                'relatives' => array(RELATIVE_NONE) 
     487                                  )); 
    546488                $return['files_count'] = $this->bo->vfs->count_files(array( 
    547                                 'string'        => $this->path, 
    548                 )); 
     489                                                'string' => $this->path, 
     490                                  )); 
    549491                $quota = $this->bo->vfs->get_quota(array( 
    550                         'string'        => $this->path 
    551                 )); 
     492                                                'string' => $this->path 
     493                                  )); 
    552494                reset($this->files_array); 
    553495                $this->readFilesInfo(); 
    554496 
    555                 for($i = 0; $i != $this->numoffiles; $i++) 
    556                 { 
     497                for ($i = 0; $i != $this->numoffiles; $i++) { 
    557498                        $files = $this->files_array[$i]; 
    558499 
    559                         if($files['mime_type'] == "Directory") 
    560                         { 
     500                        if ($files['mime_type'] == "Directory") { 
    561501                                continue; 
    562502                        } 
    563503                        /* small keys to safe bandwidth */ 
    564504                        $tuple['name'] = htmlentities($files['name']); 
    565                         if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1){ 
    566                                 if ($files['mime_type'] == 'image/png' ||  
    567                                         $files['mime_type'] == 'image/gif' ||  
    568                                         $files['mime_type'] == 'image/jpg') 
    569                                 { 
    570                                         $filename = str_replace('=','',base64_encode($tuple['name'])); 
    571                                         $pathname = str_replace('=','',base64_encode($this->path)); 
    572                                         $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file='.$filename.'&path='.$pathname; 
     505                        if ($_SESSION['phpgw_info']['user']['preferences']['filemanager']['viewIcons'] == 1) { 
     506                                if ($files['mime_type'] == 'image/png' || 
     507                                                  $files['mime_type'] == 'image/gif' || 
     508                                                  $files['mime_type'] == 'image/jpg') { 
     509                                        $filename = str_replace('=', '', base64_encode($tuple['name'])); 
     510                                        $pathname = str_replace('=', '', base64_encode($this->path)); 
     511                                        $tuple['icon'] = './index.php?menuaction=filemanager.vfs_functions.summary&file=' . $filename . '&path=' . $pathname; 
    573512                                } 
    574513                                else 
    575                                         $tuple['icon'] =  $this->mime_icon($files['mime_type'],64); 
     514                                        $tuple['icon'] = $this->mime_icon($files['mime_type'], 64); 
    576515                        } 
    577516                        else 
     
    584523                        $tuple['pub'] = $files['type']; 
    585524                        $tuple['createdby_id'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); 
    586                         $tuple['modifiedby_id'] = $files['modifiedby_id']?$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']):''; 
     525                        $tuple['modifiedby_id'] = $files['modifiedby_id'] ? $GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']) : ''; 
    587526                        $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); 
    588527                        $tuple['comment'] = $files['comment']; 
    589528                        $tuple['version'] = $files['version']; 
    590529                        $output[] = $tuple; 
    591  
    592530                } 
    593531                $return['files'] = $output; 
    594                 $return['quota']['quotaSize'] = ($quota*1024*1024); 
     532                $return['quota']['quotaSize'] = ($quota * 1024 * 1024); 
    595533                echo serialize($return); 
    596534        } 
    597         function get_folders_list() 
    598         { 
    599                 $this->update_groups();  
     535 
     536        function get_folders_list() { 
     537                $this->update_groups(); 
    600538                $this->groups_applications = array(); 
    601539 
    602540                $user_groups = $GLOBALS['phpgw']->accounts->membership(); 
    603                 foreach($user_groups as $val){ 
     541                foreach ($user_groups as $val) { 
    604542                        $account_name = $GLOBALS['phpgw']->accounts->id2name($val['account_id']); 
    605543                        $this->readable_groups[$account_name] = array( 
    606                                 'account_id' => $val['account_id'], 
    607                                 'account_name' => $account_name 
     544                                 'account_id' => $val['account_id'], 
     545                                 'account_name' => $account_name 
    608546                        ); 
    609547                } 
    610548 
    611                 foreach ($this->readable_groups as $value) 
    612                 { 
     549                foreach ($this->readable_groups as $value) { 
    613550                        $applications = CreateObject('phpgwapi.applications', $value['account_id']); 
    614551                        $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); 
     
    618555                // selectbox for change/move/and copy to 
    619556                $this->dirs = $this->all_other_directories(); 
    620                 foreach($this->dirs as $dir) 
     557                foreach ($this->dirs as $dir) 
    621558                        $return[] = $dir['directory'] . $dir['name']; 
    622559                sort(&$return, SORT_STRING); 
    623560                echo serialize($return); 
    624561        } 
    625         function fileListing() 
    626         { 
     562 
     563        function fileListing() { 
    627564                $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); 
    628                 $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); 
    629                 $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); 
    630  
    631                 if($this->numoffiles || $this->cwd) 
    632                 { 
    633                         $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; 
    634                         $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
     565                $this->t->set_block('filemanager_list_t', 'filemanager_header', 'filemanager_header'); 
     566                $this->t->set_block('filemanager_list_t', 'filemanager_footer', 'filemanager_footer'); 
     567 
     568                if ($this->numoffiles || $this->cwd) { 
     569                        $vars[path] = '<input type="hidden" id="currentPath" value="' . $this->path . '">'; 
     570                        $vars[css] = '<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
    635571                        $vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">'; 
    636572                        $_SESSION['phpgw_info']['user']['preferences']['filemanager']['lid'] = $GLOBALS['phpgw_info']['user']['account_lid']; 
    637                         $vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>'; 
     573                        $vars[preferences] = '<input type="hidden" id="userPreferences" value=\'' . serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']) . '\'>'; 
    638574                        // Used for important operations that needs security 
    639                         for ($key = ""; strlen($key) < 150; $key .= chr(rand(48,95))); 
     575                        for ($key = ""; strlen($key) < 150; $key .= chr(rand(48, 95))) 
     576                                ; 
    640577                        $_SESSION['phpgw_info']['filemanager']['user']['sec_key'] = $key; 
    641                         $vars[sec_key]='<input type="hidden" id="userKey" value=\''.$key.'\'>'; 
    642                         $vars[script]='<script>initDrawApi();</script>'; 
    643                          
    644                         $vars[new_button]=$this->toolButton('new','createfile',lang('New...')); 
     578                        $vars[sec_key] = '<input type="hidden" id="userKey" value=\'' . $key . '\'>'; 
     579                        $vars[script] = '<script>initDrawApi();</script>'; 
     580 
     581                        $vars[new_button] = $this->toolButton('new', 'createfile', lang('New...')); 
    645582                        $vars[new_button].='<input type="hidden" id="newfile_or_dir" name="newfile_or_dir" value="" />'; 
    646                          
     583 
    647584                        // reload button with this url 
    648                         $vars[refresh_button]=$this->toolButton('reload','reload',lang('reload')); 
     585                        $vars[refresh_button] = $this->toolButton('reload', 'reload', lang('reload')); 
    649586 
    650587                        // go up icon when we're not at the top, dont allow to go outside /home = fakebase 
    651                         if($this->path != '/' && $this->path != $this->bo->fakebase) 
    652                         { 
    653                                 $vars[tools_button] = $this->toolButton('tools','tools',lang('tools')); 
     588                        if ($this->path != '/' && $this->path != $this->bo->fakebase) { 
     589                                $vars[tools_button] = $this->toolButton('tools', 'tools', lang('tools')); 
    654590                        } 
    655591                        else 
    656592                                $vars[tools_button] = ""; 
    657593 
    658                         $vars[toolbar1]=$toolbar; 
    659  
    660                         if(count($this->messages)>0)  
    661                         { 
    662                                 foreach($this->messages as $msg) 
    663                                 { 
    664                                         $messages.='<span>'.$msg.'</span>'; 
     594                        $vars[toolbar1] = $toolbar; 
     595 
     596                        if (count($this->messages) > 0) { 
     597                                foreach ($this->messages as $msg) { 
     598                                        $messages.='<span>' . $msg . '</span>'; 
    665599                                } 
    666600                        } 
    667601                        $this->messages = NULL; 
    668                          
    669                         $vars[messages]=$messages; 
     602 
     603                        $vars[messages] = $messages; 
    670604 
    671605                        $this->t->set_var($vars); 
    672                         $this->t->pparse('out','filemanager_header'); 
     606                        $this->t->pparse('out', 'filemanager_header'); 
    673607                } 
    674608 
    675609                $this->t->set_var($vars); 
    676                 $this->t->pparse('out','filemanager_footer'); 
     610                $this->t->pparse('out', 'filemanager_footer'); 
    677611 
    678612                $GLOBALS['phpgw']->common->phpgw_footer(); 
     
    680614        } 
    681615 
    682         function readFilesInfo() 
    683         { 
     616        function readFilesInfo() { 
    684617                // start files info 
    685  
    686618                # Read in file info from database to use in the rest of the script 
    687619                # $fakebase is a special directory.  In that directory, we list the user's 
    688620                # home directory and the directories for the groups they're in 
    689621                $this->numoffiles = 0; 
    690                 if($this->path == $this->bo->fakebase) 
    691                 { 
     622                if ($this->path == $this->bo->fakebase) { 
    692623                        // FIXME this test can be removed 
    693                         if(!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) 
    694                         { 
     624                        if (!$this->bo->vfs->file_exists(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE)))) { 
    695625                                $this->bo->vfs->mkdir(array('string' => $this->bo->homedir, 'relatives' => array(RELATIVE_NONE))); 
    696626                        } 
    697627 
    698628                        $ls_array = $this->bo->vfs->ls(array( 
    699                                 'string' => $this->bo->homedir, 
    700                                 'relatives' => array(RELATIVE_NONE), 
    701                                 'checksubdirs' => False, 
    702                                 'nofiles' => True 
    703                         )); 
     629                                                        'string' => $this->bo->homedir, 
     630                                                        'relatives' => array(RELATIVE_NONE), 
     631                                                        'checksubdirs' => False, 
     632                                                        'nofiles' => True 
     633                                          )); 
    704634 
    705635                        $this->files_array[] = $ls_array[0]; 
     
    707637 
    708638                        reset($this->readable_groups); 
    709                         while(list($num, $group_array) = each($this->readable_groups)) 
    710                         { 
     639                        while (list($num, $group_array) = each($this->readable_groups)) { 
    711640                                # If the group doesn't have access to this app, we don't show it 
    712                                 /*if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) 
    713                                 { 
    714                                         continue; 
    715                                 } 
    716                                 */ 
    717  
    718  
    719                                 if(!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'      => array(RELATIVE_NONE)))) 
    720                                 { 
     641                                /* if(!$this->groups_applications[$group_array['account_name']][$this->bo->appname]['enabled']) 
     642                                  { 
     643                                  continue; 
     644                                  } 
     645                                 */ 
     646 
     647 
     648                                if (!$this->bo->vfs->file_exists(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE)))) { 
    721649                                        $this->bo->vfs->override_acl = 1; 
    722650                                        $this->bo->vfs->mkdir(array( 
    723                                                 'string' => $this->bo->fakebase.'/'.$group_array['account_name'], 
    724                                                 'relatives' => array(RELATIVE_NONE) 
     651                                                 'string' => $this->bo->fakebase . '/' . $group_array['account_name'], 
     652                                                 'relatives' => array(RELATIVE_NONE) 
    725653                                        )); 
    726654 
    727655                                        // FIXME we just created a fresh group dir so we know there nothing in it so we have to remove all existing content 
    728                                          
    729                                          
     656 
     657 
    730658                                        $this->bo->vfs->override_acl = 0; 
    731659 
    732                                         $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']))); 
     660                                        $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']))); 
    733661                                } 
    734662 
    735                                 $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'],'relatives'       => array(RELATIVE_NONE),'checksubdirs' => False,'nofiles' => True)); 
     663                                $ls_array = $this->bo->vfs->ls(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 'relatives' => array(RELATIVE_NONE), 'checksubdirs' => False, 'nofiles' => True)); 
    736664 
    737665                                $this->files_array[] = $ls_array[0]; 
     
    739667                                $this->numoffiles++; 
    740668                        } 
    741                 } 
    742                 else 
    743                 { 
     669                } else { 
    744670                        $ls_array = $this->bo->vfs->ls(array( 
    745                                 'string' => $this->path, 
    746                                 'relatives'     => array(RELATIVE_NONE), 
    747                                 'checksubdirs' => False, 
    748                                 'nofiles'       => False, 
    749                                 'orderby'       => $this->criteria, 
    750                                 'otype'         => $this->otype, 
    751                                 'limit'         => $this->limit, 
    752                                 'offset'        => $this->offset 
    753                         )); 
    754  
    755                         while(list($num, $file_array) = each($ls_array)) 
    756                         { 
     671                                                        'string' => $this->path, 
     672                                                        'relatives' => array(RELATIVE_NONE), 
     673                                                        'checksubdirs' => False, 
     674                                                        'nofiles' => False, 
     675                                                        'orderby' => $this->criteria, 
     676                                                        'otype' => $this->otype, 
     677                                                        'limit' => $this->limit, 
     678                                                        'offset' => $this->offset 
     679                                          )); 
     680 
     681                        while (list($num, $file_array) = each($ls_array)) { 
    757682                                $this->numoffiles++; 
    758683                                $this->files_array[] = $file_array; 
     
    760685                } 
    761686 
    762                 if(!is_array($this->files_array)) 
    763                 { 
     687                if (!is_array($this->files_array)) { 
    764688                        $this->files_array = array(); 
    765689                } 
    766690                // end file count 
    767691        } 
    768          
    769         function removedir() 
    770         { 
     692 
     693        function removedir() { 
    771694                //$toRemove = $this->path ^ $_SESSION['phpgw_info']['filemanager']['user']['sec_key']; 
    772695                $toRemove = $this->path; 
    773                  
    774                 if ( $this->bo->vfs->rm(array( 'string' => $toRemove, 'relatives' => array (RELATIVE_NONE) )) ) 
     696 
     697                if ($this->bo->vfs->rm(array('string' => $toRemove, 'relatives' => array(RELATIVE_NONE)))) 
    775698                        echo "True"; 
    776699                else 
    777700                        echo "False"; 
    778701        } 
    779          
    780         function createdir() 
    781         { 
    782                 if( $this->bo->badchar = $this->bo->bad_chars($this->filename, True, True) ) 
    783                 { 
    784                         echo lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
     702 
     703        function createdir() { 
     704                if ($this->bo->badchar = $this->bo->bad_chars($this->filename, True, True)) { 
     705                        echo lang('Error:') . $this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
    785706                        return; 
    786707                } 
    787708                /* TODO is this right or should it be a single $ ? */ 
    788                 if($this->filename[strlen($this->filename)-1] == ' ' || $this->filename[0] == ' ') 
    789                 { 
    790                         echo lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 
    791                 } 
    792                  
     709                if ($this->filename[strlen($this->filename) - 1] == ' ' || $this->filename[0] == ' ') { 
     710                        echo lang('Error:') . lang('Cannot create directory because it begins or ends in a space'); 
     711                } 
     712 
    793713                $ls_array = $this->bo->vfs->ls(array( 
    794                         'string'        => $this->path . '/' . $this->filename, 
    795                         'relatives'     => array(RELATIVE_NONE), 
    796                         'checksubdirs'  => False, 
    797                         'nofiles'       => True 
    798                 )); 
     714                                                'string' => $this->path . '/' . $this->filename, 
     715                                                'relatives' => array(RELATIVE_NONE), 
     716                                                'checksubdirs' => False, 
     717                                                'nofiles' => True 
     718                                  )); 
    799719 
    800720                $fileinfo = $ls_array[0]; 
    801721 
    802                 if($fileinfo['name']) 
    803                 { 
    804                         if($fileinfo['mime_type'] != 'Directory') 
    805                         { 
    806                                 echo lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 
    807                         } 
    808                         else 
    809                         { 
    810                                 echo lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 
    811                         } 
    812                 } 
    813                 else 
    814                 { 
     722                if ($fileinfo['name']) { 
     723                        if ($fileinfo['mime_type'] != 'Directory') { 
     724                                echo lang('Error:') . lang('%1 already exists as a file', $fileinfo['name']); 
     725                        } else { 
     726                                echo lang('Error:') . lang('Directory %1 already exists', $fileinfo['name']); 
     727                        } 
     728                } else { 
    815729                        $this->bo->vfs->cd(array('string' => $this->path, 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    816                          
    817                         if( $this->bo->vfs->mkdir(array('string' => $this->filename )) ) 
    818                         { 
    819                                 echo lang('Created directory %1', $this->disppath.'/'.$this->filename); 
    820                         } 
    821                         else 
    822                         { 
    823                                 echo lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->filename); 
     730 
     731                        if ($this->bo->vfs->mkdir(array('string' => $this->filename))) { 
     732                                echo lang('Created directory %1', $this->disppath . '/' . $this->filename); 
     733                        } else { 
     734                                echo lang('Error:') . lang('Could not create %1', $this->disppath . '/' . $this->filename); 
    824735                        } 
    825736                } 
    826737                echo lang('Directory created'); 
    827738        } 
    828          
    829         function getReturnExecuteForm() 
    830         { 
     739 
     740        function getReturnExecuteForm() { 
    831741                $response = $_SESSION['response']; 
    832                  
     742 
    833743                unset($_SESSION['response']); 
    834                  
     744 
    835745                echo $response; 
    836746        } 
    837          
     747 
    838748        function showUploadboxes() 
    839749        { 
    840750                $notify = CreateObject('filemanager.notifications'); 
    841                  
     751 
    842752                $var = array( 
    843                                         'change_upload_boxes'   => lang('Show'),                                 
    844                                         'form_action'                   => $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'), 
    845                                         'emails_to'                             => $notify->EmailsToSend($GLOBALS['phpgw']->preferences->values['email']), 
    846                                         'lang_file'                             => lang('File'), 
    847                                         'lang_comment'                  => lang('Comment'), 
    848                                         'lang_advanced_upload'  => lang('Advanced Upload'), 
    849                                         'lang_upload'                   => lang('Upload files'), 
    850                                         'max_size'                              => lang('Note: Uploaded is limited to %1MB',( $this->current_config['filemanager_Max_file_size'])),                              
    851                                         'path'                                  => $this->path 
     753                         'change_upload_boxes'  => lang('Show'), 
     754                         'form_action'                  => $GLOBALS[phpgw]->link('/filemanager/inc/upload.php'), 
     755                         'emails_to'                            => $notify->EmailsToSend($GLOBALS['phpgw']->preferences->values['email']), 
     756                         'lang_file'                            => lang('File(s)'), 
     757                         'lang_comment'                 => lang('Comment(s)'), 
     758                         'lang_advanced_upload' => lang('Advanced Upload'), 
     759                         'lang_upload'                  => lang('Upload files'), 
     760                         'max_size'                             => lang('The maximum size for each file is %1MB', ($this->current_config['filemanager_Max_file_size'])), 
     761                         'path'                                 => $this->path 
    852762                ); 
    853                  
    854                 print( serialize($var) ); 
    855                  
     763 
     764                print( serialize($var)); 
    856765        } 
    857766 
    858767        /* create textfile */ 
    859         function createfile() 
     768        function createfile()  
    860769        { 
    861                 $this->filename=$this->newfile_or_dir; 
    862                 if($this->filename) 
    863                 { 
    864                         if($badchar = $this->bo->bad_chars($this->filename, True, True)) 
    865                         { 
    866                                 $this->messages[] = lang('Error:').lang('File names cannot contain "%1"',$badchar); 
     770                $this->filename = $this->newfile_or_dir; 
     771                if ($this->filename) { 
     772                        if ($badchar = $this->bo->bad_chars($this->filename, True, True)) { 
     773                                $this->messages[] = lang('Error:') . lang('File names cannot contain "%1"', $badchar); 
    867774 
    868775                                $this->fileListing(); 
    869776                        } 
    870777 
    871                         if($this->bo->vfs->file_exists(array( 
    872                                 'string'=> $this->filename, 
    873                                 'relatives'     => array(RELATIVE_ALL) 
    874                         ))) 
    875                         { 
    876                                 $this->messages[]= lang('Error:').lang('File %1 already exists. Please edit it or delete it first.', $this->filename); 
     778                        if ($this->bo->vfs->file_exists(array( 
     779                                                        'string' => $this->filename, 
     780                                                        'relatives' => array(RELATIVE_ALL) 
     781                                          ))) { 
     782                                $this->messages[] = lang('Error:') . lang('File %1 already exists. Please edit it or delete it first.', $this->filename); 
    877783                                $this->fileListing(); 
    878784                        } 
    879785 
    880                         if($this->bo->vfs->touch(array( 
    881                                 'string'        => $this->filename, 
    882                                 'relatives'     => array(RELATIVE_ALL) 
    883                         ))) 
    884                         { 
     786                        if ($this->bo->vfs->touch(array( 
     787                                                        'string' => $this->filename, 
     788                                                        'relatives' => array(RELATIVE_ALL) 
     789                                          ))) { 
    885790                                $this->edit = 1; 
    886791                                $this->numoffiles++; 
    887792                                $this->edit(); 
    888                         } 
    889                         else 
    890                         { 
    891                                 $this->messages[]= lang('Error:').lang('File %1 could not be created.', $this->filename); 
     793                        } else { 
     794                                $this->messages[] = lang('Error:') . lang('File %1 could not be created.', $this->filename); 
    892795                                $this->fileListing(); 
    893796                        } 
     
    896799 
    897800        # Handle Editing files 
    898         function edit() 
    899         { 
    900                 if($this->filename) 
    901                 { 
    902                         if (! $this->vfs_functions->verifyLock($this->path.'/'.$this->filename,RELATIVE_NONE)){ 
     801 
     802        function edit() { 
     803                if ($this->filename) { 
     804                        if (!$this->vfs_functions->verifyLock($this->path . '/' . $this->filename, RELATIVE_NONE)) { 
    903805                                $GLOBALS['phpgw']->redirect('/index.php'); 
    904806                        } 
    905807                        $ls_array = $this->bo->vfs->ls(array( 
    906                                 'string'        => $this->path.'/'.$this->filename, 
    907                                 'relatives'     => array(RELATIVE_NONE), 
    908                                 'checksubdirs'  => False, 
    909                                 'nofiles'       => True 
     808                                                        'string' => $this->path . '/' . $this->filename, 
     809                                                        'relatives' => array(RELATIVE_NONE), 
     810                                                        'checksubdirs' => False, 
     811                                                        'nofiles' => True 
     812                                          )); 
     813                        $this->bo->vfs->touch(array( 
     814                                 'string' => $this->path . '/' . $this->filename, 
     815                                 'relatives' => array(RELATIVE_NONE) 
    910816                        )); 
    911                         $this->bo->vfs->touch(array( 
    912                                 'string'=> $this->path.'/'.$this->filename, 
    913                                 'relatives'     => array(RELATIVE_NONE) 
    914                         )); 
    915  
    916  
    917                         if($ls_array[0]['mime_type']) 
    918                         { 
     817 
     818 
     819                        if ($ls_array[0]['mime_type']) { 
    919820                                $mime_type = $ls_array[0]['mime_type']; 
    920                         } 
    921                         elseif($this->prefs['viewtextplain']) 
    922                         { 
     821                        } elseif ($this->prefs['viewtextplain']) { 
    923822                                $mime_type = 'text/plain'; 
    924823                        } 
    925                         $editable = array('','text/plain','text/csv','text/html','text/text','message/rfc822'); 
    926  
    927                         if(!in_array($mime_type,$editable)){ 
    928                                 $this->messages[] = lang('Error:').lang('Impossible to edit this file'); 
     824                        $editable = array('', 'text/plain', 'text/csv', 'text/html', 'text/text', 'message/rfc822'); 
     825 
     826                        if (!in_array($mime_type, $editable)) { 
     827                                $this->messages[] = lang('Error:') . lang('Impossible to edit this file'); 
    929828                                $this->readFilesInfo(); 
    930829                                $this->fileListing(); 
     
    940839                        $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 
    941840 
    942                 $this->t->set_block('filemanager_edit','row','row'); 
     841                $this->t->set_block('filemanager_edit', 'row', 'row'); 
    943842 
    944843 
    945844                $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; 
    946845 
    947                 $vars[preview_content]=''; 
    948                 if($this->edit_file) 
    949                 { 
     846                $vars[preview_content] = ''; 
     847                if ($this->edit_file) { 
    950848                        $this->edit_file_content = stripslashes($this->edit_file_content); 
    951849                } 
    952850 
    953                 if($this->edit_preview_x) 
    954                 { 
     851                if ($this->edit_preview_x) { 
    955852                        $content = $this->edit_file_content; 
    956853 
    957                         $vars[lang_preview_of]=lang('Preview of %1', $this->path.'/'.$edit_file); 
    958  
    959                         $vars[preview_content]=nl2br($content); 
    960                 } 
    961                 elseif($this->edit_save_x || $this->edit_save_done_x) 
    962                 { 
     854                        $vars[lang_preview_of] = lang('Preview of %1', $this->path . '/' . $edit_file); 
     855 
     856                        $vars[preview_content] = nl2br($content); 
     857                } elseif ($this->edit_save_x || $this->edit_save_done_x) { 
    963858                        $content = $this->edit_file_content; 
    964859                        //die( $content); 
    965                         if($this->bo->vfs->write(array( 
    966                                 'string'        => $this->path.'/'.$this->edit_file, 
    967                                 'relatives'     => array(RELATIVE_NONE), 
    968                                 'content'       => $content 
    969                         ))) 
    970                         { 
    971                                 $this->messages[]=lang('Saved %1', $this->path.'/'.$this->edit_file); 
    972  
    973                                 if($this->edit_save_done_x) 
    974                                 { 
     860                        if ($this->bo->vfs->write(array( 
     861                                                        'string' => $this->path . '/' . $this->edit_file, 
     862                                                        'relatives' => array(RELATIVE_NONE), 
     863                                                        'content' => $content 
     864                                          ))) { 
     865                                $this->messages[] = lang('Saved %1', $this->path . '/' . $this->edit_file); 
     866 
     867                                if ($this->edit_save_done_x) { 
    975868                                        $this->readFilesInfo(); 
    976869                                        $this->fileListing(); 
    977870                                        exit; 
    978871                                } 
    979                         } 
    980                         else 
    981                         { 
    982                                 $this->messages[]=lang('Could not save %1', $this->path.'/'.$this->edit_file); 
     872                        } else { 
     873                                $this->messages[] = lang('Could not save %1', $this->path . '/' . $this->edit_file); 
    983874                        } 
    984875                } 
     
    986877                # If we're in preview or save mode, we only show the file 
    987878                # being previewed or saved 
    988                 if($this->edit_file &&($this->filename != $this->edit_file)) 
    989                 { 
     879                if ($this->edit_file && ($this->filename != $this->edit_file)) { 
    990880                        continue; 
    991881                } 
    992882 
    993                 if($this->filename && $this->bo->vfs->file_exists(array( 
    994                         'string'        => $this->filename, 
    995                         'relatives'     => array(RELATIVE_ALL) 
    996                 ))) 
    997                 { 
    998                         if($this->edit_file) 
    999                         { 
     883                if ($this->filename && $this->bo->vfs->file_exists(array( 
     884                                                'string' => $this->filename, 
     885                                                'relatives' => array(RELATIVE_ALL) 
     886                                  ))) { 
     887                        if ($this->edit_file) { 
    1000888                                $content = stripslashes($this->edit_file_content); 
    1001                         } 
    1002                         else 
    1003                         { 
     889                        } else { 
    1004890                                $content = $this->bo->vfs->read(array('string' => $this->filename)); 
    1005891                        } 
    1006                         $vars[form_action]= $GLOBALS['phpgw']->link('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path); 
    1007                         $vars[edit_file]=$this->filename; 
     892                        $vars[form_action] = $GLOBALS['phpgw']->link('/index.php', 'menuaction=filemanager.uifilemanager.index', 'path=' . $this->path); 
     893                        $vars[edit_file] = $this->filename; 
    1008894                        # We need to include all of the fileman entries for each file's form, 
    1009895                        # so we loop through again 
    1010                         for($i = 0; $i != $this->numoffiles; $i++) 
    1011                         { 
    1012                                 if($this->filename) $value='value="'.$this->filename.'"'; 
    1013                                 $vars[filemans_hidden]='<input type="hidden" name="filename" '.$value.' />'; 
    1014                         } 
    1015                         $vars[file_content]=$content; 
    1016  
    1017                         $vars[buttonPreview]=$this->inputButton('edit_preview','edit_preview',lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1))); 
    1018                         $vars[buttonSave]=$this->inputButton('edit_save','save',lang('Save %1', $this->bo->html_encode($this->filename, 1))); 
    1019                         $vars[buttonDone]=$this->inputButton('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); 
    1020                         $vars[buttonCancel]=$this->inputButton('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); 
    1021  
    1022                         if ($mime_type == 'text/html'){ 
     896                        for ($i = 0; $i != $this->numoffiles; $i++) { 
     897                                if ($this->filename) 
     898                                        $value = 'value="' . $this->filename . '"'; 
     899                                $vars[filemans_hidden] = '<input type="hidden" name="filename" ' . $value . ' />'; 
     900                        } 
     901                        $vars[file_content] = $content; 
     902 
     903                        $vars[buttonPreview] = $this->inputButton('edit_preview', 'edit_preview', lang('Preview %1', $this->bo->html_encode($this->fileman[0], 1))); 
     904                        $vars[buttonSave] = $this->inputButton('edit_save', 'save', lang('Save %1', $this->bo->html_encode($this->filename, 1))); 
     905                        $vars[buttonDone] = $this->inputButton('edit_save_done', 'ok', lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->filename, 1))); 
     906                        $vars[buttonCancel] = $this->inputButton('edit_cancel', 'cancel', lang('Cancel editing %1 without saving', $this->bo->html_encode($this->filename, 1))); 
     907 
     908                        if ($mime_type == 'text/html') { 
    1023909                                $vars[fck_edit] = '<script type="text/javascript" src="filemanager/tp/ckeditor/ckeditor.js"></script> 
    1024                                         <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">'.$content.'</textarea> 
     910                                        <textarea cols="80" id="edit_file_content" name="edit_file_content" rows="10">' . $content . '</textarea> 
    1025911                                                <script type="text/javascript"> CKEDITOR.replace( \'edit_file_content\',{ 
    1026912removePlugins : \'elementspath\', 
     
    1035921["Styles","Format","Font","FontSize"]] 
    1036922                                });</script>'; 
    1037  
    1038923                        } 
    1039924 
    1040925 
    1041926                        $this->t->set_var($vars); 
    1042                         $this->t->parse('rows','row'); 
    1043                         $this->t->pparse('out','row'); 
    1044  
    1045                 } 
    1046  
    1047         } 
    1048  
    1049         function history() 
    1050         { 
    1051                 if($this->file) // FIXME this-file is never defined 
    1052                 { 
     927                        $this->t->parse('rows', 'row'); 
     928                        $this->t->pparse('out', 'row'); 
     929                } 
     930        } 
     931 
     932        function history() { 
     933                if ($this->file) { // FIXME this-file is never defined 
    1053934                        $journal_array = $this->bo->vfs->get_journal(array( 
    1054                                 'string'        => $this->file,//FIXME 
    1055                                 'relatives'     => array(RELATIVE_ALL) 
    1056                         )); 
    1057  
    1058                         if(is_array($journal_array)) 
    1059                         { 
     935                                                        'string' => $this->file, //FIXME 
     936                                                        'relatives' => array(RELATIVE_ALL) 
     937                                          )); 
     938 
     939                        if (is_array($journal_array)) { 
    1060940                                $this->html_table_begin(); 
    1061941                                $this->html_table_row_begin(); 
     
    1074954                                $this->html_table_row_end(); 
    1075955 
    1076                                 while(list($num, $journal_entry) = each($journal_array)) 
    1077                                 { 
     956                                while (list($num, $journal_entry) = each($journal_array)) { 
    1078957                                        $this->html_table_row_begin(); 
    1079958                                        $this->html_table_col_begin(); 
     
    1081960                                        $this->html_table_col_end(); 
    1082961                                        $this->html_table_col_begin(); 
    1083                                         $this->bo->html_text($journal_entry['version'] . '&nbsp;&nbsp;&nbsp;' ); 
     962                                        $this->bo->html_text($journal_entry['version'] . '&nbsp;&nbsp;&nbsp;'); 
    1084963                                        $this->html_table_col_end(); 
    1085964                                        $this->html_table_col_begin(); 
     
    1094973                                $GLOBALS['phpgw']->common->phpgw_footer(); 
    1095974                                $GLOBALS['phpgw']->common->phpgw_exit(); 
    1096                         } 
    1097                         else 
    1098                         { 
     975                        } else { 
    1099976                                echo lang('No version history for this file/directory'); 
    1100977                        } 
    1101978                } 
    1102979        } 
    1103         function view() 
    1104         { 
     980 
     981        function view() { 
    1105982                if (!$this->bo->vfs->acl_check(array( 
    1106                         'string'        => $this->path, 
    1107                         'relatives'     => array(RELATIVE_NONE), 
    1108                         'operation'     => PHPGW_ACL_READ 
    1109                 ))) 
    1110                 { 
     983                                                'string' => $this->path, 
     984                                                'relatives' => array(RELATIVE_NONE), 
     985                                                'operation' => PHPGW_ACL_READ 
     986                                  ))) { 
    1111987                        $this->messages[] = lang("You have no permission to access this file"); 
    1112                         header('Location:'.$this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index','&path='.base64_encode($this->bo->homedir))); 
     988                        header('Location:' . $this->encode_href('inc/index.php?menuaction=filemanager.uifilemanager.index', '&path=' . base64_encode($this->bo->homedir))); 
    1113989 
    1114990                        return; 
    1115991                } 
    1116                 if($this->file) //FIXME 
    1117                 { 
     992                if ($this->file) { //FIXME 
    1118993                        $ls_array = $this->bo->vfs->ls(array( 
    1119                                 'string'        => $this->path.'/'.$this->file,//FIXME 
    1120                                 'relatives'     => array(RELATIVE_NONE), 
    1121                                 'checksubdirs'  => False, 
    1122                                 'nofiles'       => True 
    1123                         )); 
    1124                         if($ls_array[0]['mime_type']) 
    1125                         { 
     994                                                        'string' => $this->path . '/' . $this->file, //FIXME 
     995                                                        'relatives' => array(RELATIVE_NONE), 
     996                                                        'checksubdirs' => False, 
     997                                                        'nofiles' => True 
     998                                          )); 
     999                        if ($ls_array[0]['mime_type']) { 
    11261000                                $mime_type = $ls_array[0]['mime_type']; 
    1127                         } 
    1128                         elseif($this->prefs['viewtextplain']) 
    1129                         { 
     1001                        } elseif ($this->prefs['viewtextplain']) { 
    11301002                                $mime_type = 'text/plain'; 
    11311003                        } 
    1132                         $viewable = array('text/plain','text/csv','text/html', 
    1133                                 'text/text','image/jpeg','image/png','image/gif', 
    1134                                 'audio/mpeg','video/mpeg'); 
    1135  
    1136                         if(in_array($mime_type,$viewable))  
    1137                         { 
    1138                                 /*Note: if you put application/octet-stream you force download */ 
     1004                        $viewable = array('text/plain', 'text/csv', 'text/html', 
     1005                                 'text/text', 'image/jpeg', 'image/png', 'image/gif', 
     1006                                 'audio/mpeg', 'video/mpeg'); 
     1007 
     1008                        if (in_array($mime_type, $viewable)) { 
     1009                                /* Note: if you put application/octet-stream you force download */ 
    11391010                                header('Content-type: ' . $mime_type); 
    11401011                                header('Content-disposition: filename="' . addslashes($this->file) . '"'); 
    11411012                                Header("Pragma: public"); 
    1142                         } 
    1143                         else 
    1144                         { 
    1145                                 $GLOBALS['phpgw']->browser->content_header($this->file,$mime_type,$ls_array[0]['size']); 
    1146                         } 
    1147                         if ($ls_array[0]['size'] < 10240) 
    1148                         { 
     1013                        } else { 
     1014                                $GLOBALS['phpgw']->browser->content_header($this->file, $mime_type, $ls_array[0]['size']); 
     1015                        } 
     1016                        if ($ls_array[0]['size'] < 10240) { 
    11491017                                echo $this->bo->vfs->read(array( 
    1150                                         'string'    => $this->path.'/'.$this->file,//FIXME 
    1151                                         'relatives'    => array(RELATIVE_NONE) 
     1018                                         'string' => $this->path . '/' . $this->file, //FIXME 
     1019                                         'relatives' => array(RELATIVE_NONE) 
    11521020                                )); 
    1153                         } 
    1154                         else 
    1155                         { 
     1021                        } else { 
    11561022                                $this->bo->vfs->print_content(array( 
    1157                                         'string' => $this->path.'/'.$this->file, 
    1158                                         'relatives' => array(RELATIVE_NONE) 
    1159                                 ) 
    1160                         ); 
     1023                                         'string' => $this->path . '/' . $this->file, 
     1024                                         'relatives' => array(RELATIVE_NONE) 
     1025                                                  ) 
     1026                                ); 
    11611027                        } 
    11621028                        $GLOBALS['phpgw']->common->phpgw_exit(); 
     
    11641030        } 
    11651031 
    1166         function export(){ 
    1167                 if($this->file) 
    1168                 { 
     1032        function export() { 
     1033                if ($this->file) { 
    11691034                        $ls_array = $this->bo->vfs->ls(array( 
    1170                                 'string'        => $this->path.'/'.$this->file, 
    1171                                 'relatives'    => array(RELATIVE_NONE), 
    1172                                 'checksubdirs' => False, 
    1173                                 'nofiles'      => True 
    1174                         )); 
    1175                         /*$timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); 
    1176                         if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 
    1177                         { 
    1178                                 // recently than last minute: someone is editing 
    1179                         }*/ 
     1035                                                        'string' => $this->path . '/' . $this->file, 
     1036                                                        'relatives' => array(RELATIVE_NONE), 
     1037                                                        'checksubdirs' => False, 
     1038                                                        'nofiles' => True 
     1039                                          )); 
     1040                        /* $timestamp = $this->vfs_functions->dateString2timeStamp($ls_array[0]['modified']); 
     1041                          if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 
     1042                          { 
     1043                          // recently than last minute: someone is editing 
     1044                          } */ 
    11801045                        $mime_type = $ls_array[0]['mime_type']; 
    11811046                        $formats = array('text/html'); 
    1182                         if(!in_array($mime_type,$formats)){ 
     1047                        if (!in_array($mime_type, $formats)) { 
    11831048                                echo lang('Impossible to export this file'); 
    11841049                                return False; 
    11851050                        } 
    1186                         $content = $this->bo->vfs->read(array('string' => $this->path.'/'.$this->file, 
    1187                                        'relatives'    => array(RELATIVE_NONE) 
    1188                                )); 
     1051                        $content = $this->bo->vfs->read(array('string' => $this->path . '/' . $this->file, 
     1052                                                        'relatives' => array(RELATIVE_NONE) 
     1053                                          )); 
    11891054 
    11901055                        include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); 
     
    11921057                        $dompdf->load_html($content); 
    11931058                        $dompdf->set_paper($this->prefs['pdf_paper_type'], $this->prefs['pdf_type']); 
    1194                         /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate'*/ 
     1059                        /* Would be nice to implement 'Title','Subject','Author','Creator','CreationDate' */ 
    11951060                        $dompdf->render(); 
    1196                         $dompdf->stream(strtok($this->file,'.').".pdf"); 
     1061                        $dompdf->stream(strtok($this->file, '.') . ".pdf"); 
    11971062                        $GLOBALS['phpgw']->common->phpgw_exit(); 
    11981063                } 
     
    12001065 
    12011066        //give back an array with all directories except current and dirs that are not accessable 
    1202         function all_other_directories() 
    1203         { 
     1067        function all_other_directories() { 
    12041068                # First we get the directories in their home directory 
    12051069                $dirs = array(); 
    12061070                $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $this->bo->userinfo['account_lid']); 
    12071071 
    1208                 $tmp_arr=array( 
    1209                         'string'        => $this->bo->homedir, 
    1210                         'relatives'     => array(RELATIVE_NONE), 
    1211                         'checksubdirs'  => True, 
    1212                         'mime_type'     => 'Directory' 
     1072                $tmp_arr = array( 
     1073                         'string' => $this->bo->homedir, 
     1074                         'relatives' => array(RELATIVE_NONE), 
     1075                         'checksubdirs' => True, 
     1076                         'mime_type' => 'Directory' 
    12131077                ); 
    12141078 
    1215                 $ls_array = $this->bo->vfs->ls($tmp_arr,True); 
    1216  
    1217                 while(list($num, $dir) = each($ls_array)) 
    1218                 { 
     1079                $ls_array = $this->bo->vfs->ls($tmp_arr, True); 
     1080 
     1081                while (list($num, $dir) = each($ls_array)) { 
    12191082                        $dirs[] = $dir; 
    12201083                } 
     
    12231086                # Then we get the directories in their readable groups' home directories 
    12241087                reset($this->readable_groups); 
    1225                 while(list($num, $group_array) = each($this->readable_groups)) 
    1226                 { 
     1088                while (list($num, $group_array) = each($this->readable_groups)) { 
    12271089                        // Don't list directories for groups that don't exists 
    1228                         $test=$this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase.'/'.$group_array['account_name'], 
    1229                                 'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
    1230                         if($test[mime_type]!='Directory') 
    1231                         { 
     1090                        $test = $this->bo->vfs->get_real_info(array('string' => $this->bo->fakebase . '/' . $group_array['account_name'], 
     1091                                                        'relatives' => array(RELATIVE_NONE), 'relative' => False)); 
     1092                        if ($test[mime_type] != 'Directory') { 
    12321093                                continue; 
    12331094                        } 
     
    12351096                        $dirs[] = array('directory' => $this->bo->fakebase, 'name' => $group_array['account_name']); 
    12361097 
    1237                         $tmp_arr=array( 
    1238                                 'string'        => $this->bo->fakebase.'/'.$group_array['account_name'], 
    1239                                 'relatives'     => array(RELATIVE_NONE), 
    1240                                 'checksubdirs'  => True, 
    1241                                 'mime_type'     => 'Directory' 
     1098                        $tmp_arr = array( 
     1099                                 'string' => $this->bo->fakebase . '/' . $group_array['account_name'], 
     1100                                 'relatives' => array(RELATIVE_NONE), 
     1101                                 'checksubdirs' => True, 
     1102                                 'mime_type' => 'Directory' 
    12421103                        ); 
    12431104 
    1244                         $ls_array = $this->bo->vfs->ls($tmp_arr,True); 
    1245                         while(list($num, $dir) = each($ls_array)) 
    1246                         { 
     1105                        $ls_array = $this->bo->vfs->ls($tmp_arr, True); 
     1106                        while (list($num, $dir) = each($ls_array)) { 
    12471107                                $dirs[] = $dir; 
    12481108                        } 
    12491109                } 
    12501110                reset($dirs); 
    1251                 while(list($num, $dir) = each($dirs)) 
    1252                 { 
    1253                         if(!$dir['directory']) 
    1254                         { 
     1111                while (list($num, $dir) = each($dirs)) { 
     1112                        if (!$dir['directory']) { 
    12551113                                continue; 
    12561114                        } 
    12571115 
    12581116                        # So we don't display // 
    1259                         if($dir['directory'] != '/') 
    1260                         { 
     1117                        if ($dir['directory'] != '/') { 
    12611118                                $dir['directory'] .= '/'; 
    12621119                        } 
     
    12661123        } 
    12671124 
    1268         function update_groups() 
    1269         { 
     1125        function update_groups() { 
    12701126                # Get their readable groups to be used throughout the script 
    12711127                $acl = array(); 
    12721128                $groups = array(); 
    1273                 $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'],1,'filemanager'); 
     1129                $acl = $GLOBALS['phpgw']->acl->get_ids_for_location($GLOBALS['phpgw_info']['user']['account_id'], 1, 'filemanager'); 
    12741130                if (is_array($acl)) 
    1275                         foreach($acl as $key => $value){ 
     1131                        foreach ($acl as $key => $value) { 
    12761132                                $info = array(); 
    12771133                                $info = $GLOBALS['phpgw']->accounts->get_account_data($value); 
     
    12831139                        } 
    12841140                $this->readable_groups = array(); 
    1285                 while(list($num, $account) = each($groups)) 
    1286                 { 
    1287                         if($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'],'operation' => PHPGW_ACL_READ))) 
    1288                         { 
     1141                while (list($num, $account) = each($groups)) { 
     1142                        if ($this->bo->vfs->acl_check(array('owner_id' => $account['account_id'], 'operation' => PHPGW_ACL_READ))) { 
    12891143                                $this->readable_groups[$account['account_lid']] = Array('account_id' => $account['account_id'], 'account_name' => $account['account_lid']); 
    12901144                        } 
    12911145                } 
    1292  
    1293         } 
    1294         function search() 
    1295         { 
     1146        } 
     1147 
     1148        function search() { 
    12961149                /* TODO this is a primitive search */ 
    12971150                $this->update_groups(); 
    1298                         $this->dirs = $this->all_other_directories(); 
     1151                $this->dirs = $this->all_other_directories(); 
    12991152                $path = $this->path; 
    1300                 if (strlen($this->text) > 3) 
    1301                 {                                                                 
     1153                if (strlen($this->text) > 3) { 
    13021154                        $this->text = strtoupper($this->text); 
    1303                         foreach($this->dirs as $elem) 
    1304                         { 
    1305                                 $this->path = $elem['directory'].$elem['name']; 
     1155                        foreach ($this->dirs as $elem) { 
     1156                                $this->path = $elem['directory'] . $elem['name']; 
    13061157                                reset($this->files_array); 
    1307                                 $this->readFilesInfo(); 
    1308                                 for($i = 0; $i < count($this->files_array); $i++) 
    1309                                 { 
     1158                                $this->readFilesInfo(); 
     1159                                for ($i = 0; $i < count($this->files_array); $i++) { 
    13101160                                        $comment = strtoupper($this->files_array[$i]['comment']); 
    13111161                                        $name = strtoupper($this->files_array[$i]['name']); 
    1312                                         if (strstr($name,$this->text) || 
    1313                                         strstr($comment,$this->text) ){ 
    1314                                                 $return[$this->files_array[$i]['directory'].$name] = $this->files_array[$i]; 
    1315                                                 $return[$this->files_array[$i]['directory'].$name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']); 
     1162                                        if (strstr($name, $this->text) || 
     1163                                                          strstr($comment, $this->text)) { 
     1164                                                $return[$this->files_array[$i]['directory'] . $name] = $this->files_array[$i]; 
     1165                                                $return[$this->files_array[$i]['directory'] . $name]['icon'] = $this->mime_icon($this->files_array[$i]['mime_type']); 
    13161166                                        } 
    13171167                                } 
    1318                                 if (count($return) > 50) 
    1319                                 { 
    1320                                         $return = array_slice($return,0,50); 
     1168                                if (count($return) > 50) { 
     1169                                        $return = array_slice($return, 0, 50); 
    13211170                                        break; 
    13221171                                } 
    1323                         }        
     1172                        } 
    13241173                } 
    13251174                echo serialize(array_values($return)); 
     
    13271176 
    13281177        /* seek icon for mimetype else return an unknown icon */ 
    1329         function mime_icon($mime_type, $size=16) 
    1330         { 
    1331                 if(!$mime_type) $mime_type='unknown'; 
    1332  
    1333                 $mime_type=str_replace  ('/','_',$mime_type); 
    1334  
    1335                 $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); 
    1336                 if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); 
     1178 
     1179        function mime_icon($mime_type, $size=16) { 
     1180                if (!$mime_type) 
     1181                        $mime_type = 'unknown'; 
     1182 
     1183                $mime_type = str_replace('/', '_', $mime_type); 
     1184 
     1185                $img = $GLOBALS['phpgw']->common->image('filemanager', 'mime' . $size . '_' . strtolower($mime_type)); 
     1186                if (!$img) 
     1187                        $img = $GLOBALS['phpgw']->common->image('filemanager', 'mime' . $size . '_unknown'); 
    13371188 
    13381189                return $img; 
    13391190        } 
    13401191 
    1341         function toolButton($link,$img='',$description='') 
    1342         { 
    1343                 $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 
    1344  
    1345                 if($img) 
    1346                 { 
    1347                         return '<div name="'.$link.'" class="toolButton" onclick="toolbar.control(\''.$link.'\',this);" title="'.$description.'"><img src="'.$image.'" alt="'.$description.'"/><small>'.$description.'</small></div>'; 
    1348                 } 
    1349         } 
    1350  
    1351         function inputButton($name,$img='',$description='') 
    1352         { 
    1353                 $image=$GLOBALS['phpgw']->common->image('filemanager','button_'.strtolower($img)); 
    1354  
    1355                 if($img) 
    1356                 { 
     1192        function toolButton($link, $img='', $description='') { 
     1193                $image = $GLOBALS['phpgw']->common->image('filemanager', 'button_' . strtolower($img)); 
     1194 
     1195                if ($img) { 
     1196                        return '<div name="' . $link . '" class="toolButton" onclick="toolbar.control(\'' . $link . '\',this);" title="' . $description . '"><img src="' . $image . '" alt="' . $description . '"/><small>' . $description . '</small></div>'; 
     1197                } 
     1198        } 
     1199 
     1200        function inputButton($name, $img='', $description='') { 
     1201                $image = $GLOBALS['phpgw']->common->image('filemanager', 'button_' . strtolower($img)); 
     1202 
     1203                if ($img) { 
    13571204                        return '<td class="" align="center" valign="middle" height="28" width="70"> 
    1358                         <input title="'.$description.'" name="'.$name.'" type="image" alt="'.$name.'" src="'.$image.'" value="clicked" /><br><small>'.$description.'</small> 
     1205                        <input title="' . $description . '" name="' . $name . '" type="image" alt="' . $name . '" src="' . $image . '" value="clicked" /><br><small>' . $description . '</small> 
    13591206                        </td>'; 
    13601207                } 
    13611208        } 
    13621209 
    1363  
    1364         function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) 
    1365         { 
     1210        function html_form_input($type = NULL, $name = NULL, $value = NULL, $maxlength = NULL, $size = NULL, $checked = NULL, $string = '', $return = 1) { 
    13661211                $text = ' '; 
    1367                 if($type != NULL && $type) 
    1368                 { 
    1369                         if($type == 'checkbox') 
    1370                         { 
     1212                if ($type != NULL && $type) { 
     1213                        if ($type == 'checkbox') { 
    13711214                                $value = $this->bo->string_encode($value, 1); 
    13721215                        } 
    1373                         $text .= 'type="'.$type.'" '; 
    1374                 } 
    1375                 if($name != NULL && $name) 
    1376                 { 
    1377                         $text .= 'name="'.$name.'" '; 
    1378                 } 
    1379                 if($value != NULL && $value) 
    1380                 { 
    1381                         $text .= 'value="'.$value.'" '; 
    1382                 } 
    1383                 if(is_int($maxlength) && $maxlength >= 0) 
    1384                 { 
    1385                         $text .= 'maxlength="'.$maxlength.'" '; 
    1386                 } 
    1387                 if(is_int($size) && $size >= 0) 
    1388                 { 
    1389                         $text .= 'size="'.$size.'" '; 
    1390                 } 
    1391                 if($checked != NULL && $checked) 
    1392                 { 
     1216                        $text .= 'type="' . $type . '" '; 
     1217                } 
     1218                if ($name != NULL && $name) { 
     1219                        $text .= 'name="' . $name . '" '; 
     1220                } 
     1221                if ($value != NULL && $value) { 
     1222                        $text .= 'value="' . $value . '" '; 
     1223                } 
     1224                if (is_int($maxlength) && $maxlength >= 0) { 
     1225                        $text .= 'maxlength="' . $maxlength . '" '; 
     1226                } 
     1227                if (is_int($size) && $size >= 0) { 
     1228                        $text .= 'size="' . $size . '" '; 
     1229                } 
     1230                if ($checked != NULL && $checked) { 
    13931231                        $text .= 'checked '; 
    13941232                } 
    13951233 
    1396                 return '<input'.$text.$string.'>'; 
    1397         } 
    1398  
    1399         function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) 
    1400         { 
     1234                return '<input' . $text . $string . '>'; 
     1235        } 
     1236 
     1237        function html_form_option($value = NULL, $displayed = NULL, $selected = NULL, $return = 0) { 
    14011238                $text = ' '; 
    1402                 if($value != NULL && $value) 
    1403                 { 
    1404                         $text .= ' value="'.$value.'" '; 
    1405                 } 
    1406                 if($selected != NULL && $selected) 
    1407                 { 
     1239                if ($value != NULL && $value) { 
     1240                        $text .= ' value="' . $value . '" '; 
     1241                } 
     1242                if ($selected != NULL && $selected) { 
    14081243                        $text .= ' selected'; 
    14091244                } 
    1410                 return  '<option'.$text.'>'.$displayed.'</option>'; 
    1411         } 
    1412  
    1413         function encode_href($href = NULL, $args = NULL , $extra_args) 
    1414         { 
     1245                return '<option' . $text . '>' . $displayed . '</option>'; 
     1246        } 
     1247 
     1248        function encode_href($href = NULL, $args = NULL, $extra_args) { 
    14151249                $href = $this->bo->string_encode($href, 1); 
    1416                 $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); 
     1250                $all_args = $args . '&' . $this->bo->string_encode($extra_args, 1); 
    14171251 
    14181252                $address = $GLOBALS['phpgw']->link($href, $all_args); 
     
    14211255        } 
    14221256 
    1423         function html_link($href = NULL, $args = NULL , $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) 
    1424         { 
     1257        function html_link($href = NULL, $args = NULL, $extra_args, $text = NULL, $return = 1, $encode = 1, $linkonly = 0, $target = NULL) { 
    14251258                //      unset($encode); 
    1426                 if($encode) 
    1427                 { 
     1259                if ($encode) { 
    14281260                        $href = $this->bo->string_encode($href, 1); 
    1429                         $all_args = $args.'&'.$this->bo->string_encode($extra_args, 1); 
    1430                 } 
    1431                 else 
    1432                 { 
     1261                        $all_args = $args . '&' . $this->bo->string_encode($extra_args, 1); 
     1262                } else { 
    14331263                        //                              $href = $this->bo->string_encode($href, 1); 
    1434                         $all_args = $args.'&'.$extra_args; 
     1264                        $all_args = $args . '&' . $extra_args; 
    14351265                } 
    14361266                ### 
     
    14411271 
    14421272                /* Auto-detect and don't disturb absolute links */ 
    1443                 if(!preg_match("|^http(.{0,1})://|", $href)) 
    1444                 { 
     1273                if (!preg_match("|^http(.{0,1})://|", $href)) { 
    14451274                        //Only add an extra / if there isn't already one there 
    1446  
    14471275                        // die(SEP); 
    1448                         if(!($href[0] == SEP)) 
    1449                         { 
     1276                        if (!($href[0] == SEP)) { 
    14501277                                $href = SEP . $href; 
    14511278                        } 
     
    14551282                        $address = $GLOBALS['phpgw']->link($href, $all_args); 
    14561283                        //                              $address = $GLOBALS['phpgw']->link($href); 
    1457                 } 
    1458                 else 
    1459                 { 
     1284                } else { 
    14601285                        $address = $href; 
    14611286                } 
    14621287 
    14631288                /* If $linkonly is set, don't add any HTML */ 
    1464                 if($linkonly) 
    1465                 { 
     1289                if ($linkonly) { 
    14661290                        $rstring = $address; 
    1467                 } 
    1468                 else 
    1469                 { 
    1470                         if($target) 
    1471                         { 
    1472                                 $target = 'target='.$target; 
     1291                } else { 
     1292                        if ($target) { 
     1293                                $target = 'target=' . $target; 
    14731294                        } 
    14741295 
    14751296                        $text = trim($text); 
    1476                         $rstring = '<a href="'.$address.'" '.$target.'>'.$text.'</a>'; 
     1297                        $rstring = '<a href="' . $address . '" ' . $target . '>' . $text . '</a>'; 
    14771298                } 
    14781299 
     
    14801301        } 
    14811302 
    1482         function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) 
    1483         { 
    1484                 if($width != NULL && $width) 
    1485                 { 
     1303        function html_table_begin($width = NULL, $border = NULL, $cellspacing = NULL, $cellpadding = NULL, $rules = NULL, $string = '', $return = 0) { 
     1304                if ($width != NULL && $width) { 
    14861305                        $width = "width=$width"; 
    14871306                } 
    1488                 if(is_int($border) && $border >= 0) 
    1489                 { 
     1307                if (is_int($border) && $border >= 0) { 
    14901308                        $border = "border=$border"; 
    14911309                } 
    1492                 if(is_int($cellspacing) && $cellspacing >= 0) 
    1493                 { 
     1310                if (is_int($cellspacing) && $cellspacing >= 0) { 
    14941311                        $cellspacing = "cellspacing=$cellspacing"; 
    14951312                } 
    1496                 if(is_int($cellpadding) && $cellpadding >= 0) 
    1497                 { 
     1313                if (is_int($cellpadding) && $cellpadding >= 0) { 
    14981314                        $cellpadding = "cellpadding=$cellpadding"; 
    14991315                } 
    1500                 if($rules != NULL && $rules) 
    1501                 { 
     1316                if ($rules != NULL && $rules) { 
    15021317                        $rules = "rules=$rules"; 
    15031318                } 
     
    15071322        } 
    15081323 
    1509         function html_table_end($return = 0) 
    1510         { 
     1324        function html_table_end($return = 0) { 
    15111325                $rstring = "</table>"; 
    15121326                return($this->bo->eor($rstring, $return)); 
    15131327        } 
    15141328 
    1515         function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) 
    1516         { 
    1517                 if($align != NULL && $align) 
    1518                 { 
     1329        function html_table_row_begin($align = NULL, $halign = NULL, $valign = NULL, $bgcolor = NULL, $string = '', $return = 0) { 
     1330                if ($align != NULL && $align) { 
    15191331                        $align = "align=$align"; 
    15201332                } 
    1521                 if($halign != NULL && $halign) 
    1522                 { 
     1333                if ($halign != NULL && $halign) { 
    15231334                        $halign = "halign=$halign"; 
    15241335                } 
    1525                 if($valign != NULL && $valign) 
    1526                 { 
     1336                if ($valign != NULL && $valign) { 
    15271337                        $valign = "valign=$valign"; 
    15281338                } 
    1529                 if($bgcolor != NULL && $bgcolor) 
    1530                 { 
     1339                if ($bgcolor != NULL && $bgcolor) { 
    15311340                        $bgcolor = "bgcolor=$bgcolor"; 
    15321341                } 
     
    15351344        } 
    15361345 
    1537         function html_table_row_end($return = 0) 
    1538         { 
     1346        function html_table_row_end($return = 0) { 
    15391347                $rstring = "</tr>"; 
    15401348                return($this->bo->eor($rstring, $return)); 
    15411349        } 
    15421350 
    1543         function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) 
    1544         { 
    1545                 if($align != NULL && $align) 
    1546                 { 
     1351        function html_table_col_begin($align = NULL, $halign = NULL, $valign = NULL, $rowspan = NULL, $colspan = NULL, $string = '', $return = 0) { 
     1352                if ($align != NULL && $align) { 
    15471353                        $align = "align=$align"; 
    15481354                } 
    1549                 if($halign != NULL && $halign) 
    1550                 { 
     1355                if ($halign != NULL && $halign) { 
    15511356                        $halign = "halign=$halign"; 
    15521357                } 
    1553                 if($valign != NULL && $valign) 
    1554                 { 
     1358                if ($valign != NULL && $valign) { 
    15551359                        $valign = "valign=$valign"; 
    15561360                } 
    1557                 if(is_int($rowspan) && $rowspan >= 0) 
    1558                 { 
     1361                if (is_int($rowspan) && $rowspan >= 0) { 
    15591362                        $rowspan = "rowspan=$rowspan"; 
    15601363                } 
    1561                 if(is_int($colspan) && $colspan >= 0) 
    1562                 { 
     1364                if (is_int($colspan) && $colspan >= 0) { 
    15631365                        $colspan = "colspan=$colspan"; 
    15641366                } 
     
    15681370        } 
    15691371 
    1570         function html_table_col_end($return = 0) 
    1571         { 
     1372        function html_table_col_end($return = 0) { 
    15721373                $rstring = "</td>"; 
    15731374                return($this->bo->eor($rstring, $return)); 
    15741375        } 
     1376 
    15751377} 
  • branches/2.2/filemanager/inc/upload.php

    r3610 r3879  
    1414 
    1515$bo = CreateObject('filemanager.bofilemanager'); 
    16  
    17 $c = CreateObject('phpgwapi.config','filemanager'); 
     16$c      = CreateObject('phpgwapi.config','filemanager'); 
    1817$c->read_repository(); 
    19 $current_config = $c->config_data; 
    20 $upload_max_size = $current_config['filemanager_Max_file_size']; 
    21 $path = $_POST['path']; 
    22 $notifUser = $_POST['notifTo']; 
    23 $show_upload_boxes = count($_FILES['upload_file']['name']); 
    24 $filesUpload = $_FILES['upload_file']; 
     18 
     19$current_config                 = $c->config_data; 
     20$upload_max_size                = $current_config['filemanager_Max_file_size']; 
     21$path                                   = $_POST['path']; 
     22$notifUser                              = $_POST['notifTo']; 
     23$show_upload_boxes      = count($_FILES['upload_file']['name']); 
     24$filesUpload                            = $_FILES['upload_file']; 
     25 
     26 
     27error_log( print_r($_FILES['upload_file'], true), 3, "/tmp/log" ); 
    2528 
    2629function create_summaryImage($file) 
     
    8487} 
    8588 
    86 if($path != '/') 
    87 { 
    88         for($i = 0; $i != $show_upload_boxes; $i++) 
    89         { 
    90                 if($badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True)) 
    91                 { 
    92                         $return[] = lang('Error:').lang('File names cannot contain "%1"', $badchar); 
     89if( $path != '/' ) 
     90{ 
     91        for( $i = 0; $i != $show_upload_boxes; $i++) 
     92        { 
     93                if ( $_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024) ) 
     94                { 
     95                        $return[] = array(  
     96                                                                "file"          => $_FILES['upload_file']['name'][$i] , 
     97                                                                "size"          => $_FILES['upload_file']['size'][$i] , 
     98                                                                "size_max"      => ($upload_max_size*1024*1024)  
     99                         ); 
    93100                        continue; 
    94101                } 
    95  
    96                 # Check to see if the file exists in the database, and get its info at the same time 
    97                 $ls_array = $bo->vfs->ls(array( 
    98                         'string'=> $path . '/' . $_FILES['upload_file']['name'][$i], 
    99                         'relatives'     => array(RELATIVE_NONE), 
    100                         'checksubdirs'  => False, 
    101                         'nofiles'       => True 
    102                 )); 
    103  
    104                 $fileinfo = $ls_array[0]; 
    105  
    106                 if($fileinfo['name']) 
    107                 { 
    108                         if($fileinfo['mime_type'] == 'Directory') 
    109                         { 
    110                                 $return[] = lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']); 
     102                elseif( $_FILES['upload_file']['size'][$i] > 0 ) 
     103                { 
     104                        if( $badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True )) 
     105                        { 
     106                                $return[] = array( 
     107                                                                "file"          => $_FILES['upload_file']['name'][$i], 
     108                                                                "badchar"       => lang('File names cannot contain "%1"', $badchar) 
     109                                );                                       
    111110                                continue; 
    112111                        } 
    113                 } 
    114  
    115                 if ($_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024)) 
    116                 { 
    117                         $return[] = lang('The size of %1 has exceded the limit: %2', $_FILES['upload_file']['name'][$i], $upload_max_size); 
    118                         continue; 
    119                 } 
    120                 elseif($_FILES['upload_file']['size'][$i] > 0) 
    121                 { 
     112 
     113                        # Check to see if the file exists in the database, and get its info at the same time 
     114                        $ls_array = $bo->vfs->ls(array( 
     115                                                'string'=> $path . '/' . $_FILES['upload_file']['name'][$i], 
     116                                                'relatives'     => array(RELATIVE_NONE), 
     117                                                'checksubdirs'  => False, 
     118                                                'nofiles'       => True 
     119                        )); 
     120 
     121                        $fileinfo = $ls_array[0]; 
     122 
     123                        if( $fileinfo['name'] ) 
     124                        { 
     125                                if( $fileinfo['mime_type'] == 'Directory' ) 
     126                                { 
     127                                        $return[] = array( 
     128                                                                                "file"          => $_FILES['upload_file']['name'][$i], 
     129                                                                                "directory"     => lang('Cannot replace %1 because it is a directory', $fileinfo['name'] ) 
     130                                        ); 
     131                                        continue; 
     132                                } 
     133                        } 
     134 
    122135                        if($fileinfo['name'] && $fileinfo['deleteable'] != 'N') 
    123136                        { 
     
    131144                                $bo->vfs->cp($tmp_arr); 
    132145                                $tmp_arr=array( 
    133                                         'string'=> $_FILES['upload_file']['name'][$i], 
    134                                         'relatives'     => array(RELATIVE_ALL), 
    135                                         'attributes'    => array( 
    136                                                 'owner_id' => $bo->userinfo['username'], 
    137                                                 'modifiedby_id' => $bo->userinfo['username'], 
    138                                                 'size' => $_FILES['upload_file']['size'][$i], 
    139                                                 'mime_type' => $_FILES['upload_file']['type'][$i], 
    140                                                 'deleteable' => 'Y', 
    141                                                 'comment' => stripslashes($_POST['upload_comment'][$i]) 
     146                                                'string'=> $_FILES['upload_file']['name'][$i], 
     147                                                'relatives'     => array(RELATIVE_ALL), 
     148                                                'attributes'    => array( 
     149                                                        'owner_id' => $bo->userinfo['username'], 
     150                                                        'modifiedby_id' => $bo->userinfo['username'], 
     151                                                        'size' => $_FILES['upload_file']['size'][$i], 
     152                                                        'mime_type' => $_FILES['upload_file']['type'][$i], 
     153                                                        'deleteable' => 'Y', 
     154                                                        'comment' => stripslashes($_POST['upload_comment'][$i]) 
    142155                                        ) 
    143156                                ); 
    144157                                $bo->vfs->set_attributes($tmp_arr); 
    145158 
    146                                 $return[] = lang("There is a file %1, that was not replaced",$_FILES['upload_file']['name'][$i]); 
     159                                $return[] = array( 
     160                                                                "file"          => $_FILES['upload_file']['name'][$i],                                                                   
     161                                                                "undefined"     => lang( "There is a file %1, that was not replaced", $_FILES['upload_file']['name'][$i] ) 
     162                                ); 
    147163                        } 
    148164                        else 
     
    155171                                { 
    156172                                        $bo->vfs->set_attributes(array( 
    157                                                 'string'=> $_FILES['upload_file']['name'][$i], 
    158                                                 'relatives'     => array(RELATIVE_ALL), 
    159                                                 'attributes'=> array( 
    160                                                         'mime_type' => $_FILES['upload_file']['type'][$i], 
    161                                                         'comment' => stripslashes($_POST['upload_comment'][$i]) 
    162                                                 ) 
     173                                                        'string'                => $_FILES['upload_file']['name'][$i], 
     174                                                        'relatives'     => array(RELATIVE_ALL), 
     175                                                        'attributes'    => array( 
     176                                                                'mime_type'     => $_FILES['upload_file']['type'][$i], 
     177                                                                'comment'       => stripslashes($_POST['upload_comment'][$i]) 
     178                                                        ) 
    163179                                        )); 
    164180                                } 
    165                                 else{ 
    166                                         $return[] = lang('Error:').lang('It was not possible to send your file'); 
     181                                else 
     182                                { 
     183                                        $return[] = array (  
     184                                                                                "file"          => $_FILES['upload_file']['name'][$i], 
     185                                                                                "sendFile"      => lang('It was not possible to send your file') 
     186                                        ); 
    167187                                } 
    168  
    169                         } 
    170                 } 
    171                 elseif($_FILES['upload_file']['name'][$i]) 
     188                        } 
     189                } 
     190                elseif( $_FILES['upload_file']['name'][$i] ) 
    172191                { 
    173192                        $bo->vfs->touch(array( 
     
    177196 
    178197                        $bo->vfs->set_attributes(array( 
    179                                 'string'=> $_FILES['upload_file']['name'][$i], 
    180                                 'relatives'     => array(RELATIVE_ALL), 
    181                                 'attributes'=> array( 
    182                                         'mime_type' => $_FILES['upload_file']['type'][$i], 
    183                                         'comment' => stripslashes($_POST['upload_comment'][$i]) 
    184                                 ) 
     198                                        'string'                => $_FILES['upload_file']['name'][$i], 
     199                                        'relatives'     => array(RELATIVE_ALL), 
     200                                        'attributes'    => array( 
     201                                                                                'mime_type'     => $_FILES['upload_file']['type'][$i], 
     202                                                                                'comment'       => stripslashes($_POST['upload_comment'][$i]) 
     203                                        ) 
    185204                        )); 
    186  
    187                 } 
    188  
    189                 if (!(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE)) 
     205                } 
     206 
     207                if ( !(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE ) ) 
    190208                { 
    191209                        $content = create_summaryImage($_FILES['upload_file']['tmp_name'][$i]); 
    192                         if ($content){ 
     210                        if ($content) 
     211                        { 
    193212                                $bo->vfs->set_summary(array( 
    194213                                        'string'=> $_FILES['upload_file']['name'][$i], 
  • branches/2.2/filemanager/js/common_functions.js

    r3679 r3879  
    9898                         
    9999                        var pArgs = unserialize(data); 
    100                                 pArgs.lang_add_file             = get_lang("Add file"); 
    101100                                pArgs.lang_click_here   = get_lang("Click here"); 
    102101                                pArgs.lang_more_files   = get_lang("More files"); 
     
    104103                                pArgs.height                    = 210; 
    105104                                pArgs.path_filemanager  = path_filemanager; 
    106                                 pArgs.width                     = 450; 
     105                                pArgs.width                     = 500; 
    107106                 
    108107                        var _html = Xtools.parse( Xtools.xml("upload_files"), "upload.xsl", pArgs ); 
     
    233232 
    234233 
    235 function setRestricted(name){ 
     234function setRestricted(name) 
     235{ 
    236236        var continue_set = confirm(get_lang('This property will change the visibility of all users that have access to this file, continue?')); 
    237         if (continue_set) 
    238                 cExecute_('./index.php?menuaction=filemanager.vfs_functions.setRestricted&file='+base64_encode(name)+'&path='+base64_encode(currentPath),handler.restricted); 
    239 } 
    240  
    241 function presetComments(el){ 
     237         
     238        if ( continue_set ) 
     239        { 
     240                cExecute_('./index.php?menuaction=filemanager.vfs_functions.setRestricted&file=' 
     241                                + base64_encode(name)+'&path='+base64_encode(currentPath),handler.restricted); 
     242        } 
     243} 
     244 
     245function presetComments(el) 
     246{ 
    242247        if (permissions['edit'] == 0){ 
    243248                el.blur(); 
     
    247252} 
    248253 
    249 function setComments(el){ 
    250         if (el.value == oldValue) return; 
     254function setComments(el) 
     255{ 
     256        if ( el.value == oldValue ) 
     257                return; 
     258         
    251259        var filename = base64_encode(el.id); 
    252         cExecute_('./index.php?menuaction=filemanager.vfs_functions.editComment&file='+filename+'&comment='+base64_encode(el.value),handler.updateComment); 
     260         
     261        cExecute_('./index.php?menuaction=filemanager.vfs_functions.editComment&file=' 
     262                                + filename+'&comment='+base64_encode(el.value), handler.updateComment); 
    253263} 
    254264 
     
    320330                         width                  : 250, 
    321331                         height                 : 290, 
    322                          top                    : 100, 
    323                          left                   : 400, 
     332                         top                            : 100, 
     333                         left                           : 400, 
    324334                         draggable              : true, 
    325                          visible                : "display", 
     335                         visible                        : "display", 
    326336                         resizable              : true, 
    327337                         zindex                 : zIndex++, 
    328338                         title                  : "Expresso FileManager - " + get_lang('View'), 
    329                          closeAction    : "remove", 
     339                         closeAction            : "remove", 
    330340                         content                : Xtools.parse(Xtools.xml("view_config"), "view.xsl", pTools)    
    331341                }; 
     
    369379        if (size < kbyte) 
    370380        { 
    371                 return size + 'B'; 
     381                return size + ' B'; 
    372382        } 
    373383        else if (size < mbyte) 
    374384        { 
    375                 return parseInt(size/kbyte) + 'KB'; 
     385                return parseInt(size/kbyte) + ' KB'; 
    376386        } 
    377387        else if (size < gbyte) 
    378388        { 
    379389                if ( size/mbyte > 100) 
    380                         return (size/mbyte).toFixed(0) + 'MB'; 
     390                        return (size/mbyte).toFixed(0) + ' MB'; 
    381391                else 
    382                         return (size/mbyte).toFixed(1) + 'MB'; 
     392                        return (size/mbyte).toFixed(1) + ' MB'; 
    383393        } 
    384394        else 
    385395        { 
    386                 return (size/gbyte).toFixed(1) + 'GB'; 
     396                return (size/gbyte).toFixed(1) + ' GB'; 
    387397        } 
    388398} 
     
    391401{ 
    392402        var newElement = document.createElement('div'); 
    393                 newElement.innerHTML  = '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' + 
    394                                                                 '<input name="upload_comment[]" type="text" style="margin-right:2px;" />' + 
    395                                                                 '<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>'; 
     403                newElement.innerHTML  = '<div></div>' + 
     404                                                                        '<input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px;" />' + 
     405                                                                        '<input name="upload_comment[]" type="text" style="margin-right:2px;" />' + 
     406                                                                        '<span style="color:red; cursor:pointer;" onclick="removeInput(this);">'+get_lang('delete')+'</span>'; 
    396407         
    397408        document.getElementById('uploadOption').parentNode.appendChild(newElement); 
     
    447458{ 
    448459        var _formUp                     = document.getElementById('form_up'); 
    449         var _uploadFiles        = document.getElementsByTagName('input'); 
     460        var _uploadFiles                = document.getElementsByTagName('input'); 
    450461        var _flagSend           = true; 
    451462         
     
    463474         
    464475        if( _flagSend ) 
    465         { 
    466                 cExecuteForm_( _formUp ,handler.upload); 
    467         } 
     476                cExecuteForm_( _formUp , handler.upload ); 
    468477        else 
    469478                write_msg(get_lang("No file(s) to send") + "!"); 
    470  
    471         close_window(); 
    472 } 
     479} 
  • branches/2.2/filemanager/js/config.js

    r3875 r3879  
    162162} 
    163163 
    164 function rename_folder(){ 
     164function rename_folder() 
     165{ 
    165166        var dirName = document.getElementById('search1').value; 
    166167        var toName = prompt(get_lang('enter the name you want to move %1 to',dirName),dirName); 
    167         if (toName.length > 1){ 
     168        if (toName.length > 1) 
     169        { 
    168170                cExecute_('index.php?menuaction=filemanager.uiconfig.renameFolder&dir='+base64_encode(dirName)+'&to='+base64_encode(toName),alert); 
    169171        } 
  • branches/2.2/filemanager/js/connector.js

    r3678 r3879  
    100100function cExecuteForm_(form, handler){ 
    101101        connector.showProgressBar(); 
    102         if(! (divUpload = document.getElementById('divUpload'))) { 
    103                 divUpload               = document.createElement('DIV');                 
    104                 divUpload.id    = 'divUpload'; 
     102         
     103        if( ! ( divUpload = document.getElementById('divUpload') ) ) 
     104        { 
     105                divUpload                = document.createElement('DIV');                 
     106                divUpload.id             = 'divUpload'; 
    105107                document.body.appendChild(divUpload); 
    106108        } 
    107109 
    108110        handlerExecuteForm = handler; 
    109         var form_handler = function (data){ 
     111         
     112        var form_handler = function (data) 
     113        { 
    110114                handlerExecuteForm(data); 
    111115                handlerExecuteForm = null; 
    112116        } 
     117         
    113118        divUpload.innerHTML= "<iframe onload=\"connector.hideProgressBar();cExecute_('./index.php/index.php?menuaction=filemanager.uifilemanager.getReturnExecuteForm',"+form_handler+");\"  style='display:none;width:0;height:0;' name='uploadFile'></iframe>"; 
     119         
    114120        form.target ="uploadFile"; 
    115     form.submit(); 
     121        form.submit(); 
    116122} 
    117123 
  • branches/2.2/filemanager/js/draw_api.js

    r3869 r3879  
    169169} 
    170170 
    171 function initDrawApi(){ 
    172         SecEl = document.getElementById('userKey'); 
     171function initDrawApi() 
     172{ 
     173        var SecEl = document.getElementById('userKey'); 
    173174        crypt = new crypt(SecEl.value); 
     175         
    174176        SecEl.parentNode.removeChild(SecEl); 
    175177 
     
    184186        window.onresize = resizeDiv; 
    185187        document.body.style.overflow = "hidden"; 
    186         cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list); 
    187 } 
    188  
    189 function folderList(){ 
     188        cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list', handler.draw_folders_list ); 
     189} 
     190 
     191function folderList() 
     192{ 
    190193        this.td = '<td style="padding-left: 2px; padding-right: 2px;" valign="middle">'; 
    191194} 
    192 folderList.prototype.init = function(){ 
     195 
     196folderList.prototype.init = function() 
     197{ 
    193198        this.element = document.getElementById('fmFileWindow'); 
    194199} 
    195 folderList.prototype.clear = function(){ 
     200 
     201folderList.prototype.clear = function() 
     202{ 
    196203        this.element.innerHTML = ""; 
    197204} 
    198205 
    199 folderList.prototype.drawSearch = function(data){ 
     206folderList.prototype.drawSearch = function(data) 
     207{ 
    200208        var fl = folderList; 
    201209        var files = unserialize(data); 
     
    555563                        } 
    556564                        var pswd = crypt.encode(password); 
    557                         cExecute_('./index.php?menuaction=filemanager.vfs_functions.archive&pswd='+base64_encode(pswd.toString())+'&path='+base64_encode(currentPath)+filesUrl,handler.archive); 
     565                        cExecute_('./index.php?menuaction=filemanager.vfs_functions.archive&pswd=' 
     566                                        + base64_encode(pswd.toString())+'&path='+base64_encode(currentPath)+filesUrl,handler.archive); 
    558567                        break; 
    559568                case 'move_to': 
     
    633642function unarchive(filename) 
    634643{ 
    635         password = crypt.encode(prompt(get_lang('Please, type archive password or leave it empty if it is not encrypted'))); 
    636         if (password == null) 
     644        var password = crypt.encode(prompt(get_lang('Please, type archive password or leave it empty if it is not encrypted'))); 
     645 
     646        if (password != null ) 
     647        { 
     648                cExecute_('./index.php?menuaction=filemanager.vfs_functions.unarchive&pswd=' 
     649                                + base64_encode(password)+'&path='+base64_encode(currentPath)+'&file='+base64_encode(filename), handler.archive); 
     650        } 
     651        else 
    637652                return; 
    638         cExecute_('./index.php?menuaction=filemanager.vfs_functions.unarchive&pswd='+base64_encode(password)+'&path='+base64_encode(currentPath)+'&file='+base64_encode(filename),handler.archive); 
    639653} 
    640654 
    641655function move_to(to,filesUrl) 
    642656{ 
    643         cExecute_('./index.php?menuaction=filemanager.vfs_functions.moveto&from='+base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl,handler.moveto); 
     657        cExecute_( './index.php?menuaction=filemanager.vfs_functions.moveto&from=' 
     658                        + base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl, handler.moveto ); 
    644659} 
    645660 
    646661function copy_to(to,filesUrl) 
    647662{ 
    648         cExecute_('./index.php?menuaction=filemanager.vfs_functions.copyto&from='+base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl,handler.copyto); 
     663        cExecute_('./index.php?menuaction=filemanager.vfs_functions.copyto&from=' 
     664                                + base64_encode(currentPath)+'&to='+base64_encode(to)+filesUrl, handler.copyto ); 
    649665} 
    650666 
     
    696712                                 
    697713                        var parentDir_en = base64_encode( parentDir ); 
    698                         cExecute_('./index.php?menuaction=filemanager.uifilemanager.createdir&path='+parentDir_en+'&filename='+base64_encode(name), handler.refreshDir); 
     714                        cExecute_('./index.php?menuaction=filemanager.uifilemanager.createdir&path=' 
     715                                        + parentDir_en+'&filename='+base64_encode(name), handler.refreshDir); 
     716                                 
    699717                        currentPath = parentDir + '/' + name; 
    700718                        close_window(); 
     
    744762                        var pArgs = 
    745763                        { 
    746                                 'lang_new_folder'                       : get_lang('new folder'), 
     764                                'lang_new_folder'               : get_lang('new folder'), 
    747765                                'lang_remove_folder'            : get_lang('remove folder'), 
    748                                 'path_filemanager'                      : path_filemanager, 
     766                                'path_filemanager'              : path_filemanager, 
    749767                                'onclick_new_folder'            : 'editFolders("new")', 
    750                                 'onclick_remove_folder'         : 'editFolders("remove")' 
     768                                'onclick_remove_folder' : 'editFolders("remove")' 
    751769                        }; 
    752770                         
     
    758776} 
    759777 
    760 function draw_window_card(content){ 
     778function draw_window_card(content) 
     779{ 
    761780        var menu = document.getElementById('menu_newFile'); 
    762         if (menu == null){ 
     781        if (menu == null) 
     782        { 
    763783                menu = document.createElement('DIV'); 
    764784                menu.className = 'menubox'; 
     
    783803        menuTimeout = setTimeout("hide_card()",4000); 
    784804} 
    785 function hide_card(){ 
    786         var e=document.getElementById('menu_newFile'); 
    787         if (e!=null) 
    788                 e.style.visibility = 'hidden'; 
    789 } 
    790  
    791 function draw_paging(num_files,data){ 
    792         num_files = parseInt(num_files); 
    793         total_pages = 1; 
    794  
    795         if(last_folder != current_folder){ 
    796                 lastPage = 1; 
    797                 current_page = 1; 
    798                 last_folder = current_folder; 
    799         } 
    800  
    801         if(num_files > parseInt(preferences.files_per_page)) { 
    802                 total_pages = parseInt(num_files/preferences.files_per_page); 
    803                 if((num_files/preferences.files_per_page) > total_pages) 
    804                         total_pages++; 
    805         } 
    806  
    807         if(total_pages == 1) { 
    808                 if(span_paging = document.getElementById("span_paging")) { 
    809                         span_paging.parentNode.removeChild(span_paging); 
    810                 } 
    811                 return; 
    812         } 
    813  
    814         span_paging = document.getElementById("span_paging"); 
    815         if(!span_paging){ 
    816                 span_paging = document.createElement("DIV"); 
    817                 span_paging.id = "span_paging"; 
    818                 span_paging.className = "boxHeaderText"; 
    819                 span_paging.align="right"; 
    820                 document.getElementById("div_menu_c3").appendChild(span_paging); 
    821         } 
    822         span_paging.style.width="100%"; 
    823         span_paging.innerHTML=""; 
    824         files_range_begin = 1; 
    825         files_range_end = preferences.files_per_page; 
    826         if(current_page != 1) { 
    827                 lnk_page = document.createElement("A"); 
    828                 lnk_page.setAttribute("href", "javascript:current_page=1;offset=0;toolbar.control('reload');"); 
    829         } 
    830         else { 
    831                 lnk_page = document.createElement("SPAN"); 
    832         } 
    833         span_paging.appendChild(lnk_page); 
    834  
    835         lnk_page.innerHTML = "&lt;&lt;"; 
    836         lnk_page.title = get_lang("First"); 
    837         span_paging.innerHTML += "&nbsp;"; 
    838  
    839         if(current_page == lastPage + numPages) 
    840                 lastPage = current_page - 1; 
    841         else if((lastPage != 1 && lastPage == current_page) || current_page == total_pages) 
    842                 lastPage = current_page - (numPages - 1); 
    843         else if(current_page == 1) 
    844                 lastPage = 1; 
    845  
    846         if(lastPage < 1) 
    847                 lastPage = 1; 
    848         else if(lastPage > 1 && (lastPage > (total_pages -(numPages - 1)))) 
    849                 lastPage = total_pages -(numPages - 1); 
    850  
    851         var     hasMarked = false; 
    852  
    853         for(i = lastPage; i <= total_pages; i++) { 
    854  
    855                 if(current_page == i || (i == total_pages && !hasMarked)) { 
    856                         lnk_page = document.createElement("SPAN"); 
    857                         span_paging.appendChild(lnk_page); 
    858                         lnk_page.innerHTML = "&nbsp;<b>"+i+"</b>&nbsp;"; 
    859                         hasMarked = true; 
    860                         continue; 
    861                 } 
    862                 else{ 
    863                         lnk_page = document.createElement("A"); 
    864                         span_paging.appendChild(lnk_page); 
    865                         files_range_begin = ((i*preferences.files_per_page)-(preferences.files_per_page-1)); 
    866                         files_range_end = (i*preferences.files_per_page); 
    867                         lnk_page.setAttribute("href", "javascript:current_page="+i+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 
    868                } 
    869  
    870                 lnk_page.innerHTML = "&nbsp;...&nbsp;"; 
    871  
    872                 if(i == (lastPage + numPages)) 
    873                                 break; 
    874                 else if(lastPage == 1 || i != lastPage) 
    875                         lnk_page.innerHTML = "&nbsp;"+i+"&nbsp;"; 
    876  
    877                 span_paging.innerHTML += "&nbsp;";                                                                             
    878         } 
    879  
    880         if(current_page != total_pages) { 
    881                 lnk_page = document.createElement("A"); 
    882                 files_range_begin = ((total_pages*preferences.files_per_page)-(preferences.files_per_page-1)); 
    883                 files_range_end = (total_pages*preferences.files_per_page); 
    884                 lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 
    885         } 
    886         else { 
    887                 lnk_page = document.createElement("SPAN"); 
    888         } 
    889         span_paging.innerHTML += "&nbsp;"; 
    890         span_paging.appendChild(lnk_page); 
    891  
    892         lnk_page.title = get_lang("Last"); 
    893         lnk_page.innerHTML = "&gt;&gt;"; 
    894 } 
    895  
     805function hide_card() 
     806{ 
     807        var menuNewFile = document.getElementById('menu_newFile'); 
     808         
     809        if ( menuNewFile != null ) 
     810                menuNewFile.style.visibility = 'hidden'; 
     811} 
     812 
     813function draw_paging( num_files, data) 
     814{ 
     815        num_files = parseInt(num_files); 
     816        var total_pages = 1; 
     817 
     818        if( last_folder != current_folder ) 
     819        { 
     820                lastPage = 1; 
     821                current_page = 1; 
     822                last_folder = current_folder; 
     823        } 
     824 
     825        if( num_files > parseInt(preferences.files_per_page) )  
     826        { 
     827                total_pages = parseInt(num_files/preferences.files_per_page); 
     828                 
     829                if( (num_files/preferences.files_per_page) > total_pages ) 
     830                        total_pages++; 
     831        } 
     832 
     833        if( total_pages == 1)  
     834        { 
     835                if( span_paging = document.getElementById("span_paging") ) 
     836                { 
     837                        span_paging.parentNode.removeChild(span_paging); 
     838                } 
     839                 
     840                return; 
     841        } 
     842 
     843        span_paging = document.getElementById("span_paging"); 
     844 
     845        if( !span_paging ) 
     846        { 
     847                span_paging = document.createElement("DIV"); 
     848                span_paging.id = "span_paging"; 
     849                span_paging.className = "boxHeaderText"; 
     850                span_paging.align="right"; 
     851                document.getElementById("div_menu_c3").appendChild(span_paging); 
     852        } 
     853        span_paging.style.width="100%"; 
     854        span_paging.innerHTML=""; 
     855        files_range_begin = 1; 
     856        files_range_end = preferences.files_per_page; 
     857         
     858        if ( current_page != 1)  
     859        { 
     860                lnk_page = document.createElement("A"); 
     861                lnk_page.setAttribute("href", "javascript:current_page=1;offset=0;toolbar.control('reload');"); 
     862        } 
     863        else 
     864        { 
     865                lnk_page = document.createElement("SPAN"); 
     866        } 
     867         
     868        span_paging.appendChild(lnk_page); 
     869 
     870        lnk_page.innerHTML = "&lt;&lt;"; 
     871        lnk_page.title = get_lang("First"); 
     872        span_paging.innerHTML += "&nbsp;"; 
     873 
     874        if( current_page == lastPage + numPages) 
     875                lastPage = current_page - 1; 
     876        else if( (lastPage != 1 && lastPage == current_page) || current_page == total_pages ) 
     877                lastPage = current_page - (numPages - 1); 
     878        else if( current_page == 1 ) 
     879                lastPage = 1; 
     880 
     881        if(lastPage < 1) 
     882                lastPage = 1; 
     883        else if( lastPage > 1 && (lastPage > (total_pages -(numPages - 1))) ) 
     884                lastPage = total_pages -(numPages - 1); 
     885 
     886        var     hasMarked = false; 
     887 
     888        for( i = lastPage; i <= total_pages; i++)  
     889        { 
     890                if( current_page == i || (i == total_pages && !hasMarked))  
     891                { 
     892                        lnk_page = document.createElement("SPAN"); 
     893                        span_paging.appendChild(lnk_page); 
     894                        lnk_page.innerHTML = "&nbsp;<b>"+i+"</b>&nbsp;"; 
     895                        hasMarked = true; 
     896                        continue; 
     897                } 
     898                else 
     899                { 
     900                        lnk_page = document.createElement("A"); 
     901                        span_paging.appendChild(lnk_page); 
     902                        files_range_begin = ((i*preferences.files_per_page)-(preferences.files_per_page-1)); 
     903                        files_range_end = (i*preferences.files_per_page); 
     904                        lnk_page.setAttribute("href", "javascript:current_page="+i+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 
     905                } 
     906 
     907                lnk_page.innerHTML = "&nbsp;...&nbsp;"; 
     908 
     909                if( i == (lastPage + numPages) ) 
     910                        break; 
     911                else if(lastPage == 1 || i != lastPage) 
     912                        lnk_page.innerHTML = "&nbsp;"+i+"&nbsp;"; 
     913 
     914                span_paging.innerHTML += "&nbsp;";                                                                             
     915        } 
     916 
     917        if( current_page != total_pages )   
     918        { 
     919                lnk_page = document.createElement("A"); 
     920                files_range_begin = ((total_pages*preferences.files_per_page)-(preferences.files_per_page-1)); 
     921                files_range_end = (total_pages*preferences.files_per_page); 
     922                lnk_page.setAttribute("href", "javascript:current_page="+total_pages+";offset=((current_page-1)*preferences.files_per_page);toolbar.control('reload');"); 
     923        } 
     924        else 
     925        { 
     926                lnk_page = document.createElement("SPAN"); 
     927        } 
     928         
     929        span_paging.innerHTML += "&nbsp;"; 
     930        span_paging.appendChild(lnk_page); 
     931 
     932        lnk_page.title = get_lang("Last"); 
     933        lnk_page.innerHTML = "&gt;&gt;"; 
     934} 
  • branches/2.2/filemanager/js/handler.js

    r3619 r3879  
    1 function handler(){ 
    2 } 
    3  
    4 handler.prototype.del = function(data) 
     1(function() 
    52{ 
    6         var _return = data; 
    7         var deletedFiles = ""; 
     3        function archive(data) 
     4        { 
     5                var returnVal = data.split('|'); 
     6                 
     7                if (returnVal[0] == 'False') 
     8                { 
     9                        write_error(get_lang('It was not possible to execute it')); 
     10                } 
     11                else 
     12                 
     13                if (returnVal[0] == 'wpasswd') 
     14                { 
     15                        write_error(get_lang('Wrong password')); 
     16                        return; 
     17                } 
     18                else 
     19                         write_msg(get_lang('Your operation was successfully executed')); 
     20                 
     21                toolbar.control('reload'); 
     22        } 
     23 
     24        function copyto(data) 
     25        { 
     26                var returnVal = data.split('|'); 
     27                 
     28                if (returnVal[0] == 'NODIR') 
     29                        write_error(get_lang('Could not copy file because no destination directory is given')); 
     30                else if(returnVal[0] == 'SOMEERROR') 
     31                { 
     32                        write_error(get_lang('Could not copy %1 file(s)',returnVal[1])); 
     33                } 
     34                else  if(returnVal[0] == 'COPIED') 
     35                { 
     36                        if (returnVal[1] == 1) 
     37                                write_msg(get_lang('File copied successfuly')); 
     38                        else 
     39                                write_msg(get_lang('%1 files copied successfuly', returnVal[1])); 
     40                } 
     41        } 
     42 
     43        function del(data) 
     44        { 
     45                var _return = data; 
     46                var deletedFiles = ""; 
     47 
     48                _return = _return.substring(0, ( _return.length - 1 ) ); 
     49                _return = _return.split("|"); 
     50 
     51 
     52                for (var i = 0 ; i < _return.length; i++) 
     53                {        
     54                        if ( _return[i] == 'False') 
     55                        { 
     56                                write_error(get_lang('Could not delete %1', _return[i+1]) ); 
     57                                return; 
     58                        } 
     59                        else 
     60                        { 
     61                                if ( _return[i] != "" ) 
     62                                { 
     63                                        deletedFiles += ", " + _return[i]; 
     64                                } 
     65 
     66                                if (i > 3) //to avoid big message 
     67                                { 
     68                                        deletedFiles = "  " + _return.length + " " +get_lang("files"); 
     69                                        break; 
     70                                } 
     71                        } 
     72                } 
     73 
     74                write_msg(get_lang('Deleted %1',deletedFiles.substr(2))); 
     75 
     76                toolbar.control('reload'); 
     77        } 
     78 
     79        function draw_folders_list(data) 
     80        { 
     81                toolbar.control('reload'); 
     82                folders_tree = new dFTree({name: 'main'}); 
     83 
     84                folders = unserialize(data); 
     85 
     86                var rootFold = new dNode({id:'root', caption: get_lang("Directories") }); 
     87                folders_tree.add(rootFold,'root'); 
     88 
     89                for ( var i = 0 ; i < folders.length; i++ ) 
     90                { 
     91                        var lastIndex = folders[i].lastIndexOf('/'); 
     92                        if (folders[i] != "/home/"+preferences.lid) 
     93                                var name = folders[i].substr(lastIndex+1,folders[i].length); 
     94                        else 
     95                                var name = get_lang("My Folder"); 
     96                        var parentDir = folders[i].substr(0,lastIndex); 
     97 
     98                        if ( parentDir == '/home' ) 
     99                                parentDir = 'root'; 
     100 
     101                        var search_child = function( ListFolders, name ) 
     102                        { 
     103                                for ( j = 0 ; j < ListFolders.length; j++ ) 
     104                                { 
     105                                        if ( ListFolders[j].indexOf( name + '/') > -1 ) 
     106                                                return true; 
     107                                } 
     108 
     109                                return false; 
     110                        } 
     111 
     112                        folder = new dNode({id:folders[i], caption:name, plusSign:search_child(folders,folders[i]), onClick:'load(\''+folders[i]+'\',this)'}); 
     113 
     114                        if (i == 0) 
     115                                folders_tree.add(folder,'root'); 
     116                        else 
     117                                folders_tree.add(folder,parentDir); 
     118                } 
     119 
     120                document.getElementById('content_folders').innerHTML = ""; 
     121 
     122                folders_tree.draw(document.getElementById('content_folders')); 
     123 
     124                folders_tree.openTo(currentPath); 
     125 
     126                folders_tree.getNodeById(currentPath)._select(); 
     127        } 
     128 
     129        function moveto(data)  
     130        { 
     131                returnVal = data.split('|'); 
     132                if (returnVal[0] == 'NODIR') 
     133                        write_error(get_lang('Could not copy file because no destination directory is given')); 
     134                else if(returnVal[0] == 'SOMEERROR'){ 
     135                        write_error(get_lang('Could not move %1 file(s)',returnVal[1])); 
     136                } 
     137                else  if(returnVal[0] == 'MOVED'){ 
     138                        if (returnVal[1] == 1) 
     139                                write_msg(get_lang('File moved successfuly')); 
     140                        else 
     141                                write_msg(get_lang('%1 files moved successfuly', returnVal[1])); 
     142                } 
     143                handler.refreshDir(); 
     144        } 
     145 
     146        function refreshDir(data)  
     147        { 
     148                cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list); 
     149        } 
     150 
     151        function rename(data)  
     152        { 
     153                if ( data == null ) 
     154                { 
     155                        var returnVal = new Array ("True",oldValue,oldValue); 
     156                } 
     157                else 
     158                        var returnVal = data.split('|'); 
     159                 
     160                if ( returnVal[0] == "True" ) 
     161                { 
     162                        if (returnVal[1] != returnVal[2]) write_msg(get_lang('Renamed %1 to %2',returnVal[1],returnVal[2])); 
     163                                var nameLink = document.createElement('A'); 
     164                         
     165                        var inputName = document.getElementById('input_'+returnVal[1]); 
     166                        var trFile = inputName.parentNode.parentNode.parentNode; 
     167 
     168                        nameLink.innerHTML = returnVal[2]; 
     169                        nameLink.href="./index.php?menuaction=filemanager.uifilemanager.view&file=" 
     170                                        + base64_encode(returnVal[2])+"&path="+base64_encode(currentPath); 
     171                        nameLink.target = "_blank"; 
     172                        nameLink.id = "name_"+returnVal[2]; 
     173 
     174                        inputName.parentNode.appendChild(nameLink); 
     175                        inputName.parentNode.removeChild(inputName); 
     176                        trFile.innerHTML = trFile.innerHTML.replace(returnVal[1],returnVal[2]); 
     177                        trFile.id = trFile.id.replace(returnVal[1],returnVal[2]); 
     178                } 
     179                else 
     180                { 
     181                        if ( returnVal[1] == "badchar" ) 
     182                                write_error(get_lang('File names cannot contain "%1"',returnVal[2])); 
     183                        else if (returnVal[1] == "slashes") 
     184                                write_error(get_lang('File names cannot contain \\ or /')); 
     185                        else if (returnVal[1] == "editing") 
     186                                write_error(get_lang('This file is being edited right now')); 
     187                        else 
     188                                write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2])); 
     189                } 
     190 
     191        } 
    8192         
    9         _return = _return.substring(0, ( _return.length - 1 ) ); 
    10         _return = _return.split("|"); 
     193        function restricted(data) 
     194        { 
     195                if (data.indexOf("True") == 0) 
     196                { 
     197                                returnVal = data.split('|'); 
     198                                var img_lock = document.getElementById('restrict_'+returnVal[1]); 
     199 
     200                        if (img_lock.style.backgroundImage.indexOf('button_unlock') > 0) 
     201                        { 
     202                                img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_unlock/g,'button_lock'); 
     203                                write_msg(get_lang('%1 marked as restricted',returnVal[1])); 
     204                        } 
     205                        else 
     206                        { 
     207                                img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_lock/g,'button_unlock'); 
     208                                write_msg(get_lang('%1 unmarked as restricted',returnVal[1])); 
     209                        } 
     210                } 
     211                else 
     212                        write_error("Could not mark as restricted"); 
     213        } 
     214 
     215        function updateComment(data) 
     216        { 
     217                var returnVal = data.split('|'); 
     218                if (data.indexOf("True") == 0) 
     219                { 
     220                        write_msg(get_lang('Updated comment for %1',returnVal[1])); 
     221                } 
     222                else 
     223                { 
     224                        if (returnVal[1] == "badchar") 
     225                                write_error(get_lang('Comments cannot contain "%1"',returnVal[2])); 
     226                        else 
     227                                write_error(get_lang('You have no permission to access this file')); 
     228                } 
     229 
     230        } 
    11231         
     232        function upload(data) 
     233        { 
     234                var response = unserialize(data); 
     235 
     236                if ( response[0] == "Ok" ) 
     237                { 
     238                        write_msg(get_lang('All files created sucessfuly')); 
     239                        _winBuild( "dwindownewUpload" , "remove" );      
     240                } 
     241                else 
     242                {        
     243                        var _inputs = document.getElementsByTagName('input'); 
     244 
     245                        for( var i = 0; i < response.length; i++ ) 
     246                        { 
     247                                for( var j = 0 ; j < _inputs.length ; j++ ) 
     248                                { 
     249                                        if( _inputs[j].getAttribute('type') == 'file' ) 
     250                                        {        
     251                                                if( _inputs[j].value.indexOf( response[i]['file'] ) > -1 ) 
     252                                                { 
     253                                                        var _parent     = _inputs[j].parentNode; 
     254                                                        var _div = _parent.firstChild;   
     255                                                        _div.style.display              = "block"; 
     256                                                        _div.style.color                        = "red"; 
     257                                                        _div.style.height                       = "16px"; 
     258                                                        _div.style.paddingLeft  = "17px"; 
     259                                                        _div.style.background   = "url('"+path_filemanager+"images/warning.gif') no-repeat left top"; 
     260                                                        _div.style.cursor                       = "pointer"; 
     261                                                        _div.onclick    = function(){ this.style.display = 'none'; } ; 
     262                                                         
     263                                                        if( response[i]['size_max'] ) 
     264                                                        { 
     265                                                                _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: Tamanho do arquivo "  
     266                                                                                          + borkb( response[i]['size'] ) + "  - Permitido  " + borkb( response[i]['size_max'] ); 
     267                                                        } 
     268                                                        else    if( response[i]['badchar'] ) 
     269                                                        {        
     270                                                                _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: "  + response[i]['badchar'];    
     271                                                        } 
     272                                                        else    if( response[i]['directory'] ) 
     273                                                        {        
     274                                                                _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: "  + response[i]['directory'];  
     275                                                        } 
     276                                                        else    if( response[i]['sendFile'] ) 
     277                                                        {        
     278                                                                _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: "  + response[i]['sendFile'];   
     279                                                        } 
     280                                                        else    if( response[i]['undefined'] ) 
     281                                                        { 
     282                                                                _div.innerHTML = "<span style='font-weight:bold' >Erro </span>:: "  + response[i]['undefined'];  
     283                                                        } 
     284                                                }        
     285                                        } 
     286                                }        
     287                        }        
     288                }        
     289 
     290                connector.hideProgressBar();             
     291                toolbar.control('reload'); 
     292        } 
     293 
     294        function handler(){} 
     295 
     296        handler.prototype.archive                       = archive; 
     297        handler.prototype.copyto                        = copyto; 
     298        handler.prototype.del                           = del; 
     299        handler.prototype.draw_folders_list     = draw_folders_list; 
     300        handler.prototype.moveto                        = moveto; 
     301        handler.prototype.refreshDir                    = refreshDir; 
     302        handler.prototype.rename                        = rename; 
     303        handler.prototype.restricted                    = restricted; 
     304        handler.prototype.updateComment = updateComment; 
     305        handler.prototype.upload                        = upload; 
     306 
     307        window.handler = new handler; 
    12308         
    13         for (var i = 0 ; i < _return.length; i++) 
    14         {        
    15                 if ( _return[i] == 'False') 
    16                 { 
    17                         write_error(get_lang('Could not delete %1', _return[i+1]) ); 
    18                         return; 
    19                 } 
    20                 else 
    21                 { 
    22                         if ( _return[i] != "" ) 
    23                         { 
    24                                 deletedFiles += ", " + _return[i]; 
    25                         } 
    26          
    27                         if (i > 3) //to avoid big message 
    28                         { 
    29                                 deletedFiles = "  " + _return.length + " " +get_lang("files"); 
    30                                 break; 
    31                         } 
    32                 } 
    33         } 
    34          
    35         write_msg(get_lang('Deleted %1',deletedFiles.substr(2))); 
    36          
    37         toolbar.control('reload'); 
    38  
    39 } 
    40  
    41 handler.prototype.rename = function(data) { 
    42         if (data == null){ 
    43                 var returnVal = new Array ("True",oldValue,oldValue); 
    44         } 
    45         else 
    46                 var returnVal = data.split('|'); 
    47         if ( returnVal[0] == "True" ){ 
    48                 if (returnVal[1] != returnVal[2]) write_msg(get_lang('Renamed %1 to %2',returnVal[1],returnVal[2])); 
    49                 var nameLink = document.createElement('A'); 
    50                 var inputName = document.getElementById('input_'+returnVal[1]); 
    51                 var trFile = inputName.parentNode.parentNode.parentNode; 
    52  
    53                 nameLink.innerHTML = returnVal[2]; 
    54                 nameLink.href="./index.php?menuaction=filemanager.uifilemanager.view&file="+base64_encode(returnVal[2])+"&path="+base64_encode(currentPath); 
    55                 nameLink.target = "_blank"; 
    56                 nameLink.id = "name_"+returnVal[2]; 
    57  
    58                 inputName.parentNode.appendChild(nameLink); 
    59                 inputName.parentNode.removeChild(inputName); 
    60                 trFile.innerHTML = trFile.innerHTML.replace(returnVal[1],returnVal[2]); 
    61                 trFile.id = trFile.id.replace(returnVal[1],returnVal[2]); 
    62         } 
    63         else 
    64         { 
    65                 if (returnVal[1] == "badchar") 
    66                         write_error(get_lang('File names cannot contain "%1"',returnVal[2])); 
    67                 else if (returnVal[1] == "slashes") 
    68                         write_error(get_lang('File names cannot contain \\ or /')); 
    69                 else if (returnVal[1] == "editing") 
    70                         write_error(get_lang('This file is being edited right now')); 
    71                 else 
    72                         write_error(get_lang('Could not rename %1 to %2', returnVal[1], returnVal[2])); 
    73         } 
    74  
    75 } 
    76  
    77 handler.prototype.upload = function(data) 
    78 { 
    79          
    80         connector.hideProgressBar(); 
    81         var response = unserialize(data); 
    82         if (response[0] == "Ok") 
    83                 write_msg(get_lang('All files created sucessfuly')); 
    84         else 
    85                 for (var i=0;i < response.length; i++) 
    86                         write_error(response[i]); 
    87         toolbar.control('reload'); 
    88 } 
    89  
    90 handler.prototype.restricted = function(data) 
    91 { 
    92         if (data.indexOf("True") == 0){ 
    93                 returnVal = data.split('|'); 
    94                 var img_lock = document.getElementById('restrict_'+returnVal[1]); 
    95                 if (img_lock.style.backgroundImage.indexOf('button_unlock') > 0) 
    96                 { 
    97                         img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_unlock/g,'button_lock'); 
    98                         write_msg(get_lang('%1 marked as restricted',returnVal[1])); 
    99                 } 
    100                 else 
    101                 { 
    102                         img_lock.style.backgroundImage = img_lock.style.backgroundImage.replace(/button_lock/g,'button_unlock'); 
    103                         write_msg(get_lang('%1 unmarked as restricted',returnVal[1])); 
    104                 } 
    105         } 
    106         else 
    107                 write_error("Could not mark as restricted"); 
    108 } 
    109  
    110 handler.prototype.archive = function(data) 
    111 { 
    112         returnVal = data.split('|'); 
    113         if (returnVal[0] == 'False') 
    114         { 
    115                 write_error(get_lang('It was not possible to execute it')); 
    116         } 
    117         else 
    118         if (returnVal[0] == 'wpasswd') 
    119         { 
    120                 write_error(get_lang('Wrong password')); 
    121                 return; 
    122         } 
    123         else 
    124                  write_msg(get_lang('Your operation was successfully executed')); 
    125         toolbar.control('reload'); 
    126  
    127 } 
    128  
    129 handler.prototype.updateComment = function (data) 
    130 { 
    131         var returnVal = data.split('|'); 
    132         if (data.indexOf("True") == 0) 
    133         { 
    134                 write_msg(get_lang('Updated comment for %1',returnVal[1])); 
    135         } 
    136         else 
    137         { 
    138                 if (returnVal[1] == "badchar") 
    139                         write_error(get_lang('Comments cannot contain "%1"',returnVal[2])); 
    140                 else 
    141                         write_error(get_lang('You have no permission to access this file')); 
    142         } 
    143  
    144 } 
    145  
    146 handler.prototype.draw_folders_list = function (data) 
    147 { 
    148         toolbar.control('reload'); 
    149         folders_tree = new dFTree({name: 'main'}); 
    150          
    151         folders = unserialize(data); 
    152          
    153         var rootFold = new dNode({id:'root', caption: get_lang("Directories") }); 
    154         folders_tree.add(rootFold,'root'); 
    155          
    156         for ( var i = 0 ; i < folders.length; i++ ) 
    157         { 
    158                 var lastIndex = folders[i].lastIndexOf('/'); 
    159                 if (folders[i] != "/home/"+preferences.lid) 
    160                         var name = folders[i].substr(lastIndex+1,folders[i].length); 
    161                 else 
    162                         var name = get_lang("My Folder"); 
    163                 var parentDir = folders[i].substr(0,lastIndex); 
    164          
    165                 if ( parentDir == '/home' ) 
    166                         parentDir = 'root'; 
    167                  
    168                 var search_child = function( ListFolders, name ) 
    169                 { 
    170                         for ( j = 0 ; j < ListFolders.length; j++ ) 
    171                         { 
    172                                 if ( ListFolders[j].indexOf( name + '/') > -1 ) 
    173                                         return true; 
    174                         } 
    175                          
    176                         return false; 
    177                 } 
    178                  
    179                 folder = new dNode({id:folders[i], caption:name, plusSign:search_child(folders,folders[i]), onClick:'load(\''+folders[i]+'\',this)'}); 
    180                  
    181                 if (i == 0) 
    182                         folders_tree.add(folder,'root'); 
    183                 else 
    184                         folders_tree.add(folder,parentDir); 
    185         } 
    186          
    187         document.getElementById('content_folders').innerHTML = ""; 
    188          
    189         folders_tree.draw(document.getElementById('content_folders')); 
    190      
    191         folders_tree.openTo(currentPath); 
    192          
    193         folders_tree.getNodeById(currentPath)._select(); 
    194 } 
    195  
    196 handler.prototype.copyto = function (data) 
    197 { 
    198         returnVal = data.split('|'); 
    199         if (returnVal[0] == 'NODIR') 
    200                 write_error(get_lang('Could not copy file because no destination directory is given')); 
    201         else if(returnVal[0] == 'SOMEERROR'){ 
    202                 write_error(get_lang('Could not copy %1 file(s)',returnVal[1])); 
    203         } 
    204         else  if(returnVal[0] == 'COPIED'){ 
    205                 if (returnVal[1] == 1) 
    206                         write_msg(get_lang('File copied successfuly')); 
    207                 else 
    208                         write_msg(get_lang('%1 files copied successfuly', returnVal[1])); 
    209         } 
    210 } 
    211  
    212 handler.prototype.moveto = function (data) { 
    213         returnVal = data.split('|'); 
    214         if (returnVal[0] == 'NODIR') 
    215                 write_error(get_lang('Could not copy file because no destination directory is given')); 
    216         else if(returnVal[0] == 'SOMEERROR'){ 
    217                 write_error(get_lang('Could not move %1 file(s)',returnVal[1])); 
    218         } 
    219         else  if(returnVal[0] == 'MOVED'){ 
    220                 if (returnVal[1] == 1) 
    221                         write_msg(get_lang('File moved successfuly')); 
    222                 else 
    223                         write_msg(get_lang('%1 files moved successfuly', returnVal[1])); 
    224         } 
    225         handler.refreshDir(); 
    226 } 
    227 handler.prototype.refreshDir = function (data) { 
    228         cExecute_('./index.php?menuaction=filemanager.uifilemanager.get_folders_list',handler.draw_folders_list); 
    229 } 
    230  
    231 var handler = new handler(); 
     309})(); 
  • branches/2.2/filemanager/setup/phpgw_pt-br.lang

    r3875 r3879  
    1212comment filemanager     pt-br   Comentário 
    1313comments cannot contain "%1"    filemanager     pt-br   Comentários não podem conter "%1" 
     14Comment(s)      filemanager     pt-br   Comentário(s) 
    1415%1 files copied successfuly     filemanager     pt-br   %1 arquivos foram copiados com sucesso 
    1516File copied successfuly filemanager     pt-br   O arquivo foi copiado com sucesso 
     
    3940You have no permission to access this file      filemanager     pt-br   Você não tem permissão para acessar este arquivo 
    4041One of the files sent was considered infected   filemanager     pt-bt   Um dos arquivos enviados foi considerado infectado por vírus 
    41 Note: Uploaded is limited to %1MB       filemanager     pt-br   Nota: O tamanho máximo de envio é limitado a %1MB 
     42The maximum size for each file is %1MB  filemanager     pt-br   O tamanho máximo para cada arquivo é de %1MB 
    4243This property will change the visibility of all users that have access to this file, continue?  filemanager     pt-br   Esta propriedade altera visibilidade dos usuários que estão compartilhados, deseja continuar? 
    4344Click to change comments        filemanager     pt-br   Clique para alterar comentários 
     
    8990filemanager preferences filemanager     pt-br   Preferências para Gerenciador de Arquivos 
    9091files   filemanager     pt-br   Arquivos 
     92File(s) filemanager     pt-br   Arquivo(s) 
    9193files in this directory filemanager     pt-br   Arquivos nesse diretório 
    9294folder  filemanager     pt-br   Pasta 
  • branches/2.2/filemanager/tp/expressowindow/xsl/upload.xsl

    r3647 r3879  
    66        <xsl:param name="form_action" /> 
    77        <xsl:param name="height"/> 
    8         <xsl:param name="lang_add_file" /> 
    98        <xsl:param name="lang_advanced_upload" /> 
    109        <xsl:param name="lang_click_here"/> 
     
    3231                                </div> 
    3332                                 
    34                                 <div style="height:{$height}px; margin: 4px; overflow-y:auto;">  
    35                                          
     33                                <div style="height:{$height}px; margin: 4px; overflow-y:auto; overflow-x:hidden;">       
    3634                                        <div id="sendNotifcation" style="margin: 4px; overflow-y:auto;"/> 
    37                                          
    38                                         <div id="uploadOption"> 
    39                                                 <span style="margin-right:{($width)-250}px;"> 
    40                                                         <xsl:value-of select="$lang_file"/> 
    41                                                 </span> 
    42                                                 <span> 
    43                                                         <xsl:value-of select="$lang_comment"/> 
    44                                                 </span> 
    45                                                 <br/> 
    46                                                 <input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px" /> 
     35                                        <span style="margin-right:{($width)-250}px;"> 
     36                                                <label style="margin-left:1px;"><xsl:value-of select="$lang_file"/></label> 
     37                                                <label style="margin-left:200px;"><xsl:value-of select="$lang_comment"/></label> 
     38                                        </span> 
     39                                        <br/> 
     40                                        <div id="uploadOption" > 
     41                                                <div></div> 
     42                                                <input maxlength="255" name="upload_file[]" type="file" style="margin-right:5px" /> 
    4743                                                <input name="upload_comment[]" type="text"/> 
    4844                                                <input type="hidden" name="uploadprocess" value="true"/> 
     
    6561                                        </div>                                           
    6662                                         
    67                                         <div style="font-weight:bold; margin-top: 15px;"> 
     63                                        <div style="font-weight:bold; color: #f00; font-size:10pt; margin-top: 15px;"> 
    6864                                                <xsl:value-of select="$max_size"/> 
    6965                                        </div> 
Note: See TracChangeset for help on using the changeset viewer.