1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
HCSF - A multilingual CMS and Shopsystem |
5
|
|
|
Copyright (C) 2014 Marcus Haase - [email protected] |
6
|
|
|
|
7
|
|
|
This program is free software: you can redistribute it and/or modify |
8
|
|
|
it under the terms of the GNU General Public License as published by |
9
|
|
|
the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
(at your option) any later version. |
11
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
GNU General Public License for more details. |
16
|
|
|
|
17
|
|
|
You should have received a copy of the GNU General Public License |
18
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace HaaseIT\HCSF\Controller\Admin; |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
use HaaseIT\Toolbox\Tools; |
25
|
|
|
use Zend\ServiceManager\ServiceManager; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class DBStatus |
29
|
|
|
* @package HaaseIT\HCSF\Controller\Admin |
30
|
|
|
*/ |
31
|
|
|
class DBStatus extends Base |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var \PDO |
35
|
|
|
*/ |
36
|
|
|
private $db; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var \Twig_Environment |
40
|
|
|
*/ |
41
|
|
|
private $twig; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* DBStatus constructor. |
45
|
|
|
* @param ServiceManager $serviceManager |
46
|
|
|
*/ |
47
|
|
|
public function __construct(ServiceManager $serviceManager) |
48
|
|
|
{ |
49
|
|
|
parent::__construct($serviceManager); |
50
|
|
|
$this->db = $serviceManager->get('db'); |
51
|
|
|
$this->twig = $serviceManager->get('twig'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
*/ |
57
|
|
|
public function preparePage() |
58
|
|
|
{ |
59
|
|
|
$this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager, [], 'admin/base.twig'); |
60
|
|
|
$this->P->cb_pagetype = 'content'; |
61
|
|
|
$this->P->cb_subnav = 'admin'; |
62
|
|
|
|
63
|
|
|
$this->P->cb_customcontenttemplate = 'DBStatus'; |
64
|
|
|
|
65
|
|
|
$this->handleTextcats(); |
66
|
|
|
$this->handleTextcatArchive(); |
67
|
|
|
$this->handleContent(); |
68
|
|
|
$this->handleContentArchive(); |
69
|
|
|
|
70
|
|
|
if ($this->config->getCore('enable_module_shop')) { |
71
|
|
|
$this->handleItems(); |
72
|
|
|
$this->handleItemGroups(); |
73
|
|
|
$this->handleOrderItems(); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* |
79
|
|
|
*/ |
80
|
|
|
private function handleTextcats() |
81
|
|
|
{ |
82
|
|
|
if (filter_input(INPUT_GET, 'clearorphanedtextcats') !== null) { |
83
|
|
|
$this->db->exec('DELETE FROM textcat_lang WHERE tcl_tcid NOT IN (SELECT tc_id FROM textcat_base)'); |
84
|
|
|
} |
85
|
|
|
/** @var \PDOStatement $hResult */ |
86
|
|
|
$hResult = $this->db->query('SELECT * FROM textcat_lang WHERE tcl_tcid NOT IN (SELECT tc_id FROM textcat_base)'); |
87
|
|
|
$this->P->cb_customdata['rows_textcat_lang'] = $hResult->rowCount(); |
88
|
|
|
if ($this->P->cb_customdata['rows_textcat_lang'] > 0) { |
89
|
|
|
$aListSetting = [ |
90
|
|
|
['title' => 'tcl_id', 'key' => 'tcl_id', 'width' => '6%', 'linked' => false,], |
91
|
|
|
['title' => 'tcl_tcid', 'key' => 'tcl_tcid', 'width' => '6%', 'linked' => false,], |
92
|
|
|
['title' => 'tcl_lang', 'key' => 'tcl_lang', 'width' => '6%', 'linked' => false,], |
93
|
|
|
['title' => 'tcl_text', 'key' => 'tcl_text', 'width' => '82%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
94
|
|
|
]; |
95
|
|
|
$aData = $hResult->fetchAll(); |
96
|
|
|
$this->P->cb_customdata['rows_textcat_lang_list'] = Tools::makeListtable( |
97
|
|
|
$aListSetting, |
98
|
|
|
$aData, |
99
|
|
|
$this->twig |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* |
106
|
|
|
*/ |
107
|
|
|
private function handleTextcatArchive() |
108
|
|
|
{ |
109
|
|
|
if (filter_input(INPUT_GET, 'clearorphanedtextcatsarchive') !== null) { |
110
|
|
|
$this->db->exec('DELETE FROM textcat_lang_archive WHERE tcl_tcid NOT IN (SELECT tc_id FROM textcat_base)'); |
111
|
|
|
} |
112
|
|
|
/** @var \PDOStatement $hResult */ |
113
|
|
|
$hResult = $this->db->query('SELECT * FROM textcat_lang_archive WHERE tcl_tcid NOT IN (SELECT tc_id FROM textcat_base)'); |
114
|
|
|
$this->P->cb_customdata['rows_textcat_lang_archive'] = $hResult->rowCount(); |
115
|
|
|
if ($this->P->cb_customdata['rows_textcat_lang_archive'] > 0) { |
116
|
|
|
$aListSetting = [ |
117
|
|
|
['title' => 'tcla_timestamp', 'key' => 'tcla_timestamp', 'width' => '15%', 'linked' => false,], |
118
|
|
|
['title' => 'tcla_id', 'key' => 'tcla_id', 'width' => '6%', 'linked' => false,], |
119
|
|
|
['title' => 'tcl_id', 'key' => 'tcl_id', 'width' => '6%', 'linked' => false,], |
120
|
|
|
['title' => 'tcl_tcid', 'key' => 'tcl_tcid', 'width' => '6%', 'linked' => false,], |
121
|
|
|
['title' => 'tcl_lang', 'key' => 'tcl_lang', 'width' => '6%', 'linked' => false,], |
122
|
|
|
['title' => 'tcl_text', 'key' => 'tcl_text', 'width' => '61%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
123
|
|
|
]; |
124
|
|
|
$aData = $hResult->fetchAll(); |
125
|
|
|
$this->P->cb_customdata['rows_textcat_lang_archive_list'] = Tools::makeListtable($aListSetting, |
126
|
|
|
$aData, $this->twig); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* |
132
|
|
|
*/ |
133
|
|
|
private function handleContent() |
134
|
|
|
{ |
135
|
|
|
if (filter_input(INPUT_GET, 'clearorphanedcontent') !== null) { |
136
|
|
|
$this->db->exec('DELETE FROM content_lang WHERE cl_cb NOT IN (SELECT cb_id FROM content_base)'); |
137
|
|
|
} |
138
|
|
|
/** @var \PDOStatement $hResult */ |
139
|
|
|
$hResult = $this->db->query('SELECT * FROM content_lang WHERE cl_cb NOT IN (SELECT cb_id FROM content_base)'); |
140
|
|
|
$this->P->cb_customdata['rows_content_lang'] = $hResult->rowCount(); |
141
|
|
|
if ($this->P->cb_customdata['rows_content_lang'] > 0) { |
142
|
|
|
$aListSetting = [ |
143
|
|
|
['title' => 'cl_id', 'key' => 'cl_id', 'width' => '6%', 'linked' => false,], |
144
|
|
|
['title' => 'cl_cb', 'key' => 'cl_cb', 'width' => '6%', 'linked' => false,], |
145
|
|
|
['title' => 'cl_lang', 'key' => 'cl_lang', 'width' => '6%', 'linked' => false,], |
146
|
|
|
['title' => 'cl_html', 'key' => 'cl_html', 'width' => '43%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
147
|
|
|
['title' => 'cl_keywords', 'key' => 'cl_keywords', 'width' => '13%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
148
|
|
|
['title' => 'cl_description', 'key' => 'cl_description', 'width' => '13%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
149
|
|
|
['title' => 'cl_title', 'key' => 'cl_title', 'width' => '13%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
150
|
|
|
]; |
151
|
|
|
$aData = $hResult->fetchAll(); |
152
|
|
|
$this->P->cb_customdata['rows_content_lang_list'] = Tools::makeListtable($aListSetting, |
153
|
|
|
$aData, $this->twig); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* |
159
|
|
|
*/ |
160
|
|
|
private function handleContentArchive() |
161
|
|
|
{ |
162
|
|
|
if (filter_input(INPUT_GET, 'clearorphanedcontentarchive') !== null) { |
163
|
|
|
$this->db->exec('DELETE FROM content_lang_archive WHERE cl_cb NOT IN (SELECT cb_id FROM content_base)'); |
164
|
|
|
} |
165
|
|
|
/** @var \PDOStatement $hResult */ |
166
|
|
|
$hResult = $this->db->query('SELECT * FROM content_lang_archive WHERE cl_cb NOT IN (SELECT cb_id FROM content_base)'); |
167
|
|
|
$this->P->cb_customdata['rows_content_lang_archive'] = $hResult->rowCount(); |
168
|
|
|
if ($this->P->cb_customdata['rows_content_lang_archive'] > 0) { |
169
|
|
|
$aListSetting = [ |
170
|
|
|
['title' => 'cla_timestamp', 'key' => 'cla_timestamp', 'width' => '15%', 'linked' => false,], |
171
|
|
|
['title' => 'cla_id', 'key' => 'cla_id', 'width' => '6%', 'linked' => false,], |
172
|
|
|
['title' => 'cl_id', 'key' => 'cl_id', 'width' => '6%', 'linked' => false,], |
173
|
|
|
['title' => 'cl_cb', 'key' => 'cl_cb', 'width' => '6%', 'linked' => false,], |
174
|
|
|
['title' => 'cl_lang', 'key' => 'cl_lang', 'width' => '6%', 'linked' => false,], |
175
|
|
|
['title' => 'cl_html', 'key' => 'cl_html', 'width' => '33%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
176
|
|
|
['title' => 'cl_keywords', 'key' => 'cl_keywords', 'width' => '10%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
177
|
|
|
['title' => 'cl_description', 'key' => 'cl_description', 'width' => '10%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
178
|
|
|
['title' => 'cl_title', 'key' => 'cl_title', 'width' => '10%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
179
|
|
|
]; |
180
|
|
|
$aData = $hResult->fetchAll(); |
181
|
|
|
$this->P->cb_customdata['rows_content_lang_archive_list'] = Tools::makeListtable($aListSetting, |
182
|
|
|
$aData, $this->twig); |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* |
188
|
|
|
*/ |
189
|
|
|
private function handleItems() |
190
|
|
|
{ |
191
|
|
|
if (filter_input(INPUT_GET, 'clearorphaneditems') !== null) { |
192
|
|
|
$this->db->exec('DELETE FROM item_lang WHERE itml_pid NOT IN (SELECT itm_id FROM item_base)'); |
193
|
|
|
} |
194
|
|
|
/** @var \PDOStatement $hResult */ |
195
|
|
|
$hResult = $this->db->query('SELECT * FROM item_lang WHERE itml_pid NOT IN (SELECT itm_id FROM item_base)'); |
196
|
|
|
$this->P->cb_customdata['rows_item_lang'] = $hResult->rowCount(); |
197
|
|
|
if ($this->P->cb_customdata['rows_item_lang'] > 0) { |
198
|
|
|
$aListSetting = [ |
199
|
|
|
['title' => 'itml_id', 'key' => 'itml_id', 'width' => '6%', 'linked' => false,], |
200
|
|
|
['title' => 'itml_pid', 'key' => 'itml_pid', 'width' => '6%', 'linked' => false,], |
201
|
|
|
['title' => 'itml_lang', 'key' => 'itml_lang', 'width' => '6%', 'linked' => false,], |
202
|
|
|
[ |
203
|
|
|
'title' => 'itml_name_override', |
204
|
|
|
'key' => 'itml_name_override', |
205
|
|
|
'width' => '18%', |
206
|
|
|
'linked' => false, |
207
|
|
|
'escapehtmlspecialchars' => true, |
208
|
|
|
], |
209
|
|
|
[ |
210
|
|
|
'title' => 'itml_text1', |
211
|
|
|
'key' => 'itml_text1', |
212
|
|
|
'width' => '32%', |
213
|
|
|
'linked' => false, |
214
|
|
|
'escapehtmlspecialchars' => true, |
215
|
|
|
], |
216
|
|
|
[ |
217
|
|
|
'title' => 'itml_text2', |
218
|
|
|
'key' => 'itml_text2', |
219
|
|
|
'width' => '32%', |
220
|
|
|
'linked' => false, |
221
|
|
|
'escapehtmlspecialchars' => true, |
222
|
|
|
], |
223
|
|
|
]; |
224
|
|
|
$aData = $hResult->fetchAll(); |
225
|
|
|
$this->P->cb_customdata['rows_item_lang_list'] = Tools::makeListtable($aListSetting, |
226
|
|
|
$aData, $this->twig); |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* |
232
|
|
|
*/ |
233
|
|
|
private function handleItemGroups() |
234
|
|
|
{ |
235
|
|
|
if (filter_input(INPUT_GET, 'clearorphaneditemgroups') !== null) { |
236
|
|
|
$this->db->exec('DELETE FROM itemgroups_text WHERE itmgt_pid NOT IN (SELECT itmg_id FROM itemgroups_base)'); |
237
|
|
|
} |
238
|
|
|
/** @var \PDOStatement $hResult */ |
239
|
|
|
$hResult = $this->db->query('SELECT * FROM itemgroups_text WHERE itmgt_pid NOT IN (SELECT itmg_id FROM itemgroups_base)'); |
240
|
|
|
$this->P->cb_customdata['rows_itemgroups_text'] = $hResult->rowCount(); |
241
|
|
|
if ($this->P->cb_customdata['rows_itemgroups_text'] > 0) { |
242
|
|
|
$aListSetting = [ |
243
|
|
|
['title' => 'itmgt_id', 'key' => 'itmgt_id', 'width' => '6%', 'linked' => false,], |
244
|
|
|
['title' => 'itmgt_pid', 'key' => 'itmgt_pid', 'width' => '6%', 'linked' => false,], |
245
|
|
|
['title' => 'itmgt_lang', 'key' => 'itmgt_lang', 'width' => '6%', 'linked' => false,], |
246
|
|
|
[ |
247
|
|
|
'title' => 'itmgt_shorttext', |
248
|
|
|
'key' => 'itmgt_shorttext', |
249
|
|
|
'width' => '41%', |
250
|
|
|
'linked' => false, |
251
|
|
|
'escapehtmlspecialchars' => true, |
252
|
|
|
], |
253
|
|
|
[ |
254
|
|
|
'title' => 'itmgt_details', |
255
|
|
|
'key' => 'itmgt_details', |
256
|
|
|
'width' => '41%', |
257
|
|
|
'linked' => false, |
258
|
|
|
'escapehtmlspecialchars' => true, |
259
|
|
|
], |
260
|
|
|
]; |
261
|
|
|
$aData = $hResult->fetchAll(); |
262
|
|
|
$this->P->cb_customdata['rows_itemgroups_text_list'] = Tools::makeListtable($aListSetting, |
263
|
|
|
$aData, $this->twig); |
264
|
|
|
} |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* |
269
|
|
|
*/ |
270
|
|
|
private function handleOrderItems() |
271
|
|
|
{ |
272
|
|
|
if (filter_input(INPUT_GET, 'clearorphanedorderitems') !== null) { |
273
|
|
|
$this->db->exec('DELETE FROM orders_items WHERE oi_o_id NOT IN (SELECT o_id FROM orders)'); |
274
|
|
|
} |
275
|
|
|
/** @var \PDOStatement $hResult */ |
276
|
|
|
$hResult = $this->db->query('SELECT * FROM orders_items WHERE oi_o_id NOT IN (SELECT o_id FROM orders)'); |
277
|
|
|
$this->P->cb_customdata['rows_orders_items'] = $hResult->rowCount(); |
278
|
|
|
if ($this->P->cb_customdata['rows_orders_items'] > 0) { |
279
|
|
|
$aListSetting = [ |
280
|
|
|
['title' => 'oi_id', 'key' => 'oi_id', 'width' => '8%', 'linked' => false,], |
281
|
|
|
['title' => 'oi_o_id', 'key' => 'oi_o_id', 'width' => '9%', 'linked' => false,], |
282
|
|
|
['title' => 'oi_cartkey', 'key' => 'oi_cartkey', 'width' => '13%', 'linked' => false,], |
283
|
|
|
['title' => 'oi_amount', 'key' => 'oi_amount', 'width' => '9%', 'linked' => false,], |
284
|
|
|
['title' => 'oi_vat', 'key' => 'oi_vat', 'width' => '8%', 'linked' => false,], |
285
|
|
|
['title' => 'oi_rg', 'key' => 'oi_rg', 'width' => '8%', 'linked' => false,], |
286
|
|
|
['title' => 'oi_rg_rebate', 'key' => 'oi_rg_rebate', 'width' => '9%', 'linked' => false,], |
287
|
|
|
['title' => 'oi_price_netto_list', 'key' => 'oi_price_netto_list', 'width' => '9%', 'linked' => false,], |
288
|
|
|
['title' => 'oi_price_netto_sale', 'key' => 'oi_price_netto_sale', 'width' => '9%', 'linked' => false,], |
289
|
|
|
['title' => 'oi_price_netto_rebated', 'key' => 'oi_price_netto_rebated', 'width' => '9%', 'linked' => false,], |
290
|
|
|
['title' => 'oi_price_brutto_use', 'key' => 'oi_price_brutto_use', 'width' => '9%', 'linked' => false,], |
291
|
|
|
//['title' => 'oi_img', 'key' => 'oi_img', 'width' => '41%', 'linked' => false, 'escapehtmlspecialchars' => true,], |
292
|
|
|
|
293
|
|
|
]; |
294
|
|
|
$aData = $hResult->fetchAll(); |
295
|
|
|
$this->P->cb_customdata['rows_orders_items_list'] = Tools::makeListtable($aListSetting, |
296
|
|
|
$aData, $this->twig); |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
|