phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: infolog csv_import.php,1.7,1.8


From: Ralf Becker <address@hidden>
Subject: [Phpgroupware-cvs] CVS: infolog csv_import.php,1.7,1.8
Date: Thu, 14 Feb 2002 14:56:09 -0500

Update of /cvsroot/phpgroupware/infolog
In directory subversions:/tmp/cvs-serv31510

Modified Files:
        csv_import.php 
Log Message:
cats may now be separated by ',' or ';'

Index: csv_import.php
===================================================================
RCS file: /cvsroot/phpgroupware/infolog/csv_import.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** csv_import.php      4 Oct 2001 20:13:00 -0000       1.7
--- csv_import.php      14 Feb 2002 19:56:06 -0000      1.8
***************
*** 86,112 ****
  $cat2id = array( );
  
! function cat_id( $cats )
  {
        if (!$cats)
                return '';
!               
!       $cats = explode(',',$cats);
!       
!       while (list($k,$cat) = each($cats)) {
!               if (isset($cat2id[$cat])) {
!                       $ids[$cat] = $cat2id[$cat];                             
                                // cat is in cache
!               } else {
!                       if (!is_object($GLOBALS['phpgw']->categories)) {
                                $GLOBALS['phpgw']->categories = 
createobject('phpgwapi.categories');
!                       }                       
!                       if ($id = $GLOBALS['phpgw']->categories->name2id( $cat 
)) {     // cat exists
                                $cat2id[$cat] = $ids[$cat] = $id;
!                       } else {                                                
                                                                        // 
create new cat
!                               $GLOBALS['phpgw']->categories->add( 
$cat,0,$cat,'','public',0);
!                               $cat2id[$cat] = $ids[$cat] = 
$GLOBALS['phpgw']->categories->name2id( $cat );
                        }
                }
        }
!       return implode( ',',$ids );
  }
  
--- 86,128 ----
  $cat2id = array( );
  
! function cat_id($cats)
  {
        if (!$cats)
+       {
                return '';
!       }
! 
!       $cats = split('[,;]',$cats);
! 
!       while (list($k,$cat) = each($cats))
!       {
!               if (isset($cat2id[$cat]))
!               {
!                       $ids[$cat] = $cat2id[$cat];     // cat is in cache
!               }
!               else
!               {
!                       if (!is_object($GLOBALS['phpgw']->categories))
!                       {
                                $GLOBALS['phpgw']->categories = 
createobject('phpgwapi.categories');
!                       }
!                       if ($id = $GLOBALS['phpgw']->categories->name2id( 
addslashes($cat) ))
!                       {       // cat exists
                                $cat2id[$cat] = $ids[$cat] = $id;
!                       }
!                       else
!                       {       // create new cat
!                               $GLOBALS['phpgw']->categories->add( 
array('name' => $cat,'descr' => $cat ));
!                               $cat2id[$cat] = $ids[$cat] = 
$GLOBALS['phpgw']->categories->name2id( addslashes($cat) );
                        }
                }
        }
!       $id_str = implode( ',',$ids );
! 
!       if (count($ids) > 1)            // multiple cats need to be in ','
!       {
!               $id_str = ",$id_str,";
!       }
!       return  $id_str;
  }
  
***************
*** 297,305 ****
                                                        // echo "'$val'</p>";
  
-                                                       $quote = $val[0] == '@' 
? "'" : '';
- 
                                                        $reg = 
$CPreReg.'([a-zA-Z_0-9]+)'.$CPosReg;
                                                        while 
(ereg($reg,$val,$vars)) { // expand all CSV fields
!                                                               $val = 
str_replace($CPre.$vars[1].$CPos,$quote.$fields[index($vars[1],$csv_fields)].$quote,$val);
                                                        }
                                                        if ($val[0] == '@') {
--- 313,319 ----
                                                        // echo "'$val'</p>";
  
                                                        $reg = 
$CPreReg.'([a-zA-Z_0-9]+)'.$CPosReg;
                                                        while 
(ereg($reg,$val,$vars)) { // expand all CSV fields
!                                                               $val = 
str_replace($CPre.$vars[1].$CPos,$val[0] == '@' ? 
"'".addslashes($fields[index($vars[1],$csv_fields)])."'" : 
$fields[index($vars[1],$csv_fields)],$val);
                                                        }
                                                        if ($val[0] == '@') {




reply via email to

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