forked from extern/egroupware
php5.2 fixes
This commit is contained in:
parent
a012a4ba22
commit
654294ae97
@ -74,7 +74,7 @@ class export_csv implements iface_export_record
|
|||||||
* @param array _options options for specific backends
|
* @param array _options options for specific backends
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function __construct( $_stream, $_options ) {
|
public function __construct( $_stream, array $_options ) {
|
||||||
if (!is_object($GLOBALS['egw']->translation)) {
|
if (!is_object($GLOBALS['egw']->translation)) {
|
||||||
$GLOBALS['egw']->translation = new translation();
|
$GLOBALS['egw']->translation = new translation();
|
||||||
}
|
}
|
||||||
|
@ -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 string $_resource resource containing data. May be each valid php-stream
|
||||||
* @param array $_options options for the resource array with keys: charset and fieldsep
|
* @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->resource = $_resource;
|
||||||
$this->csv_fieldsep = $_options['fieldsep'];
|
$this->csv_fieldsep = $_options['fieldsep'];
|
||||||
$this->csv_charset = $_options['charset'];
|
$this->csv_charset = $_options['charset'];
|
||||||
|
@ -128,7 +128,7 @@ class import_export_helper_functions {
|
|||||||
|
|
||||||
$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
|
$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
|
||||||
foreach ( $cat_names as $cat_name ) {
|
foreach ( $cat_names as $cat_name ) {
|
||||||
|
if ( $cat_name == '' ) continue;
|
||||||
if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 ) {
|
if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 ) {
|
||||||
$cat_id = $cats->add( array(
|
$cat_id = $cats->add( array(
|
||||||
'name' => $cat_name,
|
'name' => $cat_name,
|
||||||
@ -179,10 +179,11 @@ class import_export_helper_functions {
|
|||||||
|
|
||||||
$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
|
$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
|
||||||
$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
|
$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
|
$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
|
$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 ) {
|
foreach ( $_conversion as $idx => $conversion_string ) {
|
||||||
if ( empty( $conversion_string ) ) continue;
|
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
|
// 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;
|
$_record[$idx] = $val;
|
||||||
}
|
}
|
||||||
@ -253,6 +254,7 @@ class import_export_helper_functions {
|
|||||||
case '|T{' : return trim( $_matches[2] );
|
case '|T{' : return trim( $_matches[2] );
|
||||||
case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_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:
|
default:
|
||||||
throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!');
|
throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user