hpdl
|
1
|
1
|
<?php
|
|
2
|
/*
|
hpdl
|
153
|
3
|
$Id: order_total.php 435 2006-02-16 10:02:53Z hpdl $
|
hpdl
|
1
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
hpdl
|
404
|
8
|
Copyright (c) 2006 osCommerce
|
hpdl
|
1
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
hpdl
|
428
|
13
|
class osC_OrderTotal {
|
hpdl
|
434
|
14
|
var $_modules = array(),
|
|
15
|
$_group = 'order_total';
|
hpdl
|
1
|
16
|
|
|
17
|
// class constructor
|
hpdl
|
428
|
18
|
function osC_OrderTotal() {
|
|
19
|
global $osC_Database, $osC_Language;
|
hpdl
|
377
|
20
|
|
hpdl
|
435
|
21
|
if (isset($_SESSION['osC_OrderTotal_data']) === false) {
|
|
22
|
$_SESSION['osC_OrderTotal_data'] = array('cartID' => null,
|
|
23
|
'output' => array());
|
|
24
|
}
|
|
25
|
|
|
26
|
$this->_data =& $_SESSION['osC_OrderTotal_data'];
|
|
27
|
|
hpdl
|
428
|
28
|
$Qmodules = $osC_Database->query('select code from :table_templates_boxes where modules_group = "order_total"');
|
|
29
|
$Qmodules->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
30
|
$Qmodules->setCache('modules-order_total');
|
|
31
|
$Qmodules->execute();
|
hpdl
|
1
|
32
|
|
hpdl
|
428
|
33
|
while ($Qmodules->next()) {
|
hpdl
|
434
|
34
|
$this->_modules[] = $Qmodules->value('code');
|
hpdl
|
428
|
35
|
}
|
hpdl
|
404
|
36
|
|
hpdl
|
428
|
37
|
$Qmodules->freeResult();
|
hpdl
|
1
|
38
|
|
hpdl
|
428
|
39
|
$osC_Language->load('modules-order_total');
|
|
40
|
|
hpdl
|
434
|
41
|
foreach ($this->_modules as $module) {
|
hpdl
|
428
|
42
|
include('includes/modules/order_total/' . $module . '.' . substr(basename(__FILE__), (strrpos(basename(__FILE__), '.')+1)));
|
|
43
|
|
|
44
|
$module_class = 'osC_OrderTotal_' . $module;
|
|
45
|
|
|
46
|
$GLOBALS[$module_class] = new $module_class();
|
hpdl
|
1
|
47
|
}
|
|
48
|
}
|
|
49
|
|
hpdl
|
432
|
50
|
// class methods
|
|
51
|
function getCode() {
|
|
52
|
return $this->_code;
|
|
53
|
}
|
|
54
|
|
|
55
|
function getTitle() {
|
|
56
|
return $this->_title;
|
|
57
|
}
|
|
58
|
|
|
59
|
function getDescription() {
|
|
60
|
return $this->_description;
|
|
61
|
}
|
|
62
|
|
|
63
|
function getStatus() {
|
|
64
|
return $this->_status;
|
|
65
|
}
|
|
66
|
|
|
67
|
function getSortOrder() {
|
|
68
|
return $this->_sort_order;
|
|
69
|
}
|
|
70
|
|
hpdl
|
433
|
71
|
function getResult() {
|
hpdl
|
435
|
72
|
global $osC_ShoppingCart;
|
hpdl
|
1
|
73
|
|
hpdl
|
435
|
74
|
if ($this->_data['cartID'] != $osC_ShoppingCart->getCartID()) {
|
|
75
|
$this->_data['cartID'] = $osC_ShoppingCart->getCartID();
|
hpdl
|
428
|
76
|
|
hpdl
|
435
|
77
|
$this->_data['output'] = array();
|
hpdl
|
428
|
78
|
|
hpdl
|
435
|
79
|
foreach ($this->_modules as $module) {
|
|
80
|
$module = 'osC_OrderTotal_' . $module;
|
|
81
|
|
|
82
|
if ($GLOBALS[$module]->getStatus() === true) {
|
|
83
|
$GLOBALS[$module]->process();
|
|
84
|
|
|
85
|
foreach ($GLOBALS[$module]->output as $output) {
|
|
86
|
if (tep_not_null($output['title']) && tep_not_null($output['text'])) {
|
|
87
|
$this->_data['output'][] = array('code' => $GLOBALS[$module]->getCode(),
|
|
88
|
'title' => $output['title'],
|
|
89
|
'text' => $output['text'],
|
|
90
|
'value' => $output['value'],
|
|
91
|
'sort_order' => $GLOBALS[$module]->getSortOrder());
|
|
92
|
}
|
hpdl
|
1
|
93
|
}
|
|
94
|
}
|
|
95
|
}
|
|
96
|
}
|
|
97
|
|
hpdl
|
435
|
98
|
return $this->_data['output'];
|
hpdl
|
1
|
99
|
}
|
|
100
|
|
hpdl
|
431
|
101
|
function hasActive() {
|
|
102
|
static $has_active;
|
|
103
|
|
|
104
|
if (isset($has_active) === false) {
|
|
105
|
$has_active = false;
|
|
106
|
|
hpdl
|
434
|
107
|
foreach ($this->_modules as $module) {
|
hpdl
|
432
|
108
|
if ($GLOBALS['osC_OrderTotal_' . $module]->getStatus() === true) {
|
hpdl
|
431
|
109
|
$has_active = true;
|
|
110
|
break;
|
|
111
|
}
|
|
112
|
}
|
|
113
|
}
|
|
114
|
|
|
115
|
return $has_active;
|
|
116
|
}
|
|
117
|
|
hpdl
|
428
|
118
|
function hasKeys() {
|
|
119
|
static $has_keys;
|
|
120
|
|
|
121
|
if (isset($has_keys) === false) {
|
|
122
|
$has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
|
|
123
|
}
|
|
124
|
|
|
125
|
return $has_keys;
|
|
126
|
}
|
|
127
|
|
|
128
|
function install() {
|
|
129
|
global $osC_Database, $osC_Language;
|
|
130
|
|
|
131
|
$Qinstall = $osC_Database->query('insert into :table_templates_boxes (title, code, author_name, author_www, modules_group) values (:title, :code, :author_name, :author_www, :modules_group)');
|
|
132
|
$Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
133
|
$Qinstall->bindValue(':title', $this->_title);
|
|
134
|
$Qinstall->bindValue(':code', $this->_code);
|
|
135
|
$Qinstall->bindValue(':author_name', $this->_author_name);
|
|
136
|
$Qinstall->bindValue(':author_www', $this->_author_www);
|
|
137
|
$Qinstall->bindValue(':modules_group', $this->_group);
|
|
138
|
$Qinstall->execute();
|
|
139
|
|
|
140
|
foreach ($osC_Language->getAll() as $key => $value) {
|
|
141
|
if (file_exists(dirname(__FILE__) . '/../languages/' . $key . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
|
|
142
|
foreach ($osC_Language->extractDefinitions($key . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
|
|
143
|
$Qcheck = $osC_Database->query('select id from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id limit 1');
|
|
144
|
$Qcheck->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
|
|
145
|
$Qcheck->bindValue(':definition_key', $def['key']);
|
|
146
|
$Qcheck->bindValue(':content_group', $def['group']);
|
|
147
|
$Qcheck->bindInt(':languages_id', $value['id']);
|
|
148
|
$Qcheck->execute();
|
|
149
|
|
|
150
|
if ($Qcheck->numberOfRows() === 1) {
|
|
151
|
$Qdef = $osC_Database->query('update :table_languages_definitions set definition_value = :definition_value where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id');
|
|
152
|
} else {
|
|
153
|
$Qdef = $osC_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)');
|
|
154
|
}
|
|
155
|
$Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
|
|
156
|
$Qdef->bindInt(':languages_id', $value['id']);
|
|
157
|
$Qdef->bindValue(':content_group', $def['group']);
|
|
158
|
$Qdef->bindValue(':definition_key', $def['key']);
|
|
159
|
$Qdef->bindValue(':definition_value', $def['value']);
|
|
160
|
$Qdef->execute();
|
|
161
|
}
|
|
162
|
}
|
|
163
|
}
|
|
164
|
|
|
165
|
osC_Cache::clear('languages');
|
|
166
|
}
|
|
167
|
|
|
168
|
function remove() {
|
|
169
|
global $osC_Database, $osC_Language;
|
|
170
|
|
|
171
|
$Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
|
|
172
|
$Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
173
|
$Qdel->bindValue(':code', $this->_code);
|
|
174
|
$Qdel->bindValue(':modules_group', $this->_group);
|
|
175
|
$Qdel->execute();
|
|
176
|
|
|
177
|
if ($this->hasKeys()) {
|
|
178
|
$Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
|
|
179
|
$Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
180
|
$Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
|
|
181
|
$Qdel->execute();
|
|
182
|
}
|
|
183
|
|
|
184
|
if (file_exists(dirname(__FILE__) . '/../languages/' . $osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
|
|
185
|
foreach ($osC_Language->extractDefinitions($osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
|
|
186
|
$Qdel = $osC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
|
|
187
|
$Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
|
|
188
|
$Qdel->bindValue(':definition_key', $def['key']);
|
|
189
|
$Qdel->bindValue(':content_group', $def['group']);
|
|
190
|
$Qdel->execute();
|
|
191
|
}
|
|
192
|
|
|
193
|
osC_Cache::clear('languages');
|
|
194
|
}
|
|
195
|
}
|
|
196
|
|
|
197
|
function _usortModules($a, $b) {
|
hpdl
|
432
|
198
|
if ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() == $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) {
|
|
199
|
return strnatcasecmp($GLOBALS['osC_OrderTotal_' . $a]->getTitle(), $GLOBALS['osC_OrderTotal_' . $a]->getTitle());
|
hpdl
|
428
|
200
|
}
|
|
201
|
|
hpdl
|
432
|
202
|
return ($GLOBALS['osC_OrderTotal_' . $a]->getSortOrder() < $GLOBALS['osC_OrderTotal_' . $b]->getSortOrder()) ? -1 : 1;
|
hpdl
|
428
|
203
|
}
|
hpdl
|
1
|
204
|
}
|
hpdl
|
428
|
205
|
?>
|