Projekt

Allgemein

Profil

GX-Bug #60045 » ProductInfoContentView.inc.php

Till Tepelmann, 24.12.2018 13:08

 
1
<?php
2
/* --------------------------------------------------------------
3
   ProductInfoContentView.inc.php 2018-10-29
4
   Gambio GmbH
5
   http://www.gambio.de
6
   Copyright (c) 2018 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
   based on:
13
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
14
   (c) 2002-2003 osCommerce(product_info.php,v 1.94 2003/05/04); www.oscommerce.com
15
   (c) 2003      nextcommerce (product_info.php,v 1.46 2003/08/25); www.nextcommerce.org
16
   (c) 2003 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: product_info.php 1320 2005-10-25 14:21:11Z matthias $)
17

    
18

    
19
   Released under the GNU General Public License
20
   -----------------------------------------------------------------------------------------
21
   Third Party contribution:
22
   Customers Status v3.x  (c) 2002-2003 Copyright Elari elari@free.fr | www.unlockgsm.com/dload-osc/ | CVS : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/elari/?sortby=date#dirlist
23
   New Attribute Manager v4b                            Autor: Mike G | mp3man@internetwork.net | http://downloads.ephing.com
24
   Cross-Sell (X-Sell) Admin 1                          Autor: Joshua Dechant (dreamscape)
25
   Released under the GNU General Public License
26
   ---------------------------------------------------------------------------------------*/
27

    
28
// include needed functions
29
require_once DIR_FS_INC . 'xtc_get_download.inc.php';
30
require_once DIR_FS_INC . 'xtc_delete_file.inc.php';
31
require_once DIR_FS_INC . 'xtc_get_all_get_params.inc.php';
32
require_once DIR_FS_INC . 'xtc_date_long.inc.php';
33
require_once DIR_FS_INC . 'xtc_draw_hidden_field.inc.php';
34
require_once DIR_FS_INC . 'xtc_image_button.inc.php';
35
require_once DIR_FS_INC . 'xtc_draw_form.inc.php';
36
require_once DIR_FS_INC . 'xtc_draw_input_field.inc.php';
37
require_once DIR_FS_INC . 'xtc_image_submit.inc.php';
38
require_once DIR_FS_INC . 'xtc_check_categories_status.inc.php';
39
require_once DIR_FS_INC . 'xtc_get_products_mo_images.inc.php';
40
require_once DIR_FS_INC . 'xtc_get_vpe_name.inc.php';
41
require_once DIR_FS_INC . 'get_cross_sell_name.inc.php';
42
require_once DIR_FS_INC . 'xtc_get_products_stock.inc.php';
43
require_once DIR_FS_CATALOG . 'gm/inc/gm_prepare_number.inc.php';
44

    
45
/**
46
 * Class ProductInfoContentView
47
 */
48
class ProductInfoContentView extends ContentView
49
{
50
	protected $getArray  = array(); // $_GET
51
	protected $postArray = array(); // $_POST
52

    
53
	protected $cheapestCombiArray   = array();
54
	protected $combiId              = 0;
55
	protected $currency             = '';
56
	protected $currentCategoryId    = 0;
57
	protected $currentCombiArray    = array();
58
	protected $customerDiscount     = 0.0;
59
	protected $fsk18DisplayAllowed  = true;
60
	protected $fsk18PurchaseAllowed = true;
61
	protected $customerStatusId     = -1;
62
	protected $hasProperties        = false;
63
	protected $languageId           = 0;
64
	protected $language             = '';
65
	protected $lastListingSql       = '';
66
	protected $main;
67
	protected $product;
68
	protected $productPriceArray    = array();
69
	protected $showGraduatedPrices  = false;
70
	protected $showPrice            = true;
71
	protected $xtcPrice;
72
	protected $maxImageHeight = 0;
73
	protected $additionalFields		= array();
74
	protected $offerAggregationLimit = 100;
75

    
76

    
77
	function __construct($p_template = 'default')
78
	{
79
		parent::__construct();
80
		$filepath = DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/module/product_info/';
81

    
82
		// get default template
83
		$c_template = $this->get_default_template($filepath, $p_template);
84

    
85
		$this->set_content_template('module/product_info/' . $c_template);
86
		$this->set_flat_assigns(true);
87
	}
88

    
89

    
90
	function prepare_data()
91
	{
92
		if($this->product instanceof product && $this->product->isProduct())
93
		{
94
			$this->_setPriceData();
95

    
96
			$this->_assignProductData();
97

    
98
			$this->_assignProductNavigator();
99
			$this->_assignFormTagData();
100
			$this->_assignWidgets();
101
			$this->_assignReviews();
102
			$this->_assignProductLists();
103
			$this->_assignItemCondition();
104
			$this->_assignRichSnippetData();
105

    
106
			// TODO move to control
107
			$this->_updateProductViewsStatistic();
108
			$this->_updateTracking();
109
			
110
			// test google analytics json
111
			//$serializer = new GAProductSerializer();
112
			//
113
			//$productId  = new IdType($this->product->data['products_id']);
114
			//$languageId = new IdType($_SESSION['languages_id']);
115
			//
116
			//$this->set_content_data('easyJson', $serializer->encode(GoogleAnalyticsServiceFactory::frontendService()
117
			//                                                                                     ->getProductsDataById($productId,
118
			//                                                                                                           $languageId),
119
			//                                                        JSON_PRETTY_PRINT));
120
		}
121
	}
122

    
123

    
124
	public function get_html()
125
	{
126
		if(($this->product instanceof product) === false || !$this->product->isProduct())
127
		{
128
			// product not found in database
129
			$error = TEXT_PRODUCT_NOT_FOUND;
130

    
131
			/* @var ErrorMessageContentView $coo_error_message */
132
			$errorView = MainFactory::create_object('ErrorMessageContentView');
133
			$errorView->set_error($error);
134
			$htmlOutput = $errorView->get_html();
135
		}
136
		else
137
		{
138
			$this->prepare_data();
139
			$htmlOutput = $this->build_html();
140
		}
141

    
142
		return $htmlOutput;
143
	}
144

    
145

    
146
	protected function _assignProductData()
147
	{
148
		// assign properties and set $this->hasProperties flag
149
		$this->_setPropertiesData();
150

    
151
		$this->_assignAttributes();
152
		$this->_assignDate();
153
		$this->_assignDeactivatedButtonFlag();
154
		$this->_assignGPrint();
155
		$this->_assignDescription();
156
		$this->_assignDiscount();
157
		$this->_assignEan();
158
		$this->_assignGraduatedPrices();
159
		$this->_assignId();
160
		$this->_assignImageData();
161
		$this->_assignImageMaxHeight();
162
		$this->_assignLegalAgeFlag();
163
		$this->_assignModelNumber();
164
		$this->_assignName();
165
		$this->_assignNumberOfOrders();
166
		$this->_assignPrice();
167
		$this->_assignProductUrl();
168
		$this->_assignQuantity();
169
		$this->_assignShippingTime();
170
		$this->_assignStatus();
171
		$this->_assignVpe();
172
		$this->_assignWeight();
173
		$this->_assignAdditionalFields();
174

    
175
		if($this->_showPrice())
176
		{
177
			$this->_assignShippingLink();
178
			$this->_assignTaxInfo();
179
		}
180

    
181
		if($this->_productIsForSale())
182
		{
183
			$this->_assignInputFieldQuantity();
184
			$this->_assignPayPalInstallments();
185
		}
186
		else
187
		{
188
			$this->_assignDeprecatedIdHiddenField();
189
		}
190

    
191
		$this->set_content_data('showManufacturerImages', gm_get_conf('SHOW_MANUFACTURER_IMAGE_PRODUCT_DETAILS'));
192
		$this->set_content_data('showProductRibbons', gm_get_conf('SHOW_PRODUCT_RIBBONS'));
193

    
194
		$showRating = false;
195
		if(gm_get_conf('ENABLE_RATING') === 'true')
196
		{
197
			$showRating = true;
198
		}
199
		$this->content_array['showRating'] = $showRating;
200
	}
201

    
202
	protected function _assignPayPalInstallments()
203
	{
204
		if(strtolower((string)@constant('MODULE_PAYMENT_PAYPAL3_INSTALLMENTS_STATUS')) == true)
205
		{
206
			$output = '';
207
			$paypalConfiguration = MainFactory::create('PayPalConfigurationStorage');
208
			$showSpecific = (bool)$paypalConfiguration->get('show_installments_presentment_specific_product');
209
			$hasAttributes = trim($this->content_array['MODULE_product_options']) !== '';
210
			$showComputed = $hasAttributes === false &&
211
			                $this->hasProperties === false &&
212
			                (bool)$paypalConfiguration->get('show_installments_presentment_specific_computed');
213
			$productPrice = $this->productPriceArray['plain'];
214
			$paypalInstallments = MainFactory::create('PayPalInstallments');
215
			if($showSpecific && $productPrice >= $paypalInstallments->getMinimumAmount()['amount'] && $productPrice <= $paypalInstallments->getMaximumAmount()['amount'])
216
			{
217
				if($showComputed == true)
218
				{
219
					try
220
					{
221
						$response = $paypalInstallments->getInstallmentInfo($productPrice, $_SESSION['currency'], 'DE');
222
						if(!empty($response->financing_options[0]->qualifying_financing_options))
223
						{
224
							$representativeOption = $paypalInstallments->getRepresentativeOption($response->financing_options[0]->qualifying_financing_options);
225
							$specificContentView = MainFactory::create('PayPalInstallmentSpecificUpstreamPresentmentContentView');
226
							$specificContentView->qualifyingOptions           = $response->financing_options[0]->qualifying_financing_options;
227
							$specificContentView->nonQualifyingOptions        = $response->financing_options[0]->non_qualifying_financing_options;
228
							$specificContentView->lender                      = implode(', ', [COMPANY_NAME, TRADER_STREET .' '. TRADER_STREET_NUMBER, TRADER_ZIPCODE .' '. TRADER_LOCATION]);
229
							$specificContentView->currency                    = $_SESSION['currency'];
230
							$specificContentView->cashPurchasePrice           = $productPrice;
231
							$specificContentView->numberOfInstallments        = $representativeOption->credit_financing->term;
232
							$specificContentView->borrowingRate               = $representativeOption->credit_financing->nominal_rate;
233
							$specificContentView->annualPercentageRate        = $representativeOption->credit_financing->apr;
234
							$specificContentView->installmentAmount           = $representativeOption->monthly_payment->value;
235
							$specificContentView->totalAmount                 = $representativeOption->total_cost->value;
236
							$specificContentView->representativeFinancingCode = $representativeOption->credit_financing->financing_code;
237
							$output = $specificContentView->get_html();
238
						}
239
					}
240
					catch(Exception $e)
241
					{
242
						$output = sprintf("<!-- PPI Exception -->\n");
243
					}
244
				}
245
				else
246
				{
247
					if($this->hasProperties || $hasAttributes)
248
					{
249
						$amount = 'dynamic';
250
					}
251
					else
252
					{
253
						$amount = $productPrice;
254
					}
255
					$contentView = MainFactory::create('ContentView');
256
					$contentView->set_content_template('module/paypalinstallmentspecificstatic.html');
257
					$contentView->set_flat_assigns(true);
258
					$contentView->set_caching_enabled(false);
259
					$contentView->set_content_data('amount', $amount);
260
					$output = $contentView->get_html();
261
				}
262
			}
263
			else
264
			{
265
				$contentView = MainFactory::create('ContentView');
266
				$contentView->set_content_template('module/paypalinstallmentspecificoutofbounds.html');
267
				$contentView->set_flat_assigns(true);
268
				$contentView->set_caching_enabled(false);
269
				$output = $contentView->get_html();
270
			}
271
			$this->set_content_data('PayPalInstallments', $output);
272
		}
273
	}
274

    
275
	protected function _assignProductLists()
276
	{
277
		$this->_assignAlsoPurchased();
278
		$this->_assignCrossSelling();
279
		$this->_assignReverseCrossSelling();
280
		$this->_assignYoochoose();
281
	}
282

    
283

    
284
	protected function _assignWidgets()
285
	{
286
		$this->_assignKlarna();
287
		$this->_assignWishlist();
288

    
289
		$this->_assignSocialServices();
290
		$this->_assignTellAFriend();
291
		$this->_assignPriceOffer();
292
		$this->_assignPrintLink();
293
	}
294

    
295

    
296
	protected function _assignProductNavigator()
297
	{
298
		if(ACTIVATE_NAVIGATOR == 'true')
299
		{
300
			/* @var ProductNavigatorContentView $view */
301
			$view = MainFactory::create_object('ProductNavigatorContentView');
302
			$view->setProduct($this->product);
303
			$view->setCategoryId($this->currentCategoryId);
304
			$view->setLastListingSql($this->lastListingSql);
305
			$view->setFSK18DisplayAllowed((int)$this->fsk18DisplayAllowed);
306
			$view->setCustomerStatusId($this->customerStatusId);
307
			$view->setLanguageId($this->languageId);
308
			$html = $view->get_html();
309
			$this->set_content_data('PRODUCT_NAVIGATOR', $html);
310
		}
311
	}
312

    
313

    
314
	protected function _updateProductViewsStatistic()
315
	{
316
		$query = 'UPDATE ' . TABLE_PRODUCTS_DESCRIPTION . '
317
					SET products_viewed = products_viewed+1
318
					WHERE
319
						products_id = ' . (int)$this->product->data['products_id'] . ' AND
320
						language_id = ' . (int)$this->languageId;
321

    
322
		xtc_db_query($query);
323
	}
324

    
325

    
326
	protected function _assignKlarna()
327
	{
328
		$partpay_active = strtoupper((string)@constant('MODULE_PAYMENT_KLARNA2_PARTPAY_STATUS')) == 'TRUE';
329
		if($partpay_active === true && gm_get_conf('KLARNA_SHOW_PRODUCT_PARTPAY'))
330
		{
331
			$klarna = new GMKlarna();
332
			$this->set_content_data('KLARNA_WIDGET',
333
			                        $klarna->getWidgetCode($this->productPriceArray['plain'], 'product'));
334
		}
335
		else
336
		{
337
			$this->set_content_data('KLARNA_WIDGET', '');
338
		}
339
	}
340

    
341

    
342
	protected function _setPriceData()
343
	{
344
		$query  = 'SELECT products_properties_combis_id
345
					FROM products_properties_combis
346
					WHERE products_id = ' . (int)$this->product->data['products_id'];
347
		$result = xtc_db_query($query);
348

    
349
		if(xtc_db_num_rows($result) >= 1)
350
		{
351
			if(xtc_db_num_rows($result) == 1)
352
			{
353
				$row           = xtc_db_fetch_array($result);
354
				$this->combiId = $row['products_properties_combis_id'];
355
			}
356

    
357
			$coo_properties_control = MainFactory::create_object('PropertiesControl');
358
			if($this->combiId > 0)
359
			{
360
				// GET selected combi (GET)
361
				$this->currentCombiArray = $coo_properties_control->get_combis_full_struct($this->combiId,
362
				                                                                           $this->languageId);
363
			}
364
			if($this->currentCombiArray == false)
365
			{
366
				// GET CHEAPEST COMBI
367
				$this->cheapestCombiArray            = $coo_properties_control->get_cheapest_combi($this->product->data['products_id'],
368
				                                                                                   $this->languageId);
369
				$this->xtcPrice->showFrom_Attributes = true;
370
			}
371
		}
372

    
373
		$this->productPriceArray = $this->xtcPrice->xtcGetPrice($this->product->data['products_id'], true, 1,
374
		                                                        $this->product->data['products_tax_class_id'],
375
		                                                        $this->product->data['products_price'], 1);
376

    
377
		if(!empty($this->cheapestCombiArray) && $this->cheapestCombiArray['combi_price'] != 0)
378
		{
379
			$this->productPriceArray = $this->xtcPrice->xtcGetPrice($this->product->data['products_id'], true, 1,
380
			                                                        $this->product->data['products_tax_class_id'],
381
			                                                        $this->product->data['products_price'], 1, 0, true,
382
			                                                        true,
383
			                                                        $this->cheapestCombiArray['products_properties_combis_id']);
384
		}
385

    
386
		if(!empty($this->currentCombiArray) && $this->currentCombiArray['combi_price'] != 0)
387
		{
388
			$this->productPriceArray = $this->xtcPrice->xtcGetPrice($this->product->data['products_id'], true, 1,
389
			                                                        $this->product->data['products_tax_class_id'],
390
			                                                        $this->product->data['products_price'], 1, 0, true,
391
			                                                        true,
392
			                                                        $this->currentCombiArray['products_properties_combis_id']);
393
		}
394
	}
395

    
396

    
397
	protected function _assignAlsoPurchased()
398
	{
399
		/* @var AlsoPurchasedContentView $view */
400
		$view = MainFactory::create_object('AlsoPurchasedContentView');
401
		$view->set_coo_product($this->product);
402
		$html = $view->get_html();
403
		$this->set_content_data('MODULE_also_purchased', $html);
404
	}
405

    
406

    
407
	protected function _assignYoochoose()
408
	{
409
		if(defined('YOOCHOOSE_ACTIVE') && YOOCHOOSE_ACTIVE)
410
		{
411
			include_once(DIR_WS_INCLUDES . 'yoochoose/recommendations.php');
412
			include_once(DIR_WS_INCLUDES . 'yoochoose/functions.php');
413

    
414
			/* @var YoochooseAlsoInterestingContentView $view */
415
			$view = MainFactory::create_object('YoochooseAlsoInterestingContentView');
416
			$view->setProduct($this->product);
417
			$html = $view->get_html();
418
			$this->set_content_data('MODULE_yoochoose_also_interesting', $html);
419

    
420
			$yooHtml = '<img src="' . getTrackingURL('click', $this->product) . '" width="0" height="0" alt="">';
421

    
422
			if(array_key_exists('ycr', $this->getArray))
423
			{
424
				$yooHtml .= '<img src="' . getTrackingURL('follow', $this->product) . '" width="0" height="0" alt="">';
425
			}
426

    
427
			$this->set_content_data('MODULE_yoochoose_product_tracking', $yooHtml . "\n");
428
		}
429
	}
430

    
431

    
432
	protected function _assignAttributes()
433
	{
434
		// CREATE ProductAttributesContentView OBJECT
435
		/* @var ProductAttributesContentView $view */
436
		$view = MainFactory::create_object('ProductAttributesContentView');
437

    
438
		// SET TEMPLATE
439
		$filepath   = DIR_FS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/module/product_options/';
440
		$c_template = $view->get_default_template($filepath, $this->product->data['options_template']);
441
		$view->set_content_template('module/product_options/' . $c_template);
442

    
443
		// SET DATA
444
		$view->set_coo_product($this->product);
445
		$view->set_language_id($this->languageId);
446

    
447
		// GET HTML
448
		$html = $view->get_html();
449
		$this->set_content_data('MODULE_product_options', $html);
450
	}
451

    
452

    
453
	protected function _assignCrossSelling()
454
	{
455
		/* @var CrossSellingContentView $view */
456
		$view = MainFactory::create_object('CrossSellingContentView');
457
		$view->set_type('cross_selling');
458
		$view->set_coo_product($this->product);
459
		$html = $view->get_html();
460
		$this->set_content_data('MODULE_cross_selling', $html);
461
	}
462

    
463

    
464
	protected function _assignReverseCrossSelling()
465
	{
466
		if(ACTIVATE_REVERSE_CROSS_SELLING == 'true')
467
		{
468
			/* @var CrossSellingContentView $view */
469
			$view = MainFactory::create_object('CrossSellingContentView');
470
			$view->set_type('reverse_cross_selling');
471
			$view->set_coo_product($this->product);
472
			$html = $view->get_html();
473
			$this->set_content_data('MODULE_reverse_cross_selling', $html);
474
		}
475
	}
476

    
477

    
478
	protected function _assignRichSnippetData()
479
	{
480
		$isActive = (bool)$this->product->data['products_fsk18'] === false
481
		            && (STOCK_ALLOW_CHECKOUT === 'true' || (($this->product->data['products_quantity'] > 0) && STOCK_ALLOW_CHECKOUT === 'false'))
482
		            && (string)$this->product->data['gm_price_status'] === '0';
483
		if(!$isActive)
484
		{
485
			return;
486
		}
487
		
488
		$taxIncluded = (int)$_SESSION['customers_status']['customers_status_show_price_tax'] === 1;
489
		
490
		$itemCondition = 'NewCondition';
491
		if($this->content_array['ITEM_CONDITION'] === 'refurbished')
492
		{
493
			$itemCondition = 'RefurbishedCondition';
494
		}
495
		elseif($this->content_array['ITEM_CONDITION'] === 'used')
496
		{
497
			$itemCondition = 'UsedCondition';
498
		}
499
		
500
		$productsQuantity = xtc_get_products_stock($this->product->data['products_id']);
501
		$availability = $productsQuantity > 0 ? 'InStock' : 'OutOfStock';
502
		
503
		$linkedData = [
504
			'@context' => 'http://schema.org',
505
			'@type' => 'Product',
506
			'name' => $this->product->data['products_name'],
507
			'description' => $this->product->data['products_description'],
508
			'image' => [GM_HTTP_SERVER . DIR_WS_INFO_IMAGES . rawurlencode($this->product->data['products_image'])],
509
			'itemCondition' => $itemCondition,
510
			'offers' => [
511
				'@type' => 'Offer',
512
				'availability' => $availability,
513
				'price' => $this->productPriceArray['plain'],
514
				'priceCurrency' => $this->getCurrency(),
515
				'priceSpecification' => [
516
					'@type' => 'http://schema.org/PriceSpecification',
517
					'price' => $this->productPriceArray['plain'],
518
					'priceCurrency' => $this->getCurrency(),
519
					'valueAddedTaxIncluded' => $taxIncluded,
520
				]
521
			],
522
		];
523
		
524
		$additionalImagesArray = xtc_get_products_mo_images($this->product->data['products_id']);
525
		if(is_array($additionalImagesArray) && !empty($additionalImagesArray))
526
		{
527
			foreach($additionalImagesArray as $imageArray)
528
			{
529
				$linkedData['image'][] = GM_HTTP_SERVER . DIR_WS_INFO_IMAGES . rawurlencode($imageArray['image_name']);
530
			}
531
		}
532

    
533
		if(!empty($this->product->data['products_model']))
534
		{
535
			$linkedData['model'] = $this->product->data['products_model'];
536
		}
537
		
538
		if((float)$this->product->data['gm_min_order'] === 0)
539
		{
540
			$linkedData['offers']['availability'] = 'http://schema.org/OutOfStock';
541
		}
542
		
543
		if($this->content_array['ITEM_CONDITION'] === 'refurbished')
544
		{
545
			$linkedData['offers']['itemCondition'] = 'http://schema.org/RefurbishedCondition';
546
		}
547
		elseif($this->content_array['ITEM_CONDITION'] === 'used')
548
		{
549
			$linkedData['offers']['itemCondition'] = 'http://schema.org/UsedCondition';
550
		}
551
		
552
		if(in_array(strlen($this->product->data['products_ean']), [8, 12, 13, 14], true))
553
		{
554
			$offer['gtin' . strlen($this->product->data['products_ean'])] = $this->product->data['products_ean'];
555
		}
556
		
557
		if(!empty($this->product->data['manufacturers_id']))
558
		{
559
			/** @var \ManufacturerReadService $manufacturerReadService */
560
			$manufacturerReadService = StaticGXCoreLoader::getService('ManufacturerRead');
561
			$manufacturer = $manufacturerReadService->getById(new IdType((int)$this->product->data['manufacturers_id']));
562
			$linkedData['brand'] = [
563
				'@type' => 'Brand',
564
				'name' => $manufacturer->getName(),
565
			];
566
		}
567
		
568
		/** @var \VPEReadService $vpeReader */
569
		$vpeReader = StaticGXCoreLoader::getService('VPERead');
570
		if($this->product->data['products_vpe_value'] > 0 && (int)$this->product->data['products_vpe'])
571
		{
572
			$vpe = $vpeReader->getById(new IdType((int)$this->product->data['products_vpe']));
573
			$linkedData['offers']['priceSpecification']['@type'] = 'http://schema.org/UnitPriceSpecification';
574
			$linkedData['offers']['priceSpecification']['referenceQuantity'] = [
575
				'@type' => 'QuantitativeValue',
576
				'value' => $this->product->data['products_vpe_value'],
577
				'unitText' => $vpe->getName(new LanguageCode(new StringType(strtolower($_SESSION['language_code'])))),
578
			];
579
		}
580
		
581
		/** @var \xtcPrice_ORIGIN $xtcPrice */
582
		$xtcPrice = $this->getXtcPrice();
583

    
584
		$totalVariants = $this->getNumberOfVariants((int)$this->product->data['products_id']);
585
		if($totalVariants < $this->getOfferAggregationLimit())
586
		{
587
			$propertiesCombis = $this->getProductPropertiesCombis((int)$this->product->data['products_id']);
588
			if(!empty($propertiesCombis))
589
			{
590
				$linkedData['offers'] = [];
591
				foreach($propertiesCombis as $combi)
592
				{
593
					$combiPrice = $combi['combi_price'];
594
					$productPrice = $this->product->data['products_price'];
595
					if($combi['combi_price_type'] === 'calc' ||
596
					   $combi['combi_price_type'] === 'fix')
597
					{
598
						$combiPrice += $productPrice;
599
					}
600
					$combiPrice = $xtcPrice->xtcFormat($combiPrice, false, $this->product->data['products_tax_class_id'], true);
601
					/* output separate offers for variants */
602
					$offer = [
603
						'@type'              => 'Offer',
604
						'itemOffered'        => [
605
							'@type' => 'Product',
606
							'model' => $this->product->data['products_model'] . '-' . $combi['combi_model'],
607
						],
608
						'availability' => $combi['combi_quantity'] > 0 ? 'InStock' : 'OutOfStock',
609
						'priceSpecification' => [
610
							'@type'                 => 'http://schema.org/PriceSpecification',
611
							'price'                 => number_format($combiPrice, 2, '.', ''),
612
							'priceCurrency'         => $this->getCurrency(),
613
							'valueAddedTaxIncluded' => $taxIncluded,
614
						]
615
					];
616
					
617
					if(in_array(strlen($combi['combi_ean']), [8, 12, 13, 14], true))
618
					{
619
						$offer['gtin' . strlen($combi['combi_ean'])] = $combi['combi_ean'];
620
					}
621
					
622
					if((int)$combi['products_vpe_id'] !== 0)
623
					{
624
						$vpe                                              = $vpeReader->getById(new IdType((int)$combi['products_vpe_id']));
625
						$offer['priceSpecification']['@type']             = 'http://schema.org/UnitPriceSpecification';
626
						$offer['priceSpecification']['referenceQuantity'] = [
627
							'@type'    => 'QuantitativeValue',
628
							'value'    => $combi['vpe_value'],
629
							'unitText' => $vpe->getName(new LanguageCode(new StringType(strtolower($_SESSION['language_code'])))),
630
						];
631
					}
632
					$linkedData['offers'][] = $offer;
633
					unset($linkedData['availability']);
634
				}
635
			}
636
		}
637
		else
638
		{
639
			$productPrice = $this->product->data['products_price'];
640
			$db = StaticGXCoreLoader::getDatabaseQueryBuilder();
641
			$maxPropertiesCombisPriceResult = $db->query('SELECT products_id, MAX(IF(combi_price_type = \'fix\', combi_price, combi_price + ' . $productPrice . ')) AS max_price FROM `products_properties_combis` WHERE products_id = ' . (int)$this->product->data['products_id'] . ' GROUP BY products_id');
642
			$minPropertiesCombisPriceResult = $db->query('SELECT products_id, MIN(IF(combi_price_type = \'fix\', combi_price, combi_price + ' . $productPrice . ')) AS min_price FROM `products_properties_combis` WHERE products_id = ' . (int)$this->product->data['products_id'] . ' GROUP BY products_id');
643
			if($maxPropertiesCombisPriceResult->num_rows() > 0 && $minPropertiesCombisPriceResult->num_rows() > 0)
644
			{
645
				$maxPropertiesCombisPriceRow = $maxPropertiesCombisPriceResult->row_array();
646
				$maxPropertiesCombisPrice = $maxPropertiesCombisPriceRow['max_price'];
647
				$minPropertiesCombisPriceRow = $minPropertiesCombisPriceResult->row_array();
648
				$minPropertiesCombisPrice = $minPropertiesCombisPriceRow['min_price'];
649
				$minCombiPrice = $xtcPrice->xtcFormat($minPropertiesCombisPrice, false, $this->product->data['products_tax_class_id'], true);
650
				$maxCombiPrice = $xtcPrice->xtcFormat($maxPropertiesCombisPrice, false, $this->product->data['products_tax_class_id'], true);
651
			}
652
			else
653
			{
654
				$maxAttributesPriceOffsetResult = $db->query('SELECT options_id, MAX(if(price_prefix = \'-\', -1, 1) * options_values_price) AS max_modifier FROM `products_attributes` where products_id = ' . (int)$this->product->data['products_id'] . ' GROUP BY options_id');
655
				$minAttributesPriceOffsetResult = $db->query('SELECT options_id, MIN(if(price_prefix = \'-\', -1, 1) * options_values_price) AS min_modifier FROM `products_attributes` where products_id = ' . (int)$this->product->data['products_id'] . ' GROUP BY options_id');
656
				
657
				$maxAttributesPriceOffset = 0;
658
				foreach($maxAttributesPriceOffsetResult->result_array() as $maxAttributesPriceOffsetRow)
659
				{
660
					$maxAttributesPriceOffset += $maxAttributesPriceOffsetRow['max_modifier'];
661
				}
662
				$minAttributesPriceOffset = 0;
663
				foreach($minAttributesPriceOffsetResult->result_array() as $minAttributesPriceOffsetRow)
664
				{
665
					$minAttributesPriceOffset += $minAttributesPriceOffsetRow['min_modifier'];
666
				}
667
				
668
				$minCombiPrice = $xtcPrice->xtcFormat($productPrice + $minAttributesPriceOffset, false, $this->product->data['products_tax_class_id'], true);
669
				$maxCombiPrice = $xtcPrice->xtcFormat($productPrice + $maxAttributesPriceOffset, false, $this->product->data['products_tax_class_id'], true);
670
			}
671
			
672
			$linkedData['offers'] = [
673
				'@type'         => 'AggregateOffer',
674
				'lowPrice'      => $minCombiPrice,
675
				'highPrice'     => $maxCombiPrice,
676
				'priceCurrency' => $_SESSION['currency'],
677
				'offerCount'    => $totalVariants,
678
				//'valueAddedTaxIncluded' => $taxIncluded,
679
			];
680
		}
681
		
682
		
683
		$aggregateRating = $this->product->getAggregateRatingData();
684
		if($aggregateRating['count'] > 0)
685
		{
686
			$linkedData['aggregateRating'] = [
687
				'@type' => 'http://schema.org/AggregateRating',
688
				'ratingCount' => $aggregateRating['count'],
689
				'ratingValue' => $aggregateRating['averageRating'],
690
				'bestRating' => 5,
691
				'worstRating' => 1,
692
			];
693
		}
694
		
695
		$reviews = $this->product->getReviews(PRODUCT_REVIEWS_VIEW);
696
		if(count($reviews) > 0)
697
		{
698
			$linkedData['review'] = [];
699
			foreach($reviews as $review)
700
			{
701
				$linkedData['review'][] = [
702
					'@type' => 'http://schema.org/Review',
703
					'datePublished' => $review['DATE_CLEAN'],
704
					'author' => [
705
						'@type' => 'http://schema.org/Person',
706
						'name' => $review['AUTHOR'],
707
					],
708
					'url' => $review['URL'],
709
					'reviewBody' => $review['TEXT'],
710
					'reviewRating' => [
711
						'@type' => 'http://schema.org/Rating',
712
						'ratingValue' => $review['RATING_CLEAN'],
713
						'bestRating' => 5,
714
						'worstRating' => 1,
715
					]
716
				];
717
			}
718
		}
719
		
720
		$jsonLD = json_encode($linkedData/*, JSON_PRETTY_PRINT*/);
721

    
722
		$this->set_content_data('JSONLD', $jsonLD);
723
	}
724
 
725
	protected function getNumberOfVariants($productsId)
726
	{
727
		$db = StaticGXCoreLoader::getDatabaseQueryBuilder();
728
		/* properties */
729
		$propertiesCountRow = $db->select('COUNT(*) AS num_combis')
730
			->where('products_id', (int)$productsId)
731
			->get('products_properties_combis')
732
			->row_array();
733
		if((int)$propertiesCountRow['num_combis'] > 0)
734
		{
735
			return (int)$propertiesCountRow['num_combis'];
736
		}
737
		
738
		$attribsCounts = $db->select('`options_id`, COUNT(`options_id`) AS num_values')
739
		                    ->where('products_id', (int)$productsId)
740
		                    ->group_by('options_id')
741
		                    ->get('products_attributes')
742
		                    ->result_array();
743
		$totalAttributes = 0;
744
		if(!empty($attribsCounts))
745
		{
746
			$totalAttributes = 1;
747
			foreach($attribsCounts as $attribCount)
748
			{
749
				$totalAttributes *= $attribCount['num_values'];
750
			}
751
		}
752
		return $totalAttributes;
753
	}
754
	
755
	protected function getProductPropertiesCombis($productsId)
756
	{
757
		/* properties */
758
		$db = StaticGXCoreLoader::getDatabaseQueryBuilder();
759
		$combis = $db->where('products_id', (int)$productsId)
760
			->order_by('sort_order', 'ASC')
761
			->get('products_properties_combis')
762
			->result_array();
763
		if(!empty($combis))
764
		{
765
			return $combis;
766
		}
767
		
768
		/* attributes */
769
		$attributes = $db->where('products_id', (int)$productsId)
770
			->order_by('options_values_id', 'ASC')
771
			->order_by('sortorder', 'ASC')
772
			->get('products_attributes')
773
			->result_array();
774
		if(!empty($attributes))
775
		{
776
			$attributesLists = [];
777
			$attributeModels = [];
778
			$attributePrices = [];
779
			$attributeStocks = [];
780
			$combiEan = '';
781
			$combiVpeId = 0;
782
			$combiVpeValue = 0.0;
783
			foreach($attributes as $attribute)
784
			{
785
				$optionsId = $attribute['options_id'];
786
				$valuesId = $attribute['options_values_id'];
787
				if(!array_key_exists($optionsId, $attributesLists))
788
				{
789
					$attributesLists[$optionsId] = [];
790
				}
791
				$attributesLists[$optionsId][] = $valuesId;
792
				$attributeModels[$optionsId.'-'.$valuesId] = $attribute['attributes_model'];
793
				$priceFactor = $attribute['price_prefix'] === '-' ? -1 : 1;
794
				$attributePrices[$optionsId.'-'.$valuesId] = $priceFactor * $attribute['options_values_price'];
795
				$attributeStocks[$optionsId.'-'.$valuesId] = $attribute['attributes_stock'];
796
				$combiEan = (empty($combiEan) && !empty($attribute['gm_ean'])) ? $attribute['gm_ean'] : '';
797
				if($combiVpeId === 0 && (int)$attribute['products_vpe_id'] !== 0)
798
				{
799
					$combiVpeId = (int)$attribute['products_vpe_id'];
800
					$combiVpeValue = (float)$attribute['gm_vpe_value'];
801
				}
802
			}
803
			$options = array_keys($attributesLists);
804
			$counts = [];
805
			foreach($options as $optionId)
806
			{
807
				$counts[] = count($attributesLists[$optionId]);
808
			}
809
			
810
			$attribSet = array_fill(0, count($attributesLists), 0);
811
			$attributeCombis = [];
812
			do
813
			{
814
				$optionsToValues = [];
815
				foreach($options as $oIndex => $optionId)
816
				{
817
					$valuesId = $attributesLists[$options[$oIndex]][$attribSet[$oIndex]];
818
					$optionsToValues[$optionId] = $valuesId;
819
				}
820
				$uPID = (string)$productsId;
821
				$combiModel = '';
822
				$combiPrice = 0.0;
823
				$combiQuantity = 999999;
824
				foreach($optionsToValues as $optionsId => $valuesId)
825
				{
826
					$uPID .= '{' . $optionsId . '}' . $valuesId;
827
					$combiModel .= empty($combiModel) ? '' : '-';
828
					$combiModel .= $attributeModels[$optionsId . '-' . $valuesId];
829
					$combiPrice += $attributePrices[$optionsId . '-' . $valuesId];
830
					$combiQuantity = min($combiQuantity, (float)$attributeStocks[$optionsId . '-' . $valuesId]);
831
				}
832
				$attributeCombis[] = [
833
					'products_id'        => $productsId,
834
					'unique_products_id' => $uPID,
835
					'combi_model'        => $combiModel,
836
					'combi_ean'          => $combiEan,
837
					'combi_quantity'     => $combiQuantity,
838
					'combi_price_type'   => 'calc',
839
					'combi_price'        => $combiPrice,
840
					'products_vpe_id'    => $combiVpeId,
841
					'vpe_value'          => $combiVpeValue,
842
				];
843
			} while($this->incrementArray($attribSet, $counts) !== false);
844
			
845
			return $attributeCombis;
846
		}
847
		
848
		return [];
849
	}
850
	
851
	
852
	/**
853
	 * Helper for iterating through combinations of attributes.
854
	 *
855
	 * @param $attribSet
856
	 * @param $counts
857
	 *
858
	 * @return bool
859
	 */
860
	protected function incrementArray(&$attribSet, $counts)
861
	{
862
		$incPos = 0;
863
		while(true)
864
		{
865
			if($attribSet[$incPos] < $counts[$incPos] - 1)
866
			{
867
				$attribSet[$incPos]++;
868
				break;
869
			}
870
			else
871
			{
872
				if($incPos < count($counts) - 1)
873
				{
874
					$attribSet[$incPos] = 0;
875
					$incPos++;
876
				}
877
				else
878
				{
879
					return false;
880
				}
881
			}
882
		}
883
		return true;
884
	}
885
	
886
	protected function _assignItemCondition()
887
    {
888
        $itemCondition = 'new';
889
        
890
        $query = 'SELECT `google_export_condition`
891
                  FROM `products_item_codes` 
892
                  WHERE `products_id` = ' . (int)$this->product->data['products_id'];
893
        
894
        $result = xtc_db_query($query);
895
    
896
        if(xtc_db_num_rows($result))
897
        {
898
            $row = xtc_db_fetch_array($result);
899
            
900
            if ($row['google_export_condition'] === 'gebraucht')
901
            {
902
                $itemCondition = 'used';
903
            }
904
            elseif ($row['google_export_condition'] === 'erneuert')
905
            {
906
                $itemCondition = 'refurbished';
907
            }
908
        }
909
        
910
        $this->set_content_data('ITEM_CONDITION', $itemCondition);
911
	}
912

    
913

    
914
	protected function _assignReviews()
915
	{
916
		// Aggregate review data
917
		$this->set_content_data('AGGREGATE_REVIEW_DATA', $this->product->getAggregateRatingData());
918

    
919
		/* @var ProductReviewsContentView $view */
920
		$view = MainFactory::create_object('ProductReviewsContentView');
921
		$view->setProduct($this->product);
922
		$html = $view->get_html();
923
		if(trim($html) !== '')
924
		{
925
			$this->set_content_data('MODULE_products_reviews', $html);
926
		}
927
	}
928

    
929

    
930
	protected function _assignProductUrl()
931
	{
932
		if(xtc_not_null($this->product->data['products_url']))
933
		{
934
			$this->set_content_data('PRODUCTS_URL', sprintf(TEXT_MORE_INFORMATION, xtc_href_link(FILENAME_REDIRECT,
935
			                                                                                     'action=product&id='
936
			                                                                                     . $this->product->data['products_id'],
937
			                                                                                     'NONSSL', true)));
938
		}
939
	}
940

    
941

    
942
	protected function _assignDate()
943
	{
944
		if($this->product->data['products_date_available'] > date('Y-m-d H:i:s'))
945
		{
946
			$this->set_content_data('PRODUCTS_DATE_AVIABLE', sprintf(TEXT_DATE_AVAILABLE,
947
			                                                         xtc_date_long($this->product->data['products_date_available'])));
948
		}
949
		else
950
		{
951
			if($this->product->data['products_date_added'] != '1000-01-01 00:00:00'
952
			   && $this->product->data['gm_show_date_added'] == 1
953
			)
954
			{
955
				$this->set_content_data('PRODUCTS_ADDED', sprintf(TEXT_DATE_ADDED,
956
				                                                  xtc_date_long($this->product->data['products_date_added'])));
957
			}
958
		}
959
	}
960

    
961

    
962
	protected function _assignGraduatedPrices()
963
	{
964
		/* @var GraduatedPricesContentView $view */
965
		$view = MainFactory::create_object('GraduatedPricesContentView');
966
		$view->set_coo_product($this->product);
967
		$view->set_customers_status_graduated_prices((int)$this->showGraduatedPrices);
968
		$html = $view->get_html();
969
		$this->set_content_data('MODULE_graduated_price', $html);
970
	}
971

    
972

    
973
	// TODO move out of view into control
974
	protected function _updateTracking()
975
	{
976
		$i = is_array($_SESSION['tracking']['products_history']) ? count($_SESSION['tracking']['products_history']) : 0;
977
		if($i > 6)
978
		{
979
			array_shift($_SESSION['tracking']['products_history']);
980
			$_SESSION['tracking']['products_history'][6] = $this->product->data['products_id'];
981
			$_SESSION['tracking']['products_history']    = array_unique($_SESSION['tracking']['products_history']);
982
		}
983
		else
984
		{
985
			$_SESSION['tracking']['products_history'][$i] = $this->product->data['products_id'];
986
			$_SESSION['tracking']['products_history']     = array_unique($_SESSION['tracking']['products_history']);
987
		}
988
	}
989

    
990

    
991
	protected function _assignPrintLink()
992
	{
993
		if(gm_get_conf('SHOW_PRINT') == 'true')
994
		{
995
			$this->set_content_data('SHOW_PRINT', 1);
996
		}
997

    
998
		$this->_assignDeprecatedPrintLink();
999
	}
1000

    
1001

    
1002
	protected function _assignSocialServices()
1003
	{
1004
		$this->_assignFacebook();
1005
		$this->_assignWhatsApp();
1006
		$this->_assignTwitter();
1007
		$this->_assignGooglePlus();
1008
		$this->_assignPinterest();
1009
	}
1010

    
1011

    
1012
	protected function _assignFacebook()
1013
	{
1014
		if(gm_get_conf('SHOW_FACEBOOK') == 'true')
1015
		{
1016
			$this->set_content_data('SHOW_FACEBOOK', 1);
1017
		}
1018
	}
1019

    
1020

    
1021
	protected function _assignWhatsApp()
1022
	{
1023
		if(gm_get_conf('SHOW_WHATSAPP') == 'true')
1024
		{
1025
			$this->set_content_data('SHOW_WHATSAPP', 1);
1026
		}
1027
	}
1028
	protected function _assignTwitter()
1029
	{
1030
		if(gm_get_conf('SHOW_TWITTER') == 'true')
1031
		{
1032
			$this->set_content_data('SHOW_TWITTER', 1);
1033
		}
1034
	}
1035

    
1036

    
1037
	protected function _assignGooglePlus()
1038
	{
1039
		if(gm_get_conf('SHOW_GOOGLEPLUS') == 'true')
1040
		{
1041
			$this->set_content_data('SHOW_GOOGLEPLUS', 1);
1042
		}
1043
	}
1044

    
1045

    
1046
	protected function _assignPinterest()
1047
	{
1048
		if(gm_get_conf('SHOW_PINTEREST') == 'true')
1049
		{
1050
			$this->set_content_data('SHOW_PINTEREST', 1);
1051
		}
1052
	}
1053

    
1054
	protected function _assignImageMaxHeight()
1055
	{
1056
		$this->set_content_data('IMAGE_MAX_HEIGHT', $this->maxImageHeight);
1057
	}
1058

    
1059

    
1060
	protected function _assignImageData()
1061
	{
1062
		$imagesDataArray     = [];
1063
		$thumbnailsDataArray = [];
1064

    
1065
		/* @var GMAltText $altTextManager */
1066
		$altTextManager = MainFactory::create_object('GMAltText');
1067

    
1068
		if($this->product->data['products_image'] != '' && $this->product->data['gm_show_image'] == '1')
1069
		{
1070
			$imageArray = array(
1071
					'image_name' => $this->product->data['products_image'],
1072
					'image_id'   => 0,
1073
					'image_nr'   => 0
1074
			);
1075

    
1076
			$imagesDataArray[]     = $this->_buildImageArray($imageArray, $altTextManager);
1077
			$thumbnailsDataArray[] = $this->_buildThumbnailArray($imageArray, $altTextManager);
1078
		}
1079

    
1080
		$additionalImagesArray = xtc_get_products_mo_images($this->product->data['products_id']);
1081

    
1082
		if(is_array($additionalImagesArray) && !empty($additionalImagesArray))
1083
		{
1084
			foreach($additionalImagesArray as $imageArray)
1085
			{
1086
				$imagesDataArray[]     = $this->_buildImageArray($imageArray, $altTextManager);
1087
				$thumbnailsDataArray[] = $this->_buildThumbnailArray($imageArray, $altTextManager);
1088
			}
1089
		}
1090

    
1091
		$this->set_content_data('images', $imagesDataArray);
1092
		$this->set_content_data('thumbnails', $thumbnailsDataArray);
1093

    
1094
		$this->_assignGMotion();
1095

    
1096
		$this->_assignDeprecatedDimensionValues();
1097
	}
1098

    
1099

    
1100
	protected function _assignGMotion()
1101
	{
1102
		/* @var GMGMotion $gMotion */
1103
		$gMotion = MainFactory::create_object('GMGMotion');
1104
		$this->set_content_data('GMOTION', $gMotion->check_status($this->product->data['products_id']));
1105
	}
1106

    
1107

    
1108
	/**
1109
	 * GX-Customizer
1110
	 */
1111
	protected function _assignGPrint()
1112
	{
1113
		$gPrintProductManager = new GMGPrintProductManager();
1114

    
1115
		if($gPrintProductManager->get_surfaces_groups_id($this->product->data['products_id']) !== false)
1116
		{
1117
			$gPrintConfiguration = new GMGPrintConfiguration($this->languageId);
1118

    
1119
			$this->set_content_data('GM_GPRINT_SHOW_PRODUCTS_DESCRIPTION',
1120
			                        $gPrintConfiguration->get_configuration('SHOW_PRODUCTS_DESCRIPTION'));
1121
			$this->set_content_data('GM_GPRINT', 1);
1122

    
1123
			if(gm_get_conf('CUSTOMIZER_POSITION') == '2' && gm_get_env_info('TEMPLATE_VERSION') < 3)
1124
			{
1125
				$customizerTabHtml = '[TAB:Customize]<div id="customizer_tab_container"></div>';
1126
				$this->product->data['products_description'] .= $customizerTabHtml;
1127
			}
1128
		}
1129
	}
1130

    
1131

    
1132
	/**
1133
	 * assign formated price or link to contact form if price status is "Preis auf Anfrage"
1134
	 */
1135
	protected function _assignPrice()
1136
	{
1137
		$this->set_content_data('PRODUCTS_PRICE', $this->productPriceArray['formated']);
1138

    
1139
		if($this->product->data['gm_price_status'] == 1)
1140
		{
1141
			$seoBoost     = MainFactory::create_object('GMSEOBoost', [], true);
1142
			$sefParameter = '';
1143

    
1144
			$query  = "SELECT
1145
							content_id,
1146
							content_title
1147
						FROM " . TABLE_CONTENT_MANAGER . "
1148
						WHERE
1149
							languages_id = '" . (int)$this->languageId . "' AND
1150
							content_group = '7'";
1151
			$result = xtc_db_query($query);
1152
			if(xtc_db_num_rows($result))
1153
			{
1154
				$row                 = xtc_db_fetch_array($result);
1155
				$contactContentId    = $row['content_id'];
1156
				$contactContentTitle = $row['content_title'];
1157

    
1158
				if(defined('SEARCH_ENGINE_FRIENDLY_URLS') && SEARCH_ENGINE_FRIENDLY_URLS === 'false')
1159
				{
1160
					$sefParameter = '&content=' . xtc_cleanName($contactContentTitle);
1161
				}
1162
			}
1163
			if($seoBoost->boost_content)
1164
			{
1165
				$contactUrl = xtc_href_link($seoBoost->get_boosted_content_url($contactContentId, $this->languageId)
1166
				                            . '?subject=' . rawurlencode(GM_SHOW_PRICE_ON_REQUEST . ': '
1167
				                                                         . $this->product->data['products_name']));
1168
			}
1169
			else
1170
			{
1171
				$contactUrl = xtc_href_link(FILENAME_CONTENT,
1172
				                            'coID=7&subject=' . rawurlencode(GM_SHOW_PRICE_ON_REQUEST . ': '
1173
				                                                             . $this->product->data['products_name'])
1174
				                            . $sefParameter);
1175
			}
1176

    
1177
			$contactLinkHtml = '<a href="' . $contactUrl . '" class="btn btn-lg btn-price-on-request price-on-request">' . GM_SHOW_PRICE_ON_REQUEST . '</a>';
1178

    
1179
			$this->set_content_data('PRODUCTS_PRICE', $contactLinkHtml);
1180
		}
1181
	}
1182

    
1183

    
1184
	protected function _assignDiscount()
1185
	{
1186
		if($this->customerDiscount != 0)
1187
		{
1188
			$discount = $this->customerDiscount;
1189

    
1190
			if($this->product->data['products_discount_allowed'] < $this->customerDiscount)
1191
			{
1192
				$discount = (double)$this->product->data['products_discount_allowed'];
1193
			}
1194

    
1195
			if($discount != 0)
1196
			{
1197
				$this->set_content_data('PRODUCTS_DISCOUNT', $discount . '%');
1198
			}
1199
		}
1200
	}
1201

    
1202

    
1203
	protected function _assignDescription()
1204
	{
1205
		/* @var GMTabTokenizer $tabTokenizer */
1206
		$tabTokenizer = MainFactory::create_object('GMTabTokenizer',
1207
		                                           array(stripslashes($this->product->data['products_description'])));
1208
		$description  = $tabTokenizer->get_prepared_output();
1209

    
1210
		$this->set_content_data('PRODUCTS_DESCRIPTION', $description);
1211
		$this->set_content_data('description', $tabTokenizer->head_content);
1212

    
1213
		$tabs = array();
1214
		foreach($tabTokenizer->tab_content as $key => $value)
1215
		{
1216
			$tabs[] = array('title' => $value, 'content' => $tabTokenizer->panel_content[$key]);
1217
		}
1218

    
1219
		$mediaContent = $this->_getMediaContentHtml();
1220
		if(trim($mediaContent) !== '')
1221
		{
1222
			$languageTextManager = MainFactory::create_object('LanguageTextManager',
1223
			                                                  array('products_media', $this->languageId));
1224
			$tabs[]              = array(
1225
					'title'   => $languageTextManager->get_text('text_media_content_tab'),
1226
					'content' => $mediaContent
1227
			);
1228
		}
1229

    
1230
		$this->set_content_data('tabs', $tabs);
1231
	}
1232

    
1233

    
1234
	/**
1235
	 * @return bool
1236
	 */
1237
	protected function _productIsForSale()
1238
	{
1239
		return ($this->showPrice
1240
		        && $this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 0)
1241
		       && ($this->product->data['products_fsk18'] == '0' || $this->fsk18PurchaseAllowed);
1242
	}
1243

    
1244

    
1245
	/**
1246
	 * @param array     $imageArray
1247
	 * @param GMAltText $altTextManager
1248
	 *
1249
	 * @return array
1250
	 */
1251
	protected function _buildImageArray(array $imageArray, GMAltText $altTextManager)
1252
	{
1253
		$imageMaxWidth  = 369;
1254
		$imageMaxHeight = 279;
1255

    
1256
		$infoImageSizeArray = @getimagesize(DIR_WS_INFO_IMAGES . $imageArray['image_name']);
1257

    
1258
		$imagePaddingLeft = 0;
1259
		$imagePaddingTop  = 0;
1260

    
1261
		if(isset($infoImageSizeArray[0]) && $infoImageSizeArray[0] < $imageMaxWidth)
1262
		{
1263
			$imagePaddingLeft = round(($imageMaxWidth - $infoImageSizeArray[0]) / 2);
1264
		}
1265

    
1266
		if(isset($infoImageSizeArray[1]) && $infoImageSizeArray[1] < $imageMaxHeight)
1267
		{
1268
			$imagePaddingTop = round(($imageMaxHeight - $infoImageSizeArray[1]) / 2);
1269
		}
1270

    
1271
		if($this->maxImageHeight < $infoImageSizeArray[1]){
1272
			$this->maxImageHeight = $infoImageSizeArray[1];
1273
		}
1274

    
1275
		$zoomImageFilepath = DIR_WS_POPUP_IMAGES . $imageArray['image_name'];
1276

    
1277
		if(file_exists(DIR_WS_ORIGINAL_IMAGES . $imageArray['image_name']))
1278
		{
1279
			$zoomImageFilepath = DIR_WS_ORIGINAL_IMAGES . $imageArray['image_name'];
1280
		}
1281

    
1282
		$imageDataArray = array(
1283
				'IMAGE'           => DIR_WS_INFO_IMAGES . $imageArray['image_name'],
1284
				'IMAGE_ALT'       => $altTextManager->get_alt($imageArray["image_id"], $imageArray['image_nr'],
1285
				                                              $this->product->data['products_id']),
1286
				'IMAGE_NR'        => $imageArray['image_nr'],
1287
				'ZOOM_IMAGE'      => $zoomImageFilepath,
1288
				'PRODUCTS_NAME'   => $this->product->data['products_name'],
1289
				'PADDING_LEFT'    => $imagePaddingLeft,
1290
				'PADDING_TOP'     => $imagePaddingTop,
1291
				'IMAGE_POPUP_URL' => DIR_WS_POPUP_IMAGES . $imageArray['image_name'],
1292
				'WIDTH'           => $infoImageSizeArray[0],
1293
				'HEIGHT'          => $infoImageSizeArray[1]
1294

    
1295
		);
1296

    
1297
		return $imageDataArray;
1298
	}
1299

    
1300

    
1301
	/**
1302
	 * @param array     $imageArray
1303
	 * @param GMAltText $altTextManager
1304
	 *
1305
	 * @return array
1306
	 */
1307
	protected function _buildThumbnailArray(array $imageArray, GMAltText $altTextManager)
1308
	{
1309
		$thumbnailMaxWidth  = 86;
1310
		$thumbnailMaxHeight = 86;
1311

    
1312
		$thumbnailImageSizeArray = @getimagesize(DIR_WS_IMAGES . 'product_images/gallery_images/'
1313
		                                         . $imageArray['image_name']);
1314

    
1315
		$thumbnailPaddingLeft = 0;
1316
		$thumbnailPaddingTop  = 0;
1317

    
1318
		if(isset($thumbnailImageSizeArray[0]) && $thumbnailImageSizeArray[0] < $thumbnailMaxWidth)
1319
		{
1320
			$thumbnailPaddingLeft = round(($thumbnailMaxWidth - $thumbnailImageSizeArray[0]) / 2);
1321
		}
1322

    
1323
		if(isset($thumbnailImageSizeArray[1]) && $thumbnailImageSizeArray[1] < $thumbnailMaxHeight)
1324
		{
1325
			$thumbnailPaddingTop = round(($thumbnailMaxHeight - $thumbnailImageSizeArray[1]) / 2);
1326
		}
1327

    
1328
		$zoomImageFilepath = DIR_WS_POPUP_IMAGES . $imageArray['image_name'];
1329

    
1330
		if(file_exists(DIR_WS_ORIGINAL_IMAGES . $imageArray['image_name']))
1331
		{
1332
			$zoomImageFilepath = DIR_WS_ORIGINAL_IMAGES . $imageArray['image_name'];
1333
		}
1334

    
1335
		$thumbnailDataArray = array(
1336
				'IMAGE'         => DIR_WS_IMAGES . 'product_images/gallery_images/' . $imageArray['image_name'],
1337
				'IMAGE_ALT'     => $altTextManager->get_alt($imageArray["image_id"], $imageArray['image_nr'],
1338
				                                            $this->product->data['products_id']),
1339
				'IMAGE_NR'      => $imageArray['image_nr'],
1340
				'ZOOM_IMAGE'    => $zoomImageFilepath,
1341
				'INFO_IMAGE'    => DIR_WS_INFO_IMAGES . $imageArray['image_name'],
1342
				'PRODUCTS_NAME' => $this->product->data['products_name'],
1343
				'PADDING_LEFT'  => $thumbnailPaddingLeft,
1344
				'PADDING_TOP'   => $thumbnailPaddingTop
1345
		);
1346

    
1347
		return $thumbnailDataArray;
1348
	}
1349

    
1350

    
1351
	protected function _assignInputFieldQuantity()
1352
	{
1353
		$this->set_content_data('QUANTITY', gm_convert_qty($this->product->data['gm_min_order'], false));
1354
		$this->set_content_data('DISABLED_QUANTITY', 0);
1355

    
1356
		if((double)$this->product->data['gm_min_order'] != 1)
1357
		{
1358
			$this->set_content_data('GM_MIN_ORDER', gm_convert_qty($this->product->data['gm_min_order'], false));
1359
		}
1360

    
1361
		$quantityStepping = (double)$this->product->data['gm_graduated_qty'];
1362
		if((double)$this->product->data['gm_graduated_qty'] != 1)
1363
		{
1364
			$this->set_content_data('GM_GRADUATED_QTY',
1365
			                        gm_convert_qty($this->product->data['gm_graduated_qty'], false));
1366
		}
1367
		$this->set_content_data('QTY_STEPPING', $quantityStepping);
1368

    
1369
		$this->_assignDeprecatedPurchaseData();
1370
	}
1371

    
1372

    
1373
	protected function _assignWishlist()
1374
	{
1375
		if(gm_get_conf('GM_SHOW_WISHLIST') == 'true')
1376
		{
1377
			$this->set_content_data('SHOW_WISHLIST', 1);
1378
		}
1379
		else
1380
		{
1381
			$this->set_content_data('SHOW_WISHLIST', 0);
1382
		}
1383

    
1384
		$this->_assignDeprecatedWishlist();
1385
	}
1386

    
1387

    
1388
	protected function _assignLegalAgeFlag()
1389
	{
1390
		if($this->product->data['products_fsk18'] == '1')
1391
		{
1392
			$this->set_content_data('PRODUCTS_FSK18', 'true');
1393
		}
1394
	}
1395

    
1396

    
1397
	/**
1398
	 * @return bool
1399
	 */
1400
	protected function _showPrice()
1401
	{
1402
		return $this->showPrice
1403
		       && ($this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 0
1404
		           || ($this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 2
1405
		               && $this->product->data['products_price'] > 0));
1406
	}
1407

    
1408

    
1409
	protected function _assignTaxInfo()
1410
	{
1411
		// price incl tax
1412
		$tax_rate = $this->xtcPrice->TAX[$this->product->data['products_tax_class_id']];
1413
		$tax_info = $this->main->getTaxInfo($tax_rate);
1414
		$this->set_content_data('PRODUCTS_TAX_INFO', $tax_info);
1415
	}
1416

    
1417

    
1418
	protected function _assignShippingLink()
1419
	{
1420
		if($this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 0)
1421
		{
1422
			$this->set_content_data('PRODUCTS_SHIPPING_LINK',
1423
			                        $this->main->getShippingLink(true, $this->product->data['products_id']));
1424
		}
1425
	}
1426

    
1427

    
1428
	protected function _assignTellAFriend()
1429
	{
1430
		if(gm_get_conf('GM_TELL_A_FRIEND') == 'true')
1431
		{
1432
			$this->set_content_data('GM_TELL_A_FRIEND', 1);
1433
		}
1434
	}
1435

    
1436

    
1437
	protected function _assignPriceOffer()
1438
	{
1439
		if($this->product->data['gm_show_price_offer'] == 1
1440
		   && $this->showPrice
1441
		   && $this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 0
1442
		)
1443
		{
1444
			$this->set_content_data('GM_PRICE_OFFER', 1);
1445
		}
1446
	}
1447

    
1448

    
1449
	protected function _assignStatus()
1450
	{
1451
		$this->set_content_data('PRODUCTS_STATUS', $this->product->data['products_status']);
1452
	}
1453

    
1454

    
1455
	protected function _assignNumberOfOrders()
1456
	{
1457
		$this->set_content_data('PRODUCTS_ORDERED', $this->product->data['products_ordered']);
1458
	}
1459

    
1460

    
1461
	protected function _assignFormTagData()
1462
	{
1463
		$this->set_content_data('FORM_ACTION_URL', xtc_href_link(FILENAME_PRODUCT_INFO,
1464
		                                                         xtc_get_all_get_params(array('action'))
1465
		                                                         . 'action=add_product', 'NONSSL', true, true, true));
1466
		$this->set_content_data('FORM_ID', 'cart_quantity');
1467
		$this->set_content_data('FORM_NAME', 'cart_quantity');
1468
		$this->set_content_data('FORM_METHOD', 'post');
1469

    
1470
		$this->_assignDeprecatedFormTagData();
1471
	}
1472

    
1473

    
1474
	protected function _setPropertiesData()
1475
	{
1476
		$coo_stop_watch = LogControl::get_instance()->get_stop_watch();
1477
		$coo_stop_watch->start('PropertiesView get_selection_form');
1478

    
1479
		$propertiesSelectionForm = $this->_buildPropertiesSelectionForm();
1480
		$this->_assignPropertiesSelectionForm($propertiesSelectionForm);
1481

    
1482
		$coo_stop_watch->stop('PropertiesView get_selection_form');
1483
		//$coo_stop_watch->log_total_time('PropertiesView get_selection_form');
1484

    
1485
		$this->hasProperties = trim($propertiesSelectionForm) != "";
1486
	}
1487

    
1488

    
1489
	protected function _assignModelNumber()
1490
	{
1491
		$modelNumber = $this->product->data['products_model'];
1492

    
1493
		if($this->hasProperties)
1494
		{
1495
			// OVERRIDE PRODUCTS MODEL
1496
			if($this->currentCombiArray != false)
1497
			{
1498
				if(APPEND_PROPERTIES_MODEL == "true" && trim($this->currentCombiArray['combi_model']) != '')
1499
				{
1500
					if(trim($modelNumber) != '')
1501
					{
1502
						$modelNumber .= '-';
1503
					}
1504
					$modelNumber .= $this->currentCombiArray['combi_model'];
1505
				}
1506
				else if(APPEND_PROPERTIES_MODEL == "false" && trim($this->currentCombiArray['combi_model']) != '')
1507
				{
1508
					$modelNumber = $this->currentCombiArray['combi_model'];
1509
				}
1510
			}
1511
		}
1512
		
1513
		$this->set_content_data('SHOW_PRODUCTS_MODEL',
1514
		                        gm_get_conf('SHOW_PRODUCTS_MODEL_IN_PRODUCT_DETAILS') === 'true');
1515
		$this->set_content_data('PRODUCTS_MODEL', $modelNumber);
1516
	}
1517

    
1518

    
1519
	protected function _assignQuantity()
1520
	{
1521
		$quantity     = 0;
1522
		$quantityUnit = '';
1523

    
1524
		if($this->product->data['gm_show_qty_info'] == 1)
1525
		{
1526
			$quantity = gm_convert_qty(xtc_get_products_stock($this->product->data['products_id']), false);
1527
		}
1528

    
1529
		if($this->product->data['quantity_unit_id'] > 0)
1530
		{
1531
			$quantityUnit = $this->product->data['unit_name'];
1532
		}
1533

    
1534
		if($this->hasProperties && $this->product->data['gm_show_qty_info'] == 1)
1535
		{
1536
			// OVERRIDE PRODUCTS QUANTITY
1537
			if(($this->product->data['use_properties_combis_quantity'] == 0
1538
			    && STOCK_CHECK == 'true'
1539
			    && ATTRIBUTE_STOCK_CHECK == 'true')
1540
			   || $this->product->data['use_properties_combis_quantity'] == 2
1541
			)
1542
			{
1543
				$quantity = $this->currentCombiArray['combi_quantity'];
1544
				$this->set_content_data('SHOW_PRODUCTS_QUANTITY', true);
1545

    
1546
				if(empty($this->currentCombiArray))
1547
				{
1548
					$this->set_content_data('SHOW_PRODUCTS_QUANTITY', true);
1549
					$quantity = '-';
1550
				}
1551
			}
1552
		}
1553

    
1554
		$this->set_content_data('PRODUCTS_QUANTITY', $quantity);
1555
		$this->set_content_data('PRODUCTS_QUANTITY_UNIT', $quantityUnit);
1556
	}
1557

    
1558

    
1559
	protected function _assignDeactivatedButtonFlag()
1560
	{
1561
		$deactivateButton = false;
1562

    
1563
		if($this->hasProperties)
1564
		{
1565
			if($this->currentCombiArray == false)
1566
			{
1567
				$deactivateButton = true;
1568
			}
1569
			else if($this->product->data['gm_show_qty_info'] == 1)
1570
			{
1571
				if(($this->product->data['use_properties_combis_quantity'] == 0
1572
				    && STOCK_CHECK == 'true'
1573
				    && ATTRIBUTE_STOCK_CHECK == 'true')
1574
				   || $this->product->data['use_properties_combis_quantity'] == 2
1575
				)
1576
				{
1577
					if($this->currentCombiArray['combi_quantity'] < gm_convert_qty($this->product->data['gm_min_order'],
1578
					                                                               false)
1579
					   && STOCK_ALLOW_CHECKOUT == 'false'
1580
					)
1581
					{
1582
						$deactivateButton = true;
1583
					}
1584
				}
1585
			}
1586
		}
1587

    
1588
		$this->set_content_data('DEACTIVATE_BUTTON', $deactivateButton);
1589
	}
1590

    
1591

    
1592
	protected function _assignWeight()
1593
	{
1594
		$showWeight = 0;
1595
		$weight     = 0;
1596

    
1597
		if($this->product->data['gm_show_weight'] == '1')
1598
		{
1599
			$showWeight = 1;
1600
			$weight     = gm_prepare_number($this->product->data['products_weight'],
1601
			                                $this->xtcPrice->currencies[$this->xtcPrice->actualCurr]['decimal_point']);
1602

    
1603
			if($this->hasProperties)
1604
			{
1605
				// OVERRIDE WEIGHT
1606
				$weight = '-';
1607

    
1608
				if($this->currentCombiArray != false)
1609
				{
1610
					if($this->product->data['use_properties_combis_weight'] == 0)
1611
					{
1612
						$weight = gm_prepare_number($this->currentCombiArray['combi_weight']
1613
						                            + $this->product->data['products_weight'],
1614
						                            $this->xtcPrice->currencies[$this->xtcPrice->actualCurr]['decimal_point']);
1615
					}
1616
					else
1617
					{
1618
						$weight = gm_prepare_number($this->currentCombiArray['combi_weight'],
1619
						                            $this->xtcPrice->currencies[$this->xtcPrice->actualCurr]['decimal_point']);
1620
					}
1621
				}
1622
			}
1623
		}
1624

    
1625
		$this->set_content_data('SHOW_PRODUCTS_WEIGHT', $showWeight);
1626
		$this->set_content_data('PRODUCTS_WEIGHT', $weight);
1627
	}
1628

    
1629

    
1630
	protected function _assignVpe()
1631
	{
1632
		$vpeHtml = '';
1633

    
1634
		if($this->product->data['products_vpe_status'] == 1 && $this->product->data['products_vpe_value'] != 0.0
1635
		   && $this->productPriceArray['plain'] > 0
1636
		)
1637
		{
1638
			$price          = $this->productPriceArray['plain'] * (1 / $this->product->data['products_vpe_value']);
1639
			$priceFormatted = $this->xtcPrice->xtcFormat($price, true);
1640
			$vpeName        = xtc_get_vpe_name($this->product->data['products_vpe']);
1641
			$vpeHtml        = $priceFormatted . TXT_PER . $vpeName;
1642

    
1643
			if($this->hasProperties)
1644
			{
1645
			    $propertiesControl = MainFactory::create('PropertiesControl');
1646
			    
1647
				// OVERRIDE VPE
1648
				if(!empty($this->currentCombiArray) && $this->currentCombiArray['products_vpe_id'] > 0
1649
				   && $this->currentCombiArray['vpe_value'] != 0
1650
				)
1651
				{
1652
                    $vpeHtml = $this->_buildVpeHtml($this->productPriceArray['plain'], $this->currentCombiArray['products_vpe_id'], $this->currentCombiArray['vpe_value']);
1653
				}
1654
				elseif($this->cheapestCombiArray['products_vpe_id'] > 0 && $this->cheapestCombiArray['vpe_value'] != 0 && !$propertiesControl->has_non_linear_combi_surcharge((int)$this->product->data['products_id']))
1655
				{
1656
                    $vpeHtml = $this->_buildVpeHtml($this->productPriceArray['plain'], $this->cheapestCombiArray['products_vpe_id'], $this->cheapestCombiArray['vpe_value']);
1657
				}
1658
				elseif($propertiesControl->has_non_linear_combi_surcharge((int)$this->product->data['products_id']))
1659
                {
1660
                    $vpeHtml = '';
1661
                }
1662
			}
1663
		}
1664

    
1665
		$this->set_content_data('PRODUCTS_VPE', $vpeHtml);
1666
	}
1667
    
1668
    
1669
    protected function _buildVpeHtml($price, $vpeId, $vpeValue)
1670
    {
1671
        $vpePrice       = $price * (1 / $vpeValue);
1672
        $priceFormatted = $this->xtcPrice->xtcFormat($vpePrice, true);
1673
        $vpeName        = xtc_get_vpe_name($vpeId);
1674
        
1675
        return $priceFormatted . TXT_PER . $vpeName;
1676
    }
1677

    
1678

    
1679
	protected function _assignShippingTime()
1680
	{
1681
		$languageTextManager = MainFactory::create('LanguageTextManager', 'product_info');
1682
		
1683
		$name     = '';
1684
		$image    = '';
1685
		$imageAlt = '';
1686

    
1687
		if(ACTIVATE_SHIPPING_STATUS == 'true'
1688
		   && $this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 0
1689
		)
1690
		{
1691
			$name  = $this->main->getShippingStatusName($this->product->data['products_shippingtime']);
1692
			$image = $this->main->getShippingStatusImage($this->product->data['products_shippingtime']);
1693
		}
1694

    
1695
		if($this->hasProperties)
1696
		{
1697

    
1698
			// OVERRIDE SHIPPING STATUS
1699
			if(ACTIVATE_SHIPPING_STATUS == 'true'
1700
			   && $this->xtcPrice->gm_check_price_status($this->product->data['products_id']) == 0
1701
			   && $this->product->data['use_properties_combis_shipping_time'] == 1
1702
			)
1703
			{
1704
				if($this->currentCombiArray != false)
1705
				{
1706
					$name  = $this->main->getShippingStatusName($this->currentCombiArray['combi_shipping_status_id']);
1707
					$image = $this->main->getShippingStatusImage($this->currentCombiArray['combi_shipping_status_id']);
1708
				}
1709
				else
1710
				{
1711
					$name  = '';
1712
					$image = 'images/icons/status/gray.png';
1713
				}
1714
				$this->set_content_data('SHOW_SHIPPING_TIME', true);
1715
			}
1716
		}
1717
		
1718
		$imageAlt = ($name !== '')? $name : $languageTextManager->get_text('unknown_shippingtime');
1719

    
1720
		$this->set_content_data('SHIPPING_NAME', $name);
1721
		$this->set_content_data('SHIPPING_IMAGE', $image);
1722
		$this->set_content_data('SHIPPING_IMAGE_ALT', $imageAlt);
1723
		$this->set_content_data('ABROAD_SHIPPING_INFO_LINK_ACTIVE',
1724
		                        $this->main->getShippingStatusInfoLinkActive($this->product->data['products_shippingtime']));
1725
		$this->set_content_data('ABROAD_SHIPPING_INFO_LINK', main::get_abroad_shipping_info_link());
1726
	}
1727

    
1728

    
1729
	protected function _assignEan()
1730
	{
1731
		$this->set_content_data('PRODUCTS_EAN', $this->product->data['products_ean']);
1732
	}
1733

    
1734

    
1735
	protected function _assignId()
1736
	{
1737
		$this->set_content_data('PRODUCTS_ID', $this->product->data['products_id']);
1738
	}
1739

    
1740

    
1741
	protected function _assignName()
1742
	{
1743
		$this->set_content_data('PRODUCTS_NAME', $this->product->data['products_name']);
1744
	}
1745

    
1746

    
1747
	/**
1748
	 * @return string
1749
	 */
1750
	protected function _buildPropertiesSelectionForm()
1751
	{
1752
		/* @var PropertiesView $view */
1753
		$view                    = MainFactory::create_object('PropertiesView',
1754
		                                                      array($this->getArray, $this->postArray));
1755
		$propertiesSelectionForm = $view->get_selection_form($this->product->data['products_id'], $this->languageId,
1756
		                                                     false, $this->currentCombiArray);
1757

    
1758
		return $propertiesSelectionForm;
1759
	}
1760

    
1761

    
1762
	/**
1763
	 * @param $propertiesSelectionForm
1764
	 */
1765
	protected function _assignPropertiesSelectionForm($propertiesSelectionForm)
1766
	{
1767
		$this->set_content_data('properties_selection_form', $propertiesSelectionForm);
1768
	}
1769

    
1770

    
1771
	protected function _assignAdditionalFields()
1772
	{
1773
		$additionalFieldsHtml = '';
1774

    
1775
		if(gm_get_conf('SHOW_ADDITIONAL_FIELDS_PRODUCT_DETAILS') === 'true')
1776
		{
1777
			$view = MainFactory::create_object('AdditionalFieldContentView');
1778
			$view->setLanguageId($this->languageId);
1779
			$view->setAdditionalFields($this->additionalFields);
1780
			$additionalFieldsHtml = $view->get_html();
1781
		}
1782

    
1783
		$this->set_content_data('additional_fields', $additionalFieldsHtml);
1784
	}
1785

    
1786

    
1787
	##### SETTER / GETTER #####
1788

    
1789
	/**
1790
	 * @return array
1791
	 */
1792
	public function getGetArray()
1793
	{
1794
		return $this->getArray;
1795
	}
1796

    
1797

    
1798
	/**
1799
	 * $_GET-Data
1800
	 *
1801
	 * @param array $getArray
1802
	 */
1803
	public function setGetArray(array $getArray)
1804
	{
1805
		$this->getArray = $getArray;
1806
	}
1807

    
1808

    
1809
	/**
1810
	 * @return array
1811
	 */
1812
	public function getPostArray()
1813
	{
1814
		return $this->postArray;
1815
	}
1816

    
1817

    
1818
	/**
1819
	 * $_POST-Data
1820
	 *
1821
	 * @param array $postArray
1822
	 */
1823
	public function setPostArray(array $postArray)
1824
	{
1825
		$this->postArray = $postArray;
1826
	}
1827

    
1828

    
1829
	/**
1830
	 * @param product $product
1831
	 */
1832
	public function setProduct(product $product)
1833
	{
1834
		$this->product = $product;
1835
	}
1836

    
1837

    
1838
	/**
1839
	 * @return product
1840
	 */
1841
	public function getProduct()
1842
	{
1843
		return $this->product;
1844
	}
1845

    
1846

    
1847
	/**
1848
	 * @param int $p_categoryId
1849
	 */
1850
	public function setCurrentCategoryId($p_categoryId)
1851
	{
1852
		$this->currentCategoryId = (int)$p_categoryId;
1853
	}
1854

    
1855

    
1856
	/**
1857
	 * @return int
1858
	 */
1859
	public function getCurrentCategoryId()
1860
	{
1861
		return $this->currentCategoryId;
1862
	}
1863

    
1864

    
1865
	/**
1866
	 * @return int
1867
	 */
1868
	public function getCombiId()
1869
	{
1870
		return $this->combiId;
1871
	}
1872

    
1873

    
1874
	/**
1875
	 * @param int $p_combiId
1876
	 */
1877
	public function setCombiId($p_combiId)
1878
	{
1879
		$this->combiId = (int)$p_combiId;
1880
	}
1881

    
1882

    
1883
	/**
1884
	 * @return int
1885
	 */
1886
	public function getLanguageId()
1887
	{
1888
		return $this->languageId;
1889
	}
1890

    
1891

    
1892
	/**
1893
	 * @param int $p_languageId
1894
	 */
1895
	public function setLanguageId($p_languageId)
1896
	{
1897
		$this->languageId = (int)$p_languageId;
1898
	}
1899

    
1900

    
1901
	/**
1902
	 * @return main
1903
	 */
1904
	public function getMain()
1905
	{
1906
		return $this->main;
1907
	}
1908

    
1909

    
1910
	/**
1911
	 * @param mixed $main
1912
	 */
1913
	public function setMain(main $main)
1914
	{
1915
		$this->main = $main;
1916
	}
1917

    
1918

    
1919
	/**
1920
	 * @return xtcPrice
1921
	 */
1922
	public function getXtcPrice()
1923
	{
1924
		return $this->xtcPrice;
1925
	}
1926

    
1927

    
1928
	/**
1929
	 * @param xtcPrice $xtcPrice
1930
	 */
1931
	public function setXtcPrice(xtcPrice $xtcPrice)
1932
	{
1933
		$this->xtcPrice = $xtcPrice;
1934
	}
1935

    
1936

    
1937
	/**
1938
	 * @return string
1939
	 */
1940
	public function getCurrency()
1941
	{
1942
		return $this->currency;
1943
	}
1944

    
1945

    
1946
	/**
1947
	 * @param string $p_currency
1948
	 */
1949
	public function setCurrency($p_currency)
1950
	{
1951
		$this->currency = (string)$p_currency;
1952
	}
1953

    
1954

    
1955
	/**
1956
	 * @return boolean
1957
	 */
1958
	public function getShowGraduatedPrices()
1959
	{
1960
		return $this->showGraduatedPrices;
1961
	}
1962

    
1963

    
1964
	/**
1965
	 * @param boolean $p_showGraduatedPrices
1966
	 */
1967
	public function setShowGraduatedPrices($p_showGraduatedPrices)
1968
	{
1969
		$this->showGraduatedPrices = (bool)$p_showGraduatedPrices;
1970
	}
1971

    
1972

    
1973
	/**
1974
	 * @return double
1975
	 */
1976
	public function getCustomerDiscount()
1977
	{
1978
		return $this->customerDiscount;
1979
	}
1980

    
1981

    
1982
	/**
1983
	 * @param double $p_customerDiscount
1984
	 */
1985
	public function setCustomerDiscount($p_customerDiscount)
1986
	{
1987
		$this->customerDiscount = (double)$p_customerDiscount;
1988
	}
1989

    
1990

    
1991
	/**
1992
	 * @return boolean
1993
	 */
1994
	public function getShowPrice()
1995
	{
1996
		return $this->showPrice;
1997
	}
1998

    
1999

    
2000
	/**
2001
	 * @param boolean $p_showPrice
2002
	 */
2003
	public function setShowPrice($p_showPrice)
2004
	{
2005
		$this->showPrice = (bool)$p_showPrice;
2006
	}
2007

    
2008

    
2009
	/**
2010
	 * @return string
2011
	 */
2012
	public function getLanguage()
2013
	{
2014
		return $this->language;
2015
	}
2016

    
2017

    
2018
	/**
2019
	 * @param string $p_language
2020
	 */
2021
	public function setLanguage($p_language)
2022
	{
2023
		$this->language = basename((string)$p_language);
2024
	}
2025

    
2026

    
2027
	/**
2028
	 * @return boolean
2029
	 */
2030
	public function getFSK18PurchaseAllowed()
2031
	{
2032
		return $this->fsk18PurchaseAllowed;
2033
	}
2034

    
2035

    
2036
	/**
2037
	 * @param boolean $p_FSK18PurchaseAllowed
2038
	 */
2039
	public function setFSK18PurchaseAllowed($p_FSK18PurchaseAllowed)
2040
	{
2041
		$this->fsk18PurchaseAllowed = (bool)$p_FSK18PurchaseAllowed;
2042
	}
2043

    
2044

    
2045
	/**
2046
	 * @return boolean
2047
	 */
2048
	public function getFSK18DisplayAllowed()
2049
	{
2050
		return $this->fsk18DisplayAllowed;
2051
	}
2052

    
2053

    
2054
	/**
2055
	 * @param boolean $p_FSK18DisplayAllowed
2056
	 */
2057
	public function setFSK18DisplayAllowed($p_FSK18DisplayAllowed)
2058
	{
2059
		$this->fsk18DisplayAllowed = (bool)$p_FSK18DisplayAllowed;
2060
	}
2061

    
2062

    
2063
	/**
2064
	 * @return string
2065
	 */
2066
	public function getLastListingSql()
2067
	{
2068
		return $this->lastListingSql;
2069
	}
2070

    
2071

    
2072
	/**
2073
	 * @param string $p_lastListingSql
2074
	 */
2075
	public function setLastListingSql($p_lastListingSql)
2076
	{
2077
		$this->lastListingSql = (string)$p_lastListingSql;
2078
	}
2079

    
2080

    
2081
	/**
2082
	 * @return int
2083
	 */
2084
	public function getCustomerStatusId()
2085
	{
2086
		return $this->customerStatusId;
2087
	}
2088

    
2089

    
2090
	/**
2091
	 * @param int $p_customerStatusId
2092
	 */
2093
	public function setCustomerStatusId($p_customerStatusId)
2094
	{
2095
		$this->customerStatusId = (int)$p_customerStatusId;
2096
	}
2097

    
2098
	/**
2099
	 * @return array
2100
	 */
2101
	public function getAdditionalFields()
2102
	{
2103
		return $this->additionalFields;
2104
	}
2105

    
2106

    
2107
	/**
2108
	 * @param array $p_additionalFields
2109
	 */
2110
	public function setAdditionalFields($p_additionalFields)
2111
	{
2112
		$this->additionalFields = $p_additionalFields;
2113
	}
2114

    
2115

    
2116
	##### DEPRECATED since GX2.2 #####
2117

    
2118
	protected function _assignDeprecatedPurchaseData()
2119
	{
2120
		$this->set_content_data('ADD_QTY', xtc_draw_input_field('products_qty', str_replace('.', ',',
2121
		                                                                                    (double)$this->product->data['gm_min_order']),
2122
		                                                        'id="gm_attr_calc_qty"') . ' '
2123
		                                   . xtc_draw_hidden_field('products_id', $this->product->data['products_id'],
2124
		                                                           'id="gm_products_id"'), 2);
2125

    
2126
		$this->set_content_data('ADD_CART_BUTTON',
2127
		                        xtc_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'id="cart_button"'), 2);
2128
	}
2129

    
2130

    
2131
	protected function _assignDeprecatedWishlist()
2132
	{
2133
		if(gm_get_conf('GM_SHOW_WISHLIST') == 'true')
2134
		{
2135
			$this->set_content_data('ADD_WISHLIST_BUTTON',
2136
			                        '<a href="javascript:submit_to_wishlist()" id="gm_wishlist_link">'
2137
			                        . xtc_image_button('button_in_wishlist.gif', NC_WISHLIST) . '</a>', 2);
2138
		}
2139
	}
2140

    
2141

    
2142
	protected function _assignDeprecatedPrintLink()
2143
	{
2144
		$this->set_content_data('PRODUCTS_PRINT',
2145
		                        '<img src="templates/' . CURRENT_TEMPLATE . '/buttons/' . $this->language
2146
		                        . '/print.gif"  style="cursor:hand;" onclick="javascript:window.open(\''
2147
		                        . xtc_href_link(FILENAME_PRINT_PRODUCT_INFO,
2148
		                                        'products_id=' . $this->product->data['products_id'])
2149
		                        . '\', \'popup\', \'toolbar=0, width=640, height=600\')" alt="" />');
2150
	}
2151

    
2152

    
2153
	protected function _assignDeprecatedFormTagData()
2154
	{
2155
		$this->set_content_data('FORM_ACTION', xtc_draw_form('cart_quantity', xtc_href_link(FILENAME_PRODUCT_INFO,
2156
		                                                                                    xtc_get_all_get_params(array('action'))
2157
		                                                                                    . 'action=add_product',
2158
		                                                                                    'NONSSL', true, true, true),
2159
		                                                     'post',
2160
		                                                     'name="cart_quantity" onsubmit="gm_qty_check = new GMOrderQuantityChecker(); return gm_qty_check.check();"'),
2161
		                        2);
2162
		$this->set_content_data('FORM_END', '</form>', 2);
2163
	}
2164

    
2165

    
2166
	protected function _assignDeprecatedIdHiddenField()
2167
	{
2168
		$this->set_content_data('GM_PID', xtc_draw_hidden_field('products_id', $this->product->data['products_id'],
2169
		                                                        'id="gm_products_id"'), 2);
2170
	}
2171

    
2172

    
2173
	protected function _assignDeprecatedDimensionValues()
2174
	{
2175
		if(PRODUCT_IMAGE_INFO_WIDTH < (190 - 16))
2176
		{
2177
			$this->set_content_data('MIN_IMAGE_WIDTH', 188, 2);
2178
			$this->set_content_data('MIN_INFO_BOX_WIDTH', 156 - 10, 2);
2179
			$this->set_content_data('MARGIN_LEFT', 188 + 10, 2);
2180
		}
2181
		else
2182
		{
2183
			$this->set_content_data('MIN_IMAGE_WIDTH', PRODUCT_IMAGE_INFO_WIDTH + 16, 2);
2184
			$this->set_content_data('MIN_INFO_BOX_WIDTH', PRODUCT_IMAGE_INFO_WIDTH + 16 - 32 - 10, 2);
2185
			$this->set_content_data('MARGIN_LEFT', PRODUCT_IMAGE_INFO_WIDTH + 16 + 10, 2);
2186
		}
2187
	}
2188

    
2189

    
2190
	/**
2191
	 * @return string
2192
	 */
2193
	protected function _getMediaContentHtml()
2194
	{
2195
		/* @var ProductMediaContentView $view */
2196
		$view = MainFactory::create_object('ProductMediaContentView');
2197
		$view->setProductId($this->product->data['products_id']);
2198
		$view->setLanguageId($this->languageId);
2199
		$view->setCustomerStatusId($this->customerStatusId);
2200
		$html = $view->get_html();
2201

    
2202
		return $html;
2203
	}
2204
	
2205
	
2206
	/**
2207
	 * @return int
2208
	 */
2209
	public function getOfferAggregationLimit()
2210
	{
2211
		return $this->offerAggregationLimit;
2212
	}
2213
	
2214
	
2215
	/**
2216
	 * @param int $offerAggregationLimit
2217
	 */
2218
	public function setOfferAggregationLimit($offerAggregationLimit)
2219
	{
2220
		$this->offerAggregationLimit = $offerAggregationLimit;
2221
	}
2222
}
    (1-1/1)