phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: etemplate/inc class.editor.inc.php,1.30,1.31 cla


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: etemplate/inc class.editor.inc.php,1.30,1.31 class.link_widget.inc.php,1.4,1.5 class.uietemplate.inc.php,1.49,1.50
Date: Sun, 20 Oct 2002 11:02:22 -0400

Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv15000

Modified Files:
        class.editor.inc.php class.link_widget.inc.php 
        class.uietemplate.inc.php 
Log Message:
Got fileattachments working as links:
- link-widget and infolog/link-class can attach files now
- changed the value of the file-widget (it's an array now)

Index: class.editor.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.editor.inc.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** class.editor.inc.php        19 Oct 2002 11:03:00 -0000      1.30
--- class.editor.inc.php        20 Oct 2002 15:02:20 -0000      1.31
***************
*** 493,497 ****
                        elseif ($content['import_xml'])
                        {
!                               $msg = $this->import_xml($content['file']);
                        }
                        elseif ($content['db_tools'])
--- 493,497 ----
                        elseif ($content['import_xml'])
                        {
!                               $msg = 
$this->import_xml($content['file']['tmp_name']);
                        }
                        elseif ($content['db_tools'])

Index: class.link_widget.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.link_widget.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.link_widget.inc.php   18 Oct 2002 20:19:57 -0000      1.4
--- class.link_widget.inc.php   20 Oct 2002 15:02:20 -0000      1.5
***************
*** 50,61 ****
                        {
                        case 'link-to':
!                               if ($value['button'] == 'search' && count($ids 
= $this->link->query($value['app'],$value['query'])))
                                {
                                        $extension_data['app'] = $value['app'];
!                
                                        $value = $extension_data;
                                        $value['options-id'] = $ids;
                                        $value['remark'] = '';
!                                       
                                        $tpl = new 
etemplate('etemplate.link_widget.create');
                                }
--- 50,68 ----
                        {
                        case 'link-to':
!                               if ($value['button'] == 'upload' && 
!empty($value['file']) && $value['file']['tmp_name'] != 'none')
!                               {
!                                       $value = $extension_data;
!                                       $value['remark'] = '';
! 
!                                       $tpl = new 
etemplate('etemplate.link_widget.attach');
!                               }
!                               elseif ($value['button'] == 'search' && 
count($ids = $this->link->query($value['app'],$value['query'])))
                                {
                                        $extension_data['app'] = $value['app'];
! 
                                        $value = $extension_data;
                                        $value['options-id'] = $ids;
                                        $value['remark'] = '';
! 
                                        $tpl = new 
etemplate('etemplate.link_widget.create');
                                }
***************
*** 98,103 ****
                                {
                                        $value[$row] = $link;
!                                       $value[$row]['title'] = 
$this->link->title($link['app'],$link['id']);
!                                       $value[$row]['view']  = 
$this->link->view($link['app'],$link['id']);
                                }
                                break;
--- 105,110 ----
                                {
                                        $value[$row] = $link;
!                                       $value[$row]['title'] = 
$this->link->title($link['app'],$link['id'],$link);
!                                       $value[$row]['view']  = 
$this->link->view($link['app'],$link['id'],$link);
                                }
                                break;
***************
*** 114,139 ****
                function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
                {
!                       if ($value['search'])
!                       {
!                               $button = 'search';
!                       }
!                       elseif ($value['create'])
                        {
!                               $button = 'create';
                        }
!                       elseif ($value['new'])
!                       {
!                               $button = 'new';
!                       }
!                       elseif (is_array($value['unlink']))
                        {
                                $button = 'unlink';
                                list($unlink) = @each($value['unlink']);
                        }
-                       //echo "<p>start: link_widget::post_process: 
button='$button', unlink='$unlink', value ="; _debug_array($value);
                        unset($value[$button]);
  
                        $value = array_merge($extension_data,$value);
! 
                        switch ($button)
                        {
--- 121,142 ----
                function 
post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
                {
!                       $buttons = 
array('search','create','new','upload','attach');
!                       while (!$button && list(,$name) = each($buttons))
                        {
!                               $button = $value[$name] ? $name : '';
                        }
!                       if (is_array($value['unlink']))
                        {
                                $button = 'unlink';
                                list($unlink) = @each($value['unlink']);
                        }
                        unset($value[$button]);
  
                        $value = array_merge($extension_data,$value);
!                       
!                       if ($button && $this->debug)
!                       {
!                               echo "<p>start: link_widget::post_process: 
button='$button', unlink='$unlink', value ="; _debug_array($value);
!                       }
                        switch ($button)
                        {
***************
*** 141,146 ****
                                        if ($value['to_app'])                   
                        // make the link
                                        {
!                                               $link_id = 
$this->link->link($value['to_app'],$value['to_id'],$value['app'],$value['id'],$value['remark']);
!                                               //echo 
"<p>link($value[to_app],$value[to_id],$value[app],$value[id],'$value[remark]')</p>\n";
                                                if (isset($value['primary']) && 
!$value['anz_links'] )
                                                {
--- 144,150 ----
                                        if ($value['to_app'])                   
                        // make the link
                                        {
!                                               $link_id = 
$this->link->link($value['to_app'],$value['to_id'],
!                                                       
$value['app'],$value['id'],$value['remark']);
!                                               
                                                if (isset($value['primary']) && 
!$value['anz_links'] )
                                                {
***************
*** 152,155 ****
--- 156,187 ----
                                case 'new':
                                        $extension_data = $value;
+                                       $loop = True;
+                                       break;
+ 
+                               case 'attach':
+                                       if (is_array($value['file']) && 
$value['to_app'])
+                                       {
+                                               $link_id = 
$this->link->link($value['to_app'],$value['to_id'],
+                                                       
'vfs',$value['file'],$value['remark']);
+                                               
unlink($value['file']['tmp_name']);
+                                               unset($value['file']); 
+                                       }
+                                       $extension_data = $value;
+                                       $loop = True;
+                                       break;
+ 
+                               case 'upload':          // need to rename file, 
as php deletes it otherwise
+                                       if (is_array($value['file']) && 
!empty($value['file']['tmp_name']) && 
+                                           $value['file']['tmp_name'] != 
'none')
+                                       {
+                                               
move_uploaded_file($value['file']['tmp_name'],$value['file']['tmp_name'].'+');
+                                               $value['file']['tmp_name'] .= 
'+';
+                                               $extension_data = $value;
+                                       }
+                                       else
+                                       {
+                                               unset($value['file']);
+                                               $button = '';
+                                       }
                                        $loop = True;
                                        break;

Index: class.uietemplate.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.uietemplate.inc.php,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -r1.49 -r1.50
*** class.uietemplate.inc.php   18 Oct 2002 21:33:39 -0000      1.49
--- class.uietemplate.inc.php   20 Oct 2002 15:02:20 -0000      1.50
***************
*** 460,464 ****
                                        $options .= " 
onFocus=\"self.status='".addslashes(lang($help))."'; return true;\"";
                                        $options .= " onBlur=\"self.status=''; 
return true;\"";
!                                       if ($cell['type'] == 'button')  // for 
button additionally when mouse over button
                                        {
                                                $options .= " 
onMouseOver=\"self.status='".addslashes(lang($help))."'; return true;\"";
--- 460,464 ----
                                        $options .= " 
onFocus=\"self.status='".addslashes(lang($help))."'; return true;\"";
                                        $options .= " onBlur=\"self.status=''; 
return true;\"";
!                                       if ($cell['type'] == 'button' || 
$cell['type'] == 'file')       // for button additionally when mouse over button
                                        {
                                                $options .= " 
onMouseOver=\"self.status='".addslashes(lang($help))."'; return true;\"";
***************
*** 702,710 ****
                                case 'file':
                                        $html .= 
$this->html->input_hidden($path = 
str_replace($name,$name.'_path',$form_name),'.');
!                                       $html .= 
$this->html->input($form_name,'','file');
                                        
$GLOBALS['phpgw_info']['etemplate']['form_options'] =
                                                
"enctype=\"multipart/form-data\" 
onSubmit=\"set_element2(this,'$path','$form_name')\"";
                                        
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
-                                       
$GLOBALS['phpgw_info']['etemplate']['to_process'][$path] = 'file-path';
                                        break;
                                case 'vbox':
--- 702,709 ----
                                case 'file':
                                        $html .= 
$this->html->input_hidden($path = 
str_replace($name,$name.'_path',$form_name),'.');
!                                       $html .= 
$this->html->input($form_name,'','file',$options);
                                        
$GLOBALS['phpgw_info']['etemplate']['form_options'] =
                                                
"enctype=\"multipart/form-data\" 
onSubmit=\"set_element2(this,'$path','$form_name')\"";
                                        
$GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = $cell['type'];
                                        break;
                                case 'vbox':
***************
*** 873,876 ****
--- 872,893 ----
                                                
$this->set_array($content,$form_name,$value);
                                                break;
+                                       case 'file':
+                                               $parts = 
explode('[',str_replace(']','',$form_name));
+                                               $name = array_shift($parts);
+                                               $index  = count($parts) ? 
'['.implode('][',$parts).']' : '';
+                                               $value = array();
+                                               $parts = 
array('tmp_name','type','size','name');
+                                               while (list(,$part) = 
each($parts))
+                                               {
+                                                       $value[$part] = 
$this->get_array($GLOBALS['HTTP_POST_FILES'][$name],$part.$index);
+                                               }
+                                               $value['path'] = 
$this->get_array($content_in,substr($form_name,0,-1).'_path]');
+                                               $value['ip'] = 
get_var('REMOTE_ADDR',Array('SERVER'));
+                                               if 
(function_exists('is_uploaded_file') && !is_uploaded_file($value['tmp_name']))
+                                               {
+                                                       $value = array();       
// to be on the save side
+                                               }
+                                               //_debug_array($value);
+                                               // fall-throught
                                        default:
                                                
$this->set_array($content,$form_name,$value);





reply via email to

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