phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] filemanager/inc class.uifilemanager.inc.php, 1.23 cla


From: ceb
Subject: [Phpgroupware-cvs] filemanager/inc class.uifilemanager.inc.php, 1.23 class.bofilemanager.inc.php, 1.17
Date: Thu, 24 Feb 2005 15:06:56 -0000

Update of filemanager/inc

Modified Files:
     Branch: MAIN
            class.uifilemanager.inc.php lines: +118 -148
            class.bofilemanager.inc.php lines: +37 -5

Log Message:
update

====================================================
Index: filemanager/inc/class.uifilemanager.inc.php
diff -u filemanager/inc/class.uifilemanager.inc.php:1.22 
filemanager/inc/class.uifilemanager.inc.php:1.23
--- filemanager/inc/class.uifilemanager.inc.php:1.22    Fri Jan 28 00:19:03 2005
+++ filemanager/inc/class.uifilemanager.inc.php Sat Jan 29 02:34:48 2005
@@ -20,12 +20,10 @@
                (
                        'index'                 => True,
                        'action'                => True,
-                       'help'                  => True,
                        'history'               => True,
                        'view'                  => True,
                        'view_file'             => True,
                        'edit'                  => True,
-                       'rename'                => True,
                        'edit_comments' => True,
                        'update'                => True,
                        'preferences'   => True,
@@ -73,7 +71,7 @@
                {
                        $this->action                   = 
CreateObject('filemanager.uiaction_base');
                        $this->bofilemanager    = $this->action->bofilemanager;
-                       //$this->actions                = 
CreateObject('filemanager.uiactions');
+                       $this->fileman                  = 
$this->bofilemanager->fileman;
                        //$this->nextmatchs             = 
CreateObject('phpgwapi.nextmatchs');
                        //$this->browser                = 
CreateObject('phpgwapi.browser');

@@ -172,28 +170,29 @@
                                _debug_array($_POST);
                        }

-                       /*$actions = Array(
-                               'rename'        => lang('rename'),
-                               'delete'        => lang('delete'),
-                               'go'    => lang('go to'),
-                               'copy'  => lang('copy to'),
-                               'move'  => lang('move to'),
-                               'download'      => lang('download'),
-                               'newdir'        => lang('create folder'),
-                               'newfile'       => lang('create file'),
-                               'edit'          => lang('edit'),
-                               'edit_comments'         => lang('edit 
comments'),
-                               'apply_edit_comment'            => '1',
-                               'apply_edit_name'               => '1',
-                               'cancel'        => lang('cancel'),
-                               'upload'  => lang('upload files')
+                       $functions = Array
+                       (
+                               'rename',
+                               'delete',
+                               'go',
+                               'copy',
+                               'move',
+                               'download',
+                               'newdir',
+                               'newfile',
+                               'edit',
+                               'edit_comments',
+                               'apply_edit_comment',
+                               'apply_edit_name',
+                               'cancel',
+                               'upload'
                        );
-
+
                        $local_functions = array(
                                'rename',
-                               'edit_comments'
-                       );*/
-                       $functions = array
+                               'edit_comments'
+                       );
+                       $bo_functions = array
                        (
                                'apply_edit_comment',
                                'apply_edit_name',
@@ -204,8 +203,7 @@
                                'newfile',
                                'go',
                                'upload',
-                               'download',
-                               'edit'
+                               'download'
                        );

                        $link_data = array
@@ -230,22 +228,30 @@
                                        {
                                                switch($action)
                                                {
+                                                       case 'rename':
+                                                               
$link_data['rename_files'] = True;
+                                                               $edit = 
$this->bofilemanager->get_fileman();
+                                                               
$this->bofilemanager->save_sessiondata($edit,'changes');
+                                                               break;
                                                        case 'edit':
                                                                
$link_data['menuaction'] = $this->bofilemanager->appname.'.uiaction_edit.edit';
                                                                break;
                                                        default:
-                                                               //echo ' 
bofunction: f_' . $action;
-                                                               $f_function = 
'f_'.$action;
-                                                               $error = 
$this->bofilemanager->$f_function();
-
-                                                               if($action == 
'newfile' && !is_array($error))
+                                                               
if(in_array($action,$bo_functions))
                                                                {
-                                                                       
$link_data['menuaction']        = 
$this->bofilemanager->appname.'.uiaction_edit.edit';
-                                                                       
$link_data['file']                      = 
urlencode($this->bofilemanager->createfile);
-                                                               }
-                                                               
elseif(is_array($error))
-                                                               {
-                                                                       
$var['errors'] = implode("\n",$error);
+                                                                       //echo 
' bofunction: f_' . $action;
+                                                                       
$f_function = 'f_'.$action;
+                                                                       $error 
= $this->bofilemanager->$f_function();
+
+                                                                       
if($action == 'newfile' && !is_array($error))
+                                                                       {
+                                                                               
$link_data['menuaction']        = 
$this->bofilemanager->appname.'.uiaction_edit.edit';
+                                                                               
$link_data['file']                      = 
urlencode($this->bofilemanager->createfile);
+                                                                       }
+                                                                       
elseif(is_array($error))
+                                                                       {
+                                                                               
$var['errors'] = implode("\n",$error);
+                                                                       }
                                                                }
                                                                break;
                                                }
@@ -557,12 +563,14 @@

                function index()
                {
-                       $files_array = $this->bofilemanager->load_files();
+                       $rename_files = $_GET['rename_files'];
+                       $edit_comments = $_GET['edit_comments'];

-                       //_debug_array($files_array);
+                       $files_array = $this->bofilemanager->load_files();
+                       //_debug_array($this->bofilemanager->changes);
                        $usage = 0;
                        $files_array = $this->dirs_first($files_array);
-
+
                        $file_attributes[] =  array('widget'=> array('type' => 
'plain','caption' => lang('sort by')),
                                                                                
'help' => array('widget' => array('type' => 'help','onClick' => 
$this->bofilemanager->build_help('sort_by'))));
                        @reset($this->bofilemanager->file_attributes);
@@ -571,9 +579,8 @@

                        foreach($this->bofilemanager->file_attributes as 
$attribute => $translation)
                        {
-                               if 
(!is_array($this->bofilemanager->settings)||$this->bofilemanager->settings[$attribute])
+                               if ($this->bofilemanager->settings[$attribute])
                                {
-
                                        $file_attributes[] = array('widget'=> 
array('type' => 'link','caption' => lang($attribute),
                                                                                
                                                'href' =>  
$GLOBALS['phpgw']->link('/index.php', array(
                                                                                
                                                'menuaction'    => 
$this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.index',
@@ -590,75 +597,69 @@
                                $file = $files_array[$i];
                                $usage += $file['size'];

-                               if (!count($edit) )
-                               {
-                                       $file_output[$i]['checkbox'] = 
array('widget' => array( 'type' => 'checkbox',
-                                                                       'name' 
=> 'fileman[]',
-                                                                       'value' 
=> $file['name']
-                                                               ));
-                               }
+                               $file_output[$i]['checkbox'] = array('widget' 
=> array( 'type' => 'checkbox','name' => 'fileman[]','value' => $file['name'],
+                                                                               
                                                                'checked' => 
($this->bofilemanager->changes[$file['name']] == $file['name']?True:False)));
                                @reset($this->bofilemanager->file_attributes);
                                while(list($internal,$displayed) = 
each($this->bofilemanager->file_attributes))
                                {
-                                       if 
(!is_array($this->bofilemanager->settings)||$this->bofilemanager->settings[$internal])
+                                       if 
($this->bofilemanager->settings[$internal])
                                        {
-                                               if 
($internal==$edit[$file['name']])
+                                               switch($internal)
                                                {
-                                                       
$file_output[$i][$internal] = array('widget' => array('type' => 'text',
-                                                                       'name' 
=> 'changes['.$file['name'].']',
-                                                                       'value' 
=> $file[$internal]
-                                                                       ));
-                                               }
-                                               else
-                                               {
-                                                       switch($internal)
-                                                       {
-                                                               case 'owner_id':
-                                                               case 'owner':
-                                                               case 
'createdby_id':
-                                                               case 
'modifiedby_id':
+                                                       case 'owner_id':
+                                                       case 'owner':
+                                                       case 'createdby_id':
+                                                       case 'modifiedby_id':
                                                                        $name = 
$GLOBALS['phpgw']->accounts->id2name($file[$internal]) ;
                                                                        
$file_output[$i][$internal] = $name ? $name: '';
                                                                        break;
-                                                               case 'created':
-                                                               case 'modified':
+                                                       case 'created':
+                                                       case 'modified':
                                                                        
//Convert ISO 8601 date format used by DAV into something people can read
                                                                        
$file_output[$i][$internal] =  
$this->bofilemanager->convert_date($file[$internal]);
                                                                        break;
-                                                               case 'name':
-                                                                       
$mime_parts = explode('/',$file['mime_type']);
-                                                                       
$file_icon = $this->mime_ico[$file['mime_type']];
-                                                                       if 
(!$file_icon)
+                                                       case 'name':
+                                                                       if 
($rename_files && $this->bofilemanager->changes[$file['name']] == $file['name'])
                                                                        {
-                                                                               
$file_icon = ( $this->mime_ico[$mime_parts[0]]) ?  
$this->mime_ico[$mime_parts[0]] :  $this->mime_ico['unknown'];
-                                                                               
if (strpos($file['name'],'.exe') !== false) $file_icon =  
$this->mime_ico['exe'];
-                                                                       }
-                                                                       
$file_output[$i]['name']['icon'] = array('widget' => array( 'type' => 'image',
-                                                                               
                                                'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,$file_icon)));
-                                                                       if 
($file['mime_type']=='Directory')
-                                                                       {
-                                                                               
$href = array('menuaction' => 
$this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.index',
-                                                                               
                                                'path' => 
$this->bofilemanager->path . $this->bofilemanager->dispsep . $file['name']);
+                                                                               
$file_output[$i][$internal] = array('widget' => array('type' => 'text',
+                                                                               
                                                                                
                        'name' => 'changes['.$file['name'].']',
+                                                                               
                                                                                
                        'value' => $file[$internal]));
                                                                        }
                                                                        else
                                                                        {
-                                                                               
$href = Array( 'menuaction'     => 
$this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.view',
+                                                                               
$mime_parts = explode('/',$file['mime_type']);
+                                                                               
$file_icon = $this->mime_ico[$file['mime_type']];
+                                                                               
if (!$file_icon)
+                                                                               
{
+                                                                               
        $file_icon = ( $this->mime_ico[$mime_parts[0]]) ?  
$this->mime_ico[$mime_parts[0]] :  $this->mime_ico['unknown'];
+                                                                               
        if (strpos($file['name'],'.exe') !== false) $file_icon =  
$this->mime_ico['exe'];
+                                                                               
}
+                                                                               
$file_output[$i]['name']['icon'] = array('widget' => array( 'type' => 'image',
+                                                                               
                                                'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,$file_icon)));
+                                                                               
if ($file['mime_type']=='Directory')
+                                                                               
{
+                                                                               
        $href = array('menuaction' => 
$this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.index',
+                                                                               
                                                'path' => 
$this->bofilemanager->path . $this->bofilemanager->dispsep . $file['name']);
+                                                                               
}
+                                                                               
else
+                                                                               
{
+                                                                               
        $href = Array( 'menuaction'     => 
$this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.view',
                                                                                
                                        'path' => 
urlencode($this->bofilemanager->path),'file' => urlencode($file['name']));
-                                                                       }
-                                                                       
$file_output[$i]['name']['link'] = array('widget' => array('type' => 
'link','caption' => $file['name'],
+                                                                               
}
+                                                                               
$file_output[$i]['name']['link'] = array('widget' => array('type' => 
'link','caption' => $file['name'],
                                                                                
                                                                        'href' 
=> $GLOBALS['phpgw']->link('/index.php', $href)));
-                                                                       
if($mime_parts[0] == 'text')
-                                                                       {
-                                                                               
$href['menuaction']     = $this->bofilemanager->appname.'.uiaction_edit.edit';
-                                                                               
$href['edit_file']      = urlencode($file['name']);
-                                                                               
$file_output[$i]['name']['edit'] = array('widget' => array( 'type' => 'image',
+                                                                               
if($mime_parts[0] == 'text')
+                                                                               
{
+                                                                               
        $href['menuaction']     = 
$this->bofilemanager->appname.'.uiaction_edit.edit';
+                                                                               
        $href['edit_file']      = urlencode($file['name']);
+                                                                               
        $file_output[$i]['name']['edit'] = array('widget' => array( 'type' => 
'image',
                                                                                
                                                'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,'pencil'),
                                                                                
                                                'link' =>  
$GLOBALS['phpgw']->link('/index.php', $href)));
+                                                                               
}
                                                                        }
                                                                        break;
-                                                               default:
+                                                       default:
                                                                        
$file_output[$i][$internal] = $file[$internal];
-                                                       }
                                                }
                                        }
                                }
@@ -786,9 +787,8 @@
                                        $data['img_dl'] = array('widget' => 
array('type' => 'image',
                                                                                
                                'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,'bottom'),
                                                                                
                                'title' => lang('download files'),
-                                                                               
                                'link' => 
$GLOBALS['phpgw']->link('/index.php',Array(
-                                                                               
                                                        'menuaction' => 
$this->bofilemanager->appname.'.ui'.$this->bofilemanager->appname.'.index',
-                                                                               
                                                        'path' => 
urlencode($this->bofilemanager->homedir)))));
+                                                                               
                                'name' => 'params[download]',
+                                                                               
                                'value' => 'download'));
                                        $data['help_dl']        = 
array('widget' => array('type' => 'help','onClick' => 
$this->bofilemanager->build_help('download')));
                                        $data['lang_dl']        = 
lang('download');
                                }
@@ -799,37 +799,21 @@
                                $data['errors'] = $this->bofilemanager->errors;
                        }

-                       if (count($edit))
+                       if ($rename_files || $edit_comments)
                        {
-                               $data['img_cancel'] = array('widget' => 
array('type' => 'image',
-                                                                               
        'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,'button_cancel'),
-                                                                               
        'alt' => lang('folder')
-                                               ));
-                               $data['button_cancel'] = array('widget' => 
array('type' => 'submit',
-                                                                               
'name' => 'cancel',
-                                                                               
'value' => lang('cancel')
-                                               ));
-                               $data['img_ok'] = array('widget' => 
array('type' => 'image',
+                               $data['rename'] = array
+                               (
+                                       'img_ok' => array('widget' => 
array('type' => 'image',
                                                                                
        'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,'button_ok'),
-                                                                               
        'alt' => lang('folder')
-                                               ));
-                               $data['button_ok'] = array('widget' => 
array('type' => 'submit',
-                                                                       'name' 
=> 'submit',
-                                                                       'value' 
=> lang('ok')
-                                       ));
-                               @reset($edit);
-                               while( list($file,$prop) = each($edit))
-                               {
-                                       $data['fileman'][] = array('widget' => 
array('type'=>'hidden',
-                                                                       'name' 
=> 'fileman[]',
-                                                                       'value' 
=> $file
-                                               ));
-                               }
-                               @reset($edit); list($file,$prop) = each($edit);
-                               $data['action'] = array('widget' => 
array('type'=>'hidden',
-                                                                       'name' 
=> 'apply_edit_'.$prop,
-                                                                       'value' 
=> 1
-                                               ));
+                                                                               
        'title' => lang('apply changes'),
+                                                                               
        'name'  => 'params[apply_edit_' . ($rename_files?'name':'comment') . 
']',
+                                                                               
        'value' => 'apply_edit_' . ($rename_files?'name':'comment'))),
+                                       'img_cancel' => array('widget' => 
array('type' => 'image',
+                                                                               
        'src' => 
$GLOBALS['phpgw']->common->image($this->bofilemanager->appname,'button_cancel'),
+                                                                               
        'title' => lang('cancel'),
+                                                                               
        'name'  => 'params[cancel]',
+                                                                               
        'value' => 'cancel'))
+                               );
                        }
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('index' => $data));
                }
@@ -842,15 +826,7 @@
                                );
                        Header('Location: 
'.$GLOBALS['phpgw']->link('/index.php',$var));
                }
-               function rename()
-               {
-                       $edit=array();
-                       for ($i=0; 
$i!=count($this->bofilemanager->fileman);$i++)
-                       {
-                               $edit[$this->bofilemanager->fileman[$i]] = 
'name';
-                       }
-                       $this->index($edit);
-               }
+
                function edit_comments()
                {
                        $edit=array();
@@ -970,25 +946,19 @@
                                $this->bofilemanager->file = 
$file_array['file'];
                        }
                        $file = 
$this->bofilemanager->path.SEP.$this->bofilemanager->file;
-                       if($GLOBALS['phpgw']->vfs->file_exists(array(
-                               'string' => $file,
-                               'relatives' => Array(RELATIVE_NONE)
-                               )))
+                       if($GLOBALS['phpgw']->vfs->file_exists(array('string' 
=> $file,'relatives' => Array(RELATIVE_NONE))))
                        {
+                               $ls_array = 
$GLOBALS['phpgw']->vfs->ls(array('string' => $file,'relatives' => array 
(RELATIVE_ALL),'checksubdirs' => False,'nofiles' => True));
+                               $mime_type = $ls_array[0]['mime_type'];
+                               /*$mime_part = explode('/',$mime_type);
+                               $mime_type = 
($mime_part=='text'?'application/octet-stream':$mime_type);
+                               echo $mime_type;
+                               exit;*/
+
                                $browser = CreateObject('phpgwapi.browser');
-                               
$browser->content_header($this->bofilemanager->file,$GLOBALS['phpgw']->vfs->file_type(array(
-                                               'string' => $file,
-                                               'relatives' => 
Array(RELATIVE_NONE))),
-                                       $GLOBALS['phpgw']->vfs->get_size(array(
-                                               'string' => $file,
-                                               'relatives' => 
Array(RELATIVE_NONE),
-                                               'checksubdirs' => True
-                                               )));
-//                             
$browser->content_header($this->bofilemanager->file);
-                               echo $GLOBALS['phpgw']->vfs->read(array(
-                                       'string' => $file,
-                                       'relatives' => Array(RELATIVE_NONE)
-                                       ));
+                               
$browser->content_header($this->bofilemanager->file,$mime_type,$ls_array[0]['size']);
+
+                               echo 
$GLOBALS['phpgw']->vfs->read(array('string' => $file,'relatives' => 
Array(RELATIVE_NONE)));
                                flush();
                        }
                        if(!is_array($file_array))
@@ -1051,7 +1021,7 @@
                        {
                                $var = array();
                                $var[] = array('width' => '90%','widget' => 
array('type' => 'label','caption' => $title));
-                               $var[] = array('widget' => array('type' => 
'checkbox','name' => 'values[' . $internal . ']','value' => 
$GLOBALS['phpgw_info']['user']['preferences']['filemanager'][$internal]?True:False));
+                               $var[] = array('widget' => array('type' => 
'checkbox','name' => 'values[' . $internal . ']','value' => 'True','checked' => 
$GLOBALS['phpgw_info']['user']['preferences']['filemanager'][$internal]?True:False));
                                $table_rows[] = array('table_col' => $var);
                        }

@@ -1065,7 +1035,7 @@
                        {
                                $var = array();
                                $var[] = array('width' => '90%','widget' => 
array('type' => 'label','caption' => $title));
-                               $var[] = array('widget' => array('type' => 
'checkbox','name' => 'values[' . $internal . ']','value' => 
$GLOBALS['phpgw_info']['user']['preferences']['filemanager'][$internal]?True:False));
+                               $var[] = array('widget' => array('type' => 
'checkbox','name' => 'values[' . $internal . ']','value' => 'True','checked' => 
$GLOBALS['phpgw_info']['user']['preferences']['filemanager'][$internal]?True:False));
                                $table_rows[] = array('table_col' => $var);
                        }


====================================================
Index: filemanager/inc/class.bofilemanager.inc.php
diff -u filemanager/inc/class.bofilemanager.inc.php:1.16 
filemanager/inc/class.bofilemanager.inc.php:1.17
--- filemanager/inc/class.bofilemanager.inc.php:1.16    Fri Jan 28 00:19:03 2005
+++ filemanager/inc/class.bofilemanager.inc.php Sat Jan 29 02:34:48 2005
@@ -130,9 +130,11 @@
                        }
                        else
                        {
-                               $this->read_sessiondata();
+                               $this->read_sessiondata('fileman');
                        }

+                       //_debug_array($this->fileman);
+
                        $this->rootdir = $GLOBALS['phpgw']->vfs->basedir;
                        $this->fakebase = $GLOBALS['phpgw']->vfs->fakebase;
                        $this->appname = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
@@ -366,14 +368,43 @@
                        }
                }

-               function save_sessiondata()
+               function save_sessiondata($values = 0,$type = 'changes')
                {
-                       
$GLOBALS['phpgw']->session->appsession('session_data','filemanager',$this->fileman);
+                       if(is_array($values))
+                       {
+                               switch($type)
+                               {
+                                       case 'fileman':
+                                               $this->fileman = $values;
+                                               break;
+                                       default:
+                                               $this->changes = $values;
+                               }
+                       }
+                       $data = array
+                       (
+                               'fileman'       => serialize($this->fileman),
+                               'changes'       => serialize($this->changes)
+                       );
+
+                       
$GLOBALS['phpgw']->session->appsession('session_data','filemanager',$data);
                }

                function read_sessiondata()
                {
-                       $this->fileman = 
$GLOBALS['phpgw']->session->appsession('session_data','filemanager');
+                       $data = 
$GLOBALS['phpgw']->session->appsession('session_data','filemanager');
+                       $this->fileman = unserialize($data['fileman']);
+                       $this->changes = unserialize($data['changes']);
+               }
+
+               function get_fileman()
+               {
+                       $edit=array();
+                       for ($i=0; $i!=count($this->fileman);$i++)
+                       {
+                               $edit[$this->fileman[$i]] = $this->fileman[$i];
+                       }
+                       return $edit;
                }

                function create_home_dir()
@@ -560,6 +591,7 @@

                function f_apply_edit_name()
                {
+                       //_debug_array($this->changes);
                        while (list ($from, $to) = each ($this->changes))
                        {
                                if ($badchar = $this->bad_chars ($to, True, 
True))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]