1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
$Id$ |
4
|
|
|
|
5
|
|
|
osCommerce, Open Source E-Commerce Solutions |
6
|
|
|
http://www.oscommerce.com |
7
|
|
|
|
8
|
|
|
Copyright (c) 2010 osCommerce |
9
|
|
|
|
10
|
|
|
Released under the GNU General Public License |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
define('TABLE_PAGANTIS_CONFIG', 'pagantis_config'); |
14
|
|
|
|
15
|
|
|
class ht_pagantis { |
16
|
|
|
var $code = 'ht_pagantis'; |
17
|
|
|
var $group = 'header_tags'; |
18
|
|
|
var $title; |
19
|
|
|
var $description; |
20
|
|
|
var $sort_order; |
21
|
|
|
var $enabled = false; |
22
|
|
|
|
23
|
|
|
/** @var Array $extraConfig */ |
24
|
|
|
public $extraConfig; |
25
|
|
|
|
26
|
|
|
function ht_pagantis() { |
27
|
|
|
$this->title = MODULE_HEADER_TAGS_PAGANTIS_TITLE; |
28
|
|
|
$this->description = MODULE_HEADER_TAGS_PAGANTIS_DESCRIPTION; |
29
|
|
|
|
30
|
|
|
if ( defined('MODULE_HEADER_TAGS_PAGANTIS_STATUS') ) { |
31
|
|
|
$this->sort_order = MODULE_HEADER_TAGS_PAGANTIS_SORT_ORDER; |
32
|
|
|
$this->enabled = (MODULE_HEADER_TAGS_PAGANTIS_STATUS == 'True'); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
private function getExtraConfig() |
40
|
|
|
{ |
41
|
|
|
$checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'"); |
|
|
|
|
42
|
|
|
$response = array(); |
43
|
|
|
if (tep_db_num_rows($checkTable) > 0) { |
|
|
|
|
44
|
|
|
$query = "select * from ".TABLE_PAGANTIS_CONFIG; |
45
|
|
|
$result = tep_db_query($query); |
46
|
|
|
$resultArray = tep_db_fetch_array($result); |
|
|
|
|
47
|
|
|
var_dump($resultArray); |
|
|
|
|
48
|
|
|
$response = array(); |
49
|
|
|
foreach ((array)$resultArray as $key => $value) { |
50
|
|
|
var_dump($value); |
51
|
|
|
$response[$key] = $value; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
return $response; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function execute() { |
|
|
|
|
58
|
|
|
$this->extraConfig = $this->getExtraConfig(); |
59
|
|
|
echo "<script src='https://cdn.pagantis.com/js/pg-v2/sdk.js'></script>"; |
60
|
|
|
echo '<script>'; |
61
|
|
|
echo ' function loadSimulator()'; |
62
|
|
|
echo ' {'; |
63
|
|
|
echo ' if (typeof pgSDK != \'undefined\') {'; |
64
|
|
|
echo ' var price = null;'; |
65
|
|
|
echo ' var quantity = null;'; |
66
|
|
|
echo ' var positionSelector = ' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR']; |
67
|
|
|
echo ' var priceSelector = ' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
68
|
|
|
echo ' var quantitySelector = ' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
69
|
|
|
|
70
|
|
|
echo ' if (positionSelector === \'default\') {'; |
71
|
|
|
echo ' positionSelector = \'.pagantisSimulator\''; |
72
|
|
|
echo ' }'; |
73
|
|
|
|
74
|
|
|
echo ' if (priceSelector === \'default\') {'; |
75
|
|
|
echo ' priceSelector = findPriceSelector();'; |
76
|
|
|
echo ' }'; |
77
|
|
|
|
78
|
|
|
echo ' if (quantitySelector === \'default\') {'; |
79
|
|
|
echo ' quantitySelector = findQuantitySelector();'; |
80
|
|
|
echo ' if (quantitySelector === \'default\') {'; |
81
|
|
|
echo ' quantity = \'1\''; |
82
|
|
|
echo ' }'; |
83
|
|
|
echo ' }'; |
84
|
|
|
|
85
|
|
|
echo ' pgSDK.product_simulator = {};'; |
86
|
|
|
echo ' pgSDK.product_simulator.id = \'product-simulator\';'; |
87
|
|
|
echo ' pgSDK.product_simulator.publicKey = MODULE_PAYMENT_PAGANTIS_PK;'; |
88
|
|
|
echo ' pgSDK.product_simulator.selector = positionSelector;'; |
89
|
|
|
echo ' pgSDK.product_simulator.numInstalments = ' . $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] . ';'; |
90
|
|
|
echo ' pgSDK.product_simulator.type = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'] . ';'; |
91
|
|
|
echo ' pgSDK.product_simulator.skin = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'] . ';'; |
92
|
|
|
echo ' pgSDK.product_simulator.position = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'] . ';'; |
93
|
|
|
|
94
|
|
|
echo ' if (priceSelector !== \'default\') {'; |
95
|
|
|
echo ' pgSDK.product_simulator.itemAmountSelector = priceSelector;'; |
96
|
|
|
echo ' }'; |
97
|
|
|
echo ' if (quantitySelector !== \'default\' && quantitySelector !== \'none\') {'; |
98
|
|
|
echo ' pgSDK.product_simulator.itemQuantitySelector = quantitySelector;'; |
99
|
|
|
echo ' }'; |
100
|
|
|
echo ' if (price != null) {'; |
101
|
|
|
echo ' pgSDK.product_simulator.itemAmount = price;'; |
102
|
|
|
echo ' }'; |
103
|
|
|
echo ' if (quantity != null) {'; |
104
|
|
|
echo ' pgSDK.product_simulator.itemQuantity = quantity;'; |
105
|
|
|
echo ' }'; |
106
|
|
|
|
107
|
|
|
echo ' pgSDK.simulator.init(pgSDK.product_simulator);'; |
108
|
|
|
echo ' clearInterval(window.PSSimulatorId);'; |
109
|
|
|
echo ' return true;'; |
110
|
|
|
echo ' }'; |
111
|
|
|
echo ' return false;'; |
112
|
|
|
echo ' }'; |
113
|
|
|
echo ' if (!loadSimulator()) {'; |
114
|
|
|
echo ' window.PSSimulatorId = setInterval(function () {'; |
115
|
|
|
echo ' loadSimulator();'; |
116
|
|
|
echo ' }, 2000);'; |
117
|
|
|
echo ' }'; |
118
|
|
|
echo '</script>'; |
119
|
|
|
echo '<div class="pagantisSimulator"></div>'; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
function isEnabled() { |
|
|
|
|
123
|
|
|
return $this->enabled; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
function check() { |
|
|
|
|
127
|
|
|
return defined('MODULE_HEADER_TAGS_PAGANTIS_STATUS'); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
function install() { |
|
|
|
|
131
|
|
|
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Pagantis Module', 'MODULE_HEADER_TAGS_PAGANTIS_STATUS', 'True', 'Do you want to allow product titles to be added to the page title?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); |
|
|
|
|
132
|
|
|
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_PAGANTIS_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
function remove() { |
|
|
|
|
136
|
|
|
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); |
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
function keys() { |
|
|
|
|
140
|
|
|
return array('MODULE_HEADER_TAGS_PAGANTIS_STATUS', 'MODULE_HEADER_TAGS_PAGANTIS_SORT_ORDER'); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
?> |
|
|
|
|
144
|
|
|
|