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 $enabled = false; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
function ht_pagantis() { |
|
|
|
|
24
|
|
|
$this->title = MODULE_HEADER_TAGS_PAGANTIS_TITLE; |
25
|
|
|
$this->description = MODULE_HEADER_TAGS_PAGANTIS_DESCRIPTION; |
26
|
|
|
$this->sort_order = 0; |
|
|
|
|
27
|
|
|
|
28
|
|
|
if ( defined('MODULE_HEADER_TAGS_PAGANTIS_STATUS') ) { |
29
|
|
|
$this->enabled = (MODULE_HEADER_TAGS_PAGANTIS_STATUS == 'True'); |
30
|
|
|
} |
31
|
|
|
$this->extraConfig = $this->getExtraConfig(); |
|
|
|
|
32
|
|
|
$this->pk = $this->getConfig('MODULE_PAYMENT_PAGANTIS_PK'); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return array |
37
|
|
|
*/ |
38
|
|
|
private function getExtraConfig() |
39
|
|
|
{ |
40
|
|
|
$checkTable = tep_db_query("SHOW TABLES LIKE '".TABLE_PAGANTIS_CONFIG."'"); |
|
|
|
|
41
|
|
|
$response = array(); |
42
|
|
|
if (tep_db_num_rows($checkTable) > 0) { |
|
|
|
|
43
|
|
|
$query = "select * from ".TABLE_PAGANTIS_CONFIG; |
44
|
|
|
$result = tep_db_query($query); |
45
|
|
|
$response = array(); |
46
|
|
|
while ($resultArray = tep_db_fetch_array($result)) { |
|
|
|
|
47
|
|
|
$response[$resultArray['config']] = $resultArray['value']; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
return $response; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $config |
55
|
|
|
* @return array |
56
|
|
|
*/ |
57
|
|
|
private function getConfig($config = '') |
58
|
|
|
{ |
59
|
|
|
$query = "select configuration_value from ".TABLE_CONFIGURATION . " where configuration_key = '" . $config . "'"; |
|
|
|
|
60
|
|
|
$result = tep_db_query($query); |
|
|
|
|
61
|
|
|
$resultArray = tep_db_fetch_array($result); |
|
|
|
|
62
|
|
|
return $resultArray['configuration_value']; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
function execute() { |
|
|
|
|
66
|
|
|
echo "<script src='https://cdn.pagantis.com/js/pg-v2/sdk.js'></script>". PHP_EOL; |
67
|
|
|
echo '<script>'. PHP_EOL; |
68
|
|
|
|
69
|
|
|
echo ' function loadSimulator()'. PHP_EOL; |
70
|
|
|
echo ' {'. PHP_EOL; |
71
|
|
|
echo ' if (typeof pgSDK != \'undefined\') {'. PHP_EOL; |
72
|
|
|
echo ' var positionSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR']. '\';'. PHP_EOL; |
73
|
|
|
echo ' var priceSelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']. '\';'. PHP_EOL; |
74
|
|
|
echo ' var quantitySelector = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']. '\';'. PHP_EOL; |
75
|
|
|
|
76
|
|
|
echo ' if (positionSelector === \'default\') {'. PHP_EOL; |
77
|
|
|
echo ' positionSelector = \'.buttonSet\''. PHP_EOL; |
78
|
|
|
echo ' }'. PHP_EOL; |
79
|
|
|
|
80
|
|
|
echo ' if (priceSelector === \'default\') {'. PHP_EOL; |
81
|
|
|
echo ' priceSelector = \'#bodyContent>form>div>h1\''. PHP_EOL; |
82
|
|
|
echo ' }'. PHP_EOL; |
83
|
|
|
|
84
|
|
|
echo ' pgSDK.product_simulator = {};'. PHP_EOL; |
85
|
|
|
echo ' pgSDK.product_simulator.id = \'product-simulator\';'. PHP_EOL; |
86
|
|
|
echo ' pgSDK.product_simulator.publicKey = \'' . $this->pk . '\';'. PHP_EOL; |
|
|
|
|
87
|
|
|
echo ' pgSDK.product_simulator.selector = positionSelector;'. PHP_EOL; |
88
|
|
|
echo ' pgSDK.product_simulator.numInstalments = \'' . $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] . '\';'. PHP_EOL; |
89
|
|
|
echo ' pgSDK.product_simulator.type = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_TYPE'] . ';'. PHP_EOL; |
90
|
|
|
echo ' pgSDK.product_simulator.skin = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_SKIN'] . ';'. PHP_EOL; |
91
|
|
|
echo ' pgSDK.product_simulator.position = ' . $this->extraConfig['PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'] . ';'. PHP_EOL; |
92
|
|
|
echo ' pgSDK.product_simulator.itemAmountSelector = priceSelector;'. PHP_EOL; |
93
|
|
|
|
94
|
|
|
echo ' pgSDK.simulator.init(pgSDK.product_simulator);'. PHP_EOL; |
95
|
|
|
echo ' clearInterval(window.PSSimulatorId);'. PHP_EOL; |
96
|
|
|
echo ' return true;'. PHP_EOL; |
97
|
|
|
echo ' }'. PHP_EOL; |
98
|
|
|
echo ' return false;'. PHP_EOL; |
99
|
|
|
echo ' }'. PHP_EOL; |
100
|
|
|
echo ' window.PSSimulatorId = setInterval(function () {'. PHP_EOL; |
101
|
|
|
echo ' loadSimulator();'. PHP_EOL; |
102
|
|
|
echo ' }, 2000);'. PHP_EOL; |
103
|
|
|
echo '</script>'. PHP_EOL; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
function isEnabled() { |
|
|
|
|
107
|
|
|
return $this->enabled; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
function check() { |
|
|
|
|
111
|
|
|
return defined('MODULE_HEADER_TAGS_PAGANTIS_STATUS'); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
function install() { |
|
|
|
|
115
|
|
|
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', '', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); |
|
|
|
|
116
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
function remove() { |
|
|
|
|
120
|
|
|
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); |
|
|
|
|
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
function keys() { |
|
|
|
|
124
|
|
|
return array('MODULE_HEADER_TAGS_PAGANTIS_STATUS'); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
?> |
|
|
|
|
128
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.