phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: filemanager/inc class.uiaction_base.inc.php,NON


From: Jonathon Sim <address@hidden>
Subject: [Phpgroupware-cvs] CVS: filemanager/inc class.uiaction_base.inc.php,NONE,1.1 class.uiaction_edit.inc.php,NONE,1.1class.uiactions.inc.php,NONE,1.1 class.bofilemanager.inc.php,1.1,1.2class.uifilemanager.inc.php,1.1,1.2
Date: Mon, 03 Mar 2003 19:04:08 -0500

Update of /cvsroot/phpgroupware/filemanager/inc
In directory subversions:/tmp/cvs-serv19928

Modified Files:
        class.bofilemanager.inc.php class.uifilemanager.inc.php 
Added Files:
        class.uiaction_base.inc.php class.uiaction_edit.inc.php 
        class.uiactions.inc.php 
Log Message:
A fairly large set of changes (committed all at once to reduce "broken" time):
(1) Port to XSLT templates
(2) Completes (apart from all the bugs :) the functionality of the three-teir 
phpgroupware style object system (no longer is filemanager a single 3000 line 
file!)
(3) The beginings of a pluggable "uiaction" framework (ideally in the future 
this will be used for optional "rich text editors", or view filters etc)

--- NEW FILE ---
<?php

        class uiaction_base
        {
                function load_header()
                {
                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
                        unset($GLOBALS['phpgw_info']['flags']['noappheader']);
                        unset($GLOBALS['phpgw_info']['flags']['noappfooter']);
                        //$GLOBALS['phpgw']->common->phpgw_header();
                }
                
                function action_link($action)
                {
                        return $GLOBALS['phpgw']->link('/index.php',
                                                        Array(
                                                                'menuaction'    
=> $this->bo->appname.'.ui'.$this->bo->appname.'.action',
                                                                'path'          
=> urlencode($this->bo->path),
                                                                'uiaction' => 
urlencode($action)
                                                        )
                                                );
                                        
                }
        }


?>
--- NEW FILE ---
<?php
require_once('class.uiaction_base.inc.php');
define('UIEDIT_DEBUG',0);

        class uiaction_edit extends uiaction_base
        {
                //Lists the suported actions (human readable) indexed by their 
function name
                var $actions=array(
                        'edit' => 'Edit',
                        'edit_save' => false,
                        'edit_preview' => false,
                        'edit_cancel' => false
                );
                
                function uiaction_edit()
                {                       
                                        $this->bo = 
CreateObject('filemanager.bofilemanager');

                                        
$GLOBALS['phpgw']->xslttpl->add_file(array('widgets',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));

                                        $var = Array(
                                        'img_up' => array('widget' => 
array('type' => 'img',
                                                                                
        'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'up'),
                                                                                
        'alt' => lang('Up'),
                                                                                
        'link' => $GLOBALS['phpgw']->link('/index.php',Array(
                                                                                
                        'menuaction'    => 
$this->bo->appname.'.ui'.$this->bo->appname.'.index',
                                                                                
                        'path'          => urlencode($this->bo->lesspath)
                                                                                
                ))
                                                                                
        )),

                                        'img_home'      => array('widget' => 
array('type' => 'img',
                                                                                
        'src' => 
$GLOBALS['phpgw']->common->image($this->bo->appname,'folder_home'),
                                                                                
        'alt' => lang('Folder'),
                                                                                
        'link' => $GLOBALS['phpgw']->link('/index.php',Array(
                                                                                
                        'menuaction'    => 
$this->bo->appname.'.ui'.$this->bo->appname.'.index',
                                                                                
                        'path' => urlencode($this->bo->homedir)
                                                                                
                ))                                                              
                
                                                                                
        )),
                                                                                
        
                                        'dir' => $this->bo->path,
                                        'img_dir' => array('widget' => 
array('type' => 'img',
                                                                                
        'src' => 
$GLOBALS['phpgw']->common->image($this->bo->appname,'folder_large'),
                                                                                
        'alt' => lang('Folder')                                                 
                
                                                                                
        )),
                                );      
                                $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('filemanager_nav' => $var));

                        $this->template_dir = 
$GLOBALS['phpgw']->common->get_tpl_dir($GLOBALS['phpgw_info']['flags']['currentapp']);
            
                }
                function edit($parent, $param=false)
                {
                
                        
$GLOBALS['phpgw']->xslttpl->add_file(array('edit',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi','default')
 . SEP . 'app_header'));
                        
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('form_action' 
=>$GLOBALS['phpgw']->link('/index.php',
                                                                                
Array(
                                                                                
        'menuaction'    => 
$this->bo->appname.'.ui'.$this->bo->appname.'.action',
                                                                                
        'path'  => $this->bo->path
                                                                                
)
                                                                        )));
                        $this->load_header();
                        $this->bo = &$parent->bo;
                        if (UIEDIT_DEBUG) echo ' action::edit ';
//                      $this->load_header();
                        $edit_file = get_var('file', array('GET', 'POST'));
                        if (!strlen($edit_file))
                        {               
                                $edit_file = $this->bo->fileman[0];
                        }

                        
/*                      $this->bo->vfs->cd(array(
                                'string' => $this->bo->path,
                                'relatives' => array(RELATIVE_NONE)
                                ));
                        
        //              echo "path ".$this->bo->vfs->pwd()." Editing: 
".$edit_file;
*/
                        $vars = array();
                        $vars['action1'][] = array('widget' => array('type' => 
'img',
                                                                                
        'src' => $GLOBALS['phpgw']->common->image($this->bo->appname,'preview'),
                                                                                
        ));
                        $vars['action1'][] = array('widget' => array('type' => 
'submit',
                                                 'name' => 
"uiaction_edit_preview",
                                                 'value'=>lang('Preview')
                                                 ));
                        //$this->action_link('edit_preview');
                        $vars['action2'][] = array('widget' => array('type' => 
'img',
                                                                                
        'src' => 
$GLOBALS['phpgw']->common->image($this->bo->appname,'filesave'),
                                                                                
        ));
                        $vars['action2'][]  = array('widget' => array('type' => 
'submit',
                                        'name' => 'uiaction_edit_save',
                                        'value'=>lang('Save')
                                        ));
                        $vars['action3'][] = array('widget' => array('type' => 
'img',
                                                                                
        'src' => 
$GLOBALS['phpgw']->common->image($this->bo->appname,'button_cancel'),
                                                                                
        ));

                        $vars['action3'][] = array('widget' => array('type' => 
'submit',
                                        'name' => 'uiaction_edit_cancel',
                                        'value'=>lang('Close')
                                        ));
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('nav_data' => $vars));
                        $vars = array('filename' => $edit_file);
                        
                        if (get_var('edited', array('GET', 'POST')))
                        {
                                $content = get_var('edit_file_content', 
array('GET', 'POST'));
                        }
                        else
                        {
                                $content = $this->bo->vfs->read (array 
('string' => $edit_file));
                        }
                        
                        if ($param == 'edit_preview')
                        {       
                                $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('preview'=>$content));
                        //      $vars['preview'] = nl2br($content);
                        }
                        
                        elseif ($param =='edit_save')
                        {                        
                                if ($this->bo->vfs->write (array (
                                                'string'        => 
$parent->bo->path.'/'.$edit_file ,
                                                'relatives' => 
array(RELATIVE_NONE),
                                                'content'       => $content
                                        ))
                                )
                                {
                                        $vars['output'] = lang('Saved x', 
$parent->bo->path.'/'.$edit_file);
                                }
                                else
                                {
                                        $vars['output'] = lang('Could not save 
x', $parent->bo->path.'/'.$edit_file);
                                }
                        }

                                if ($edit_file && $this->bo->vfs->file_exists 
(array (
                                                                'string'        
=> $edit_file,
                                                                'relatives'     
=> array (RELATIVE_ALL)
                                        ))
                                )
                                {
                                        $vars['form_data'][] = array('widget' 
=> array('type' => "hidden" ,
                                                                                
        'name'=> "edited",
                                                                                
        'value'=>"1"
                                                                                
        ));
                                                                                
        
                                        $vars['form_data'][] = array('widget' 
=> array('type' => "hidden",
                                                'name' => 'edit_file',
                                                'value' => $edit_file
                                                ));

                                        $vars['form_data'][] = array('widget' 
=> array('type'=>"hidden",
                                                                'name'=> 
"fileman[0]",
                                                                'value' => 
$this->bo->html_encode($edit_file,1)
                                                                ));
                                        $vars['file_content'] =  $content;
                                }
                        //}
                        $GLOBALS['phpgw']->xslttpl->set_var('phpgw', 
array('filemanager_edit' => $vars));
                }
                
                function edit_cancel($parent)
                {
                         $url = $GLOBALS['phpgw']->link('/index.php',
                                                        Array(
                                                                'menuaction'    
=> $parent->bo->appname.'.ui'.$parent->bo->appname.'.index',
                                                                'path'          
=> urlencode($parent->bo->path),
                                                        )
                                                );
                        //echo "cancel : $url";
                        header('Location: '. $url);
                        exit();
                }
                function edit_save($parent)
                {
                        $this->edit($parent, 'edit_save');
                }       
                
                function edit_preview($parent)
                {
                        $this->edit($parent, 'edit_preview');
                }       
        }
?>
--- NEW FILE ---
<?php

        class uiactions 
        {       
                var $action_classes = array(
                        0=>'filemanager.uiaction_edit'
                );
                var $actions = array();
                
                function uiactions()
                {
                        //Construct the action objects
                        foreach($this->action_classes as $action_class)
                        {
                                $o = CreateObject($action_class);
                                foreach ($o->actions as $name => $displayname)
                                {
                                        $this->actions[$name] = &$o;
                                }
                        }
                }
                function run_action($parent, $action)
                {

                        
        //              print_r($this->actions);
                        $this->actions[$action]->$action($parent);
                        exit();
                }
                function dispatch($parent)
                {
                        //First, see if the action is specified in the url with 
a 'uiaction=' param
                        if ($action = get_var('uiaction', array('GET', 'POST')))
                        {
                                $this->run_action($parent, $action);    
                        }
                        @reset($_POST);
                        while(list($name,$value) = each($_POST))
                        {
                                if (substr($name, 0 , 8) == 'uiaction')
                                {
                                        $action = substr($name, 9);
                                        $this->run_action($parent, $action);

                                }
                        }
                        
                }
        }
?>

Index: class.bofilemanager.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/inc/class.bofilemanager.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.bofilemanager.inc.php 21 Sep 2002 05:26:43 -0000      1.1
--- class.bofilemanager.inc.php 4 Mar 2003 00:04:05 -0000       1.2
***************
*** 38,41 ****
--- 38,44 ----
  
                var $fileman = Array();
+               var $changes = Array();
+               var $upload_comment = Array();
+               var $upload_file = Array();
                var $op;
                var $file;
***************
*** 75,78 ****
--- 78,84 ----
                                'sortby',
                                'fileman',
+                               'upload_file',
+                               'upload_comment',
+                               'upload_name',
                                'messages',
                                'help_name',
***************
*** 81,86 ****
--- 87,99 ----
                                'show_upload_boxes',
                                'submit',
+                               'cancel',
                                'rename',
+                               'upload',
+                               'edit_comments',
+                               'apply_edit_comment',
+                               'apply_edit_name',
+                               'changes',
                                'delete',
+                               'edit',
                                'go',
                                'copy',
***************
*** 153,163 ****
                        {
                                $this->path = $this->vfs->pwd();
!                               if (!$this->path || $this->vfs->pwd(False) == 
'')
                                {
                                        $this->path = $this->homedir;
                                }
                        }
!                       $this->vfs->cd(False,False,Array(RELATIVE_NONE));
!                       $this->vfs->cd($this->path,False,Array(RELATIVE_NONE));
  
                        $this->pwd = $this->vfs->pwd();
--- 166,185 ----
                        {
                                $this->path = $this->vfs->pwd();
!                               if (!$this->path || $this->vfs->pwd(array(
!                                       'full' => False
!                                       )) == '')
                                {
                                        $this->path = $this->homedir;
                                }
                        }
!                       $this->vfs->cd(array(
!                               'relative' => False,
!                               'relatives'=>Array(RELATIVE_NONE)
!                               ));
!                       $this->vfs->cd(array(
!                               'string' => $this->path,
!                               'relative' => False,
!                               'relatives' => Array(RELATIVE_NONE)
!                               ));
  
                        $this->pwd = $this->vfs->pwd();
***************
*** 201,206 ****
                                        . 'homedir: '.$this->homedir.'<p>'
                                        . '<b>phpGW debug:</b><br>'
!                                       . 'real getabsolutepath: 
'.$this->vfs->getabsolutepath(False, False, False).'<br>'
!                                       . 'fake getabsolutepath: 
'.$this->vfs->getabsolutepath(False).'<br>'
                                        . 'appsession: 
'.$GLOBALS['phpgw']->session->appsession('vfs','').'<br>'
                                        . 'pwd: '.$this->vfs->pwd().'<br>';
--- 223,231 ----
                                        . 'homedir: '.$this->homedir.'<p>'
                                        . '<b>phpGW debug:</b><br>'
!                                       . 'real cabsolutepath: 
'.$this->vfs->getabsolutepath(array(
!                                                                       
'string' => False, 
!                                                                       'fake' 
=> False
!                                                                       
)).'<br>'
!                                       . 'fake getabsolutepath: 
'.$this->vfs->getabsolutepath().'<br>'
                                        . 'appsession: 
'.$GLOBALS['phpgw']->session->appsession('vfs','').'<br>'
                                        . 'pwd: '.$this->vfs->pwd().'<br>';
***************
*** 244,247 ****
--- 269,286 ----
                {
                        $var = get_var($name,Array('GET','POST'));
+                       
+                       //to get the file uploads, without requiring 
register_globals in php.ini
+                       if(phpversion() >= '4.2.0')
+                       {
+                               $meth = '_FILES';
+                       }
+                       else
+                       {
+                               $meth = 'HTTP_POST_FILES';
+                       }
+                       if(@isset($GLOBALS[$meth][$name]))
+                       {
+                               $var = $GLOBALS[$meth][$name];
+                       }
                        if($this->debug)
                        {
***************
*** 283,292 ****
                        if ($this->path == $this->fakebase)
                        {
!                               if 
(!$this->vfs->file_exists($this->homedir,Array(RELATIVE_NONE)))
!                               {
!                                       
$this->vfs->mkdir($this->homedir,Array(RELATIVE_NONE));
!                               }
! 
!                               $ls_array = 
$this->vfs->ls($this->homedir,Array(RELATIVE_NONE),False,False,True);
                                $this->files_array[] = $ls_array[0];
  
--- 322,342 ----
                        if ($this->path == $this->fakebase)
                        {
!                               if (!$this->vfs->file_exists(array(
!                                       'string' => $this->homedir,
!                                       'relatives' =>Array(RELATIVE_NONE)
!                                       )))
!                               {
!                                       $this->vfs->mkdir(array(
!                                               'string' => $this->homedir,
!                                               'relatives' => 
Array(RELATIVE_NONE)
!                                               ));
!                               }
! 
!                               $ls_array = $this->vfs->ls(array(
!                                       'string' => $this->homedir,
!                                       'relatives' =>Array(RELATIVE_NONE),
!                                       'checksubdirs' => False,
!                                       'nofiles' => True
!                                       ));
                                $this->files_array[] = $ls_array[0];
  
***************
*** 303,313 ****
                                        }
  
!                                       if 
(!$this->vfs->file_exists($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE)))
!                                       {
!                                               
$this->vfs->mkdir($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE));
!                                               
$this->vfs->set_attributes($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE),Array('owner_id'
 => $group_array['account_id'], 'createdby_id' => $group_array['account_id']));
!                                       }
! 
!                                       $ls_array = 
$this->vfs->ls($this->fakebase.'/'.$group_array['account_name'],Array(RELATIVE_NONE),False,False,True);
  
                                        $this->files_array[] = $ls_array[0];
--- 353,378 ----
                                        }
  
!                                       if (!$this->vfs->file_exists(array(
!                                               'string' => 
$this->fakebase.'/'.$group_array['account_name'],
!                                               'relatives' => 
Array(RELATIVE_NONE)
!                                               )))
!                                       {
!                                               $this->vfs->mkdir(array(
!                                                       'string' => 
$this->fakebase.'/'.$group_array['account_name'],
!                                                       'relatives' => 
Array(RELATIVE_NONE)
!                                                       ));
!                                               
$this->vfs->set_attributes(array(
!                                                       'string' => 
$this->fakebase.'/'.$group_array['account_name'],
!                                                       'relatives' => 
Array(RELATIVE_NONE),
!                                                       'attributes'=> 
Array('owner_id' => $group_array['account_id'], 'createdby_id' => 
$group_array['account_id'])
!                                                       ));
!                                       }
! 
!                                       $ls_array = $this->vfs->ls(array(
!                                               'string' => 
$this->fakebase.'/'.$group_array['account_name'],
!                                               'relatives' => 
Array(RELATIVE_NONE),
!                                               'checksubdirs' => False,
!                                               'nofiles' => True
!                                               ));
  
                                        $this->files_array[] = $ls_array[0];
***************
*** 316,320 ****
                        else
                        {
!                               $ls_array = 
$this->vfs->ls($this->path,Array(RELATIVE_NONE),False,False,False,$this->sortby);
  
                                if ($this->debug)
--- 381,390 ----
                        else
                        {
!                               $ls_array = $this->vfs->ls(array(
!                                       'string' => $this->path,
!                                       'relatives' => Array(RELATIVE_NONE),
!                                       'checksubdirs' => False,
!                                       'orderby' =>$this->sortby
!                                       ));
  
                                if ($this->debug)
***************
*** 336,340 ****
                                $this->files_array = Array();
                        }
- 
                        return $this->files_array;
                }
--- 406,409 ----
***************
*** 361,364 ****
--- 430,514 ----
                        $this->path = $this->todir;
                }
+               function f_apply_edit_comment()
+               {
+                       $result='';
+                       for ($i=0; $i<count($this->fileman) ; $i++)
+                       {
+                               $file = $this->fileman[$i];
+                               
+                               if (!$this->vfs->set_attributes (array (
+                                       'string'        => $file,
+                                       'relatives'     => array (RELATIVE_ALL),
+                                       'attributes'    => array (
+                                                       'comment' => 
stripslashes ($this->changes[$file])
+                                               )
+                                       )
+                               ))
+                               {
+                                       $result .= lang(' Error: failed to 
change comment for :').$file."\n";
+                               }
+                       }
+ 
+                       return $result;
+               }
+               
+               function f_apply_edit_name()
+               {
+                       $result='';
+                       while (list ($from, $to) = each ($this->changes))
+                       {
+                               if ($badchar = $this->bad_chars ($to, True, 
True))
+                               {
+                                $result .= 'File names cannot contain 
"'.$badchar.'"';
+                                       continue;
+                               }
+               
+                               if (ereg ("/", $to) || ereg ("\\\\", $to))
+                               {
+                                       //echo 
$GLOBALS['phpgw']->common->error_list (array ("File names cannot contain \\ or 
/"));
+                               $result .= "File names cannot contain \\ or /";
+                               }
+                               elseif (!$this->vfs->mv (array (
+                                                       'from'  => $from,
+                                                       'to'    => $to
+                                       ))
+                               )
+                               {
+                                       //echo 
$GLOBALS['phpgw']->common->error_list (array ('Could not rename 
'.$disppath.'/'.$from.' to '.$disppath.'/'.$to));
+                               $result .= 'Could not rename 
'.$this->path.'/'.$from.' to '.$this->path.'/'.$to;
+                               }
+                               else 
+                               {
+                                       $result .= 'Renamed 
'.$this->path.'/'.$from.' to '.$this->path.'/'.$to;
+                               }
+                       }
+                  /*html_break (2);
+                  html_link_back ();*/
+               
+               
+                       /*echo "f_apply_edit_name()";
+                       print_r($this->fileman);
+                       echo '<br />';
+                       print_r($this->changes);
+                       die();
+                       
+                       $result='';
+                       for ($i=0; $i<count($this->fileman) ; $i++)
+                       {
+                               $file = $this->fileman[$i];
+                               
+                               if (!$this->vfs->mv (array (
+                                       'from'  => $file,
+                                       'relatives'     => array (RELATIVE_ALL),
+                                       'to'    => $this->changes[$file]
+                                       )
+                               ))
+                               {
+                                       $result .= lang(' Error: failed to 
rename :').$file."\n";
+                               }
+                       }
+ */
+                       return $result;
+               }
  
                function f_delete()
***************
*** 369,373 ****
                                if($this->fileman[$i])
                                {
!                                       $ls_array = 
$this->vfs->ls($this->path.SEP.$this->fileman[$i],Array(RELATIVE_NONE),False,False,True);
                                        $fileinfo = $ls_array[0];
                                        if($fileinfo)
--- 519,528 ----
                                if($this->fileman[$i])
                                {
!                                       $ls_array = $this->vfs->ls(array(
!                                               'string' => 
$this->path.SEP.$this->fileman[$i],
!                                               'relatives' => 
Array(RELATIVE_NONE),
!                                               'checksubdirs' =>False,
!                                               'nofiles' => True
!                                               ));
                                        $fileinfo = $ls_array[0];
                                        if($fileinfo)
***************
*** 381,385 ****
                                                        $mime_type = 'File';
                                                }
!                                               
if($this->vfs->delete($this->path.SEP.$this->fileman[$i],Array(RELATIVE_USER_NONE)))
                                                {
                                                        $errors[] = '<font 
color="#0000FF">'.$mime_type.' Deleted: 
'.$this->path.SEP.$this->fileman[$i].'</font>';
--- 536,543 ----
                                                        $mime_type = 'File';
                                                }
!                                               if($this->vfs->delete(array(
!                                                       'string' => 
$this->path.SEP.$this->fileman[$i],
!                                                       'relatives' => 
Array(RELATIVE_USER_NONE)
!                                                       )))
                                                {
                                                        $errors[] = '<font 
color="#0000FF">'.$mime_type.' Deleted: 
'.$this->path.SEP.$this->fileman[$i].'</font>';
***************
*** 406,410 ****
                                if($this->fileman[$i])
                                {
!                                       
if($this->vfs->cp($this->path.SEP.$this->fileman[$i],$this->todir.SEP.$this->fileman[$i],Array(RELATIVE_NONE,RELATIVE_NONE)))
                                        {
                                                $errors[] = '<font 
color="#0000FF">File copied: '.$this->path.SEP.$this->fileman[$i].' to 
'.$this->todir.SEP.$this->fileman[$i].'</font>';
--- 564,572 ----
                                if($this->fileman[$i])
                                {
!                                       if($this->vfs->cp(array(
!                                               'from' => 
$this->path.SEP.$this->fileman[$i],
!                                               'to' => 
$this->todir.SEP.$this->fileman[$i],
!                                               'relatives' => 
Array(RELATIVE_NONE,RELATIVE_NONE)
!                                               )))
                                        {
                                                $errors[] = '<font 
color="#0000FF">File copied: '.$this->path.SEP.$this->fileman[$i].' to 
'.$this->todir.SEP.$this->fileman[$i].'</font>';
***************
*** 426,430 ****
                                if($this->fileman[$i])
                                {
!                                       
if($this->vfs->mv($this->path.SEP.$this->fileman[$i],$this->todir.SEP.$this->fileman[$i],Array(RELATIVE_NONE,RELATIVE_NONE)))
                                        {
                                                $errors[] = '<font 
color="#0000FF">File moved: '.$this->path.SEP.$this->fileman[$i].' to 
'.$this->todir.SEP.$this->fileman[$i].'</font>';
--- 588,596 ----
                                if($this->fileman[$i])
                                {
!                                       if($this->vfs->mv(array(
!                                               'from' => 
$this->path.SEP.$this->fileman[$i],
!                                               'to' => 
$this->todir.SEP.$this->fileman[$i],
!                                               'relatives' => 
Array(RELATIVE_NONE,RELATIVE_NONE)
!                                               )))
                                        {
                                                $errors[] = '<font 
color="#0000FF">File moved: '.$this->path.SEP.$this->fileman[$i].' to 
'.$this->todir.SEP.$this->fileman[$i].'</font>';
***************
*** 444,448 ****
                        for($i=0;$i!=$numoffiles;$i++)
                        {
!                               if($this->fileman[$i] && 
$this->vfs->file_exists($this->bo->path.SEP.$this->bo->fileman[$i],Array(RELATIVE_NONE)))
                                {
                                        
execmethod($this->appname.'.ui'.$this->appname.'.view_file',
--- 610,617 ----
                        for($i=0;$i!=$numoffiles;$i++)
                        {
!                               if($this->fileman[$i] && 
$this->vfs->file_exists(array(
!                                       'string' => 
$this->bo->path.SEP.$this->bo->fileman[$i],
!                                       'relatives' => Array(RELATIVE_NONE)
!                                       )))
                                {
                                        
execmethod($this->appname.'.ui'.$this->appname.'.view_file',
***************
*** 478,482 ****
                                }
  
!                               $ls_array = 
$this->vfs->ls($this->path.SEP.$this->createdir,Array(RELATIVE_NONE),False,False,True);
                                $fileinfo = $ls_array[0];
  
--- 647,656 ----
                                }
  
!                               $ls_array = $this->vfs->ls(array(
!                                       'string' => 
$this->path.SEP.$this->createdir,
!                                       'relatives' => Array(RELATIVE_NONE),
!                                       'checksubdirs' => False,
!                                       'nofiles' => True
!                                       ));
                                $fileinfo = $ls_array[0];
  
***************
*** 494,498 ****
                                else
                                {
!                                       if 
($this->vfs->mkdir($this->path.SEP.$this->createdir,Array(RELATIVE_NONE)))
                                        {
                                                $errors[] = '<font 
color="#0000FF">Created directory '.$this->path.SEP.$this->createdir.'</font>';
--- 668,675 ----
                                else
                                {
!                                       if ($this->vfs->mkdir(array(
!                                               'string' => 
$this->path.SEP.$this->createdir,
!                                               'relatives' => 
Array(RELATIVE_NONE)
!                                               )))
                                        {
                                                $errors[] = '<font 
color="#0000FF">Created directory '.$this->path.SEP.$this->createdir.'</font>';
***************
*** 517,526 ****
                                        return $errors;
                                }
!                               
if($this->vfs->file_exists($this->path.SEP.$this->createfile,Array(RELATIVE_NONE)))
                                {
                                        $errors[] = '<font color="#FF0000">File 
'.$this->path.SEP.$this->createfile.' already exists.  Please edit it or delete 
it first.</font>';
                                        return $errors;
                                }
!                               
if(!$this->vfs->touch($this->path.SEP.$this->createfile,Array(RELATIVE_NONE)))
                                {
                                        $errors[] = '<font color="#FF0000">File 
'.$this->path.SEP.$this->createfile.' could not be created.</font>';
--- 694,709 ----
                                        return $errors;
                                }
!                               if($this->vfs->file_exists(array(
!                                       'string' => 
$this->path.SEP.$this->createfile,
!                                       'relatives' => Array(RELATIVE_NONE)
!                                       )))
                                {
                                        $errors[] = '<font color="#FF0000">File 
'.$this->path.SEP.$this->createfile.' already exists.  Please edit it or delete 
it first.</font>';
                                        return $errors;
                                }
!                               if(!$this->vfs->touch(array(
!                                       'string' => 
$this->path.SEP.$this->createfile,
!                                       'relatives' => Array(RELATIVE_NONE)
!                                       )))
                                {
                                        $errors[] = '<font color="#FF0000">File 
'.$this->path.SEP.$this->createfile.' could not be created.</font>';
***************
*** 533,537 ****
--- 716,857 ----
                        return $errors;
                }
+               
+               function f_upload()
+               {
+               /*      echo 'sub:'.$this->show_upload_boxes .' uf: ';
+                       
+                       print_r($this->upload_file);
+                       echo  ' cf: '; print_r($this->upload_comment);
+                       echo ' files: '; print_r($HTTP_POST_FILES);
+                       die();*/
+                       //echo (($show_upload_boxes > 1) ? $head_pre.$msg_top : 
$head_top);
+                       for ($i = 0; $i != $this->show_upload_boxes; $i++)
+                       {
+                               if ($badchar = $this->bad_chars 
($this->upload_file['name'][$i], True, True))
+                               {
+                                       array_push($err_msgs,$this->html_encode 
('Filenames cannot contain "'.$badchar.'"', 1));
+                        //echo $GLOBALS['phpgw']->common->error_list (array 
(html_encode ('Filenames cannot contain "'.$badchar.'"', 1)));
+                                       continue;
+                               }
+               
+                               ###
+                               # Check to see if the file exists in the 
database, and get its info at the same time
+                               ###
+               
+                               $ls_array = $this->vfs->ls (array (
+                                               'string'        => $this->path 
. '/' . $this->upload_file['name'][$i],
+                                               'relatives'     => array 
(RELATIVE_NONE),
+                                               'checksubdirs'  => False,
+                                               'nofiles'       => True
+                                       )
+                               );
+               
+                               $fileinfo = $ls_array[0];
+               
+                               if ($fileinfo['name'])
+                               {
+                                       if ($fileinfo['mime_type'] == 
'Directory')
+                                       {
+                                               array_push($err_msgs,'Cannot 
replace '.$fileinfo['name'].' because it is a directory');
+                           //echo $GLOBALS['phpgw']->common->error_list (array 
('Cannot replace '.$fileinfo['name'].' because it is a directory'));
+                                               continue;
+                                       }
+                               }
+               
+                               if ($this->upload_file['size'][$i] > 0)
+                               {
+                                       if ($fileinfo['name'] && 
$fileinfo['deleteable'] != 'N')
+                                       {
+                                               if (
+                                               $this->vfs->cp (array (
+                                    'from'     => 
$this->upload_file['tmp_name'][$i],
+                                    'to'       => 
$this->upload_file['name'][$i],
+                                    'relatives'        => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
+                                 )
+                              )
+                           ) {
+                              $this->vfs->set_attributes (array (
+                                    'string'   => 
$this->upload_file['name'][$i],
+                                    'relatives'        => array (RELATIVE_ALL),
+                                    'attributes'       => array (
+                                             'owner_id' => 
$GLOBALS['userinfo']['username'],
+                                             'modifiedby_id' => 
$GLOBALS['userinfo']['username'],
+                                             'modified' => $now,
+                                             'size' => 
$this->upload_file['size'][$i],
+                                             'mime_type' => 
$this->upload_file['type'][$i],
+                                             'deleteable' => 'Y',
+                                             'comment' => stripslashes 
($upload_comment[$i])
+                                          )
+                                 )
+                              );
+                              
+                           } else {
+                              array_push($err_msgs,'Failed to upload file: 
'.$this->upload_file['name'][$i]);
+                              continue;
+                           }
+                          
+                                               $result .=' Replaced 
'.$disppath.'/'.$this->upload_file['name'][$i].' 
'.$this->upload_file['size'][$i];
+                                       }
+                                       else
+                                       {
+                                               if (
+                              $this->vfs->cp (array (
+                                    'from'     => 
$this->upload_file['tmp_name'][$i],
+                                    'to'       => 
$this->upload_file['name'][$i],
+                                    'relatives'        => array 
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
+                                 )
+                              )
+                           ) {
+               
+                              $this->vfs->set_attributes (array (
+                                    'string'   => 
$this->upload_file['name'][$i],
+                                    'relatives'        => array (RELATIVE_ALL),
+                                    'attributes'       => array (
+                                             'mime_type' => 
$this->upload_file_['type'][$i],
+                                             'comment' => stripslashes 
($this->upload_comment[$i])
+                                          )
+                                 )
+                              );
+                           } else {
+                              array_push($err_msgs,'Failed to upload file: 
'.$this->upload_file['name'][$i]);
+                              continue;
+                           }
+                                               $result .= 'Created 
'.$this->path.'/'.$this->upload_file['name'][$i] .' '. 
$this->upload_file['size'][$i];
+                                       }
+                               }
+                               elseif ($this->upload_file['name'][$i])
+                               {
+                                       $this->vfs->touch (array (
+                                                       'string'        => 
$this->upload_file['name'][$i],
+                                                       'relatives'     => 
array (RELATIVE_ALL)
+                                               )
+                                       );
+               
+                                       $this->vfs->set_attributes (array (
+                                                       'string'        => 
$this->upload_file['name'][$i],
+                                                       'relatives'     => 
array (RELATIVE_ALL),
+                                                       'attributes'    => 
array (
+                                                                               
'mime_type' => $this->upload_file['type'][$i],
+                                                                               
'comment' => $this->upload_comment[$i]
+                                                                       )
+                                               )
+                                       );
+               
+                                       $result .= 'Created 
'.$this->path.'/'.$this->upload_file['name'][$i].' '. $this->file_size[$i];
+                               }
+                       }
+               
+                  //output any error messages
+                //  $backlink = ($show_upload_boxes > 1) ? '<a 
href="javascript:window.close();">Back to file manager</a>' : html_link_back(1);
+                  $refreshjs = '
+                  <script language="javascript">
+                     window.opener.processIt(\'update\');
+                  </script>';
+                  
+ //               if (sizeof($err_msgs)) echo 
$GLOBALS['phpgw']->common->error_list ($err_msgs,'Error',$backlink);
  
+                       return $result.$err_msgs;
+               
+               }
                function load_help_info()
                {

Index: class.uifilemanager.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/filemanager/inc/class.uifilemanager.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.uifilemanager.inc.php 21 Sep 2002 05:26:43 -0000      1.1
--- class.uifilemanager.inc.php 4 Mar 2003 00:04:06 -0000       1.2
***************
*** 3,23 ****
    * phpGroupWare                                                             *
    * This file written by Mark A Peters (Skeeter) <address@hidden>  *
!   * This class user interface for the filemanager app                        *
!   * Copyright (C) 2002 Mark A Peters                                         *
!   * -------------------------------------------------------------------------*
!   * This library is free software; you can redistribute it and/or modify it  *
!   * under the terms of the GNU Lesser General Public License as published by *
!   * the Free Software Foundation; either version 2.1 of the License,         *
!   * or any later version.                                                    *
!   * This library is distributed in the hope that it will be useful, but      *
[...1561 lines suppressed...]
!                                       $this->bo->vfs->get_size(array(
!                                               'string' => $file,
!                                               'relatives' => 
Array(RELATIVE_NONE),
!                                               'checksubdirs' => True
!                                               )));
  //                            $browser->content_header($this->bo->file);
!                               echo $this->bo->vfs->read(array(
!                                       'string' => $file,
!                                       'relatives' => Array(RELATIVE_NONE)
!                                       ));
                                flush();
                        }
                        if(!is_array($file_array))
                        {
!                               exit();
                        }
                }
  
! 
        }





reply via email to

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