Projekt

Allgemein

Profil

GX-Bug #41637 » CSVFunctionLibrary.inc.php

/system/classes/csv/ - Till Tepelmann, 22.04.2015 11:47

 
1
<?php
2
/* --------------------------------------------------------------
3
   CSVFunctionLibrary.inc.php 2015-02-19 gm
4
   Gambio GmbH
5
   http://www.gambio.de
6
   Copyright (c) 2015 Gambio GmbH
7
   Released under the GNU General Public License (Version 2)
8
   [http://www.gnu.org/licenses/gpl-2.0.html]
9
   --------------------------------------------------------------
10
*/
11

    
12
require_once(DIR_FS_CATALOG . 'admin/gm/inc/no_html.inc.php');
13
require_once(DIR_FS_INC . 'xtc_get_tax_rate.inc.php');
14

    
15
/**
16
 * Description of CSVFunctionLibrary
17
 */
18
class CSVFunctionLibrary extends BaseClass
19
{	
20
	protected $coo_currencies;
21
	protected $coo_shipping_status;
22
	protected $coo_vpe_source;
23
	protected $coo_manufacturers;
24
	protected $coo_google_export_availability;
25
	protected $coo_seo_boost = false;
26
			
27
	protected $v_language_array = array();
28
	protected $v_language_by_code_array = array();
29
	protected $v_product_ids_array = array();
30
	protected $v_image_data_array = array();
31
	protected $v_additional_field_data_array = array();
32
	protected $v_personal_offers_array = array();
33
	protected $v_product_categories_array = array();
34
	protected $v_category_parents_array = array();
35
	protected $v_category_names_array = array();
36
	protected $v_google_categories_array = array();
37
	protected $v_properties_array = array();
38
	protected $v_attributes_array = array();
39
	protected $v_additional_fields_array = array();
40
	protected $coo_xtc_price;
41
	protected $coo_scheme;
42
	protected $combi_value_names_array = array();
43
	protected $property_names_array = array();
44
	
45
	public function __construct( $p_coo_scheme, $p_properties_array = array(), $p_attributes_array = array(), $p_additional_fields_array = array() )
46
	{
47
		$this->coo_scheme = $p_coo_scheme;
48
		$this->coo_currencies = MainFactory::create_object( 'CurrenciesSource' );
49
		$this->coo_shipping_status = MainFactory::create_object( 'ProductsShippingStatusSource' );
50
		$this->coo_vpe_source = MainFactory::create_object('ProductsVPESource');
51
		$this->coo_manufacturers = MainFactory::create_object( 'ManufacturersSource' );
52
		$this->coo_google_export_availability = MainFactory::create_object( 'GoogleExportAvailabilitySource' );
53
		$this->v_properties_array = $p_properties_array;
54
		$this->v_attributes_array = $p_attributes_array;
55
		$this->v_additional_fields_array = $p_additional_fields_array;
56
		$this->_init_languages_by_code();
57
		$this->_init_property_names();
58
		
59
		if( gm_get_conf('GM_SEO_BOOST_PRODUCTS') == 'true' )
60
		{
61
			$this->coo_seo_boost = new GMSEOBoost();
62
		}
63
		
64
		$t_currency = $this->coo_currencies->get_currencies( $this->coo_scheme->v_data_array[ 'currencies_id' ] );
65
		$this->coo_xtc_price = new xtcPrice( $t_currency[ 'code' ], $this->coo_scheme->v_data_array[ 'customers_status_id' ] );
66
	}
67
	
68
	public function get_data( $p_data_array, $p_field_content, $p_default_value = '', $p_preview_content = false )
69
	{
70
		$t_field_content = $this->_get_field_content($p_data_array, $p_field_content, $p_default_value);
71
		
72
		if($p_preview_content === true)
73
		{
74
			$t_field_content = htmlentities_wrapper( $t_field_content );
75
			if(strlen_wrapper($t_field_content) > 30)
76
			{
77
				$t_field_content = '<div class="preview_content_full" style="display: none">' . $t_field_content . ' <a href="#" style="color: red" class="toogle_content_size">[weniger]</a></div></div>' . 
78
								'<div class="preview_content_sub">' . substr_wrapper($t_field_content, 0, 30) . ' <a href="#" style="color: red" class="toogle_content_size">[mehr]</a></div>';
79
			}
80
		}
81
		
82
		return $t_field_content;
83
	}
84
	
85
	protected function _get_field_content($p_data_array, $p_field_content, $p_default_field_content = '')
86
	{
87
		preg_match_all( '/{([^{]+)}/', $p_field_content, $t_matches );
88
		
89
		foreach( $t_matches[1] AS $t_variable_name_data )
90
		{
91
			$t_language_code = '';
92
			$t_index = '';
93
			$t_variable_name = $t_variable_name_data;
94
			$t_variable_key_name = $t_variable_name_data;
95
			
96
			if(strpos_wrapper(trim($t_variable_name), 'collective_field') === 0)
97
			{
98
				$t_collective_variable = explode('||', $t_variable_name);
99
				$t_collective_source_names = explode(';', $t_collective_variable[1]);
100
				$t_collective_sources = explode(';', $t_collective_variable[2]);
101
				
102
				$t_variable_name_formatted = $this->collective_field($p_data_array, $t_collective_source_names, $t_collective_sources);
103
			}
104
			else
105
			{
106
				$t_filter_name = '';
107
				if(strpos_wrapper($t_variable_name, '|') !== false)
108
				{
109
					$t_variable_array = explode('|', $t_variable_name);
110
					$t_variable_name = $t_variable_array[0];
111
					$t_variable_key_name = $t_variable_array[0];
112
					$t_filter_data_array = explode(':', $t_variable_array[1]);
113
					$t_filter_name = $t_filter_data_array[0];
114
					$filter_params_array = array();
115
					if(isset($t_filter_data_array[1]))
116
					{
117
						foreach($t_filter_data_array as $t_filter_key => $t_filter_value)
118
						{
119
							if($t_filter_key > 0)
120
							{
121
								$filter_params_array[] = $t_filter_value;
122
							}
123
						}
124
					}
125
				}
126

    
127
				if(strpos_wrapper($t_variable_name, '.') !== false)
128
				{
129
					$t_variable_array = explode('.', $t_variable_name);
130

    
131
					$t_variable_name = $t_variable_array[0];
132
					$t_language_code = $t_variable_array[1];
133
				}
134

    
135
				if(strpos_wrapper($t_variable_name, '#') !== false)
136
				{
137
					$t_variable_array = explode('#', $t_variable_name);
138
					$t_variable_name = $t_variable_array[0];
139
					$t_index = $t_variable_array[1];
140
				}
141

    
142
				if( method_exists( $this, $t_variable_name ) )
143
				{
144
					$t_language_id = empty($t_language_code) ? $this->coo_scheme->v_data_array['languages_id'] : $this->_get_language_id_by_code($t_language_code);
145
					$this->_set_language_id($t_language_id);
146
					$this->_set_language_code($t_language_code);
147

    
148
					if($t_index === '')
149
					{
150
						$t_variable_name_formatted = call_user_func( array( $this, $t_variable_name ), $p_data_array );
151
					}
152
					else
153
					{
154
						$t_variable_name_formatted = call_user_func( array( $this, $t_variable_name ), $p_data_array, $t_index );
155
					}
156

    
157
					if($t_filter_name != '' && method_exists($this, $t_filter_name))
158
					{
159
						$t_variable_name_formatted = call_user_func( array( $this, $t_filter_name ), $t_variable_name_formatted, $filter_params_array );
160
					}
161
				}
162
				else if (array_key_exists($t_variable_key_name, $p_data_array))
163
				{
164
					$t_variable_name_formatted = $p_data_array[ $t_variable_key_name ];
165

    
166
					if($t_filter_name != '' && method_exists($this, $t_filter_name))
167
					{
168
						$t_variable_name_formatted = call_user_func( array( $this, $t_filter_name ), $t_variable_name_formatted, $filter_params_array );
169
					}
170
				}
171
				else
172
				{
173
					$t_variable_name_formatted = '{' . $t_variable_name_data . '}';
174
				}
175
			}
176
			$p_field_content = str_replace( '{' . $t_variable_name_data . '}', $t_variable_name_formatted, $p_field_content );
177
			
178
			if (trim($p_field_content) == '')
179
			{
180
				$p_field_content = $this->_get_field_content( $p_data_array, $p_default_field_content );
181
			}
182
		}
183
		
184
		return $p_field_content;
185
	}
186
	
187
	protected function _init_languages_by_code()
188
	{
189
		$t_sql = '
190
				SELECT languages_id, code
191
				FROM ' . TABLE_LANGUAGES;
192
		$t_result = xtc_db_query($t_sql);
193
		
194
		while($t_row = xtc_db_fetch_array($t_result))
195
		{
196
			$this->v_language_by_code_array[$t_row['code']] = $t_row['languages_id'];
197
		}
198
	}
199
	
200
	protected function _get_additional_field_value($p_additional_field_id, $p_item_id, $p_language_id = 0)
201
	{
202
		$c_additional_field_id = (int)$p_additional_field_id;
203
		$c_item_id = (int)$p_item_id;
204
		$c_language_id = (int)$p_language_id;
205
		$t_sql = 'SELECT afvd.value '
206
				. 'FROM additional_field_values afv, additional_field_value_descriptions afvd '
207
				. 'WHERE afv.additional_field_id = "' . $c_additional_field_id . '" AND '
208
				. 'afv.item_id = "' . $c_item_id . '" AND '
209
				. 'afvd.language_id = "' . $c_language_id . '"';
210
		$t_result = xtc_db_query($t_sql);
211
		
212
		if($t_row = xtc_db_fetch_array($t_result))
213
		{
214
			return $t_row['value'];
215
		}
216
		
217
		return '';
218
	}
219
	
220
	protected function _replace_whitespaces($p_text)
221
	{
222
		$t_text = $p_text;
223

    
224
		$t_text = str_replace(chr(9), '', $t_text);
225
		$t_text = str_replace(chr(10), '', $t_text);
226
		$t_text = str_replace(chr(13), '', $t_text);
227
		
228
		return $t_text;
229
	}
230
	
231
	protected function p_id( $p_data_array )
232
	{
233
		$t_return = $p_data_array[ 'products_id' ];
234
		
235
		if( $this->coo_scheme->v_data_array['export_properties'] == 1 && isset( $p_data_array[ 'products_properties_combis_id' ] ) && $p_data_array[ 'products_properties_combis_id' ] > 0 )
236
		{
237
			// contains properties
238
			$t_return .= 'p' . $p_data_array[ 'products_properties_combis_id' ];
239
		}
240
		
241
		if( $this->coo_scheme->v_data_array[ 'export_attributes' ] == 1 && isset( $p_data_array[ 'products_attributes_id' ] ) )
242
		{
243
			// contains attributes
244
			$t_return .= 'a' . $p_data_array[ 'products_attributes_id' ];
245
		}
246
		
247
		return $t_return;
248
	}
249

    
250
	protected function p_name( $p_data_array )
251
	{
252
		$t_return = isset($p_data_array['products_name.' . $this->v_language_array['code']]) ? 
253
						$p_data_array['products_name.' . $this->v_language_array['code']] : 
254
						$p_data_array['products_name'];
255
		
256
		if($this->_use_properties($p_data_array))
257
		{
258
			// contains properties
259
			$t_properties_names_array = array();
260
			
261
			foreach($this->combi_value_names_array as $t_property_id => $t_combi_array)
262
			{
263
				$t_properties_names_array[] = $this->property_names_array[$t_property_id][$this->_get_language_id()] . ': ' . $t_combi_array[$this->_get_language_id()]['name'];
264
			}
265
			
266
			if(empty($t_properties_names_array) === false)
267
			{
268
				$t_return .= ' (';
269
				$t_return .= implode(' / ', $t_properties_names_array);
270
				$t_return .= ')';
271
			}
272
		}
273
		
274
		if( $this->coo_scheme->v_data_array[ 'export_attributes' ] == 1 && isset( $p_data_array[ 'products_attributes_id' ] ) )
275
		{
276
			// contains attributes
277
			$t_return .= ' (' . $p_data_array[ 'products_options_name' ] . ': ' . $p_data_array[ 'products_options_values_name' ] . ')';
278
		}
279
		
280
		$t_return = str_replace( "\t", ' ', $t_return );
281
		
282
		return $t_return;
283
	}
284
	
285
	protected function c_name( $p_data_array )
286
	{
287
		$t_return = '';
288
		$t_category_id = (int)$this->_get_category_id( $p_data_array );
289
		$t_category = $this->_get_category( $t_category_id );
290
		if( isset( $t_category[ 'categories_name' ] ) )
291
		{
292
			$t_return = $t_category[ 'categories_name' ];
293
		}
294
		return $t_return;
295
	}
296
	
297
	protected function c_path( $p_data_array )
298
	{
299
		$t_category_id = (int)$this->_get_category_id( $p_data_array );
300
		$t_return = $this->_build_category_path( $t_category_id );
301
		
302
		return $t_return;
303
	}
304
	
305
	protected function p_link( $p_data_array )
306
	{
307
		$t_return = '';
308
		
309
		$t_parameter_string = '';
310
		if( isset( $this->coo_scheme->v_data_array[ 'campaign_id' ] ) && !empty($this->coo_scheme->v_data_array[ 'campaign_id' ]) )
311
		{
312
			$t_parameter_string .= 'refID=' . $this->coo_scheme->v_data_array[ 'campaign_id' ] . '&';
313
		}
314
		
315
		if($this->coo_scheme->v_data_array['export_properties'] == 1 && isset( $p_data_array[ 'products_properties_combis_id' ] ) && $p_data_array[ 'products_properties_combis_id' ] > 0)
316
		{
317
			$t_parameter_string .= 'combi_id=' . $p_data_array[ 'products_properties_combis_id' ] . '&';
318
		}
319
		
320
		if( $this->coo_seo_boost == false )
321
		{
322
			$t_return = $this->_generate_link( 'product_info.php', $t_parameter_string . xtc_product_link( $p_data_array[ 'products_id' ], $p_data_array[ 'products_name' ] ) );
323
		}
324
		else
325
		{
326
			$t_return = $this->_generate_link( $this->coo_seo_boost->get_boosted_product_url( $p_data_array[ 'products_id' ], $p_data_array[ 'products_name' ] ), $t_parameter_string);			
327
		}
328
		
329
		return $t_return;
330
	}
331
	
332
	protected function _generate_link($p_page = '', $p_parameters = '')
333
	{
334
		$t_link = HTTP_SERVER . DIR_WS_CATALOG;
335
    
336
		if (xtc_not_null($p_parameters)) {
337
		  $t_link .= $p_page . '?' . $p_parameters;
338
		  $t_separator = '&';
339
		} else {
340
		  $t_link .= $p_page;
341
		  $t_separator = '?';
342
		}
343

    
344
		while ( (substr_wrapper($t_link, -1) == '&') || (substr_wrapper($t_link, -1) == '?') ) $t_link = substr_wrapper($t_link, 0, -1);
345
		
346
		return $t_link;
347
  }
348
	
349
	protected function products_description( $p_data_array )
350
	{
351
		$t_products_description = isset($p_data_array['products_description.' . $this->v_language_array['code']]) ? 
352
									$p_data_array['products_description.' . $this->v_language_array['code']] : 
353
									$p_data_array['products_description'];
354

    
355
		$t_products_description = $this->_replace_whitespaces($t_products_description);
356
		
357
		return $t_products_description;
358
	}
359

    
360
	protected function p_description( $p_data_array )
361
	{
362
		$t_return = '';
363
		$t_products_description = isset($p_data_array['products_description.' . $this->v_language_array['code']]) ? 
364
									$p_data_array['products_description.' . $this->v_language_array['code']] : 
365
									$p_data_array['products_description'];
366

    
367
		if( isset( $t_products_description ) )
368
		{
369
			$t_products_description = preg_replace('!(.*?)\[TAB:(.*?)\](.*?)!is', "$1$3", $t_products_description);
370
			$t_products_description = $this->_replace_whitespaces($t_products_description);
371
			$t_products_description = no_html($t_products_description);
372
			$t_return = $t_products_description;
373
		}
374

    
375
		return $t_return;
376
	}
377
	
378
	protected function p_short_description($p_data_array)
379
	{
380
		$t_products_short_description = isset($p_data_array['products_short_description.' . $this->v_language_array['code']]) ? 
381
											$p_data_array['products_short_description.' . $this->v_language_array['code']] : 
382
											$p_data_array['products_short_description'];
383

    
384
		$t_products_short_description = $this->_replace_whitespaces($t_products_short_description);
385
		$t_products_short_description = no_html($t_products_short_description);
386
		$t_return = $t_products_short_description;
387
		
388
		return $t_return;
389
	}
390
	
391
		
392
	protected function products_short_description( $p_data_array )
393
	{
394
		$t_return = '';
395
		
396
		$t_products_short_description = isset($p_data_array['products_short_description.' . $this->v_language_array['code']]) ? 
397
											$p_data_array['products_short_description.' . $this->v_language_array['code']] : 
398
											$p_data_array['products_short_description'];
399

    
400
		$t_return = $this->_replace_whitespaces($t_products_short_description);
401
		
402
		return $t_return;
403
	}
404
	
405
	protected function checkout_information($p_data_array)
406
	{
407
		$t_checkout_information = isset($p_data_array['checkout_information.' . $this->v_language_array['code']]) ?
408
									$p_data_array['checkout_information.' . $this->v_language_array['code']] :
409
									$p_data_array['checkout_information'];
410

    
411
		$t_checkout_information = $this->_replace_whitespaces($t_checkout_information);
412

    
413
		return $t_checkout_information;
414
	}
415
	
416
	protected function p_checkout_information($p_data_array)
417
	{
418
		$t_checkout_information = isset($p_data_array['checkout_information.' . $this->v_language_array['code']]) ?
419
									$p_data_array['checkout_information.' . $this->v_language_array['code']] :
420
									$p_data_array['checkout_information'];
421

    
422
		$t_checkout_information = $this->_replace_whitespaces($t_checkout_information);
423
		$t_checkout_information = no_html($t_checkout_information);
424

    
425
		return $t_checkout_information;
426
	}
427
	
428
	protected function p_gm_alt_text( $p_data_array, $p_index = 0 )
429
	{
430
		$t_return = '';
431
		if(empty($p_index))
432
		{
433
			$t_return = isset($p_data_array['gm_alt_text.' . $this->v_language_array['code']]) ?
434
							$p_data_array['gm_alt_text.' . $this->v_language_array['code']] :
435
							$p_data_array['gm_alt_text'];
436
		}
437
		else
438
		{
439
			$this->_build_image_data_array();
440
			if(isset($this->v_image_data_array[$p_data_array['products_id']][$p_index][$this->v_language_array['id']]['gm_alt_text']))
441
			{
442
				$t_return = $this->v_image_data_array[$p_data_array['products_id']][$p_index][$this->v_language_array['id']]['gm_alt_text'];
443
			}
444
		}
445
		
446
		return $t_return;
447
	}
448
	
449
	protected function p_additional_field($p_data_array, $p_additional_field_id)
450
	{
451
		$t_return = '';
452
		$c_additional_field_id = (int)$p_additional_field_id;
453
		
454
		$this->_build_additional_field_data_array();
455
		if(isset($this->v_additional_field_data_array[$p_data_array['products_id']][$c_additional_field_id][$this->v_language_array['id']]))
456
		{
457
			$t_return = $this->v_additional_field_data_array[$p_data_array['products_id']][$c_additional_field_id][$this->v_language_array['id']];
458
		}
459
		else if(isset($this->v_additional_field_data_array[$p_data_array['products_id']][$c_additional_field_id][0]))
460
		{
461
			$t_return = $this->v_additional_field_data_array[$p_data_array['products_id']][$c_additional_field_id][0];
462
		}
463
		
464
		return $t_return;
465
	}
466
	
467
	protected function collective_field($p_data_array, $p_source_field_names, $p_collective_sources)
468
	{
469
		$t_return = '';
470
		
471
		if(in_array('properties', $p_collective_sources))
472
		{
473
			foreach($p_source_field_names as $t_source_field_name)
474
			{
475
				if(isset($this->v_properties_array[$t_source_field_name]))
476
				{
477
					$t_return = $this->combi_value_names_array[$this->v_properties_array[$t_source_field_name]][$this->_get_language_id()]['name'];
478
					break;
479
				}
480
			}
481
		}
482
		
483
		if(empty($t_return) && in_array('attributes', $p_collective_sources))
484
		{
485
			foreach($p_source_field_names as $t_source_field_name)
486
			{
487
				if(	isset($this->v_attributes_array[$t_source_field_name]) &&
488
					isset($p_data_array['options_id']) &&
489
					empty($p_data_array['options_id']) == false &&
490
					$this->v_attributes_array[$t_source_field_name] == $p_data_array['options_id'])
491
				{
492
					$t_return = $p_data_array['products_options_values_name'];
493
					break;
494
				}
495
			}
496
		}
497
		
498
		if(empty($t_return) && in_array('additional_fields', $p_collective_sources))
499
		{
500
			foreach($p_source_field_names as $t_source_field_name)
501
			{
502
				if(isset($this->v_additional_fields_array[$t_source_field_name]))
503
				{
504
					$t_return = $p_data_array['additional_field_value_' . $this->v_additional_fields_array[$t_source_field_name]];
505
					break;
506
				}
507
			}
508
		}
509
		
510
		return $t_return;
511
	}
512
	
513
	protected function p_availability( $p_data_array )
514
	{
515
		$t_return = '0000-00-00 00:00:00';
516
		
517
		if (!empty($p_data_array['products_date_available']))
518
		{
519
			$t_return = $p_data_array['products_date_available'];
520
		}
521
		
522
		// Sprachabhaengige Konstanten erlaubt?
523
		// War im alten Export-Modul umgedreht (Ja => Nein, Nein => Ja) Nochmal klaeren!!!
524
		$t_return = $t_return >= date("Y-m-d H:i:s", time()) ? 'Nein' : 'Ja';
525
		
526
		return $t_return;
527
	}
528
	
529
	protected function products_image( $p_data_array, $p_index = 0 )
530
	{
531
		$t_return = $p_data_array[ 'products_image' ];
532
		
533
		if( isset( $p_index ) && (int)$p_index != 0 )
534
		{
535
			$this->_build_image_data_array();
536
			$t_return = '';
537
			if(isset($this->v_image_data_array[$p_data_array['products_id']][$p_index]['image_name']))
538
			{
539
				$t_return = $this->v_image_data_array[$p_data_array['products_id']][$p_index]['image_name'];
540
			}
541
		}
542
		
543
		return $t_return;
544
	}
545
	
546
	protected function p_image( $p_data_array, $p_index = 0 )
547
	{
548
		$t_return = $this->_get_image_path('popup') . $p_data_array[ 'products_image' ];
549
		
550
		if( isset( $p_index ) && (int)$p_index != 0 )
551
		{
552
			$this->_build_image_data_array();
553
			$t_return = '';
554
			if(isset($this->v_image_data_array[$p_data_array['products_id']][$p_index]['image_name']))
555
			{
556
				$t_return = $this->_get_image_path('popup') . $this->v_image_data_array[$p_data_array['products_id']][$p_index]['image_name'];
557
			}
558
		}
559
		
560
		return $t_return;
561
	}
562
	
563
	protected function p_thumb_image( $p_data_array )
564
	{
565
		$t_return = '';
566
		
567
		if( isset( $p_data_array[ 'products_image' ] ) && !empty( $p_data_array[ 'products_image' ] ) )
568
		{
569
			$t_image_dir = $this->_get_image_path('thumb');
570
			$t_return = $t_image_dir . $p_data_array[ 'products_image' ];
571
		}
572
		
573
		return $t_return;
574
	}
575
	
576
	protected function p_info_image( $p_data_array )
577
	{
578
		$t_return = '';
579
		
580
		if( isset( $p_data_array[ 'products_image' ] ) && !empty( $p_data_array[ 'products_image' ] ) )
581
		{
582
			$t_image_dir = $this->_get_image_path('info');
583
			$t_return = $t_image_dir . $p_data_array[ 'products_image' ];
584
		}
585
		
586
		return $t_return;
587
	}
588
	
589
	protected function p_popup_image( $p_data_array )
590
	{
591
		$t_return = '';
592
		
593
		if( isset( $p_data_array[ 'products_image' ] ) && !empty( $p_data_array[ 'products_image' ] ) )
594
		{
595
			$t_image_dir = $this->_get_image_path('popup');
596
			$t_return = $t_image_dir . $p_data_array[ 'products_image' ];
597
		}
598
		
599
		return $t_return;
600
	}
601
	
602
	protected function p_thumb_images( $p_data_array )
603
	{
604
		$t_image_dir = $this->_get_image_path('thumb');
605
		return $this->_get_images_for_product($t_image_dir, $p_data_array);
606
	}
607
	
608
	protected function p_info_images( $p_data_array )
609
	{
610
		$t_image_dir = $this->_get_image_path('info');
611
		return $this->_get_images_for_product($t_image_dir, $p_data_array);
612
	}
613
	
614
	protected function p_popup_images( $p_data_array )
615
	{
616
		$t_image_dir = $this->_get_image_path('popup');
617
		return $this->_get_images_for_product($t_image_dir, $p_data_array);
618
	}
619
	
620
	protected function p_price_comma( $p_data_array )
621
	{
622
		$t_return = $this->_calculate_price($p_data_array);
623
		$t_return = number_format( $t_return, 2, ',', '' );
624
		return $t_return;
625
	}
626
	
627
	protected function p_price_point( $p_data_array )
628
	{
629
		$t_return = $this->_calculate_price($p_data_array);
630
		$t_return = number_format( $t_return, 2, '.', '' );
631
		return $t_return;
632
	}
633
	
634
	protected function p_price_net_point( $p_data_array )
635
	{
636
		$t_return = $this->_calculate_price_net($p_data_array);
637
		$t_return = number_format( $t_return, 2, '.', '' );
638
		return $t_return;
639
	}
640
	
641
	protected function p_price_net_comma( $p_data_array )
642
	{
643
		$t_return = $this->_calculate_price_net($p_data_array);
644
		$t_return = number_format( $t_return, 2, ',', '' );
645
		return $t_return;
646
	}
647

    
648
	protected function p_google_special_price( $p_data_array )
649
	{
650
		$t_return = '';
651
		if( $this->coo_xtc_price->xtcCheckSpecial($p_data_array[ 'products_id' ]) )
652
		{
653
			$t_return = $this->coo_xtc_price->xtcGetPrice($p_data_array['products_id'], false, 1, $p_data_array['products_tax_class_id'], '', 0, 0, true);
654
			$t_return = number_format( $t_return, 2, ',', '' ) . " " . $this->p_currency();
655
		}
656
		return $t_return;
657
	}
658

    
659
	protected function p_google_price( $p_data_array )
660
	{
661
		$t_return = $this->_calculate_price($p_data_array, false);
662
		$t_return = number_format( $t_return, 2, ',', '' ) . " " . $this->p_currency();
663
		return $t_return;
664
	}
665
	
666
	protected function p_old_price_point( $p_data_array )
667
	{
668
		$t_return = $this->_get_old_price( $p_data_array );
669
		if( trim($t_return) != '' )
670
		{
671
			$t_return = number_format( $t_return, 2, '.', '' );
672
		}
673
		return $t_return;
674
	}
675
	
676
	protected function p_old_price_comma( $p_data_array )
677
	{
678
		$t_return = $this->_get_old_price( $p_data_array );
679
		if( trim($t_return) != '' )
680
		{
681
			$t_return = number_format( $t_return, 2, ',', '' );
682
		}
683
		return $t_return;
684
	}
685
	
686
	protected function p_old_price_point_currency( $p_data_array )
687
	{
688
		$t_return = $this->p_old_price_point( $p_data_array );
689
		if( trim($t_return) != '' )
690
		{
691
			$t_return = $this->p_currency() . " " . $t_return;
692
		}
693
		return $t_return;
694
	}
695
	
696
	protected function p_old_price_comma_currency( $p_data_array )
697
	{
698
		$t_return = $this->p_old_price_comma( $p_data_array );
699
		if( trim($t_return) != '' )
700
		{
701
			$t_return = $this->p_currency() . " " . $t_return;
702
		}
703
		return $t_return;
704
	}
705
	
706
	protected function _get_old_price( $p_data_array )
707
	{
708
		$t_return = $p_data_array['products_price'];
709
		if( $this->coo_xtc_price->xtcCheckSpecial($p_data_array[ 'products_id' ]) )
710
		{
711
			$t_return = $this->_calculate_price($p_data_array, false);
712
		}
713
		return $t_return;
714
	}
715
    
716
	protected function p_baseprice_point( $p_data_array )
717
	{
718
		$t_return = '';
719
		$t_baseprice = (double)$this->p_baseprice($p_data_array);
720
		if($t_baseprice > 0)
721
		{
722
			$t_currency = $this->coo_currencies->get_currencies($this->coo_scheme->v_data_array['currencies_id']);
723
			$t_return .= number_format($t_baseprice, 2, '.', '') . ' ' . $t_currency['code'] . ' / ' . $this->vpe_name($p_data_array);
724
		}
725
		
726
		return $t_return;
727
	}
728
	
729
	protected function p_baseprice($p_data_array)
730
	{
731
		$t_return = '';
732
		$t_vpe_value = $this->vpe_value($p_data_array);
733
		
734
		if(empty($t_vpe_value) == false)
735
		{			
736
			$t_price = $this->p_price_point($p_data_array);
737
			$t_return = $t_price / (double)$t_vpe_value;
738
		}
739
		
740
		return $t_return;
741
	}
742
	
743
	protected function p_baseprice_comma($p_data_array)
744
	{
745
		$t_return = '';
746
		$t_baseprice = (double)$this->p_baseprice($p_data_array);
747
		if($t_baseprice > 0)
748
		{
749
			$t_currency = $this->coo_currencies->get_currencies($this->coo_scheme->v_data_array['currencies_id']);
750
			$t_return = number_format($t_baseprice, 2, ',', '') . ' ' . $t_currency['code'] . ' / ' . $this->vpe_name($p_data_array);
751
		}
752
		
753
		return $t_return;
754
	}
755
	
756
	protected function _calculate_price($p_data_array, $p_include_special = true)
757
	{
758
		$t_return = 0;
759
		$t_combi_price = 0;
760
		$t_product_price = $this->coo_xtc_price->xtcGetPrice($p_data_array['products_id'], false, 1, $p_data_array['products_tax_class_id'], '', 0, 0, $p_include_special);
761
		
762
		if($this->coo_scheme->v_data_array['export_properties'] == 1 && isset( $p_data_array[ 'products_properties_combis_id' ] ) && $p_data_array[ 'products_properties_combis_id' ] > 0)
763
		{
764
			$t_combi_price = $this->coo_xtc_price->xtcGetPrice(0, false, 1, $p_data_array['products_tax_class_id'], $p_data_array['combi_price']);
765
		}
766
		
767

    
768
		if($this->coo_scheme->v_data_array['export_attributes'] == 1 && isset( $p_data_array[ 'products_attributes_id' ] ))
769
		{
770
			$t_attributes_price = $this->coo_xtc_price->xtcGetPrice(0, false, 1, $p_data_array['products_tax_class_id'], $p_data_array['options_values_price']);
771
			$t_return = $t_product_price + $t_attributes_price;
772
		}
773
		else
774
		{
775
			$t_return = $t_product_price + $t_combi_price;
776
		}
777
		
778
		return $t_return;
779
	}
780
	
781
	protected function _calculate_price_net($p_data_array)
782
	{
783
		$t_return = 0;
784
		$t_combi_price = 0;
785
		$t_product_price = $this->coo_xtc_price->xtcGetPrice($p_data_array['products_id'], false, 1, 0, '');
786
		
787
		if($this->coo_scheme->v_data_array['export_properties'] == 1 && isset( $p_data_array[ 'products_properties_combis_id' ] ) && $p_data_array[ 'products_properties_combis_id' ] > 0)
788
		{
789
			$t_combi_price = $this->coo_xtc_price->xtcGetPrice(0, false, 1, 0, $p_data_array['combi_price']);
790
		}
791
		
792
		$t_return = $t_product_price + $t_combi_price;
793
		
794
		return $t_return;
795
	}
796

    
797
	protected function become_baseprice_value($p_data_array)
798
	{
799
		$t_return = '';
800
		if(preg_match('/(\d+\s+)?(\w+)/', $this->vpe_name($p_data_array), $matches) == 1)
801
		{
802
			$t_return = 1;
803
			$t_number = trim($matches[1]);
804
			if(is_numeric($t_number))
805
			{
806
				$t_return = $t_number;
807
			}
808
		}
809
		
810
		return $t_return;
811
	}
812
	
813
	protected function become_baseprice_amount($p_data_array)
814
	{
815
		$t_return = '';
816
		$t_baseprice = (double)$this->p_baseprice($p_data_array);
817
		if( $t_baseprice > 0 )
818
		{
819
			$t_return = number_format($t_baseprice, 2, '.', '');
820
		}
821
		
822
		return $t_return;
823
	}
824
	
825
	protected function become_baseprice_unit($p_data_array)
826
	{
827
		$t_return = '';
828
		if(preg_match('/(\d+\s+)?(\w+)/', $p_data_array['products_vpe_name'], $matches) == 1)
829
		{
830
			$t_return = $matches[2];
831
		}
832
		return $t_return;
833
	}
834
    
835
    protected function p_currency()
836
    {
837
        $t_return ='';
838
        $t_currency = $this->coo_currencies->get_currencies($this->coo_scheme->v_data_array['currencies_id']);
839
        $t_return = $t_currency['code'];
840
        
841
        return $t_return;
842
    }
843
	
844
	protected function _shipping_costs( $p_data_array )
845
	{
846
		$t_shipping_costs = '';
847
		
848
		if((double)$p_data_array['nc_ultra_shipping_costs'] > 0)
849
		{
850
			$t_shipping_costs = (double)$p_data_array['nc_ultra_shipping_costs'];
851
			if(strpos_wrapper(MODULE_SHIPPING_INSTALLED, 'gambioultra') !== false)
852
			{
853
				$t_tax_rate = xtc_get_tax_rate(MODULE_SHIPPING_GAMBIOULTRA_TAX_CLASS);
854
				$t_shipping_costs = $this->coo_xtc_price->xtcAddTax($t_shipping_costs, $t_tax_rate);
855
			}
856
			else
857
			{
858
				$t_shipping_costs = $this->coo_xtc_price->xtcCalculateCurr($t_shipping_costs);
859
			}
860
		}
861
		if((double)$this->p_price_point($p_data_array) >= (double)$this->coo_scheme->v_data_array['shipping_free_minimum'])
862
		{
863
			$t_shipping_costs = 0.00;
864
		}
865
		
866
		return $t_shipping_costs;
867
	}
868
	
869
	protected function p_shipping_costs_point( $p_data_array )
870
	{
871
		$t_return = $this->_shipping_costs($p_data_array);
872
		
873
		if($t_return !== '')
874
		{
875
			$t_return = number_format((double)$t_return, 2, '.', '');
876
		}
877
		
878
		return $t_return;
879
	}
880
	
881
	protected function p_shipping_costs_comma( $p_data_array )
882
	{
883
		$t_return = $this->_shipping_costs($p_data_array);
884
		
885
		if($t_return !== '')
886
		{
887
			$t_return = number_format((double)$t_return, 2, ',', '');
888
		}
889
		
890
		return $t_return;
891
	}
892
	
893
	protected function p_weight_point( $p_data_array )
894
	{
895
		$t_return = number_format($this->_calculate_weight($p_data_array), 3, '.', '');
896
	
897
		return $t_return;
898
	}
899
	
900
	protected function p_weight_comma( $p_data_array )
901
	{
902
		$t_return = number_format($this->_calculate_weight($p_data_array), 3, ',', '');
903
		
904
		return $t_return;
905
	}
906
	
907
	protected function _calculate_weight($p_data_array)
908
	{
909
		$t_return = (double)$p_data_array['products_weight'];
910
		
911
		if($this->coo_scheme->v_data_array['export_properties'] == 1 && isset( $p_data_array[ 'products_properties_combis_id' ] ) && $p_data_array[ 'products_properties_combis_id' ] > 0)
912
		{
913
			if($p_data_array['use_properties_combis_weight'] == 0)
914
			{
915
				$t_return += (double)$p_data_array['combi_weight'];
916
			}
917
			else
918
			{
919
				$t_return = (double)$p_data_array['combi_weight'];
920
			}
921
		}
922
		else if($this->coo_scheme->v_data_array['export_attributes'] == 1 && isset( $p_data_array[ 'products_attributes_id' ] ))
923
		{
924
			$t_return = $t_return + (double)$p_data_array['options_values_weight'];
925
		}
926
		
927
		return $t_return;
928
	}
929
	
930
	protected function p_special_period($p_data_array)
931
	{
932
		if( (isset($p_data_array['specials_id']) && !empty($p_data_array['specials_id']) ) &&  ( isset( $p_data_array['status']) && $p_data_array['status'] == 1) )
933
		{
934
			$t_start_timestamp = strtotime($p_data_array['specials_date_added']);
935
			
936
			if(isset($p_data_array['specials_last_modified']) && !empty($p_data_array['specials_last_modified']))
937
			{
938
				$t_start_timestamp = strtotime($p_data_array['specials_last_modified']);
939
			}
940
			
941
			$t_end_timestamp = strtotime($p_data_array['expires_date']);
942
			
943
			if(empty($p_data_array['expires_date']))
944
			{
945
				$t_end_timestamp = strtotime('+1 year', time());
946
			}
947
			
948
			$t_return = date('c', $t_start_timestamp) . '/' . date('c', $t_end_timestamp);
949
		}
950
		else
951
		{
952
			$t_return = '';
953
		}
954
		
955
		return $t_return;
956
	}
957

    
958
	/*
959
 * GOOGLE-SHOPPING FUNKTIONEN
960
 */
961
	
962
	protected function p_google_name_vpe_prefix( $p_data_array )
963
	{
964
		$t_return = '';
965
		
966
		$t_baseprice = $this->p_baseprice_comma($p_data_array);
967
		$t_name = $this->p_name($p_data_array);
968
		
969
		if($t_baseprice > 0)
970
		{
971
			$t_return = '(' . $t_baseprice . ') ';
972
		}
973
		$t_return .= $t_name;
974
		
975
		return $t_return;
976
	}
977
	
978
	protected function p_google_name_vpe_suffix( $p_data_array )
979
	{
980
		$t_return = '';
981
		
982
		$t_baseprice = $this->p_baseprice_comma($p_data_array);
983
		$t_name = $this->p_name($p_data_array);
984
		$t_return = $t_name;
985
		if($t_baseprice > 0)
986
		{
987
			$t_return .= ' (' . $t_baseprice . ')';
988
		}
989
		
990
		return $t_return;
991
	}
992
	
993
	protected function p_google_shipping_costs( $p_data_array )
994
	{
995
		$t_return = '';
996
		$t_shipping_costs = $this->p_shipping_costs_point($p_data_array);
997
		if(empty($t_shipping_costs) == false)
998
		{
999
			$t_return = ':::' . $t_shipping_costs . ' ' . $this->p_currency();
1000
		}
1001
		
1002
		return $t_return;
1003
	}
1004

    
1005
	protected function p_google_export_availability( $p_data_array )
1006
	{
1007
		$t_return = 'auf lager';
1008
		
1009
		if(isset($p_data_array['availability']))
1010
		{
1011
			$t_return = $p_data_array['availability'];
1012
		}
1013
		else
1014
		{
1015
			$t_google_export_availability = $this->coo_google_export_availability->get_google_export_availability( $p_data_array[ 'google_export_availability_id' ] );
1016
			if(!empty($t_google_export_availability[ 'availability' ]))
1017
			{
1018
				$t_return = $t_google_export_availability[ 'availability' ];
1019
			}			
1020
		}
1021
		
1022
		return $t_return;
1023
	}
1024
	
1025
	protected function p_google_export_condition( $p_data_array )
1026
	{
1027
		$t_return = 'neu';
1028
		
1029
		if( isset( $p_data_array['google_export_condition'] ) && !empty( $p_data_array['google_export_condition'] ) )
1030
		{
1031
			$t_return = $p_data_array['google_export_condition'];
1032
		}
1033
		
1034
		return $t_return;
1035
	}
1036
	
1037
	protected function p_google_category( $p_data_array )
1038
	{
1039
		if (empty($this->v_google_categories_array))
1040
		{
1041
			$t_sql = 'SELECT google_category, products_id FROM products_google_categories WHERE products_id IN (' . implode(',', $this->v_product_ids_array) . ') GROUP BY products_id';
1042
			$t_result = xtc_db_query($t_sql);
1043
			while ($t_row = xtc_db_fetch_array($t_result))
1044
			{
1045
				$this->v_google_categories_array[$t_row['products_id']] = $t_row['google_category'];
1046
			}
1047
		}
1048
		
1049
		return $this->v_google_categories_array[$p_data_array['products_id']];
1050
	}
1051
	
1052
//	EAN (in Europa), ISBN (fuer Buecher), UPC (in Nordamerika), JAN (in Japan)
1053
	protected function p_google_export_gtin( $p_data_array )
1054
	{
1055
		// init with EAN
1056
		$t_return = $this->p_ean($p_data_array);
1057
		
1058
		if(empty($t_return) && empty($p_data_array['code_isbn']) == false)
1059
		{
1060
			$t_return = trim($p_data_array['code_isbn']);
1061
		}
1062
		elseif(empty($t_return) && !empty($p_data_array['code_upc']))
1063
		{
1064
			$t_return = trim($p_data_array['code_upc']);
1065
		}
1066
		elseif(empty($t_return) && !empty($p_data_array['code_jan']))
1067
		{
1068
			$t_return = trim($p_data_array['code_jan']);
1069
		}
1070
		
1071
		return $t_return;
1072
	}
1073
	
1074
	protected function p_google_identifier_exists($p_data_array)
1075
	{
1076
		$t_return = 'FALSE';
1077
		$t_google_gtin = $this->p_google_export_gtin($p_data_array);
1078
		
1079
		if(empty($p_data_array['identifier_exists']) == false && 
1080
			empty($t_google_gtin) == false)
1081
		{
1082
			$t_return = 'TRUE';
1083
		}
1084
		
1085
		return $t_return;
1086
	}
1087
	
1088
	protected function p_google_fsk18($p_data_array)
1089
	{
1090
		$t_return = 'FALSE';
1091
		
1092
		if($p_data_array['products_fsk18'] == 1)
1093
		{
1094
			$t_return = 'TRUE';
1095
		}
1096
		
1097
		return $t_return;
1098
	}
1099
	
1100
	protected function p_google_unit_price_measure($p_data_array)
1101
	{
1102
		$t_google_unit_price_measure = '';
1103
		$t_allowed_units_array = array('mg', 'g', 'kg', 'ml', 'cl', 'l', 'cm', 'm', 'm2', 'cbm');
1104
		$t_allowed_unit_values_array = array(1, 10, 100, 75, 50, 1000);
1105
		
1106
		$t_vpe_name = $this->vpe_name($p_data_array);
1107
		$t_vpe_value = $this->vpe_value($p_data_array);
1108
		
1109
		if($t_vpe_name != '' && empty($t_vpe_value) === false)
1110
		{
1111
			$t_vpe_name = trim($t_vpe_name);
1112
			preg_match('/([0-9]*)(.+)/', $t_vpe_name, $t_matches_array);
1113
			
1114
			$t_unit_value = (double)$t_matches_array[1];
1115
			if(empty($t_unit_value))
1116
			{
1117
				$t_unit_value = 1;
1118
			}
1119
			$t_unit_name = trim($t_matches_array[2]);
1120
			
1121
			$p_products_array['unit_pricing_base_measure'] = '';
1122
			$p_products_array['unit_price_measure'] = '';
1123
			
1124
			if(in_array($t_unit_name, $t_allowed_units_array) && in_array($t_unit_value, $t_allowed_unit_values_array))
1125
			{
1126
				$t_continue = true;
1127
				
1128
				switch($t_unit_value)
1129
				{
1130
					case 50:
1131
					case 1000:
1132
						if($t_unit_name != 'kg')
1133
						{
1134
							$t_continue = false;
1135
						}
1136
						break;
1137
					case 75:
1138
						if($t_unit_name != 'cl')
1139
						{
1140
							$t_continue = false;
1141
						}
1142
				}			
1143
				
1144
				if($t_continue === true)
1145
				{
1146
					$t_unit_price_measure_value = (string)((double)$t_vpe_value * $t_unit_value);
1147
					$t_google_unit_price_measure = $t_unit_price_measure_value . ' ' . $t_unit_name;
1148
				}
1149
			}		
1150
		}
1151
		
1152
		return $t_google_unit_price_measure;
1153
	}
1154
	
1155
	protected function p_google_unit_pricing_base_measure($p_data_array)
1156
	{
1157
		$t_google_unit_pricing_base_measure = '';
1158
		$t_allowed_units_array = array('mg', 'g', 'kg', 'ml', 'cl', 'l', 'cm', 'm', 'm2', 'cbm');
1159
		$t_allowed_unit_values_array = array(1, 10, 100, 75, 50, 1000);
1160
		
1161
		$t_vpe_name = $this->vpe_name($p_data_array);
1162
		
1163
		if($t_vpe_name != '')
1164
		{
1165
			$t_vpe_name = trim($t_vpe_name);
1166
			preg_match('/([0-9]*)(.+)/', $t_vpe_name, $t_matches_array);
1167
			
1168
			$t_unit_value = (double)$t_matches_array[1];
1169
			if(empty($t_unit_value))
1170
			{
1171
				$t_unit_value = 1;
1172
			}
1173
			$t_unit_name = trim($t_matches_array[2]);
1174
			
1175
			$p_products_array['unit_pricing_base_measure'] = '';
1176
			$p_products_array['unit_price_measure'] = '';
1177
			
1178
			if(in_array($t_unit_name, $t_allowed_units_array) && in_array($t_unit_value, $t_allowed_unit_values_array))
1179
			{
1180
				$t_continue = true;
1181
				
1182
				switch($t_unit_value)
1183
				{
1184
					case 50:
1185
					case 1000:
1186
						if($t_unit_name != 'kg')
1187
						{
1188
							$t_continue = false;
1189
						}
1190
						break;
1191
					case 75:
1192
						if($t_unit_name != 'cl')
1193
						{
1194
							$t_continue = false;
1195
						}
1196
				}			
1197
				
1198
				if($t_continue === true)
1199
				{
1200
					$t_google_unit_pricing_base_measure = $t_unit_value . ' ' . $t_unit_name;
1201
				}
1202
			}		
1203
		}
1204
		
1205
		return $t_google_unit_pricing_base_measure;
1206
	}
1207
	
1208
	protected function p_google_product_group($p_data_array)
1209
	{
1210
		$t_google_product_group = $p_data_array['products_id'];
1211
		
1212
		if(isset($p_data_array['products_attributes_id']) && empty($p_data_array['products_attributes_id']) === false)
1213
		{
1214
			$t_source_names_array = array();
1215
			
1216
			foreach($this->coo_scheme->v_fields_array AS $coo_field)
1217
			{
1218
				$t_field_content = preg_replace('/\{(collective_field\|\|.*?)\}/', '$1', $coo_field->v_data_array['field_content'], 1);
1219

    
1220
				if(strpos_wrapper($t_field_content, 'collective_field') === 0)
1221
				{
1222
					$t_collective_variable = explode('||', $t_field_content);
1223
					$t_collective_source_names = explode(';', $t_collective_variable[1]);
1224
					$t_collective_sources = explode(';', $t_collective_variable[2]);
1225

    
1226
					if(in_array('attributes', $t_collective_sources))
1227
					{
1228
						$t_source_names_array = array_merge($t_source_names_array, $t_collective_source_names);
1229
					}
1230
				}
1231
			}
1232
			
1233
			if(in_array($p_data_array['products_options_name'], $t_source_names_array) === false)
1234
			{
1235
				$t_google_product_group .= 'A' . $p_data_array['products_attributes_id'];
1236
			}
1237
		}
1238
		
1239
		if(isset($p_data_array['products_properties_combis_id']) && empty($p_data_array['products_properties_combis_id']) === false)
1240
		{
1241
			$t_source_names_array = array();
1242
			
1243
			foreach($this->coo_scheme->v_fields_array AS $coo_field)
1244
			{
1245
				$t_field_content = preg_replace('/\{(collective_field\|\|.*?)\}/', '$1', $coo_field->v_data_array['field_content'], 1);
1246

    
1247
				if(strpos_wrapper($t_field_content, 'collective_field') === 0)
1248
				{
1249
					$t_collective_variable = explode('||', $t_field_content);
1250
					$t_collective_source_names = explode(';', $t_collective_variable[1]);
1251
					$t_collective_sources = explode(';', $t_collective_variable[2]);
1252

    
1253
					if(in_array('properties', $t_collective_sources))
1254
					{
1255
						$t_source_names_array = array_merge($t_source_names_array, $t_collective_source_names);
1256
					}
1257
				}
1258
			}
1259
			
1260
			foreach($this->v_properties_array as $t_property_name => $t_property_id)
1261
			{
1262
				if(in_array($t_property_name, $t_source_names_array) !== false)
1263
				{
1264
					$t_google_product_group .= 'P' . $t_property_id . 'P' . $this->combi_value_names_array[$t_property_id][$this->_get_language_id()]['id'];
1265
				}
1266
			}
1267
		}
1268
		
1269
		return $t_google_product_group;
1270
	}
1271
	
1272
/*
1273
 * DAPARTO FUNKTIONEN
1274
 */
1275
	protected function p_daparto_shippingtime( $p_data_array )
1276
	{
1277
		if($p_data_array['products_shippingdays'] <= 2)
1278
		{
1279
			$t_return = 1;
1280
		}
1281
		else if($p_data_array['products_shippingdays'] <= 5)
1282
		{
1283
			$t_return = 2;
1284
		}
1285
		else
1286
		{ // shippingdays > 5
1287
			$t_return = 3;
1288
		}
1289
		
1290
		return $t_return;
1291
	}
1292
	
1293
	protected function _get_image_path( $p_image_type )
1294
	{
1295
		$t_image_dir = HTTP_SERVER;
1296
		
1297
		if(defined("DIR_WS_CATALOG_ORIGINAL_IMAGES"))
1298
		{
1299
			switch ($p_image_type)
1300
			{
1301
				case "thumb":
1302
					$t_image_dir .= DIR_WS_CATALOG_THUMBNAIL_IMAGES;
1303
					break;
1304
				
1305
				case "popup":
1306
					$t_image_dir .= DIR_WS_CATALOG_POPUP_IMAGES;
1307
					break;
1308
				
1309
				case "info":
1310
					$t_image_dir .= DIR_WS_CATALOG_INFO_IMAGES;
1311
					break;
1312

    
1313
				default:
1314
					break;
1315
			}
1316
		}
1317
		
1318
		else
1319
		{
1320
			$t_image_dir .= DIR_WS_CATALOG;
1321
			
1322
			switch ($p_image_type)
1323
			{
1324
				case "thumb":
1325
					$t_image_dir .= DIR_WS_THUMBNAIL_IMAGES;
1326
					break;
1327
				
1328
				case "popup":
1329
					$t_image_dir .= DIR_WS_POPUP_IMAGES;
1330
					break;
1331
				
1332
				case "info":
1333
					$t_image_dir .= DIR_WS_INFO_IMAGES;
1334
					break;
1335

    
1336
				default:
1337
					break;
1338
			}
1339
		}
1340
		
1341
		return $t_image_dir;
1342
	}
1343
		
1344
	
1345
	protected function _get_images_for_product($p_image_dir, $p_data_array)
1346
	{
1347
		$t_return = '';
1348
		if( isset( $p_data_array[ 'products_image' ] ) && !empty( $p_data_array[ 'products_image' ] ) )
1349
		{
1350
			$t_return .= $p_image_dir . $p_data_array['products_image'] . ', ';
1351
		}
1352
		
1353
		$this->_build_image_data_array();
1354
		
1355
		if(isset($this->v_image_data_array[$p_data_array['products_id']]))
1356
		{
1357
			foreach($this->v_image_data_array[$p_data_array['products_id']] AS $t_image_array)
1358
			{
1359
				if(!empty($t_image_array['image_name']))
1360
				{
1361
					$t_return .= $p_image_dir . $t_image_array['image_name'] . ', ';
1362
				}
1363
			}
1364
		}
1365
		
1366
		if(!empty($t_return))
1367
		{
1368
			$t_return = substr_wrapper($t_return, 0, (strlen_wrapper($t_return) - 2 ));
1369
		}
1370
		
1371
		
1372
		return $t_return;
1373
	}
1374
	
1375
	
1376
	protected function _get_language_id_by_code($p_language_code)
1377
	{
1378
		return $this->v_language_by_code_array[$p_language_code];
1379
	}
1380
	
1381
	
1382
	protected function _set_language_code($p_language_code)
1383
	{
1384
		$this->v_language_array['code'] = (string)$p_language_code;
1385
	}
1386
	
1387
	
1388
	protected function _get_language_code()
1389
	{
1390
		$t_language_code = false;
1391
		
1392
		if(isset($this->v_language_array['code']))
1393
		{
1394
			$t_language_code = $this->v_language_array['code'];
1395
		}
1396
		
1397
		return $t_language_code;
1398
	}
1399
	
1400
	
1401
	protected function _set_language_id($p_language_id)
1402
	{
1403
		$this->v_language_array['id'] = (int)$p_language_id;
1404
	}
1405
	
1406
	
1407
	protected function _get_language_id()
1408
	{
1409
		$t_language_id = false;
1410
		
1411
		if(isset($this->v_language_array['id']))
1412
		{
1413
			$t_language_id = $this->v_language_array['id'];
1414
		}
1415
		
1416
		return $t_language_id;
1417
	}
1418
	
1419
	
1420
	protected function _get_category_id( $p_data_array )
1421
	{
1422
		if (array_key_exists($p_data_array['products_id'], $this->v_product_categories_array))
1423
		{
1424
			return $this->v_product_categories_array[$p_data_array['products_id']];
1425
		}
1426
		
1427
		$t_category_id = 0;
1428
		$t_sql = '
1429
			SELECT categories_id
1430
			FROM ' . TABLE_PRODUCTS_TO_CATEGORIES . '
1431
			WHERE products_id = "' . $p_data_array['products_id'] . '"
1432
			AND categories_id != "0"';
1433
		$t_result = xtc_db_query( $t_sql );
1434
		while( $t_row = xtc_db_fetch_array( $t_result ) )
1435
		{
1436
			$t_category_id = $t_row['categories_id'];
1437
		}
1438
		$this->v_product_categories_array[$p_data_array['products_id']] = $t_category_id;
1439
		
1440
		return $t_category_id;
1441
	}
1442
	
1443
	protected function _build_category_path( $p_category )
1444
	{
1445
		$t_categories_names_array = array();
1446
		$t_parent_categories_array = array();
1447
		$t_actual_category_id = $p_category;
1448
		
1449
		while( $t_actual_category_id != 0 && !in_array($t_actual_category_id, $t_parent_categories_array) )
1450
		{
1451
			$t_parent_categories_array[] = $t_actual_category_id;
1452
			$t_category = $this->_get_category( $t_actual_category_id );
1453
			if( $this->coo_scheme->v_data_array['type_id'] == 1 )
1454
			{
1455
				$t_category[ 'categories_name' ] .= '[' . $t_actual_category_id . ']';
1456
			}
1457
			$t_categories_names_array[] = $t_category[ 'categories_name' ];
1458
			$t_actual_category_id = $t_category[ 'parent_id' ];
1459
		}
1460
		
1461
		$t_categories_names_array = array_reverse($t_categories_names_array);
1462
		
1463
		if (trim(implode('', $t_categories_names_array)) == '[]')
1464
		{
1465
			$t_categories_names_array = array();
1466
		}
1467
			
1468
		return implode(' > ', $t_categories_names_array);
1469
	}
1470
	
1471
	protected function _get_category( $p_category_id )
1472
	{
1473
		$t_return = false;
1474
		$c_category_id = (int)$p_category_id;
1475
		
1476
		if( $c_category_id > 0 )
1477
		{
1478
			if (array_key_exists($c_category_id, $this->v_category_parents_array) && array_key_exists($c_category_id, $this->v_category_names_array) && array_key_exists($this->_get_language_id(), $this->v_category_names_array[$c_category_id]))
1479
			{
1480
				$t_return = array();
1481
				$t_return['categories_name'] = $this->v_category_names_array[$c_category_id][$this->_get_language_id()];
1482
				$t_return['parent_id'] = $this->v_category_parents_array[$c_category_id];
1483
			}
1484
			else
1485
			{
1486
				$t_sql = '
1487
					SELECT categories_name, parent_id
1488
					FROM ' . TABLE_CATEGORIES . ' AS c
1489
					LEFT JOIN ' . TABLE_CATEGORIES_DESCRIPTION . ' AS cd ON c.categories_id = cd.categories_id
1490
					WHERE c.categories_id = "' . $c_category_id . '" 
1491
					AND language_id="' . $this->_get_language_id() . '"';
1492
				$t_result = xtc_db_query( $t_sql );
1493
				$t_return = xtc_db_fetch_array($t_result);
1494
				if (!array_key_exists($c_category_id, $this->v_category_names_array))
1495
				{
1496
					$this->v_category_names_array[$c_category_id] = array();
1497
				}
1498
				$this->v_category_names_array[$c_category_id][$this->_get_language_id()] = $t_return['categories_name'];
1499
				$this->v_category_parents_array[$c_category_id] = $t_return['parent_id'];
1500
			}
1501
		}
1502
		
1503
		return $t_return;
1504
	}
1505
	
1506
	protected function p_manufacturer_name( $p_data_array )
1507
	{
1508
		$c_manufacturer_id = (int)$p_data_array['manufacturers_id'];
1509
		$t_manufacturer_name = '';
1510
		if(!empty($c_manufacturer_id))
1511
		{
1512
			$t_manufacturer = $this->coo_manufacturers->get_manufacturer( $p_data_array['manufacturers_id'] );
1513
			if(!empty($t_manufacturer))
1514
			{
1515
				$t_manufacturer_name = $t_manufacturer[ 'manufacturers_name' ];
1516
			}
1517
		}
1518
		return $t_manufacturer_name;
1519
	}
1520
	
1521
	protected function p_model( $p_data_array )
1522
	{
1523
		$t_return = trim($p_data_array[ 'products_model' ]);
1524
		
1525
		if( $this->coo_scheme->v_data_array['export_properties'] == 1 && isset( $p_data_array[ 'products_properties_combis_id' ] ) && $p_data_array[ 'products_properties_combis_id' ] > 0 )
1526
		{
1527
			// contains properties
1528
			if( APPEND_PROPERTIES_MODEL == 'true' && $t_return != '' && $p_data_array[ 'combi_model' ] != '' )
1529
			{
1530
				$t_return .= '-';
1531
			}
1532
			else if( APPEND_PROPERTIES_MODEL == 'false' )
1533
			{
1534
				$t_return = '';
1535
			}
1536
			$t_return .= $p_data_array[ 'combi_model' ];
1537
		}
1538
		
1539
		if( $this->coo_scheme->v_data_array['export_attributes'] == 1 && isset( $p_data_array['products_attributes_id'] ) )
1540
		{
1541
			// contains attributes
1542
			if( $t_return != '' && $p_data_array[ 'attributes_model' ] != '' )
1543
			{
1544
				$t_return .= '-';
1545
			}
1546
			$t_return .= $p_data_array[ 'attributes_model' ];
1547
		}
1548
		
1549
		return $t_return;
1550
	}
1551
	
1552
	protected function p_ean($p_data_array)
1553
	{
1554
		$t_return = trim($p_data_array['products_ean']);
1555
		if($this->_use_properties($p_data_array) && trim($p_data_array['combi_ean']) != '')
1556
		{
1557
			$t_return = $p_data_array['combi_ean'];
1558
		}
1559
		
1560
		return $t_return;
1561
	}
1562
	
1563
	protected function p_expiration_date($p_data_array)
1564
	{
1565
		$t_return = $p_data_array['expiration_date'];
1566
		$t_return = str_replace('0000-00-00', '', $t_return);
1567
		
1568
		return $t_return;
1569
	}
1570
	
1571
	protected function p_quantity( $p_data_array )
1572
	{
1573
		$t_return = $p_data_array[ 'products_quantity' ];
1574
		
1575
		if($this->_use_properties($p_data_array) 
1576
				&& (($p_data_array['use_properties_combis_quantity'] == 0 && STOCK_CHECK == 'true' && ATTRIBUTE_STOCK_CHECK == 'true') 
1577
				|| $p_data_array['use_properties_combis_quantity'] == 2))
1578
		{
1579
			$t_return = $p_data_array['combi_quantity'];
1580
		}
1581
		
1582
		return $t_return;
1583
	}
1584
	
1585
	protected function p_quantity_floor( $p_data_array )
1586
	{
1587
		$t_return = $this->p_quantity($p_data_array);
1588
		
1589
		if ($t_return < 0)
1590
		{
1591
			$t_return = 0;
1592
		}
1593
		else
1594
		{
1595
			$t_return = floor($t_return);
1596
		}
1597
		
1598
		return $t_return;
1599
	}
1600
	
1601
	protected function p_shipping_status_name( $p_data_array)
1602
	{
1603
		$t_return = '';
1604
		if(isset($p_data_array['shipping_status_name.' . $this->v_language_array['code']]))
1605
		{
1606
			$t_return = $p_data_array['shipping_status_name.' . $this->v_language_array['code']];
1607
		}
1608
		else
1609
		{
1610
			$t_return = $p_data_array['shipping_status_name'];
1611
			if($this->_use_properties($p_data_array) && $p_data_array['use_properties_combis_shipping_time'] == 1)
1612
			{
1613
				$t_return = $this->coo_shipping_status->get_shipping_status_name($p_data_array['combi_shipping_status_id'], $this->coo_scheme->v_data_array['languages_id']);
1614
			}
1615
		}
1616
		
1617
		return $t_return;
1618
	}
1619
	
1620
	protected function vpe_name( $p_data_array )
1621
	{
1622
		$t_vpe_name = '';
1623
		
1624
		// eigenschaften
1625
		if($this->coo_scheme->v_data_array['export_properties'] == 1 
1626
				&& isset($p_data_array[ 'products_properties_combis_id' ]) 
1627
				&& $p_data_array[ 'products_properties_combis_id' ] > 0
1628
				&& $p_data_array['combi_vpe_value'] != 0 
1629
				&& $p_data_array['combi_vpe_id'] != 0)
1630
		{
1631
			$t_vpe_name = $this->coo_vpe_source->get_products_vpe_name($p_data_array['combi_vpe_id'], $this->coo_scheme->v_data_array['languages_id']);
1632
		}
1633
		// attribute
1634
		elseif($this->coo_scheme->v_data_array['export_attributes'] == 1 
1635
				&& (int)$p_data_array['products_attributes_id'] > 0 
1636
				&& (int)$p_data_array['products_vpe_id'] > 0 
1637
				&& (double)$p_data_array['gm_vpe_value'] > 0)
1638
		{
1639
			$t_vpe_name = $this->coo_vpe_source->get_products_vpe_name($p_data_array['products_vpe_id'], $this->coo_scheme->v_data_array['languages_id']);
1640
		}
1641
		elseif($p_data_array['products_vpe_value'] != 0 && $p_data_array['products_vpe'] != 0)
1642
		{
1643
			$t_vpe_name = $this->coo_vpe_source->get_products_vpe_name($p_data_array['products_vpe'], $this->coo_scheme->v_data_array['languages_id']);
1644
		}
1645
		
1646
		return $t_vpe_name;
1647
	}
1648
	
1649
	protected function vpe_value($p_data_array)
1650
	{
1651
		$t_return = '';
1652
		
1653
		// eigenschaften
1654
		if($this->coo_scheme->v_data_array['export_properties'] == 1 
1655
				&& isset($p_data_array[ 'products_properties_combis_id' ]) 
1656
				&& $p_data_array[ 'products_properties_combis_id' ] > 0
1657
				&& $p_data_array['combi_vpe_value'] != 0 
1658
				&& $p_data_array['combi_vpe_id'] != 0)
1659
		{
1660
			$t_return = $p_data_array['combi_vpe_value'];
1661
		}
1662
		// attribute
1663
		elseif($this->coo_scheme->v_data_array['export_attributes'] == 1 
1664
				&& (int)$p_data_array['products_attributes_id'] > 0 
1665
				&& (int)$p_data_array['products_vpe_id'] > 0 
1666
				&& (double)$p_data_array['gm_vpe_value'] > 0)
1667
		{
1668
			$t_return = $p_data_array['gm_vpe_value'];
1669
		}
1670
		elseif($p_data_array['products_vpe_value'] != 0 && $p_data_array['products_vpe'] != 0)
1671
		{
1672
			$t_return = $p_data_array['products_vpe_value'];
1673
		}
1674
		
1675
		return $t_return;
1676
	}
1677

    
1678

    
1679
	protected function p_personal_offer($p_data_array, $p_customer_status_id)
1680
	{
1681
		$t_personal_offers = '';
1682
		$c_customer_status_id = (int)$p_customer_status_id;
1683
		$this->_build_personal_offers_array($p_customer_status_id);
1684
		
1685
		if(isset($this->v_personal_offers_array[$c_customer_status_id][(int)$p_data_array['products_id']]['string']))
1686
		{
1687
			$t_personal_offers = implode('::', $this->v_personal_offers_array[$c_customer_status_id][(int)$p_data_array['products_id']]['string']);
1688
		}
1689
		
1690
		return $t_personal_offers;
1691
	}
1692
	
1693
	protected function p_group_permission($p_data_array, $p_customer_status_id)
1694
	{
1695
		return isset($p_data_array['group_permission_' . $p_customer_status_id]) ? $p_data_array['group_permission_' . $p_customer_status_id] : '';
1696
	}
1697
	
1698
	protected function p_tax($p_data_array)
1699
	{
1700
		return xtc_get_tax_rate($p_data_array['products_tax_class_id']);
1701
	}
1702
	
1703
	protected function p_attribute($p_data_array)
1704
	{
1705
		$t_return = '';
1706
		
1707
		if( $this->coo_scheme->v_data_array[ 'export_attributes' ] == 1 && isset( $p_data_array[ 'products_attributes_id' ] ) )
1708
		{
1709
			$t_return .= $p_data_array[ 'products_options_name' ] . ': ' . $p_data_array[ 'products_options_values_name' ];
1710
		}
1711
		
1712
		return $t_return;
1713
	}
1714
	
1715
	public function set_product_ids_array(&$p_product_ids_array)
1716
	{
1717
		$this->v_product_ids_array = $p_product_ids_array;
1718
	}
1719
	
1720
	protected function _build_image_data_array()
1721
	{
1722
		if(empty($this->v_image_data_array))
1723
		{
1724
			$t_sql = "SELECT 
1725
							i.products_id,
1726
							a.language_id,
1727
							a.gm_alt_text,
1728
							i.image_nr,
1729
							i.image_name						
1730
						FROM 
1731
							" . TABLE_PRODUCTS_IMAGES. " i
1732
						LEFT JOIN gm_prd_img_alt AS a ON (a.image_id = i.image_id AND a.products_id IN (" . implode(',', $this->v_product_ids_array) . ") AND a.products_id = i.products_id)
1733
						WHERE 
1734
							i.products_id IN (" . implode(',', $this->v_product_ids_array) . ")";
1735
			$t_result = xtc_db_query($t_sql);
1736
			while($t_result_array = xtc_db_fetch_array($t_result))
1737
			{
1738
				$this->v_image_data_array[$t_result_array['products_id']][$t_result_array['image_nr']][$t_result_array['language_id']]['gm_alt_text'] = $t_result_array['gm_alt_text'];
1739
				$this->v_image_data_array[$t_result_array['products_id']][$t_result_array['image_nr']]['image_name'] = $t_result_array['image_name'];
1740
			}
1741
		}			
1742
	}
1743
	
1744
	protected function _build_additional_field_data_array()
1745
	{
1746
		if(empty($this->v_additional_field_data_array))
1747
		{
1748
			$t_sql = "SELECT
1749
							af.additional_field_id,
1750
							afv.item_id,
1751
							afvd.language_id,
1752
							afvd.value
1753
						FROM 
1754
							additional_fields af
1755
						LEFT JOIN
1756
							additional_field_values afv ON (afv.additional_field_id = af.additional_field_id)
1757
						LEFT JOIN
1758
							additional_field_value_descriptions afvd ON (afv.additional_field_value_id = afvd.additional_field_value_id)
1759
						WHERE
1760
							af.item_type = 'product' AND
1761
							afv.item_id IN (" . implode(',', $this->v_product_ids_array) . ")";
1762
			$t_result = xtc_db_query($t_sql);
1763
			while($t_result_array = xtc_db_fetch_array($t_result))
1764
			{
1765
				$this->v_additional_field_data_array[$t_result_array['item_id']][$t_result_array['additional_field_id']][$t_result_array['language_id']] = $t_result_array['value'];
1766
			}
1767
		}			
1768
	}
1769
	
1770
	protected function _build_personal_offers_array($p_customer_status_id)
1771
	{
1772
		$c_customer_status_id = (int)$p_customer_status_id;
1773
		
1774
		if(!isset($this->v_personal_offers_array[$c_customer_status_id]))
1775
		{
1776
			$t_sql = "SELECT 
1777
							products_id,
1778
							quantity, 
1779
							personal_offer 
1780
						FROM " . TABLE_PERSONAL_OFFERS_BY . $c_customer_status_id . " 
1781
						WHERE 
1782
							products_id IN (" . implode(',', $this->v_product_ids_array) . ") AND
1783
							personal_offer > 0
1784
						ORDER BY quantity";
1785
			$t_result = xtc_db_query($t_sql);
1786
			while($t_result_array = xtc_db_fetch_array($t_result))
1787
			{
1788
				$this->v_personal_offers_array[$c_customer_status_id][$t_result_array['products_id']]['price'][(double)$t_result_array['quantity']] = (double)$t_result_array['personal_offer'];
1789
				$this->v_personal_offers_array[$c_customer_status_id][$t_result_array['products_id']]['string'][(double)$t_result_array['quantity']] = (double)$t_result_array['quantity'] . ':' . (double)$t_result_array['personal_offer'];
1790
			}
1791
		}		
1792
	}
1793
	
1794
	protected function _use_properties($p_data_array)
1795
	{
1796
		if($this->coo_scheme->v_data_array['export_properties'] == 1 
1797
				&& isset( $p_data_array['products_properties_combis_id'] ) 
1798
				&& (int)$p_data_array['products_properties_combis_id'] > 0)
1799
		{
1800
			return true;
1801
		}
1802
		
1803
		return false;
1804
	}
1805
	
1806
	protected function _use_attributes($p_data_array)
1807
	{
1808
		if($this->coo_scheme->v_data_array['export_attributes'] == 1 
1809
				&& isset($p_data_array['products_attributes_id']) 
1810
				&& (int)$p_data_array['products_attributes_id'] > 0)
1811
		{
1812
			return true;
1813
		}
1814
		
1815
		return false;
1816
	}
1817
	
1818
	public function _get_combi_value_names($p_combi_id)
1819
	{
1820
		$c_combi_id = (int)$p_combi_id;
1821
		
1822
		if($c_combi_id === 0)
1823
		{
1824
			$this->combi_value_names_array = array();
1825
			return;
1826
		}
1827
		
1828
		$this->combi_value_names_array = array();
1829
		
1830
		$t_sql = "SELECT 
1831
						properties_id,
1832
						properties_values_id,
1833
						values_name,
1834
						language_id
1835
					FROM products_properties_index
1836
					WHERE 
1837
						products_properties_combis_id = '" . $c_combi_id . "'";
1838
		$t_result = xtc_db_query($t_sql);
1839
		while($t_result_array = xtc_db_fetch_array($t_result))
1840
		{
1841
			$this->combi_value_names_array[$t_result_array['properties_id']][$t_result_array['language_id']] = array();		
1842
			$this->combi_value_names_array[$t_result_array['properties_id']][$t_result_array['language_id']]['id'] = $t_result_array['properties_values_id'];		
1843
			$this->combi_value_names_array[$t_result_array['properties_id']][$t_result_array['language_id']]['name'] = $t_result_array['values_name'];		
1844
		}
1845
	}
1846
	
1847
	protected function property($p_data_array, $p_property_id)
1848
	{
1849
		$t_property = '';
1850
		
1851
		if(array_key_exists($p_property_id, $this->combi_value_names_array))
1852
		{
1853
			$t_property = $this->combi_value_names_array[$p_property_id][$this->_get_language_id()]['name'];
1854
		}
1855
		
1856
		return $t_property;
1857
	}
1858
	
1859
	protected function _init_property_names()
1860
	{
1861
		$t_sql = 'SELECT 
1862
						properties_id,
1863
						language_id,
1864
						properties_name
1865
					FROM properties_description';
1866
		$t_result = xtc_db_query($t_sql);
1867
		
1868
		while($t_result_array = xtc_db_fetch_array($t_result))
1869
		{
1870
			$this->property_names_array[$t_result_array['properties_id']][$t_result_array['language_id']] = $t_result_array['properties_name'];
1871
		}		
1872
	}
1873

    
1874

    
1875
	protected function truncate($p_string, array $p_params_array)
1876
	{
1877
		if(empty($p_params_array))
1878
		{
1879
			return $p_string;
1880
		}
1881
		
1882
		$t_truncated_string = $p_string;
1883
		
1884
		if($p_params_array[0] > 0 && strlen_wrapper($p_string) > $p_params_array[0])
1885
		{
1886
			$etc = isset($p_params_array[1]) ? $p_params_array[1] : '';
1887
			
1888
			if(strlen($etc) >= 2 && substr($etc, 0, 1) == '"' && substr($etc, -1) == '"')
1889
			{
1890
				$etc = substr($etc, 1, -1);
1891
			}
1892
			
1893
			$length = (int)$p_params_array[0];
1894
			$length -= min($p_params_array[0], strlen_wrapper($etc));
1895
			$t_truncated_string = preg_replace('/\s+?(\S+)?$/', '', substr_wrapper($t_truncated_string, 0, $length+1));
1896
			
1897
			return substr_wrapper($t_truncated_string, 0, $length) . $etc;
1898
		}
1899
		
1900
		return $t_truncated_string;
1901
	}
1902
}
    (1-1/1)