From 654294ae978904f1ae6b95780b38dd8466e31471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20Wei=C3=9F?= Date: Thu, 30 Aug 2007 15:43:27 +0000 Subject: [PATCH] php5.2 fixes --- importexport/inc/class.export_csv.inc.php | 2 +- importexport/inc/class.import_csv.inc.php | 2 +- .../class.import_export_helper_functions.inc.php | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/importexport/inc/class.export_csv.inc.php b/importexport/inc/class.export_csv.inc.php index a2f418deaf..807fd5bdf1 100644 --- a/importexport/inc/class.export_csv.inc.php +++ b/importexport/inc/class.export_csv.inc.php @@ -74,7 +74,7 @@ class export_csv implements iface_export_record * @param array _options options for specific backends * @return bool */ - public function __construct( $_stream, $_options ) { + public function __construct( $_stream, array $_options ) { if (!is_object($GLOBALS['egw']->translation)) { $GLOBALS['egw']->translation = new translation(); } diff --git a/importexport/inc/class.import_csv.inc.php b/importexport/inc/class.import_csv.inc.php index bc6d36158a..d8a1b58820 100755 --- a/importexport/inc/class.import_csv.inc.php +++ b/importexport/inc/class.import_csv.inc.php @@ -73,7 +73,7 @@ class import_csv implements iface_import_record { //, Iterator { * @param string $_resource resource containing data. May be each valid php-stream * @param array $_options options for the resource array with keys: charset and fieldsep */ - public function __construct( $_resource, $_options ) { + public function __construct( $_resource, array $_options ) { $this->resource = $_resource; $this->csv_fieldsep = $_options['fieldsep']; $this->csv_charset = $_options['charset']; diff --git a/importexport/inc/class.import_export_helper_functions.inc.php b/importexport/inc/class.import_export_helper_functions.inc.php index 0e94467072..b2cfe66684 100755 --- a/importexport/inc/class.import_export_helper_functions.inc.php +++ b/importexport/inc/class.import_export_helper_functions.inc.php @@ -128,7 +128,7 @@ class import_export_helper_functions { $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); foreach ( $cat_names as $cat_name ) { - + if ( $cat_name == '' ) continue; if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 ) { $cat_id = $cats->add( array( 'name' => $cat_name, @@ -179,10 +179,11 @@ class import_export_helper_functions { $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion $ASep = '|>'; // Assignment-Separator, separats pattern and replacesment - $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value + $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value $TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed - $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim + $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF + $INE = '|INE{'; // Only insert if stuff in ^^ is not empty foreach ( $_conversion as $idx => $conversion_string ) { if ( empty( $conversion_string ) ) continue; @@ -215,11 +216,11 @@ class import_export_helper_functions { ); } - $val = preg_replace_callback( "/(cat|account|strtotime)\(([^)]+)\)/i", array( self, 'c2_dispatcher') , $val ); + $val = preg_replace_callback( "/(cat|account|strtotime)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val ); } } // clean each field - $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{)(.*)\}/", array( self, 'strclean'), $val ); + $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val ); $_record[$idx] = $val; } @@ -252,7 +253,8 @@ class import_export_helper_functions { switch( $_matches[1] ) { case '|T{' : return trim( $_matches[2] ); case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); - case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); + case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); + case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : ''; default: throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!'); }