hpdl
|
308
|
1
|
<?php
|
|
2
|
/*
|
|
3
|
$Id: $
|
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
|
8
|
Copyright (c) 2005 osCommerce
|
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
hpdl
|
333
|
13
|
class osC_Modules {
|
|
14
|
var $_modules,
|
hpdl
|
313
|
15
|
$_code,
|
hpdl
|
308
|
16
|
$_title,
|
|
17
|
$_title_link,
|
hpdl
|
313
|
18
|
$_content,
|
|
19
|
$_author_name,
|
|
20
|
$_author_www,
|
hpdl
|
331
|
21
|
$_keys,
|
hpdl
|
333
|
22
|
$_group;
|
hpdl
|
308
|
23
|
|
hpdl
|
333
|
24
|
function osC_Modules($group) {
|
hpdl
|
317
|
25
|
global $osC_Database, $osC_Template, $osC_Cache;
|
hpdl
|
313
|
26
|
|
hpdl
|
333
|
27
|
$this->_group = $group;
|
|
28
|
|
|
29
|
if ($osC_Cache->read('templates_' . $this->_group . '_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) {
|
hpdl
|
317
|
30
|
$data = $osC_Cache->getCache();
|
|
31
|
} else {
|
|
32
|
$data = array();
|
hpdl
|
313
|
33
|
|
hpdl
|
331
|
34
|
$Qspecific = $osC_Database->query('select b2p.boxes_group, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.page_specific = 1 and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
|
hpdl
|
317
|
35
|
$Qspecific->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
|
|
36
|
$Qspecific->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
37
|
$Qspecific->bindTable(':table_templates', TABLE_TEMPLATES);
|
hpdl
|
351
|
38
|
$Qspecific->bindInt(':templates_id', $osC_Template->getID());
|
hpdl
|
320
|
39
|
$Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"');
|
hpdl
|
333
|
40
|
$Qspecific->bindValue(':modules_group', $this->_group);
|
hpdl
|
317
|
41
|
$Qspecific->execute();
|
|
42
|
|
|
43
|
if ($Qspecific->numberOfRows()) {
|
|
44
|
while ($Qspecific->next()) {
|
|
45
|
$data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code');
|
|
46
|
}
|
|
47
|
} else {
|
hpdl
|
333
|
48
|
$_data = array();
|
hpdl
|
317
|
49
|
|
hpdl
|
333
|
50
|
$Qmodules = $osC_Database->query('select b2p.boxes_group, b2p.content_page, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
|
|
51
|
$Qmodules->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
|
|
52
|
$Qmodules->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
53
|
$Qmodules->bindTable(':table_templates', TABLE_TEMPLATES);
|
hpdl
|
351
|
54
|
$Qmodules->bindInt(':templates_id', $osC_Template->getID());
|
hpdl
|
333
|
55
|
$Qmodules->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"');
|
|
56
|
$Qmodules->bindValue(':modules_group', $this->_group);
|
|
57
|
$Qmodules->execute();
|
|
58
|
|
|
59
|
while ($Qmodules->next()) {
|
|
60
|
$_data[$Qmodules->value('boxes_group')][] = array('code' => $Qmodules->value('code'),
|
|
61
|
'page' => $Qmodules->value('content_page'));
|
hpdl
|
317
|
62
|
}
|
hpdl
|
319
|
63
|
|
hpdl
|
333
|
64
|
foreach ($_data as $groups => $modules) {
|
hpdl
|
319
|
65
|
$clean = array();
|
|
66
|
|
hpdl
|
333
|
67
|
foreach ($modules as $module) {
|
|
68
|
if (isset($clean[$module['code']])) {
|
|
69
|
if (substr_count($module['page'], '/') > substr_count($clean[$module['code']]['page'], '/')) {
|
|
70
|
unset($clean[$module['code']]);
|
hpdl
|
319
|
71
|
}
|
|
72
|
}
|
|
73
|
|
hpdl
|
333
|
74
|
$clean[$module['code']] = $module;
|
hpdl
|
319
|
75
|
}
|
|
76
|
|
|
77
|
$_data[$groups] = $clean;
|
|
78
|
}
|
|
79
|
|
hpdl
|
333
|
80
|
foreach ($_data as $groups => $modules) {
|
|
81
|
foreach ($modules as $module) {
|
|
82
|
$data[$groups][] = $module['code'];
|
hpdl
|
319
|
83
|
}
|
|
84
|
}
|
hpdl
|
317
|
85
|
}
|
|
86
|
|
|
87
|
$osC_Cache->writeBuffer($data);
|
hpdl
|
313
|
88
|
}
|
|
89
|
|
hpdl
|
333
|
90
|
$this->_modules = $data;
|
hpdl
|
308
|
91
|
}
|
|
92
|
|
hpdl
|
313
|
93
|
function getCode() {
|
|
94
|
return $this->_code;
|
|
95
|
}
|
|
96
|
|
hpdl
|
308
|
97
|
function getTitle() {
|
|
98
|
return $this->_title;
|
|
99
|
}
|
|
100
|
|
|
101
|
function getTitleLink() {
|
|
102
|
return $this->_title_link;
|
|
103
|
}
|
|
104
|
|
|
105
|
function hasTitleLink() {
|
|
106
|
return !empty($this->_title_link);
|
|
107
|
}
|
|
108
|
|
|
109
|
function getContent() {
|
|
110
|
return $this->_content;
|
|
111
|
}
|
|
112
|
|
|
113
|
function hasContent() {
|
|
114
|
return !empty($this->_content);
|
|
115
|
}
|
|
116
|
|
hpdl
|
333
|
117
|
function getAuthorName() {
|
|
118
|
return $this->_author_name;
|
|
119
|
}
|
|
120
|
|
|
121
|
function getAuthorAddress() {
|
|
122
|
return $this->_author_www;
|
|
123
|
}
|
|
124
|
|
hpdl
|
308
|
125
|
function getGroup($group) {
|
hpdl
|
333
|
126
|
$modules = array();
|
hpdl
|
308
|
127
|
|
hpdl
|
333
|
128
|
if (isset($this->_modules[$group])) {
|
|
129
|
foreach ($this->_modules[$group] as $module) {
|
|
130
|
if (file_exists('includes/modules/' . $this->_group . '/' . $module . '.php')) {
|
|
131
|
$class = 'osC_' . ucfirst($this->_group) . '_' . $module;
|
hpdl
|
308
|
132
|
|
hpdl
|
333
|
133
|
if (class_exists($class) === false) {
|
|
134
|
include('includes/modules/' . $this->_group . '/' . $module . '.php');
|
hpdl
|
310
|
135
|
}
|
|
136
|
|
hpdl
|
333
|
137
|
$modules[] = $class;
|
hpdl
|
308
|
138
|
}
|
|
139
|
}
|
|
140
|
}
|
|
141
|
|
hpdl
|
333
|
142
|
return $modules;
|
hpdl
|
308
|
143
|
}
|
hpdl
|
313
|
144
|
|
|
145
|
function isInstalled() {
|
|
146
|
global $osC_Database;
|
|
147
|
|
|
148
|
static $is_installed;
|
|
149
|
|
|
150
|
if (isset($is_installed) === false) {
|
hpdl
|
331
|
151
|
$Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group');
|
hpdl
|
313
|
152
|
$Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
153
|
$Qcheck->bindValue(':code', $this->_code);
|
hpdl
|
333
|
154
|
$Qcheck->bindValue(':modules_group', $this->_group);
|
hpdl
|
313
|
155
|
$Qcheck->execute();
|
|
156
|
|
|
157
|
$is_installed = ($Qcheck->numberOfRows()) ? true : false;
|
|
158
|
}
|
|
159
|
|
|
160
|
return $is_installed;
|
|
161
|
}
|
|
162
|
|
|
163
|
function hasKeys() {
|
|
164
|
static $has_keys;
|
|
165
|
|
|
166
|
if (isset($has_keys) === false) {
|
|
167
|
$has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
|
|
168
|
}
|
|
169
|
|
|
170
|
return $has_keys;
|
|
171
|
}
|
|
172
|
|
|
173
|
function getKeys() {
|
hpdl
|
333
|
174
|
if (isset($this->_keys) === false) {
|
hpdl
|
313
|
175
|
$this->_keys = array();
|
|
176
|
}
|
|
177
|
|
|
178
|
return $this->_keys;
|
|
179
|
}
|
|
180
|
|
|
181
|
function isActive() {
|
|
182
|
return true;
|
|
183
|
}
|
|
184
|
|
hpdl
|
345
|
185
|
function install() {
|
|
186
|
global $osC_Database;
|
|
187
|
|
|
188
|
$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)');
|
|
189
|
$Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
190
|
$Qinstall->bindValue(':title', $this->_title);
|
|
191
|
$Qinstall->bindValue(':code', $this->_code);
|
|
192
|
$Qinstall->bindValue(':author_name', $this->_author_name);
|
|
193
|
$Qinstall->bindValue(':author_www', $this->_author_www);
|
|
194
|
$Qinstall->bindValue(':modules_group', $this->_group);
|
|
195
|
$Qinstall->execute();
|
|
196
|
}
|
|
197
|
|
hpdl
|
313
|
198
|
function remove() {
|
|
199
|
global $osC_Database;
|
|
200
|
|
hpdl
|
333
|
201
|
$Qmodule = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group');
|
|
202
|
$Qmodule->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
203
|
$Qmodule->bindValue(':code', $this->_code);
|
|
204
|
$Qmodule->bindValue(':modules_group', $this->_group);
|
|
205
|
$Qmodule->execute();
|
hpdl
|
313
|
206
|
|
|
207
|
$Qdel = $osC_Database->query('delete from :table_templates_boxes_to_pages where templates_boxes_id = :templates_boxes_id');
|
|
208
|
$Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
hpdl
|
333
|
209
|
$Qdel->bindValue(':templates_boxes_id', $Qmodule->valueInt('id'));
|
hpdl
|
313
|
210
|
$Qdel->execute();
|
|
211
|
|
hpdl
|
331
|
212
|
$Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
|
hpdl
|
313
|
213
|
$Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
|
|
214
|
$Qdel->bindValue(':code', $this->_code);
|
hpdl
|
333
|
215
|
$Qdel->bindValue(':modules_group', $this->_group);
|
hpdl
|
313
|
216
|
$Qdel->execute();
|
|
217
|
|
|
218
|
if ($this->hasKeys()) {
|
|
219
|
$Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
|
|
220
|
$Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
|
|
221
|
$Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
|
|
222
|
$Qdel->execute();
|
|
223
|
}
|
|
224
|
}
|
hpdl
|
308
|
225
|
}
|
|
226
|
?>
|