1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* The MIT License (MIT) |
6
|
|
|
* |
7
|
|
|
* Copyright (c) 2015 Daniel Popiniuc |
8
|
|
|
* |
9
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
10
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
11
|
|
|
* in the Software without restriction, including without limitation the rights |
12
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
14
|
|
|
* furnished to do so, subject to the following conditions: |
15
|
|
|
* |
16
|
|
|
* The above copyright notice and this permission notice shall be included in all |
17
|
|
|
* copies or substantial portions of the Software. |
18
|
|
|
* |
19
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
25
|
|
|
* SOFTWARE. |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
namespace danielgp\common_lib; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* DOM component functions |
33
|
|
|
* |
34
|
|
|
* @author Daniel Popiniuc |
35
|
|
|
*/ |
36
|
|
|
trait DomComponentsByDanielGP |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
use \danielgp\browser_agent_info\BrowserAgentInfosByDanielGP, |
40
|
|
|
CommonLibLocale, |
41
|
|
|
DomBasicComponentsByDanielGP, |
42
|
|
|
DomDynamicSelectByDanielGP, |
43
|
|
|
DomComponentsByDanielGPwithCDN; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Builds a <select> based on a given array |
47
|
|
|
* |
48
|
|
|
* @version 20080618 |
49
|
|
|
* @param array $aElements |
50
|
|
|
* @param string/array $sDefaultValue |
|
|
|
|
51
|
|
|
* @param string $selectName |
52
|
|
|
* @param array $featArray |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
|
|
protected function setArrayToSelect($aElements, $sDefaultValue, $selectName, $featArray = null) |
56
|
|
|
{ |
57
|
|
|
if (!is_array($aElements)) { |
58
|
|
|
return ''; |
59
|
|
|
} |
60
|
|
|
if (isset($featArray['readonly'])) { |
61
|
|
|
return $this->setStringIntoShortTag('input', [ |
62
|
|
|
'name' => $selectName, |
63
|
|
|
'id' => $this->buildSelectId($selectName, $featArray), |
64
|
|
|
'readonly' => 'readonly', |
65
|
|
|
'class' => 'input_readonly', |
66
|
|
|
'value' => $sDefaultValue, |
67
|
|
|
]) . $aElements[$sDefaultValue]; |
68
|
|
|
} |
69
|
|
|
return $this->setArrayToSelectNotReadOnly($aElements, $sDefaultValue, $selectName, $featArray); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Converts an array to string |
74
|
|
|
* |
75
|
|
|
* @param string $sSeparator |
76
|
|
|
* @param array $aElements |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
protected function setArrayToStringForUrl($sSeparator, $aElements, $aExceptedElements = ['']) |
80
|
|
|
{ |
81
|
|
|
if (is_array($aElements)) { |
82
|
|
|
if (count($aElements) == 0) { |
83
|
|
|
$sReturn = ['']; |
84
|
|
|
} else { |
85
|
|
|
$sReturn = []; |
86
|
|
|
foreach ($aElements as $key => $value) { |
87
|
|
|
if (!in_array($key, $aExceptedElements)) { |
88
|
|
|
if (is_array($aElements[$key])) { |
89
|
|
|
$aCounter = count($aElements[$key]); |
90
|
|
|
for ($counter2 = 0; $counter2 < $aCounter; $counter2++) { |
91
|
|
|
if ($value[$counter2] !== '') { |
92
|
|
|
$sReturn[] = $key . '[]=' . $value[$counter2]; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} else { |
96
|
|
|
if ($value !== '') { |
97
|
|
|
$sReturn[] = $key . '=' . $value; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} else { |
104
|
|
|
$sReturn = ['']; |
105
|
|
|
} |
106
|
|
|
return implode($sSeparator, $sReturn); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Returns a table from an query |
111
|
|
|
* |
112
|
|
|
* @param array $gArray |
|
|
|
|
113
|
|
|
* @param array $features |
|
|
|
|
114
|
|
|
* @param boolean $bKeepFullPage |
|
|
|
|
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
|
|
protected function setArrayToTable($aElements, $ftrs = null, $bKpFlPge = true) |
|
|
|
|
118
|
|
|
{ |
119
|
|
|
$rows = count($aElements); |
120
|
|
|
if ($rows == 0) { |
121
|
|
|
$divTab = [ |
122
|
|
|
'start' => '', |
123
|
|
|
'end' => '', |
124
|
|
|
]; |
125
|
|
|
if (array_key_exists('showGroupingCounter', $ftrs)) { |
126
|
|
|
if (array_key_exists('grouping_cell_type', $ftrs) && ($ftrs['grouping_cell_type'] == 'tab')) { |
127
|
|
|
$ditTitle = 'No data found'; |
128
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
129
|
|
|
$ditTitle .= ' (0)'; |
130
|
|
|
} |
131
|
|
|
$divTab = [ |
132
|
|
|
'start' => '<div class="tabbertab tabbertabdefault" id="tab_NoData" title="' . $ditTitle . '">', |
133
|
|
|
'end' => '</div><!-- from tab_NoData -->', |
134
|
|
|
]; |
135
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
136
|
|
|
$divTab = [ |
137
|
|
|
'start' => '<div class="tabber" id="tab">' . $divTab['start'], |
138
|
|
|
'end' => $divTab['end'] . '</div><!-- from global Tab -->', |
139
|
|
|
]; |
140
|
|
|
} |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
return $divTab['start'] |
144
|
|
|
. $this->setFeedbackModern('error', 'Error', $this->lclMsgCmn('i18n_NoData')) |
145
|
|
|
. $divTab['end']; |
146
|
|
|
} |
147
|
|
|
if (isset($ftrs['limits'])) { |
148
|
|
|
$ftrs['limits'][1] = min($ftrs['limits'][1], $ftrs['limits'][2]); |
149
|
|
|
if ($ftrs['limits'][2] > $ftrs['limits'][1]) { |
150
|
|
|
$iStartingPageRecord = 1; |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
$sReturn = ''; |
154
|
|
|
if (isset($ftrs['hidden_columns'])) { |
155
|
|
|
$hdClmns = $this->setArrayValuesAsKey($ftrs['hidden_columns']); |
|
|
|
|
156
|
|
|
} else { |
157
|
|
|
$hdClmns = ['']; |
158
|
|
|
} |
159
|
|
|
if ((isset($ftrs['actions']['checkbox_inlineEdit'])) || (isset($ftrs['actions']['checkbox']))) { |
160
|
|
|
$checkboxFormId = 'frm' . date('YmdHis'); |
161
|
|
|
$sReturn .= '<form id="' . $checkboxFormId . '" ' . 'name="' . $checkboxFormId |
162
|
|
|
. '" method="post" ' . ' action="' . $_SERVER['PHP_SELF'] . '" >'; |
163
|
|
|
} |
164
|
|
|
$tbl['Def'] = '<table' |
|
|
|
|
165
|
|
|
. (isset($ftrs['table_style']) ? ' style="' . $ftrs['table_style'] . '"' : '') |
166
|
|
|
. (isset($ftrs['table_class']) ? ' class="' . $ftrs['table_class'] . '"' : '') |
167
|
|
|
. '>'; |
168
|
|
|
if (!isset($ftrs['grouping_cell_type'])) { |
169
|
|
|
$ftrs['grouping_cell_type'] = 'row'; |
170
|
|
|
} |
171
|
|
|
switch ($ftrs['grouping_cell_type']) { |
172
|
|
|
case 'row': |
173
|
|
|
$sReturn .= $tbl['Def']; |
174
|
|
|
break; |
175
|
|
|
case 'tab': |
176
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
177
|
|
|
$sReturn .= '<div class="tabber" id="tab">'; |
178
|
|
|
} |
179
|
|
|
break; |
180
|
|
|
} |
181
|
|
|
$iTableColumns = 0; |
182
|
|
|
$remebered_value = -1; |
183
|
|
|
$remindGroupValue = null; |
184
|
|
|
$color_no = null; |
185
|
|
|
if (!isset($ftrs['headers_breaked'])) { |
186
|
|
|
$ftrs['headers_breaked'] = true; |
187
|
|
|
} |
188
|
|
|
for ($rCntr = 0; $rCntr < $rows; $rCntr++) { |
189
|
|
|
if ($rCntr == 0) { |
190
|
|
|
$header = array_diff_key($aElements[$rCntr], $hdClmns); |
191
|
|
|
$iTableColumns = count($header); |
192
|
|
|
if (isset($ftrs['computed_columns'])) { |
193
|
|
|
$iTableColumns += count($ftrs['computed_columns']); |
194
|
|
|
} |
195
|
|
|
if (isset($ftrs['actions'])) { |
196
|
|
|
$iTableColumns += 1; |
197
|
|
|
} |
198
|
|
|
if (isset($ftrs['grouping_cell'])) { |
199
|
|
|
$iTableColumns -= 1; |
200
|
|
|
} |
201
|
|
|
$tbl['Head'] = '<thead>'; |
202
|
|
|
if ($ftrs['grouping_cell_type'] == 'row') { |
203
|
|
|
$sReturn .= $tbl['Head']; |
204
|
|
|
} |
205
|
|
View Code Duplication |
if (isset($iStartingPageRecord)) { |
|
|
|
|
206
|
|
|
$pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2], $bKpFlPge); |
|
|
|
|
207
|
|
|
$sReturn .= $this->setStringIntoTag($this->setStringIntoTag($pgn, 'th', [ |
208
|
|
|
'colspan' => $iTableColumns |
209
|
|
|
]), 'tr'); |
210
|
|
|
} |
211
|
|
|
$tbl['Header'] = '<tr>'; |
212
|
|
|
if (isset($ftrs['grouping_cell'])) { // Grouping columns |
213
|
|
|
$header = array_diff_key($header, [$ftrs['grouping_cell'] => '']); |
214
|
|
|
} |
215
|
|
|
if (isset($ftrs['actions'])) { // Action column |
216
|
|
|
$tbl['Header'] .= '<th> </th>'; |
217
|
|
|
} |
218
|
|
|
if (isset($ftrs['RowStyle'])) { //Exclude style columns from displaying |
219
|
|
|
$tmpClmns = $this->setArrayValuesAsKey([$ftrs['RowStyle']]); |
|
|
|
|
220
|
|
|
$header = array_diff_key($header, $tmpClmns); |
221
|
|
|
$hdClmns = array_merge($hdClmns, $tmpClmns); |
222
|
|
|
unset($tmpClmns); |
223
|
|
|
} |
224
|
|
|
$tbl['Header'] .= $this->setTableHeader($header, $ftrs['headers_breaked']); // Regular columns |
225
|
|
|
if (isset($ftrs['computed_columns'])) { // Computed columns |
226
|
|
|
$tbl['Header'] .= $this->setTableHeader($ftrs['computed_columns'], $ftrs['headers_breaked']); |
227
|
|
|
} |
228
|
|
|
$tbl['Header'] .= '</tr></thead><tbody>'; |
229
|
|
|
if ($ftrs['grouping_cell_type'] == 'row') { |
230
|
|
|
$sReturn .= $tbl['Header']; |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
$row_current = array_diff_key($aElements[$rCntr], $hdClmns); |
234
|
|
|
if (isset($ftrs['row_colored_alternated'])) { |
235
|
|
|
if ($ftrs['row_colored_alternated'][0] == '#') { |
236
|
|
|
$color_column_value = $rCntr; |
237
|
|
|
} else { |
238
|
|
|
$color_column_value = $row_current[$ftrs['row_colored_alternated'][0]]; |
239
|
|
|
} |
240
|
|
|
if ($remebered_value != $color_column_value) { |
241
|
|
|
if (isset($color_no)) { |
242
|
|
|
$color_no = 1; |
243
|
|
|
} else { |
244
|
|
|
$color_no = 2; |
245
|
|
|
} |
246
|
|
|
$remebered_value = $color_column_value; |
247
|
|
|
} |
248
|
|
|
$color = ' style="background-color: ' . $ftrs['row_colored_alternated'][$color_no] . ';"'; |
249
|
|
|
} else { |
250
|
|
|
if (isset($ftrs['RowStyle'])) { |
251
|
|
|
$color = ' style="' . $aElements[$rCntr][$ftrs['RowStyle']] . '"'; |
252
|
|
|
} else { |
253
|
|
|
$color = ''; |
254
|
|
|
} |
255
|
|
|
} |
256
|
|
|
$tbl['tr_Color'] = '<tr' . $color . '>'; |
257
|
|
|
// Grouping column |
258
|
|
|
if (isset($ftrs['grouping_cell'])) { |
259
|
|
|
foreach ($aElements[$rCntr] as $key => $value) { |
260
|
|
|
if (($ftrs['grouping_cell'] == $key) && ($remindGroupValue != $value)) { |
261
|
|
|
switch ($ftrs['grouping_cell_type']) { |
262
|
|
|
case 'row': |
263
|
|
|
$sReturn .= $tbl['tr_Color'] . '<td ' . 'colspan="' . $iTableColumns . '">' |
264
|
|
|
. $this->setStringIntoTag($value, 'div', ['class' => 'rowGroup rounded']) |
265
|
|
|
. '</td></tr>'; |
266
|
|
|
break; |
267
|
|
|
case 'tab': |
268
|
|
|
if (is_null($remindGroupValue)) { |
269
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
270
|
|
|
$groupCounter = 0; |
271
|
|
|
} |
272
|
|
|
} else { |
273
|
|
|
$sReturn .= '</tbody></table>'; |
274
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
275
|
|
|
$sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
|
|
|
|
276
|
|
|
$groupCounter = 0; |
277
|
|
|
} |
278
|
|
|
$sReturn .= '</div>'; |
279
|
|
|
} |
280
|
|
|
$sReturn .= '<div class="tabbertab'; |
281
|
|
|
if (isset($ftrs['grouping_default_tab'])) { |
282
|
|
|
$sReturn .= ($ftrs['grouping_default_tab'] == $value ? ' tabbertabdefault' : ''); |
283
|
|
|
} |
284
|
|
|
$sReturn .= '" id="tab_' . $this->cleanStringForId($value) . '" ' |
285
|
|
|
. 'title="' . $value . '">' |
286
|
|
|
. $tbl['Def'] . $tbl['Head'] . $tbl['Header']; |
287
|
|
|
break; |
288
|
|
|
} |
289
|
|
|
$remindGroupValue = $value; |
290
|
|
|
} |
291
|
|
|
} |
292
|
|
|
} |
293
|
|
|
if (isset($ftrs['grouping_cell'])) { |
294
|
|
|
if ($ftrs['grouping_cell_type'] == 'tab') { |
295
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
296
|
|
|
$groupCounter++; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
$sReturn .= $tbl['tr_Color']; |
301
|
|
|
// Action column |
302
|
|
|
if (isset($ftrs['actions'])) { |
303
|
|
|
$sReturn .= '<td style="white-space:nowrap;">'; |
304
|
|
|
$action_argument = 0; |
305
|
|
|
if (isset($ftrs['actions']['key'])) { |
306
|
|
|
$action_key = $ftrs['actions']['key']; |
307
|
|
|
} else { |
308
|
|
|
$action_key = 'view'; |
309
|
|
|
} |
310
|
|
|
if (isset($ftrs['action_prefix'])) { |
311
|
|
|
$actPrfx = $ftrs['action_prefix'] . '&'; |
312
|
|
|
$action_key = 'view2'; |
313
|
|
|
} else { |
314
|
|
|
$actPrfx = ''; |
315
|
|
|
} |
316
|
|
|
foreach ($ftrs['actions'] as $key => $value) { |
317
|
|
|
if ($action_argument != 0) { |
318
|
|
|
$sReturn .= ' '; |
319
|
|
|
} |
320
|
|
|
switch ($key) { |
321
|
|
|
case 'checkbox': |
322
|
|
|
$checkboxName = $value . '[]'; |
323
|
|
|
$checkboxNameS = $value; |
324
|
|
|
$sReturn .= ' <input type="checkbox" name="' . $checkboxName |
325
|
|
|
. '" id="n' . $aElements[$rCntr][$value] |
326
|
|
|
. '" value="' . $aElements[$rCntr][$value] . '" '; |
327
|
|
|
if (isset($_REQUEST[$checkboxNameS])) { |
328
|
|
|
if (is_array($_REQUEST[$checkboxNameS])) { |
329
|
|
|
if (in_array($aElements[$rCntr][$value], $_REQUEST[$checkboxNameS])) { |
330
|
|
|
$sReturn .= 'checked="checked" '; |
331
|
|
|
} |
332
|
|
|
} else { |
333
|
|
|
if ($aElements[$rCntr][$value] == $_REQUEST[$checkboxNameS]) { |
334
|
|
|
$sReturn .= 'checked="checked" '; |
335
|
|
|
} |
336
|
|
|
} |
337
|
|
|
} |
338
|
|
|
if (strpos($_REQUEST['view'], 'multiEdit') !== false) { |
339
|
|
|
$sReturn .= 'disabled="disabled" '; |
340
|
|
|
} |
341
|
|
|
$sReturn .= '/>'; |
342
|
|
|
break; |
343
|
|
|
case 'checkbox_inlineEdit': |
344
|
|
|
$checkboxName = $value . '[]'; |
345
|
|
|
$checkboxNameS = $value; |
346
|
|
|
$sReturn .= ' <input type="checkbox" name="' . $checkboxName |
347
|
|
|
. '" id="n' . $aElements[$rCntr][$value] . '" value="' |
348
|
|
|
. $aElements[$rCntr][$value] . '"/>'; |
349
|
|
|
break; |
350
|
|
|
case 'edit': |
351
|
|
|
$edt = ''; |
352
|
|
|
if (isset($ftrs['NoAjaxEditing'])) { |
353
|
|
|
$edt .= $_SERVER['PHP_SELF'] . '?' . $actPrfx |
354
|
|
|
. $action_key . '=' . $value[0] . '&'; |
355
|
|
|
$iActArgs = count($value[1]); |
356
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
357
|
|
|
$edt .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
358
|
|
|
} |
359
|
|
|
$sReturn .= '<a href="' . $edt . '"><i class="fa fa-pencil"> </i></a>'; |
360
|
|
View Code Duplication |
} else { |
|
|
|
|
361
|
|
|
$edt .= 'javascript:loadAE(\'' . $_SERVER['PHP_SELF'] . '?' |
362
|
|
|
. $actPrfx . $action_key . '=' . $value[0] . '&'; |
363
|
|
|
$iActArgs = count($value[1]); |
364
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
365
|
|
|
$edt .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
366
|
|
|
} |
367
|
|
|
$edt .= '\');'; |
368
|
|
|
$sReturn .= '<a href="#" onclick="' . $edt . '">' |
369
|
|
|
. '<i class="fa fa-pencil"> </i></a>'; |
370
|
|
|
} |
371
|
|
|
break; |
372
|
|
|
case 'list2': |
373
|
|
|
$edt = ''; |
374
|
|
|
if (isset($ftrs['NoAjaxEditing'])) { |
375
|
|
|
$sReturn .= '<a href="?' . $actPrfx . $action_key . '=' . $value[0] . '&'; |
376
|
|
|
$iActArgs = count($value[1]); |
377
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
378
|
|
|
$sReturn .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
379
|
|
|
} |
380
|
|
|
$sReturn .= '"><i class="fa fa-list"> </i></a>'; |
381
|
|
View Code Duplication |
} else { |
|
|
|
|
382
|
|
|
$edt .= 'javascript:loadAE(\'' . $_SERVER['PHP_SELF'] . '?' |
383
|
|
|
. $actPrfx . $action_key . '=' . $value[0] . '&'; |
384
|
|
|
$iActArgs = count($value[1]); |
385
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
386
|
|
|
$edt .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
387
|
|
|
} |
388
|
|
|
$edt .= '\');'; |
389
|
|
|
$sReturn .= '<a href="#" onclick="' . $edt . '">' |
390
|
|
|
. '<i class="fa fa-list"> </i></a>'; |
391
|
|
|
} |
392
|
|
|
break; |
393
|
|
|
case 'delete': |
394
|
|
|
$sReturn .= '<a href="javascript:setQuest(\'' . $value[0] . '\',\''; |
395
|
|
|
$iActArgs = count($value[1]); |
396
|
|
|
for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
397
|
|
|
$sReturn .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
398
|
|
|
} |
399
|
|
|
$sReturn .= '\');"><i class="fa fa-times"> </i></a>'; |
400
|
|
|
break; |
401
|
|
|
} |
402
|
|
|
$action_argument += 1; |
403
|
|
|
} |
404
|
|
|
$sReturn .= '</td>'; |
405
|
|
|
} |
406
|
|
|
// Regular columns |
407
|
|
|
$sReturn .= $this->setTableCell($row_current, $ftrs); |
408
|
|
|
// Computed columns |
409
|
|
|
if (isset($ftrs['computed_columns'])) { |
410
|
|
|
foreach ($ftrs['computed_columns'] as $key => $value) { |
411
|
|
|
if ($value[0] == '%') { |
412
|
|
|
$dec = $value[2] + 2; |
413
|
|
|
} else { |
414
|
|
|
$dec = $value[2]; |
415
|
|
|
} |
416
|
|
|
switch ($value[1]) { |
417
|
|
|
case '/': |
418
|
|
|
// next variable is only to avoid a long line |
419
|
|
|
$shorter = [ |
420
|
|
|
$aElements[$rCntr][$value[3]], |
421
|
|
|
$aElements[$rCntr][$value[4]], |
422
|
|
|
]; |
423
|
|
|
$aElements[$rCntr][$key] = $this->setDividedResult($shorter[0], $shorter[1], $dec); |
|
|
|
|
424
|
|
|
break; |
425
|
|
|
case '+': |
426
|
|
|
// next variable is only to avoid a long line |
427
|
|
|
$iTemp = $this->setArrayValuesAsKey([ |
|
|
|
|
428
|
|
|
$value[0], |
429
|
|
|
$value[1], |
430
|
|
|
$value[2] |
431
|
|
|
]); |
432
|
|
|
$aTemp = array_diff($value, $iTemp); |
433
|
|
|
$aElements[$rCntr][$key] = 0; |
434
|
|
|
foreach ($aTemp as $sValue) { |
435
|
|
|
$aElements[$rCntr][$key] += $aElements[$rCntr][$sValue]; |
436
|
|
|
} |
437
|
|
|
break; |
438
|
|
|
default: |
439
|
|
|
$row_computed[$key] = ''; |
|
|
|
|
440
|
|
|
break; |
441
|
|
|
} |
442
|
|
|
if ($value[0] == '%') { |
443
|
|
|
$row_computed[$key] = ($aElements[$rCntr][$key] * 100); |
|
|
|
|
444
|
|
|
$dec -= 2; |
445
|
|
|
} else { |
446
|
|
|
$row_computed[$key] = $aElements[$rCntr][$key]; |
447
|
|
|
} |
448
|
|
|
$decimals[$key] = $dec; |
|
|
|
|
449
|
|
|
} |
450
|
|
|
// displaying them |
451
|
|
|
$sReturn .= $this->setTableCell($row_computed, ['decimals' => $decimals]); |
|
|
|
|
452
|
|
|
} |
453
|
|
|
$sReturn .= '</tr>'; |
454
|
|
|
} |
455
|
|
View Code Duplication |
if (isset($iStartingPageRecord)) { |
|
|
|
|
456
|
|
|
$pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2]); |
|
|
|
|
457
|
|
|
$sReturn .= '<tr>' . $this->setStringIntoTag($pgn, 'th', ['colspan' => $iTableColumns]) . '</tr>'; |
458
|
|
|
} |
459
|
|
|
$sReturn .= '</tbody></table>'; |
460
|
|
|
if ($ftrs['grouping_cell_type'] == 'tab') { |
461
|
|
|
if (isset($ftrs['showGroupingCounter'])) { |
462
|
|
|
$sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
463
|
|
|
} |
464
|
|
|
$sReturn .= '</div><!-- from ' . $remindGroupValue . ' -->'; |
465
|
|
|
if (!isset($ftrs['noGlobalTab'])) { |
466
|
|
|
$sReturn .= '</div><!-- from global tab -->'; |
467
|
|
|
} |
468
|
|
|
} |
469
|
|
|
if (isset($ftrs['actions']['checkbox'])) { |
470
|
|
|
if (strpos($_REQUEST['view'], 'multiEdit') === false) { |
471
|
|
|
$sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
|
|
|
|
472
|
|
|
. '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
|
|
|
|
473
|
|
|
. '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
474
|
|
|
. '\',\'' . $checkboxName . '\',false);">Uncheck All</a> ' |
475
|
|
|
. '<input type="hidden" name="action" value="multiEdit_' . $checkboxNameS . '" />'; |
|
|
|
|
476
|
|
View Code Duplication |
if (isset($ftrs['hiddenInput'])) { |
|
|
|
|
477
|
|
|
if (is_array($ftrs['hiddenInput'])) { |
478
|
|
|
foreach ($ftrs['hiddenInput'] as $valueF) { |
479
|
|
|
$sReturn .= '<input type="hidden" name="' . $valueF |
480
|
|
|
. '" value="' . $_REQUEST[$valueF] . '" />'; |
481
|
|
|
} |
482
|
|
|
} else { |
483
|
|
|
$sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
484
|
|
|
. '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />'; |
485
|
|
|
} |
486
|
|
|
} |
487
|
|
|
$sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" ' . 'value="Edit selected" />'; |
488
|
|
|
} |
489
|
|
|
$sReturn .= '</form>'; |
490
|
|
|
} |
491
|
|
|
if (isset($ftrs['actions']['checkbox_inlineEdit'])) { |
492
|
|
|
$sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
493
|
|
|
. '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
494
|
|
|
. '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
495
|
|
|
. '\',\'' . $checkboxName . '\',false);">Uncheck All</a> '; |
496
|
|
|
if (isset($ftrs['visibleInput'])) { |
497
|
|
|
$sReturn .= $ftrs['visibleInput']; |
498
|
|
|
} |
499
|
|
|
$sReturn .= '<input type="hidden" name="view" value="save_' . $checkboxNameS . '" />'; |
500
|
|
View Code Duplication |
if (isset($ftrs['hiddenInput'])) { |
|
|
|
|
501
|
|
|
if (is_array($ftrs['hiddenInput'])) { |
502
|
|
|
foreach ($ftrs['hiddenInput'] as $valueF) { |
503
|
|
|
$sReturn .= '<input type="hidden" name="' . $valueF |
504
|
|
|
. '" value="' . $_REQUEST[$valueF] . '" />'; |
505
|
|
|
} |
506
|
|
|
} else { |
507
|
|
|
$sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
508
|
|
|
. '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />'; |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
$sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" value="Store the modification" />'; |
512
|
|
|
$sReturn .= '</form>'; |
513
|
|
|
} |
514
|
|
|
return $sReturn; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Set a control to a user-friendly calendar |
519
|
|
|
* |
520
|
|
|
* @param string $controlName |
521
|
|
|
* @param string $additionalStyle |
522
|
|
|
* @return string |
523
|
|
|
*/ |
524
|
|
View Code Duplication |
public function setCalendarControl($controlName, $additionalStyle = '') |
|
|
|
|
525
|
|
|
{ |
526
|
|
|
return $this->setStringIntoTag(' ', 'span', [ |
527
|
|
|
'onclick' => implode('', [ |
528
|
|
|
'javascript:NewCssCal(\'' . $controlName, |
529
|
|
|
'\',\'yyyyMMdd\',\'dropdown\',false,\'24\',false);', |
530
|
|
|
]), |
531
|
|
|
'class' => 'fa fa-calendar', |
532
|
|
|
'id' => $controlName . '_picker', |
533
|
|
|
'style' => 'cursor:pointer;' . $additionalStyle, |
534
|
|
|
]); |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* Set a control to a user-friendly calendar with time included |
539
|
|
|
* |
540
|
|
|
* @param string $controlName |
541
|
|
|
* @param string $additionalStyle |
542
|
|
|
* @return string |
543
|
|
|
*/ |
544
|
|
View Code Duplication |
public function setCalendarControlWithTime($controlName, $additionalStyle = '') |
|
|
|
|
545
|
|
|
{ |
546
|
|
|
return $this->setStringIntoTag(' ', 'span', [ |
547
|
|
|
'onclick' => implode('', [ |
548
|
|
|
'javascript:NewCssCal(\'' . $controlName, |
549
|
|
|
'\',\'yyyyMMdd\',\'dropdown\',true,\'24\',true);', |
550
|
|
|
]), |
551
|
|
|
'class' => 'fa fa-calendar', |
552
|
|
|
'id' => $controlName . '_picker', |
553
|
|
|
'style' => 'cursor:pointer;' . $additionalStyle, |
554
|
|
|
]); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
/** |
558
|
|
|
* Returns css codes |
559
|
|
|
* |
560
|
|
|
* @param string $cssContent |
561
|
|
|
* @param array $optionalFlags |
562
|
|
|
* @return string |
563
|
|
|
*/ |
564
|
|
|
protected function setCssContent($cssContent, $optionalFlags = null) |
565
|
|
|
{ |
566
|
|
|
$attr = []; |
567
|
|
|
if (is_null($optionalFlags)) { |
568
|
|
|
$attr['media'] = 'all'; |
569
|
|
|
} else { |
570
|
|
|
$knownAttributes = ['media']; |
571
|
|
|
foreach ($knownAttributes as $value) { |
572
|
|
|
if (in_array($value, array_keys($optionalFlags))) { |
573
|
|
|
$attr[$value] = $optionalFlags[$value]; |
574
|
|
|
} |
575
|
|
|
} |
576
|
|
|
} |
577
|
|
|
return '<style type="text/css" media="' . $attr['media'] . '">' |
578
|
|
|
. $cssContent . '</style>'; |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* Returns css link to a given file |
583
|
|
|
* |
584
|
|
|
* @param string $cssFile |
|
|
|
|
585
|
|
|
* @return string |
586
|
|
|
*/ |
587
|
|
|
protected function setCssFile($cssFileName, $hostsWithoutCDNrq = null) |
588
|
|
|
{ |
589
|
|
|
if (is_null($hostsWithoutCDNrq)) { |
590
|
|
|
$hostsWithoutCDNrq = []; |
591
|
|
|
} |
592
|
|
|
if (in_array($this->getClientRealIpAddress(), $hostsWithoutCDNrq)) { |
593
|
|
|
return '<link rel="stylesheet" type="text/css" href="' |
594
|
|
|
. filter_var($cssFileName, FILTER_SANITIZE_STRING) . '" />'; |
595
|
|
|
} |
596
|
|
|
$patternFound = $this->setCssFileCDN($cssFileName); |
597
|
|
|
return '<link rel="stylesheet" type="text/css" href="' |
598
|
|
|
. filter_var($patternFound[1], FILTER_SANITIZE_STRING) . '" />'; |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* Builds a structured modern message |
603
|
|
|
* |
604
|
|
|
* @param string $sType |
605
|
|
|
* @param string $sTitle |
606
|
|
|
* @param string $sMsg |
607
|
|
|
* @param boolean $skipBr |
608
|
|
|
*/ |
609
|
|
|
protected function setFeedbackModern($sType, $sTitle, $sMsg, $skipBr = false) |
610
|
|
|
{ |
611
|
|
|
$formatTitle[] = 'margin-top:-5px;margin-right:20px;padding:5px;'; |
|
|
|
|
612
|
|
|
$formatMessage[] = 'display:inline;padding-right:5px;padding-bottom:5px;'; |
|
|
|
|
613
|
|
|
switch ($sType) { |
614
|
|
|
case 'alert': |
615
|
|
|
$formatTitle[] = 'border:medium solid orange;background-color:orange;color:navy;'; |
616
|
|
|
$formatMessage[] = 'background-color:navy;color:orange;border:medium solid orange;'; |
617
|
|
|
break; |
618
|
|
|
case 'check': |
619
|
|
|
$formatTitle[] = 'border:medium solid green;background-color:green;color:white;'; |
620
|
|
|
$formatMessage[] = 'background-color:yellow;color:green;border:medium solid green;'; |
621
|
|
|
break; |
622
|
|
|
case 'error': |
623
|
|
|
$formatTitle[] = 'border:medium solid red;background-color:red;color:white;'; |
624
|
|
|
$formatMessage[] = 'background-color:yellow;color:red;border:medium solid red;'; |
625
|
|
|
break; |
626
|
|
|
case 'info': |
627
|
|
|
$formatTitle[] = 'border:medium solid black;background-color:black;color:white;font-weight:bold;'; |
628
|
|
|
$formatMessage[] = 'background-color: white; color: black;border:medium solid black;'; |
629
|
|
|
break; |
630
|
|
|
} |
631
|
|
|
if ($sTitle == 'light') { |
632
|
|
|
return $sMsg; |
633
|
|
|
} |
634
|
|
|
$legend = $this->setStringIntoTag($sTitle, 'legend', ['style' => implode('', $formatTitle)]); |
635
|
|
|
return implode('', [ |
636
|
|
|
($skipBr ? '' : '<br/>'), |
637
|
|
|
$this->setStringIntoTag($legend . $sMsg, 'fieldset', [ |
638
|
|
|
'style' => implode('', $formatMessage) |
639
|
|
|
]), |
640
|
|
|
]); |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
/** |
644
|
|
|
* Outputs an HTML footer |
645
|
|
|
* |
646
|
|
|
* @param array $footerInjected |
647
|
|
|
* @return string |
648
|
|
|
*/ |
649
|
|
|
protected function setFooterCommon($footerInjected = null) |
|
|
|
|
650
|
|
|
{ |
651
|
|
|
if (isset($_REQUEST['specialHook']) && (in_array('noFooter', $_REQUEST['specialHook']))) { |
652
|
|
|
return ''; |
653
|
|
|
} |
654
|
|
|
return $this->setFooterCommonInjected($footerInjected) . '</body></html>'; |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
protected function setFooterCommonInjected($footerInjected = null) |
658
|
|
|
{ |
659
|
|
|
$sReturn = ''; |
660
|
|
|
if (!is_null($footerInjected)) { |
661
|
|
|
$sReturn = $footerInjected; |
662
|
|
|
if (is_array($footerInjected)) { |
663
|
|
|
$sReturn = implode('', $footerInjected); |
664
|
|
|
} |
665
|
|
|
} |
666
|
|
|
return $sReturn; |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
/** |
670
|
|
|
* Sets the gzip footer for HTML |
671
|
|
|
*/ |
672
|
|
|
protected function setFooterGZiped() |
673
|
|
|
{ |
674
|
|
|
if (extension_loaded('zlib')) { |
675
|
|
|
return $this->setGZipedUnsafe('Footer'); |
676
|
|
|
} |
677
|
|
|
return ''; |
678
|
|
|
} |
679
|
|
|
|
680
|
|
|
private function setGZipedUnsafe($outputType) |
681
|
|
|
{ |
682
|
|
|
$rqst = new \Symfony\Component\HttpFoundation\Request; |
683
|
|
|
if (!is_null($rqst->server->get('HTTP_ACCEPT_ENCODING'))) { |
684
|
|
|
return ''; |
685
|
|
|
} |
686
|
|
|
if (strstr($rqst->server->get('HTTP_ACCEPT_ENCODING'), 'gzip')) { |
687
|
|
|
switch ($outputType) { |
688
|
|
|
case 'Footer': |
689
|
|
|
$gzipCntnt = ob_get_contents(); |
690
|
|
|
ob_end_clean(); |
691
|
|
|
$gzipSize = strlen($gzipCntnt); |
692
|
|
|
$gzipCrc = crc32($gzipCntnt); |
693
|
|
|
$gzipCntnt = gzcompress($gzipCntnt, 9); |
694
|
|
|
$gzipCntnt = substr($gzipCntnt, 0, strlen($gzipCntnt) - 4); |
695
|
|
|
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00" . $gzipCntnt . pack('V', $gzipCrc) . pack('V', $gzipSize); |
696
|
|
|
break; |
697
|
|
|
case 'Header': |
698
|
|
|
ob_start(); |
699
|
|
|
ob_implicit_flush(0); |
700
|
|
|
header('Content-Encoding: gzip'); |
701
|
|
|
break; |
702
|
|
|
} |
703
|
|
|
} |
704
|
|
|
} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* Outputs an HTML header |
708
|
|
|
* |
709
|
|
|
* @param array $headerFeatures |
710
|
|
|
* @return string |
711
|
|
|
*/ |
712
|
|
|
protected function setHeaderCommon($headerFeatures = null) |
|
|
|
|
713
|
|
|
{ |
714
|
|
|
$sReturn = []; |
715
|
|
|
if (isset($_REQUEST['specialHook']) && (in_array('noHeader', $_REQUEST['specialHook']))) { |
716
|
|
|
$sReturn[] = ''; // no Header |
717
|
|
|
} else { |
718
|
|
|
$fixedHeaderElements = [ |
719
|
|
|
'start' => '<!DOCTYPE html>', |
720
|
|
|
'lang' => '<html lang="en-US">', |
721
|
|
|
'head' => '<head>', |
722
|
|
|
'charset' => '<meta charset="utf-8" />', |
723
|
|
|
'viewport' => '<meta name="viewport" content="' . implode(', ', [ |
724
|
|
|
'width=device-width', |
725
|
|
|
'height=device-height', |
726
|
|
|
'initial-scale=1', |
727
|
|
|
]) . '" />', |
728
|
|
|
]; |
729
|
|
|
if (!is_null($headerFeatures)) { |
730
|
|
|
if (is_array($headerFeatures)) { |
731
|
|
|
$aFeatures = []; |
732
|
|
|
foreach ($headerFeatures as $key => $value) { |
733
|
|
|
switch ($key) { |
734
|
|
View Code Duplication |
case 'css': |
|
|
|
|
735
|
|
|
if (is_array($value)) { |
736
|
|
|
foreach ($value as $value2) { |
737
|
|
|
$aFeatures[] = $this->setCssFile(filter_var($value2, FILTER_SANITIZE_URL)); |
738
|
|
|
} |
739
|
|
|
} else { |
740
|
|
|
$aFeatures[] = $this->setCssFile(filter_var($value, FILTER_SANITIZE_URL)); |
741
|
|
|
} |
742
|
|
|
break; |
743
|
|
View Code Duplication |
case 'javascript': |
|
|
|
|
744
|
|
|
if (is_array($value)) { |
745
|
|
|
foreach ($value as $value2) { |
746
|
|
|
$vl = filter_var($value2, FILTER_SANITIZE_URL); |
747
|
|
|
$aFeatures[] = $this->setJavascriptFile($vl); |
748
|
|
|
} |
749
|
|
|
} else { |
750
|
|
|
$aFeatures[] = $this->setJavascriptFile(filter_var($value, FILTER_SANITIZE_URL)); |
751
|
|
|
} |
752
|
|
|
break; |
753
|
|
|
case 'lang': |
754
|
|
|
$fixedHeaderElements['lang'] = '<html lang="' |
755
|
|
|
. filter_var($value, FILTER_SANITIZE_STRING) . '">'; |
756
|
|
|
break; |
757
|
|
|
case 'title': |
758
|
|
|
$aFeatures[] = '<title>' |
759
|
|
|
. filter_var($value, FILTER_SANITIZE_STRING) . '</title>'; |
760
|
|
|
break; |
761
|
|
|
} |
762
|
|
|
} |
763
|
|
|
$sReturn[] = implode('', $fixedHeaderElements) |
764
|
|
|
. implode('', $aFeatures) |
765
|
|
|
. '</head>' |
766
|
|
|
. '<body>'; |
767
|
|
|
} else { |
768
|
|
|
$sReturn[] = implode('', $fixedHeaderElements) |
769
|
|
|
. '</head>' |
770
|
|
|
. '<body>' |
771
|
|
|
. '<p style="background-color:red;color:#FFF;">The parameter sent to ' |
772
|
|
|
. __FUNCTION__ . ' must be an array</p>' |
773
|
|
|
. $this->setFooterCommon(); |
774
|
|
|
throw new \Exception($sReturn); |
775
|
|
|
} |
776
|
|
|
} |
777
|
|
|
} |
778
|
|
|
return implode('', $sReturn); |
779
|
|
|
} |
780
|
|
|
|
781
|
|
|
/** |
782
|
|
|
* Sets the gzip header for HTML |
783
|
|
|
*/ |
784
|
|
|
protected function setHeaderGZiped() |
785
|
|
|
{ |
786
|
|
|
if (extension_loaded('zlib')) { |
787
|
|
|
return $this->setGZipedUnsafe('Header'); |
788
|
|
|
} |
789
|
|
|
return ''; |
790
|
|
|
} |
791
|
|
|
|
792
|
|
|
/** |
793
|
|
|
* Returns javascript function to support Add or Edit through Ajax |
794
|
|
|
* |
795
|
|
|
* @return string |
796
|
|
|
*/ |
797
|
|
|
protected function setJavascriptAddEditByAjax($tabName = 'tabStandard') |
798
|
|
|
{ |
799
|
|
|
return $this->setJavascriptContent(implode('', [ |
800
|
|
|
'function loadAE(action) {', |
801
|
|
|
'document.getElementById("' . $tabName . '").tabber.tabShow(1);', |
802
|
|
|
'$("#DynamicAddEditSpacer").load(action', |
803
|
|
|
'+"&specialHook[]=noHeader"', |
804
|
|
|
'+"&specialHook[]=noMenu"', |
805
|
|
|
'+"&specialHook[]=noContainer"', |
806
|
|
|
'+"&specialHook[]=noFooter"', |
807
|
|
|
');', |
808
|
|
|
'}', |
809
|
|
|
])); |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
/** |
813
|
|
|
* Returns javascript codes |
814
|
|
|
* |
815
|
|
|
* @param string $javascriptContent |
816
|
|
|
* @return string |
817
|
|
|
*/ |
818
|
|
|
protected function setJavascriptContent($javascriptContent) |
819
|
|
|
{ |
820
|
|
|
return '<script type="text/javascript">' . $javascriptContent . '</script>'; |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
/** |
824
|
|
|
* Builds up a confirmation dialog and return delection if Yes |
825
|
|
|
* |
826
|
|
|
* @return string |
827
|
|
|
*/ |
828
|
|
|
protected function setJavascriptDeleteWithConfirmation() |
829
|
|
|
{ |
830
|
|
|
return $this->setJavascriptContent('function setQuest(a, b) { ' |
831
|
|
|
. 'c = a.indexOf("_"); switch(a.slice(0, c)) { ' |
832
|
|
|
. 'case \'delete\': ' |
833
|
|
|
. 'if (confirm(\'' . $this->lclMsgCmn('i18n_ActionDelete_ConfirmationQuestion') . '\')) { ' |
834
|
|
|
. 'window.location = document.location.protocol + "//" + ' |
835
|
|
|
. 'document.location.host + document.location.pathname + ' |
836
|
|
|
. '"?view=" + a + "&" + b; } break; } }'); |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
/** |
840
|
|
|
* Returns javascript link to a given file |
841
|
|
|
* |
842
|
|
|
* @param string $jsFileName |
843
|
|
|
* @return string |
844
|
|
|
*/ |
845
|
|
|
protected function setJavascriptFile($jsFileName, $hostsWithoutCDNrq = null) |
846
|
|
|
{ |
847
|
|
|
if (is_null($hostsWithoutCDNrq)) { |
848
|
|
|
$hostsWithoutCDNrq = []; |
849
|
|
|
} |
850
|
|
|
if (in_array($this->getClientRealIpAddress(), $hostsWithoutCDNrq)) { |
851
|
|
|
return '<script type="text/javascript" src="' . $jsFileName . '"></script>'; |
852
|
|
|
} |
853
|
|
|
$patternFound = $this->setJavascriptFileCDN($jsFileName); |
854
|
|
|
return '<script type="text/javascript" src="' . $patternFound[1] . '"></script>' . $patternFound[2]; |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* Returns javascript codes from given file |
859
|
|
|
* |
860
|
|
|
* @param string $jsFileName |
861
|
|
|
* @return string |
862
|
|
|
*/ |
863
|
|
|
protected function setJavascriptFileContent($jsFileName) |
864
|
|
|
{ |
865
|
|
|
return '<script type="text/javascript">' . file_get_contents($jsFileName, true) . '</script>'; |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
/** |
869
|
|
|
* Generates a table cell |
870
|
|
|
* |
871
|
|
|
* @param array $aElements |
872
|
|
|
* @param array $features |
873
|
|
|
* @return string |
874
|
|
|
*/ |
875
|
|
|
private function setTableCell($aElements, $features = null) |
876
|
|
|
{ |
877
|
|
|
$sReturn = null; |
878
|
|
|
foreach ($aElements as $key => $value) { |
879
|
|
|
$value = str_replace(['& ', '\"', "\'"], ['& ', '"', "'"], $value); |
880
|
|
|
if ((isset($features['grouping_cell'])) && ($features['grouping_cell'] == $key)) { |
|
|
|
|
881
|
|
|
// just skip |
882
|
|
|
} else { |
883
|
|
|
$sReturn .= '<td '; |
884
|
|
|
if (isset($features['column_formatting'][$key])) { |
885
|
|
|
switch ($features['column_formatting'][$key]) { |
886
|
|
|
case '@': |
887
|
|
|
$sReturn .= 'style="text-align:left;">' . $value; |
888
|
|
|
break; |
889
|
|
|
case 'right': |
890
|
|
|
$sReturn .= 'style="text-align:right;">' . $value; |
891
|
|
|
break; |
892
|
|
|
default: |
893
|
|
|
$sReturn .= '???'; |
894
|
|
|
break; |
895
|
|
|
} |
896
|
|
|
} else { |
897
|
|
|
if (is_numeric($value)) { |
898
|
|
|
if (substr($value, 0, 1) === '0') { |
899
|
|
|
$sReturn .= 'style="text-align: right;">' . $value; |
900
|
|
|
} else { |
901
|
|
|
$decimals = 0; |
902
|
|
|
if (isset($features['no_of_decimals'])) { |
903
|
|
|
$decimals = $features['no_of_decimals']; |
904
|
|
|
} |
905
|
|
|
if (isset($features['decimals']) && array_key_exists($key, $features['decimals'])) { |
906
|
|
|
$decimals = $features['decimals'][$key]; |
907
|
|
|
} |
908
|
|
|
$sReturn .= 'style="text-align: right;">'; |
909
|
|
|
$sReturn .= $this->setNumberFormat($value, [ |
910
|
|
|
'MinFractionDigits' => $decimals, |
911
|
|
|
'MaxFractionDigits' => $decimals |
912
|
|
|
]); |
913
|
|
|
} |
914
|
|
|
} else { |
915
|
|
|
$outputet = false; |
916
|
|
|
if ((strpos($value, '-') !== false) && (strlen($value) == 10)) { |
917
|
|
|
if (preg_match("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $value, $regs)) { |
918
|
|
|
$outputet = true; |
919
|
|
|
$sReturn .= 'style="text-align:right;width: 10px;">' |
920
|
|
|
. $regs[3] . '.' . $regs[2] . '.' . $regs[1]; |
921
|
|
|
} |
922
|
|
|
} |
923
|
|
|
if (!$outputet) { |
924
|
|
|
$sReturn .= 'style="text-align:left;">' . $value; |
925
|
|
|
} |
926
|
|
|
} |
927
|
|
|
} |
928
|
|
|
$sReturn .= '</td>'; |
929
|
|
|
} |
930
|
|
|
} |
931
|
|
|
return $sReturn; |
932
|
|
|
} |
933
|
|
|
|
934
|
|
|
/** |
935
|
|
|
* Generates a table header |
936
|
|
|
* |
937
|
|
|
* @param array $aElements |
938
|
|
|
* @param boolean $bHeadersBreaked |
939
|
|
|
* @return string |
940
|
|
|
*/ |
941
|
|
|
private function setTableHeader($aElements, $bHeadersBreaked) |
942
|
|
|
{ |
943
|
|
|
if ($bHeadersBreaked) { |
944
|
|
|
$aTableHeader = $this->setArrayToArrayKbr($aElements); |
|
|
|
|
945
|
|
|
} else { |
946
|
|
|
$aTableHeader = $aElements; |
947
|
|
|
} |
948
|
|
|
$sReturn[] = null; |
|
|
|
|
949
|
|
|
foreach (array_keys($aTableHeader) as $value) { |
950
|
|
|
$sReturn[] = $this->setStringIntoTag($value, 'th'); |
951
|
|
|
} |
952
|
|
|
return implode('', $sReturn); |
953
|
|
|
} |
954
|
|
|
|
955
|
|
|
/** |
956
|
|
|
* Create an upper right box with choices for languages |
957
|
|
|
* (requires flag-icon.min.css to be loaded) |
958
|
|
|
* (makes usage of custom class "upperRightBox" and id = "visibleOnHover", provided here as scss file) |
959
|
|
|
* |
960
|
|
|
* @param array $aAvailableLanguages |
961
|
|
|
* @return string |
962
|
|
|
*/ |
963
|
|
|
protected function setUpperRightBoxLanguages($aAvailableLanguages) |
964
|
|
|
{ |
965
|
|
|
$this->handleLanguageIntoSession(); |
966
|
|
|
return '<div class="upperRightBox">' |
967
|
|
|
. '<div style="text-align:right;">' |
968
|
|
|
. '<span class="flag-icon flag-icon-' . strtolower(substr($this->tCmnSuperGlobals->get('lang'), -2)) |
969
|
|
|
. '" style="margin-right:2px;"> </span>' |
970
|
|
|
. $aAvailableLanguages[$this->tCmnSession->get('lang')] |
971
|
|
|
. '</div><!-- default Language -->' |
972
|
|
|
. $this->setUpperRightVisibleOnHoverLanguages($aAvailableLanguages) |
973
|
|
|
. '</div><!-- upperRightBox end -->'; |
974
|
|
|
} |
975
|
|
|
|
976
|
|
|
private function setUpperRightVisibleOnHoverLanguages($aAvailableLanguages) |
977
|
|
|
{ |
978
|
|
|
$linkWithoutLanguage = ''; |
979
|
|
|
if (isset($this->tCmnSuperGlobals->request)) { |
980
|
|
|
$linkWithoutLanguage = $this->setArrayToStringForUrl('&', $this->tCmnSuperGlobals->request, ['lang']) |
981
|
|
|
. '&'; |
982
|
|
|
} |
983
|
|
|
$sReturn = []; |
984
|
|
|
foreach ($aAvailableLanguages as $key => $value) { |
985
|
|
|
if ($this->tCmnSession->get('lang') !== $key) { |
986
|
|
|
$sReturn[] = '<a href="?' . $linkWithoutLanguage . 'lang=' . $key . '" style="display:block;">' |
987
|
|
|
. '<span class="flag-icon flag-icon-' . strtolower(substr($key, -2)) |
988
|
|
|
. '" style="margin-right:2px;"> </span>' |
989
|
|
|
. $value . '</a>'; |
990
|
|
|
} |
991
|
|
|
} |
992
|
|
|
return '<div id="visibleOnHover">' . implode('', $sReturn) . '</div><!-- visibleOnHover end -->'; |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
protected function setViewModernLinkAdd($identifier, $ftrs = null) |
996
|
|
|
{ |
997
|
|
|
$btnText = '<i class="fa fa-plus-square"> </i>' . ' ' . $this->lclMsgCmn('i18n_AddNewRecord'); |
998
|
|
|
return $this->setStringIntoTag($btnText, 'a', [ |
999
|
|
|
'href' => $this->setViewModernLinkAddUrl($identifier, $ftrs), |
1000
|
|
|
'style' => 'margin: 5px 0px 10px 0px; display: inline-block;', |
1001
|
|
|
]); |
1002
|
|
|
} |
1003
|
|
|
|
1004
|
|
|
protected function setViewModernLinkAddInjectedArguments($ftrs = null) |
1005
|
|
|
{ |
1006
|
|
|
$sArgmnts = ''; |
1007
|
|
|
if (isset($ftrs['injectAddArguments'])) { |
1008
|
|
|
foreach ($ftrs['injectAddArguments'] as $key => $value) { |
1009
|
|
|
$sArgmnts .= '&' . $key . '=' . $value; |
1010
|
|
|
} |
1011
|
|
|
} |
1012
|
|
|
return $sArgmnts; |
1013
|
|
|
} |
1014
|
|
|
|
1015
|
|
|
protected function setViewModernLinkAddUrl($identifier, $ftrs = null) |
1016
|
|
|
{ |
1017
|
|
|
$sArgmnts = $this->setViewModernLinkAddInjectedArguments($ftrs); |
1018
|
|
|
$rqst = new \Symfony\Component\HttpFoundation\Request; |
1019
|
|
|
$addingUrl = $rqst->server->get('PHP_SELF') . '?view=add_' . $identifier . $sArgmnts; |
1020
|
|
|
if (!isset($ftrs['NoAjax'])) { |
1021
|
|
|
$addingUrl = 'javascript:loadAE(\'' . $addingUrl . '\');'; |
1022
|
|
|
} |
1023
|
|
|
return $addingUrl; |
1024
|
|
|
} |
1025
|
|
|
|
1026
|
|
|
protected function updateDivTitleName($rememberGroupVal, $groupCounter) |
1027
|
|
|
{ |
1028
|
|
|
$jsContent = '$(document).ready(function() { $("#tab_' |
1029
|
|
|
. $this->cleanStringForId($rememberGroupVal) . '").attr("title", "' |
1030
|
|
|
. $rememberGroupVal . ' (' . $groupCounter . ')"); });'; |
1031
|
|
|
return $this->setJavascriptContent($jsContent); |
1032
|
|
|
} |
1033
|
|
|
} |
1034
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.