| Total Complexity | 141 |
| Total Lines | 682 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like DomComponentsByDanielGP often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DomComponentsByDanielGP, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 36 | trait DomComponentsByDanielGP |
||
| 37 | { |
||
| 38 | |||
| 39 | use CommonBasic, |
||
| 40 | DomCssAndJavascriptByDanielGP; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Returns a table from an query |
||
| 44 | * |
||
| 45 | * @param array $aElements |
||
| 46 | * @param array $ftrs |
||
| 47 | * @param boolean $bKpFlPge |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | protected function setArrayToTable($aElements, $ftrs = null, $bKpFlPge = true) |
||
| 51 | { |
||
| 52 | $rows = count($aElements); |
||
| 53 | if ($rows == 0) { |
||
| 54 | $divTab = [ |
||
| 55 | 'start' => '', |
||
| 56 | 'end' => '', |
||
| 57 | ]; |
||
| 58 | if (array_key_exists('showGroupingCounter', $ftrs)) { |
||
|
|
|||
| 59 | if (array_key_exists('grouping_cell_type', $ftrs) && ($ftrs['grouping_cell_type'] == 'tab')) { |
||
| 60 | $ditTitle = 'No data found'; |
||
| 61 | if (isset($ftrs['showGroupingCounter'])) { |
||
| 62 | $ditTitle .= ' (0)'; |
||
| 63 | } |
||
| 64 | $divTab = [ |
||
| 65 | 'start' => '<div class="tabbertab tabbertabdefault" id="tab_NoData" title="' . $ditTitle . '">', |
||
| 66 | 'end' => '</div><!-- from tab_NoData -->', |
||
| 67 | ]; |
||
| 68 | if (!isset($ftrs['noGlobalTab'])) { |
||
| 69 | $divTab = [ |
||
| 70 | 'start' => '<div class="tabber" id="tab">' . $divTab['start'], |
||
| 71 | 'end' => $divTab['end'] . '</div><!-- from global Tab -->', |
||
| 72 | ]; |
||
| 73 | } |
||
| 74 | } |
||
| 75 | } |
||
| 76 | return $divTab['start'] |
||
| 77 | . $this->setFeedbackModern('error', 'Error', $this->lclMsgCmn('i18n_NoData')) |
||
| 78 | . $divTab['end']; |
||
| 79 | } |
||
| 80 | if (isset($ftrs['limits'])) { |
||
| 81 | $ftrs['limits'][1] = min($ftrs['limits'][1], $ftrs['limits'][2]); |
||
| 82 | if ($ftrs['limits'][2] > $ftrs['limits'][1]) { |
||
| 83 | $iStartingPageRecord = 1; |
||
| 84 | } |
||
| 85 | } |
||
| 86 | $sReturn = ''; |
||
| 87 | if (isset($ftrs['hidden_columns'])) { |
||
| 88 | $hdClmns = $this->setArrayValuesAsKey($ftrs['hidden_columns']); |
||
| 89 | } else { |
||
| 90 | $hdClmns = ['']; |
||
| 91 | } |
||
| 92 | $checkboxFormId = ''; |
||
| 93 | if ((isset($ftrs['actions']['checkbox_inlineEdit'])) || (isset($ftrs['actions']['checkbox']))) { |
||
| 94 | $checkboxFormId = 'frm' . date('YmdHis'); |
||
| 95 | $sReturn .= '<form id="' . $checkboxFormId . '" name="' . $checkboxFormId |
||
| 96 | . '" method="post" ' . ' action="' . $this->tCmnRequest->server->get('PHP_SELF') . '" >'; |
||
| 97 | } |
||
| 98 | $tbl = []; |
||
| 99 | $tbl['Def'] = '<table' |
||
| 100 | . (isset($ftrs['table_style']) ? ' style="' . $ftrs['table_style'] . '"' : '') |
||
| 101 | . (isset($ftrs['table_class']) ? ' class="' . $ftrs['table_class'] . '"' : '') |
||
| 102 | . '>'; |
||
| 103 | if (!isset($ftrs['grouping_cell_type'])) { |
||
| 104 | $ftrs['grouping_cell_type'] = 'row'; |
||
| 105 | } |
||
| 106 | switch ($ftrs['grouping_cell_type']) { |
||
| 107 | case 'row': |
||
| 108 | $sReturn .= $tbl['Def']; |
||
| 109 | break; |
||
| 110 | case 'tab': |
||
| 111 | if (!isset($ftrs['noGlobalTab'])) { |
||
| 112 | $sReturn .= '<div class="tabber" id="tab">'; |
||
| 113 | } |
||
| 114 | break; |
||
| 115 | } |
||
| 116 | $groupCounter = 0; |
||
| 117 | $iTableColumns = 0; |
||
| 118 | $remebered_value = -1; |
||
| 119 | $remindGroupValue = null; |
||
| 120 | $color_no = null; |
||
| 121 | if (!isset($ftrs['headers_breaked'])) { |
||
| 122 | $ftrs['headers_breaked'] = true; |
||
| 123 | } |
||
| 124 | for ($rCntr = 0; $rCntr < $rows; $rCntr++) { |
||
| 125 | if ($rCntr == 0) { |
||
| 126 | $header = array_diff_key($aElements[$rCntr], $hdClmns); |
||
| 127 | $iTableColumns = count($header); |
||
| 128 | if (isset($ftrs['computed_columns'])) { |
||
| 129 | $iTableColumns += count($ftrs['computed_columns']); |
||
| 130 | } |
||
| 131 | if (isset($ftrs['actions'])) { |
||
| 132 | $iTableColumns += 1; |
||
| 133 | } |
||
| 134 | if (isset($ftrs['grouping_cell'])) { |
||
| 135 | $iTableColumns -= 1; |
||
| 136 | } |
||
| 137 | $tbl['Head'] = '<thead>'; |
||
| 138 | if ($ftrs['grouping_cell_type'] == 'row') { |
||
| 139 | $sReturn .= $tbl['Head']; |
||
| 140 | } |
||
| 141 | if (isset($iStartingPageRecord)) { |
||
| 142 | $pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2], $bKpFlPge); |
||
| 143 | $sReturn .= $this->setStringIntoTag($this->setStringIntoTag($pgn, 'th', [ |
||
| 144 | 'colspan' => $iTableColumns |
||
| 145 | ]), 'tr'); |
||
| 146 | } |
||
| 147 | $tbl['Header'] = '<tr>'; |
||
| 148 | if (isset($ftrs['grouping_cell'])) { // Grouping columns |
||
| 149 | $header = array_diff_key($header, [$ftrs['grouping_cell'] => '']); |
||
| 150 | } |
||
| 151 | if (isset($ftrs['actions'])) { // Action column |
||
| 152 | $tbl['Header'] .= '<th> </th>'; |
||
| 153 | } |
||
| 154 | if (isset($ftrs['RowStyle'])) { //Exclude style columns from displaying |
||
| 155 | $tmpClmns = $this->setArrayValuesAsKey([$ftrs['RowStyle']]); |
||
| 156 | $header = array_diff_key($header, $tmpClmns); |
||
| 157 | $hdClmns = array_merge($hdClmns, $tmpClmns); |
||
| 158 | unset($tmpClmns); |
||
| 159 | } |
||
| 160 | $tbl['Header'] .= $this->setTableHeader($header, $ftrs['headers_breaked']); // Regular columns |
||
| 161 | if (isset($ftrs['computed_columns'])) { // Computed columns |
||
| 162 | $tbl['Header'] .= $this->setTableHeader($ftrs['computed_columns'], $ftrs['headers_breaked']); |
||
| 163 | } |
||
| 164 | $tbl['Header'] .= '</tr></thead><tbody>'; |
||
| 165 | if ($ftrs['grouping_cell_type'] == 'row') { |
||
| 166 | $sReturn .= $tbl['Header']; |
||
| 167 | } |
||
| 168 | } |
||
| 169 | $row_current = array_diff_key($aElements[$rCntr], $hdClmns); |
||
| 170 | if (isset($ftrs['row_colored_alternated'])) { |
||
| 171 | if ($ftrs['row_colored_alternated'][0] == '#') { |
||
| 172 | $color_column_value = $rCntr; |
||
| 173 | } else { |
||
| 174 | $color_column_value = $row_current[$ftrs['row_colored_alternated'][0]]; |
||
| 175 | } |
||
| 176 | if ($remebered_value != $color_column_value) { |
||
| 177 | if (isset($color_no)) { |
||
| 178 | $color_no = 1; |
||
| 179 | } else { |
||
| 180 | $color_no = 2; |
||
| 181 | } |
||
| 182 | $remebered_value = $color_column_value; |
||
| 183 | } |
||
| 184 | $color = ' style="background-color: ' . $ftrs['row_colored_alternated'][$color_no] . ';"'; |
||
| 185 | } else { |
||
| 186 | if (isset($ftrs['RowStyle'])) { |
||
| 187 | $color = ' style="' . $aElements[$rCntr][$ftrs['RowStyle']] . '"'; |
||
| 188 | } else { |
||
| 189 | $color = ''; |
||
| 190 | } |
||
| 191 | } |
||
| 192 | $tbl['tr_Color'] = '<tr' . $color . '>'; |
||
| 193 | // Grouping column |
||
| 194 | if (isset($ftrs['grouping_cell'])) { |
||
| 195 | foreach ($aElements[$rCntr] as $key => $value) { |
||
| 196 | if (($ftrs['grouping_cell'] == $key) && ($remindGroupValue != $value)) { |
||
| 197 | switch ($ftrs['grouping_cell_type']) { |
||
| 198 | case 'row': |
||
| 199 | $sReturn .= $tbl['tr_Color'] . '<td ' . 'colspan="' . $iTableColumns . '">' |
||
| 200 | . $this->setStringIntoTag($value, 'div', ['class' => 'rowGroup rounded']) |
||
| 201 | . '</td></tr>'; |
||
| 202 | break; |
||
| 203 | case 'tab': |
||
| 204 | if (is_null($remindGroupValue)) { |
||
| 205 | if (isset($ftrs['showGroupingCounter'])) { |
||
| 206 | $groupCounter = 0; |
||
| 207 | } |
||
| 208 | } else { |
||
| 209 | $sReturn .= '</tbody></table>'; |
||
| 210 | if (isset($ftrs['showGroupingCounter'])) { |
||
| 211 | $sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
||
| 212 | $groupCounter = 0; |
||
| 213 | } |
||
| 214 | $sReturn .= '</div>'; |
||
| 215 | } |
||
| 216 | $sReturn .= '<div class="tabbertab'; |
||
| 217 | if (isset($ftrs['grouping_default_tab'])) { |
||
| 218 | $sReturn .= ($ftrs['grouping_default_tab'] == $value ? ' tabbertabdefault' : ''); |
||
| 219 | } |
||
| 220 | $sReturn .= '" id="tab_' . $this->cleanStringForId($value) . '" ' |
||
| 221 | . 'title="' . $value . '">' |
||
| 222 | . $tbl['Def'] . $tbl['Head'] . $tbl['Header']; |
||
| 223 | break; |
||
| 224 | } |
||
| 225 | $remindGroupValue = $value; |
||
| 226 | } |
||
| 227 | } |
||
| 228 | } |
||
| 229 | if (isset($ftrs['grouping_cell'])) { |
||
| 230 | if ($ftrs['grouping_cell_type'] == 'tab') { |
||
| 231 | if (isset($ftrs['showGroupingCounter'])) { |
||
| 232 | $groupCounter++; |
||
| 233 | } |
||
| 234 | } |
||
| 235 | } |
||
| 236 | $sReturn .= $tbl['tr_Color']; |
||
| 237 | // Action column |
||
| 238 | $checkboxName = ''; |
||
| 239 | $checkboxNameS = ''; |
||
| 240 | if (isset($ftrs['actions'])) { |
||
| 241 | $sReturn .= '<td style="white-space:nowrap;">'; |
||
| 242 | $action_argument = 0; |
||
| 243 | if (isset($ftrs['actions']['key'])) { |
||
| 244 | $actionKey = $ftrs['actions']['key']; |
||
| 245 | } else { |
||
| 246 | $actionKey = 'view'; |
||
| 247 | } |
||
| 248 | if (isset($ftrs['action_prefix'])) { |
||
| 249 | $actPrfx = $ftrs['action_prefix'] . '&'; |
||
| 250 | $actionKey = 'view2'; |
||
| 251 | } else { |
||
| 252 | $actPrfx = ''; |
||
| 253 | } |
||
| 254 | foreach ($ftrs['actions'] as $key => $value) { |
||
| 255 | if ($action_argument != 0) { |
||
| 256 | $sReturn .= ' '; |
||
| 257 | } |
||
| 258 | switch ($key) { |
||
| 259 | case 'checkbox': |
||
| 260 | $checkboxName = $value . '[]'; |
||
| 261 | $checkboxNameS = $value; |
||
| 262 | $sReturn .= ' <input type="checkbox" name="' . $checkboxName |
||
| 263 | . '" id="n' . $aElements[$rCntr][$value] |
||
| 264 | . '" value="' . $aElements[$rCntr][$value] . '" '; |
||
| 265 | if (isset($_REQUEST[$checkboxNameS])) { |
||
| 266 | if (is_array($_REQUEST[$checkboxNameS])) { |
||
| 267 | if (in_array($aElements[$rCntr][$value], $_REQUEST[$checkboxNameS])) { |
||
| 268 | $sReturn .= 'checked="checked" '; |
||
| 269 | } |
||
| 270 | } else { |
||
| 271 | if ($aElements[$rCntr][$value] == $_REQUEST[$checkboxNameS]) { |
||
| 272 | $sReturn .= 'checked="checked" '; |
||
| 273 | } |
||
| 274 | } |
||
| 275 | } |
||
| 276 | if (strpos($_REQUEST['view'], 'multiEdit') !== false) { |
||
| 277 | $sReturn .= 'disabled="disabled" '; |
||
| 278 | } |
||
| 279 | $sReturn .= '/>'; |
||
| 280 | break; |
||
| 281 | case 'checkbox_inlineEdit': |
||
| 282 | $checkboxName = $value . '[]'; |
||
| 283 | $checkboxNameS = $value; |
||
| 284 | $sReturn .= ' <input type="checkbox" name="' . $checkboxName |
||
| 285 | . '" id="n' . $aElements[$rCntr][$value] . '" value="' |
||
| 286 | . $aElements[$rCntr][$value] . '"/>'; |
||
| 287 | break; |
||
| 288 | case 'delete': |
||
| 289 | $sReturn .= '<a href="#" onclick="javascript:setQuest(\'' . $value[0] . '\',\''; |
||
| 290 | $iActArgs = count($value[1]); |
||
| 291 | for ($cntr2 = 0; $cntr2 < $iActArgs; $cntr2++) { |
||
| 292 | $sReturn .= $value[1][$cntr2] . '=' . $aElements[$rCntr][$value[1][$cntr2]]; |
||
| 293 | } |
||
| 294 | $sReturn .= '\');" id="' . $key . $rCntr . '"><i class="fa fa-times"> </i></a>'; |
||
| 295 | break; |
||
| 296 | case 'edit': |
||
| 297 | case 'list2': |
||
| 298 | case 'schedule': |
||
| 299 | $vIc = ($key == 'edit' ? 'pencil' : ($key == 'list2' ? 'list' : 'hourglass-half')); |
||
| 300 | $sReturn .= $this->setDynamicActionToSpecialCell($value, $aElements, [ |
||
| 301 | 'vIcon' => 'fa fa-' . $vIc, |
||
| 302 | 'aPrefix' => $actPrfx, |
||
| 303 | 'aKey' => $actionKey, |
||
| 304 | 'rCounter' => $rCntr, |
||
| 305 | 'Features' => $ftrs, |
||
| 306 | 'key' => $key, |
||
| 307 | ]); |
||
| 308 | break; |
||
| 309 | } |
||
| 310 | $action_argument += 1; |
||
| 311 | } |
||
| 312 | $sReturn .= '</td>'; |
||
| 313 | } |
||
| 314 | // Regular columns |
||
| 315 | $sReturn .= $this->setTableCell($row_current, $ftrs); |
||
| 316 | // Computed columns |
||
| 317 | if (isset($ftrs['computed_columns'])) { |
||
| 318 | $rowComputed = []; |
||
| 319 | $decimals = []; |
||
| 320 | foreach ($ftrs['computed_columns'] as $key => $value) { |
||
| 321 | if ($value[0] == '%') { |
||
| 322 | $dec = $value[2] + 2; |
||
| 323 | } else { |
||
| 324 | $dec = $value[2]; |
||
| 325 | } |
||
| 326 | switch ($value[1]) { |
||
| 327 | case '/': |
||
| 328 | // next variable is only to avoid a long line |
||
| 329 | $shorter = [ |
||
| 330 | $aElements[$rCntr][$value[3]], |
||
| 331 | $aElements[$rCntr][$value[4]], |
||
| 332 | ]; |
||
| 333 | $aElements[$rCntr][$key] = $this->setDividedResult($shorter[0], $shorter[1], $dec); |
||
| 334 | break; |
||
| 335 | case '+': |
||
| 336 | // next variable is only to avoid a long line |
||
| 337 | $iTemp = $this->setArrayValuesAsKey([ |
||
| 338 | $value[0], |
||
| 339 | $value[1], |
||
| 340 | $value[2] |
||
| 341 | ]); |
||
| 342 | $aTemp = array_diff($value, $iTemp); |
||
| 343 | $aElements[$rCntr][$key] = 0; |
||
| 344 | foreach ($aTemp as $sValue) { |
||
| 345 | $aElements[$rCntr][$key] += $aElements[$rCntr][$sValue]; |
||
| 346 | } |
||
| 347 | break; |
||
| 348 | default: |
||
| 349 | $rowComputed[$key] = ''; |
||
| 350 | break; |
||
| 351 | } |
||
| 352 | if ($value[0] == '%') { |
||
| 353 | $rowComputed[$key] = ($aElements[$rCntr][$key] * 100); |
||
| 354 | $dec -= 2; |
||
| 355 | } else { |
||
| 356 | $rowComputed[$key] = $aElements[$rCntr][$key]; |
||
| 357 | } |
||
| 358 | $decimals[$key] = $dec; |
||
| 359 | } |
||
| 360 | // displaying them |
||
| 361 | $sReturn .= $this->setTableCell($rowComputed, ['decimals' => $decimals]); |
||
| 362 | } |
||
| 363 | $sReturn .= '</tr>'; |
||
| 364 | } |
||
| 365 | if (isset($iStartingPageRecord)) { |
||
| 366 | $pgn = $this->setPagination($ftrs['limits'][0], $ftrs['limits'][1], $ftrs['limits'][2]); |
||
| 367 | $sReturn .= '<tr>' . $this->setStringIntoTag($pgn, 'th', ['colspan' => $iTableColumns]) . '</tr>'; |
||
| 368 | } |
||
| 369 | $sReturn .= '</tbody></table>'; |
||
| 370 | if ($ftrs['grouping_cell_type'] == 'tab') { |
||
| 371 | if (isset($ftrs['showGroupingCounter'])) { |
||
| 372 | $sReturn .= $this->updateDivTitleName($remindGroupValue, $groupCounter); |
||
| 373 | } |
||
| 374 | $sReturn .= '</div><!-- from ' . $remindGroupValue . ' -->'; |
||
| 375 | if (!isset($ftrs['noGlobalTab'])) { |
||
| 376 | $sReturn .= '</div><!-- from global tab -->'; |
||
| 377 | } |
||
| 378 | } |
||
| 379 | if (isset($ftrs['actions']['checkbox'])) { |
||
| 380 | if (strpos($_REQUEST['view'], 'multiEdit') === false) { |
||
| 381 | $sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
||
| 382 | . '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
||
| 383 | . '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
||
| 384 | . '\',\'' . $checkboxName . '\',false);">Uncheck All</a> ' |
||
| 385 | . '<input type="hidden" name="action" value="multiEdit_' . $checkboxNameS . '" />'; |
||
| 386 | if (isset($ftrs['hiddenInput'])) { |
||
| 387 | if (is_array($ftrs['hiddenInput'])) { |
||
| 388 | foreach ($ftrs['hiddenInput'] as $valueF) { |
||
| 389 | $sReturn .= '<input type="hidden" name="' . $valueF |
||
| 390 | . '" value="' . $_REQUEST[$valueF] . '" />'; |
||
| 391 | } |
||
| 392 | } else { |
||
| 393 | $sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
||
| 394 | . '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />'; |
||
| 395 | } |
||
| 396 | } |
||
| 397 | $sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" ' . 'value="Edit selected" />'; |
||
| 398 | } |
||
| 399 | $sReturn .= '</form>'; |
||
| 400 | } |
||
| 401 | if (isset($ftrs['actions']['checkbox_inlineEdit'])) { |
||
| 402 | $sReturn .= '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
||
| 403 | . '\',\'' . $checkboxName . '\',true);">Check All</a> ' |
||
| 404 | . '<a href="#" onclick="javascript:checking(\'' . $checkboxFormId |
||
| 405 | . '\',\'' . $checkboxName . '\',false);">Uncheck All</a> '; |
||
| 406 | if (isset($ftrs['visibleInput'])) { |
||
| 407 | $sReturn .= $ftrs['visibleInput']; |
||
| 408 | } |
||
| 409 | $sReturn .= '<input type="hidden" name="view" value="save_' . $checkboxNameS . '" />'; |
||
| 410 | if (isset($ftrs['hiddenInput'])) { |
||
| 411 | if (is_array($ftrs['hiddenInput'])) { |
||
| 412 | foreach ($ftrs['hiddenInput'] as $valueF) { |
||
| 413 | $sReturn .= '<input type="hidden" name="' . $valueF |
||
| 414 | . '" value="' . $_REQUEST[$valueF] . '" />'; |
||
| 415 | } |
||
| 416 | } else { |
||
| 417 | $sReturn .= '<input type="hidden" name="' . $ftrs['hiddenInput'] |
||
| 418 | . '" value="' . $_REQUEST[$ftrs['hiddenInput']] . '" />'; |
||
| 419 | } |
||
| 420 | } |
||
| 421 | $sReturn .= '<input style="margin: 0 3em 0 3em;" type="submit" value="Store the modification" />'; |
||
| 422 | $sReturn .= '</form>'; |
||
| 423 | } |
||
| 424 | return $sReturn; |
||
| 425 | } |
||
| 426 | |||
| 427 | /** |
||
| 428 | * Set a control to a user-friendly calendar |
||
| 429 | * |
||
| 430 | * @param string $controlName |
||
| 431 | * @param string $additionalStyle |
||
| 432 | * @return string |
||
| 433 | */ |
||
| 434 | public function setCalendarControl($controlName, $additionalStyle = '') |
||
| 435 | { |
||
| 436 | return $this->setStringIntoTag(' ', 'span', [ |
||
| 437 | 'onclick' => implode('', [ |
||
| 438 | 'javascript:NewCssCal(\'' . $controlName, |
||
| 439 | '\',\'yyyyMMdd\',\'dropdown\',false,\'24\',false);', |
||
| 440 | ]), |
||
| 441 | 'class' => 'fa fa-calendar', |
||
| 442 | 'id' => $controlName . '_picker', |
||
| 443 | 'style' => 'cursor:pointer;' . $additionalStyle, |
||
| 444 | ]); |
||
| 445 | } |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Set a control to a user-friendly calendar with time included |
||
| 449 | * |
||
| 450 | * @param string $controlName |
||
| 451 | * @param string $additionalStyle |
||
| 452 | * @return string |
||
| 453 | */ |
||
| 454 | public function setCalendarControlWithTime($controlName, $additionalStyle = '') |
||
| 455 | { |
||
| 456 | return $this->setStringIntoTag(' ', 'span', [ |
||
| 457 | 'onclick' => implode('', [ |
||
| 458 | 'javascript:NewCssCal(\'' . $controlName, |
||
| 459 | '\',\'yyyyMMdd\',\'dropdown\',true,\'24\',true);', |
||
| 460 | ]), |
||
| 461 | 'class' => 'fa fa-calendar', |
||
| 462 | 'id' => $controlName . '_picker', |
||
| 463 | 'style' => 'cursor:pointer;' . $additionalStyle, |
||
| 464 | ]); |
||
| 465 | } |
||
| 466 | |||
| 467 | private function setDynamicActionToSpecialCell($val, $aElements, $inP) |
||
| 468 | { |
||
| 469 | $aArgumemts = []; |
||
| 470 | $aArgumemts[] = $this->tCmnSuperGlobals->getScriptName() . '?' . $inP['aPrefix'] . $inP['aKey'] . '=' . $val[0]; |
||
| 471 | $iActArgs = count($val[1]); |
||
| 472 | for ($counter = 0; $counter < $iActArgs; $counter++) { |
||
| 473 | $aArgumemts[] = $val[1][$counter] . '=' . $aElements[$inP['rCounter']][$val[1][$counter]]; |
||
| 474 | } |
||
| 475 | $id = $inP['key'] . $inP['rCounter']; |
||
| 476 | if (isset($inP['Features']['NoAjaxEditing'])) { |
||
| 477 | return '<a href="' . implode('&', $aArgumemts) . '" id="' . $id . '"><i class="' |
||
| 478 | . $inP['vIcon'] . '"> </i></a>'; |
||
| 479 | } |
||
| 480 | return '<a href="#" onclick="javascript:loadAE(\'' . implode('&', $aArgumemts) . '\');"' |
||
| 481 | . ' id="' . $id . '"><i class="' . $inP['vIcon'] . '"> </i></a>'; |
||
| 482 | } |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Outputs an HTML footer |
||
| 486 | * |
||
| 487 | * @param array $footerInjected |
||
| 488 | * @return string |
||
| 489 | */ |
||
| 490 | protected function setFooterCommon($footerInjected = null) |
||
| 491 | { |
||
| 492 | $sHK = $this->tCmnSuperGlobals->get('specialHook'); |
||
| 493 | if (!is_null($sHK) && (in_array('noHeader', $sHK))) { |
||
| 494 | return ''; |
||
| 495 | } |
||
| 496 | return $this->setFooterCommonInjected($footerInjected) . '</body></html>'; |
||
| 497 | } |
||
| 498 | |||
| 499 | protected function setFooterCommonInjected($footerInjected = null) |
||
| 500 | { |
||
| 501 | $sReturn = ''; |
||
| 502 | if (!is_null($footerInjected)) { |
||
| 503 | $sReturn = $footerInjected; |
||
| 504 | if (is_array($footerInjected)) { |
||
| 505 | $sReturn = implode('', $footerInjected); |
||
| 506 | } |
||
| 507 | } |
||
| 508 | return $sReturn; |
||
| 509 | } |
||
| 510 | |||
| 511 | /** |
||
| 512 | * Outputs an HTML header |
||
| 513 | * |
||
| 514 | * @param array $headerFeatures |
||
| 515 | * @return string |
||
| 516 | */ |
||
| 517 | protected function setHeaderCommon($headerFeatures = null) |
||
| 518 | { |
||
| 519 | $sReturn = []; |
||
| 520 | $sHK = $this->tCmnSuperGlobals->get('specialHook'); |
||
| 521 | if (!is_null($sHK) && (in_array('noHeader', $sHK))) { |
||
| 522 | $sReturn[] = ''; // no Header |
||
| 523 | } else { |
||
| 524 | $fixedHeaderElements = [ |
||
| 525 | 'start' => '<!DOCTYPE html>', |
||
| 526 | 'lang' => '<html lang="en-US">', |
||
| 527 | 'head' => '<head>', |
||
| 528 | 'charset' => '<meta charset="utf-8" />', |
||
| 529 | 'viewport' => '<meta name="viewport" content="' . implode(', ', [ |
||
| 530 | 'width=device-width', |
||
| 531 | 'height=device-height', |
||
| 532 | 'initial-scale=1', |
||
| 533 | ]) . '" />', |
||
| 534 | ]; |
||
| 535 | if (!is_null($headerFeatures)) { |
||
| 536 | if (is_array($headerFeatures)) { |
||
| 537 | $aFeatures = []; |
||
| 538 | foreach ($headerFeatures as $key => $value) { |
||
| 539 | switch ($key) { |
||
| 540 | case 'css': |
||
| 541 | if (is_array($value)) { |
||
| 542 | foreach ($value as $value2) { |
||
| 543 | $aFeatures[] = $this->setCssFile(filter_var($value2, FILTER_SANITIZE_URL)); |
||
| 544 | } |
||
| 545 | } else { |
||
| 546 | $aFeatures[] = $this->setCssFile(filter_var($value, FILTER_SANITIZE_URL)); |
||
| 547 | } |
||
| 548 | break; |
||
| 549 | case 'javascript': |
||
| 550 | if (is_array($value)) { |
||
| 551 | foreach ($value as $value2) { |
||
| 552 | $vl = filter_var($value2, FILTER_SANITIZE_URL); |
||
| 553 | $aFeatures[] = $this->setJavascriptFile($vl); |
||
| 554 | } |
||
| 555 | } else { |
||
| 556 | $aFeatures[] = $this->setJavascriptFile(filter_var($value, FILTER_SANITIZE_URL)); |
||
| 557 | } |
||
| 558 | break; |
||
| 559 | case 'lang': |
||
| 560 | $fixedHeaderElements['lang'] = '<html lang="' |
||
| 561 | . filter_var($value, FILTER_SANITIZE_STRING) . '">'; |
||
| 562 | break; |
||
| 563 | case 'title': |
||
| 564 | $aFeatures[] = '<title>' |
||
| 565 | . filter_var($value, FILTER_SANITIZE_STRING) . '</title>'; |
||
| 566 | break; |
||
| 567 | } |
||
| 568 | } |
||
| 569 | $sReturn[] = implode('', $fixedHeaderElements) |
||
| 570 | . implode('', $aFeatures) |
||
| 571 | . '</head>' |
||
| 572 | . '<body>'; |
||
| 573 | } else { |
||
| 574 | $sReturn[] = implode('', $fixedHeaderElements) |
||
| 575 | . '</head>' |
||
| 576 | . '<body>' |
||
| 577 | . '<p style="background-color:red;color:#FFF;">The parameter sent to ' |
||
| 578 | . __FUNCTION__ . ' must be an array</p>' |
||
| 579 | . $this->setFooterCommon(); |
||
| 580 | throw new \Exception($sReturn); |
||
| 581 | } |
||
| 582 | } |
||
| 583 | } |
||
| 584 | return implode('', $sReturn); |
||
| 585 | } |
||
| 586 | |||
| 587 | /** |
||
| 588 | * Generates a table cell |
||
| 589 | * |
||
| 590 | * @param array $aElements |
||
| 591 | * @param array $features |
||
| 592 | * @return string |
||
| 593 | */ |
||
| 594 | private function setTableCell($aElements, $features = null) |
||
| 636 | } |
||
| 637 | |||
| 638 | private function setTableCellDecimals($key, $features) |
||
| 639 | { |
||
| 640 | $decimals = 0; |
||
| 641 | if (isset($features['no_of_decimals'])) { |
||
| 642 | $decimals = $features['no_of_decimals']; |
||
| 643 | } |
||
| 644 | if (isset($features['decimals']) && array_key_exists($key, $features['decimals'])) { |
||
| 645 | $decimals = $features['decimals'][$key]; |
||
| 646 | } |
||
| 647 | return $decimals; |
||
| 648 | } |
||
| 649 | |||
| 650 | private function setTableCellNumeric($key, $value, $features) |
||
| 651 | { |
||
| 652 | $styleToReturn = 'style="text-align: right;">'; |
||
| 653 | if (substr($value, 0, 1) === '0') { |
||
| 654 | return $styleToReturn . $value; |
||
| 655 | } |
||
| 656 | $decimals = $this->setTableCellDecimals($key, $features); |
||
| 657 | $nDc = ['MinFractionDigits' => $decimals, 'MaxFractionDigits' => $decimals]; |
||
| 658 | return $styleToReturn . $this->setNumberFormat($value, $nDc); |
||
| 659 | } |
||
| 660 | |||
| 661 | /** |
||
| 662 | * Generates a table header |
||
| 663 | * |
||
| 664 | * @param array $aElements |
||
| 665 | * @param boolean $bHeadersBreaked |
||
| 666 | * @return string |
||
| 667 | */ |
||
| 668 | private function setTableHeader($aElements, $bHeadersBreaked) |
||
| 669 | { |
||
| 670 | $aTableHeader = $aElements; |
||
| 671 | if ($bHeadersBreaked) { |
||
| 672 | $aTableHeader = $this->setArrayToArrayKbr($aElements); |
||
| 673 | } |
||
| 674 | $sReturn[] = null; |
||
| 675 | foreach (array_keys($aTableHeader) as $value) { |
||
| 676 | $sReturn[] = $this->setStringIntoTag($value, 'th'); |
||
| 677 | } |
||
| 678 | return implode('', $sReturn); |
||
| 679 | } |
||
| 680 | |||
| 681 | /** |
||
| 682 | * Create an upper right box with choices for languages |
||
| 683 | * (requires flag-icon.min.css to be loaded) |
||
| 684 | * (makes usage of custom class "upperRightBox" and id = "visibleOnHover", provided here as scss file) |
||
| 685 | * |
||
| 686 | * @param array $aAvailableLanguages |
||
| 687 | * @return string |
||
| 688 | */ |
||
| 689 | protected function setUpperRightBoxLanguages($aAvailableLanguages) |
||
| 700 | } |
||
| 701 | |||
| 702 | private function setUpperRightVisibleOnHoverLanguages($aAvailableLanguages) |
||
| 718 | } |
||
| 719 | |||
| 720 | } |
||
| 721 |