@@ -28,8 +28,8 @@ |
||
28 | 28 | { |
29 | 29 | parent::__construct('form'); |
30 | 30 | |
31 | - if (isset($attributes[ 'id' ])) { |
|
32 | - $this->entity->setEntityName($attributes[ 'id' ]); |
|
31 | + if (isset($attributes['id'])) { |
|
32 | + $this->entity->setEntityName($attributes['id']); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if (count($attributes)) { |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - if (empty($_SESSION[ 'o2system' ][ 'cart' ])) { |
|
33 | - $_SESSION[ 'o2system' ][ 'cart' ] = []; |
|
32 | + if (empty($_SESSION['o2system']['cart'])) { |
|
33 | + $_SESSION['o2system']['cart'] = []; |
|
34 | 34 | } |
35 | 35 | |
36 | - $this->storage =& $_SESSION[ 'o2system' ][ 'cart' ]; |
|
36 | + $this->storage = & $_SESSION['o2system']['cart']; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // ------------------------------------------------------------------------ |
@@ -56,29 +56,29 @@ discard block |
||
56 | 56 | ], $item); |
57 | 57 | |
58 | 58 | // set sku |
59 | - $sku = empty($item[ 'sku' ]) ? $item[ 'id' ] : $item[ 'sku' ]; |
|
59 | + $sku = empty($item['sku']) ? $item['id'] : $item['sku']; |
|
60 | 60 | |
61 | 61 | // set sub-total |
62 | - $item[ 'subTotal' ][ 'price' ] = $item[ 'price' ] * $item[ 'quantity' ]; |
|
63 | - $item[ 'subTotal' ][ 'discount' ] = 0; |
|
62 | + $item['subTotal']['price'] = $item['price'] * $item['quantity']; |
|
63 | + $item['subTotal']['discount'] = 0; |
|
64 | 64 | |
65 | - if (is_numeric($item[ 'discount' ])) { |
|
66 | - $item[ 'subTotal' ][ 'discount' ] = $item[ 'subTotal' ][ 'price' ] - $item[ 'discount' ]; |
|
67 | - } elseif (is_string($item[ 'discount' ]) && strpos($item[ 'discount' ], '+') !== false) { |
|
65 | + if (is_numeric($item['discount'])) { |
|
66 | + $item['subTotal']['discount'] = $item['subTotal']['price'] - $item['discount']; |
|
67 | + } elseif (is_string($item['discount']) && strpos($item['discount'], '+') !== false) { |
|
68 | 68 | $discounts = explode('+', $item['discount']); |
69 | - if(count($discounts)) { |
|
70 | - $item[ 'subTotal' ][ 'discount' ] = $item[ 'subTotal' ][ 'price' ] * (intval(reset($discounts)) / 100); |
|
71 | - foreach(array_slice($discounts, 1) as $discount) { |
|
72 | - $item[ 'subTotal' ][ 'discount' ] += $item[ 'subTotal' ][ 'discount' ] * (intval($discount) / 100); |
|
69 | + if (count($discounts)) { |
|
70 | + $item['subTotal']['discount'] = $item['subTotal']['price'] * (intval(reset($discounts)) / 100); |
|
71 | + foreach (array_slice($discounts, 1) as $discount) { |
|
72 | + $item['subTotal']['discount'] += $item['subTotal']['discount'] * (intval($discount) / 100); |
|
73 | 73 | } |
74 | 74 | } |
75 | - } elseif (is_string($item[ 'discount' ]) && strpos($item[ 'discount' ], '%') !== false) { |
|
76 | - $item[ 'subTotal' ][ 'discount' ] = $item[ 'subTotal' ][ 'price' ] * (intval($item[ 'discount' ]) / 100); |
|
75 | + } elseif (is_string($item['discount']) && strpos($item['discount'], '%') !== false) { |
|
76 | + $item['subTotal']['discount'] = $item['subTotal']['price'] * (intval($item['discount']) / 100); |
|
77 | 77 | } |
78 | 78 | |
79 | - $item[ 'subTotal' ][ 'weight' ] = $item[ 'weight' ] * $item[ 'quantity' ]; |
|
79 | + $item['subTotal']['weight'] = $item['weight'] * $item['quantity']; |
|
80 | 80 | |
81 | - $this->storage[ $sku ] = $item; |
|
81 | + $this->storage[$sku] = $item; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | // ------------------------------------------------------------------------ |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | $item = array_merge($this->offsetGet($sku), $item); |
98 | 98 | |
99 | 99 | // update sub-total |
100 | - $item[ 'subTotal' ][ 'price' ] = $item[ 'price' ] * $item[ 'quantity' ]; |
|
101 | - $item[ 'subTotal' ][ 'weight' ] = $item[ 'weight' ] * $item[ 'quantity' ]; |
|
100 | + $item['subTotal']['price'] = $item['price'] * $item['quantity']; |
|
101 | + $item['subTotal']['weight'] = $item['weight'] * $item['quantity']; |
|
102 | 102 | |
103 | - $this->storage[ $sku ] = $item; |
|
103 | + $this->storage[$sku] = $item; |
|
104 | 104 | |
105 | 105 | return true; |
106 | 106 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | |
122 | 122 | if ($this->count()) { |
123 | 123 | foreach ($this->storage as $id => $item) { |
124 | - if (isset($item[ 'subTotal' ][ 'weight' ])) { |
|
125 | - $totalWeight += (int)$item[ 'weight' ]; |
|
124 | + if (isset($item['subTotal']['weight'])) { |
|
125 | + $totalWeight += (int)$item['weight']; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | |
144 | 144 | if ($this->count()) { |
145 | 145 | foreach ($this->storage as $id => $item) { |
146 | - if (isset($item[ 'subTotal' ][ 'price' ])) { |
|
147 | - $totalPrice += (int)$item[ 'price' ]; |
|
146 | + if (isset($item['subTotal']['price'])) { |
|
147 | + $totalPrice += (int)$item['price']; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | public function destroy() |
156 | 156 | { |
157 | - unset($_SESSION[ 'o2system' ][ 'cart' ]); |
|
157 | + unset($_SESSION['o2system']['cart']); |
|
158 | 158 | parent::destroy(); |
159 | 159 | |
160 | 160 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | { |
226 | 226 | $this->config = array_merge($this->config, $config); |
227 | 227 | |
228 | - if ($this->config[ 'responsive' ]) { |
|
228 | + if ($this->config['responsive']) { |
|
229 | 229 | $this->responsive(); |
230 | 230 | } |
231 | 231 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | foreach ($columns as $key => $column) { |
267 | 267 | $column = array_merge($defaultColumn, $column); |
268 | - $this->columns[ $key ] = $column; |
|
268 | + $this->columns[$key] = $column; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | $this->setAppendColumns(); |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | ]; |
336 | 336 | |
337 | 337 | foreach ($prependColumns as $key => $column) { |
338 | - if ($this->config[ $key ] === true) { |
|
339 | - $this->columns[ $key ] = $column; |
|
338 | + if ($this->config[$key] === true) { |
|
339 | + $this->columns[$key] = $column; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | } |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | ]; |
409 | 409 | |
410 | 410 | foreach ($appendColumns as $key => $column) { |
411 | - if ($this->config[ $key ] === true) { |
|
412 | - $this->columns[ $key ] = $column; |
|
411 | + if ($this->config[$key] === true) { |
|
412 | + $this->columns[$key] = $column; |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | |
438 | 438 | public function render() |
439 | 439 | { |
440 | - if ($this->config[ 'ordering' ]) { |
|
440 | + if ($this->config['ordering']) { |
|
441 | 441 | $this->attributes->addAttributeClass('table-ordering'); |
442 | 442 | } |
443 | 443 | |
@@ -448,15 +448,15 @@ discard block |
||
448 | 448 | |
449 | 449 | $th = $tr->createColumn('th'); |
450 | 450 | |
451 | - $column[ 'attr' ][ 'data-column' ] = $key; |
|
451 | + $column['attr']['data-column'] = $key; |
|
452 | 452 | |
453 | - foreach ($column[ 'attr' ] as $name => $value) { |
|
453 | + foreach ($column['attr'] as $name => $value) { |
|
454 | 454 | if ( ! empty($value)) { |
455 | 455 | $th->attributes->addAttribute($name, $value); |
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | - if ($column[ 'sorting' ] === true) { |
|
459 | + if ($column['sorting'] === true) { |
|
460 | 460 | $icon = new Ui\Contents\Icon('fa fa-sort'); |
461 | 461 | $icon->attributes->addAttributeClass(['text-muted', 'float-right', 'mt-1']); |
462 | 462 | |
@@ -465,11 +465,11 @@ discard block |
||
465 | 465 | $th->childNodes->push($icon); |
466 | 466 | } |
467 | 467 | |
468 | - if ($column[ 'show' ] === false) { |
|
468 | + if ($column['show'] === false) { |
|
469 | 469 | $th->attributes->addAttributeClass('hidden'); |
470 | 470 | } |
471 | 471 | |
472 | - $th->textContent->push(language()->getLine($column[ 'label' ])); |
|
472 | + $th->textContent->push(language()->getLine($column['label'])); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | // Render tbody |
@@ -477,8 +477,8 @@ discard block |
||
477 | 477 | $totalEntries = $this->rows->count(); |
478 | 478 | $totalRows = $this->rows->countAll(); |
479 | 479 | $currentPage = input()->get('page') ? input()->get('page') : 1; |
480 | - $startNumber = $currentPage == 1 ? 1 : $currentPage * $this->config[ 'entries' ][ 'minimum' ]; |
|
481 | - $totalPages = round($totalRows / $this->config[ 'entries' ][ 'minimum' ]); |
|
480 | + $startNumber = $currentPage == 1 ? 1 : $currentPage * $this->config['entries']['minimum']; |
|
481 | + $totalPages = round($totalRows / $this->config['entries']['minimum']); |
|
482 | 482 | $totalPages = $totalPages == 0 && $totalRows > 0 ? 1 : $totalPages; |
483 | 483 | |
484 | 484 | $i = $startNumber; |
@@ -489,18 +489,18 @@ discard block |
||
489 | 489 | |
490 | 490 | foreach ($this->columns as $key => $column) { |
491 | 491 | |
492 | - $column[ 'key' ] = $key; |
|
492 | + $column['key'] = $key; |
|
493 | 493 | $td = $tr->createColumn(); |
494 | 494 | |
495 | - $column[ 'attr' ][ 'data-column' ] = $key; |
|
495 | + $column['attr']['data-column'] = $key; |
|
496 | 496 | |
497 | - foreach ($column[ 'attr' ] as $name => $value) { |
|
497 | + foreach ($column['attr'] as $name => $value) { |
|
498 | 498 | if ( ! empty($value)) { |
499 | 499 | $td->attributes->addAttribute($name, $value); |
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - if ($column[ 'show' ] === false) { |
|
503 | + if ($column['show'] === false) { |
|
504 | 504 | $td->attributes->addAttributeClass('hidden'); |
505 | 505 | } |
506 | 506 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | $totalPages = 0; |
520 | 520 | } |
521 | 521 | |
522 | - $showEntries = input()->get('entries') ? input()->get('entries') : $this->config[ 'entries' ][ 'minimum' ]; |
|
522 | + $showEntries = input()->get('entries') ? input()->get('entries') : $this->config['entries']['minimum']; |
|
523 | 523 | |
524 | 524 | // Build table card |
525 | 525 | $card = new Ui\Components\Card(); |
@@ -532,33 +532,33 @@ discard block |
||
532 | 532 | |
533 | 533 | $buttons = new Ui\Components\Buttons\Group(); |
534 | 534 | foreach ($this->tools as $key => $tool) { |
535 | - if ($tool[ 'show' ] === false) { |
|
535 | + if ($tool['show'] === false) { |
|
536 | 536 | continue; |
537 | 537 | } |
538 | 538 | |
539 | - if ($tool[ 'label' ] === true) { |
|
539 | + if ($tool['label'] === true) { |
|
540 | 540 | $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
541 | - if ( ! empty($tool[ 'icon' ])) { |
|
542 | - $button->setIcon($tool[ 'icon' ]); |
|
541 | + if ( ! empty($tool['icon'])) { |
|
542 | + $button->setIcon($tool['icon']); |
|
543 | 543 | } |
544 | 544 | } else { |
545 | - $button = $buttons->createButton(new Ui\Contents\Icon($tool[ 'icon' ])); |
|
545 | + $button = $buttons->createButton(new Ui\Contents\Icon($tool['icon'])); |
|
546 | 546 | $button->attributes->addAttribute('data-toggle', 'tooltip'); |
547 | 547 | $button->attributes->addAttribute('title', |
548 | 548 | language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
549 | 549 | } |
550 | 550 | |
551 | - if ( ! empty($tool[ 'href' ])) { |
|
552 | - $tool[ 'data-url' ] = $tool[ 'href' ]; |
|
551 | + if ( ! empty($tool['href'])) { |
|
552 | + $tool['data-url'] = $tool['href']; |
|
553 | 553 | } |
554 | 554 | |
555 | - if (isset($tool[ 'attr' ])) { |
|
556 | - foreach ($tool[ 'attr' ] as $name => $value) { |
|
555 | + if (isset($tool['attr'])) { |
|
556 | + foreach ($tool['attr'] as $name => $value) { |
|
557 | 557 | $button->attributes->addAttribute($name, $value); |
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | - $button->setContextualClass($tool[ 'contextual' ]); |
|
561 | + $button->setContextualClass($tool['contextual']); |
|
562 | 562 | $button->smallSize(); |
563 | 563 | $button->attributes->addAttribute('data-action', $key); |
564 | 564 | } |
@@ -573,33 +573,33 @@ discard block |
||
573 | 573 | |
574 | 574 | $buttons = new Ui\Components\Buttons\Group(); |
575 | 575 | foreach ($this->options as $key => $option) { |
576 | - if ($option[ 'show' ] === false) { |
|
576 | + if ($option['show'] === false) { |
|
577 | 577 | continue; |
578 | 578 | } |
579 | 579 | |
580 | - if ($option[ 'label' ] === true) { |
|
580 | + if ($option['label'] === true) { |
|
581 | 581 | $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
582 | - if ( ! empty($option[ 'icon' ])) { |
|
583 | - $button->setIcon($option[ 'icon' ]); |
|
582 | + if ( ! empty($option['icon'])) { |
|
583 | + $button->setIcon($option['icon']); |
|
584 | 584 | } |
585 | 585 | } else { |
586 | - $button = $buttons->createButton(new Ui\Contents\Icon($option[ 'icon' ])); |
|
586 | + $button = $buttons->createButton(new Ui\Contents\Icon($option['icon'])); |
|
587 | 587 | $button->attributes->addAttribute('data-toggle', 'tooltip'); |
588 | 588 | $button->attributes->addAttribute('title', |
589 | 589 | language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
590 | 590 | } |
591 | 591 | |
592 | - if ( ! empty($option[ 'href' ])) { |
|
593 | - $option[ 'data-url' ] = $option[ 'href' ]; |
|
592 | + if ( ! empty($option['href'])) { |
|
593 | + $option['data-url'] = $option['href']; |
|
594 | 594 | } |
595 | 595 | |
596 | - if (isset($option[ 'attr' ])) { |
|
597 | - foreach ($option[ 'attr' ] as $name => $value) { |
|
596 | + if (isset($option['attr'])) { |
|
597 | + foreach ($option['attr'] as $name => $value) { |
|
598 | 598 | $button->attributes->addAttribute($name, $value); |
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | - $button->setContextualClass($option[ 'contextual' ]); |
|
602 | + $button->setContextualClass($option['contextual']); |
|
603 | 603 | $button->smallSize(); |
604 | 604 | $button->attributes->addAttribute('data-action', $key); |
605 | 605 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | $inputGroup->childNodes->push($addOn); |
635 | 635 | |
636 | 636 | $options = []; |
637 | - foreach (range((int)$this->config[ 'entries' ][ 'minimum' ], (int)$this->config[ 'entries' ][ 'maximum' ], |
|
638 | - (int)$this->config[ 'entries' ][ 'step' ]) as $entries) { |
|
639 | - $options[ $entries ] = $entries; |
|
637 | + foreach (range((int)$this->config['entries']['minimum'], (int)$this->config['entries']['maximum'], |
|
638 | + (int)$this->config['entries']['step']) as $entries) { |
|
639 | + $options[$entries] = $entries; |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | $columnsDropdown = new Ui\Components\Dropdown(language()->getLine('TABLE_LABEL_COLUMNS')); |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | |
645 | 645 | foreach ($this->columns as $key => $column) { |
646 | 646 | |
647 | - if ($column[ 'hiding' ] === false) { |
|
647 | + if ($column['hiding'] === false) { |
|
648 | 648 | continue; |
649 | 649 | } |
650 | 650 | |
651 | 651 | $label = new Ui\Components\Form\Elements\Label(); |
652 | 652 | $label->attributes->addAttributeClass('form-check-label'); |
653 | - $label->textContent->push(language()->getLine($column[ 'label' ])); |
|
653 | + $label->textContent->push(language()->getLine($column['label'])); |
|
654 | 654 | |
655 | 655 | $checkbox = new Ui\Components\Form\Elements\Input([ |
656 | 656 | 'type' => 'checkbox', |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | $checkbox->attributes->removeAttributeClass('form-control'); |
663 | 663 | |
664 | - if ($column[ 'show' ] === true) { |
|
664 | + if ($column['show'] === true) { |
|
665 | 665 | $checkbox->attributes->addAttribute('checked', 'checked'); |
666 | 666 | } |
667 | 667 | |
@@ -707,33 +707,33 @@ discard block |
||
707 | 707 | |
708 | 708 | protected function renderBodyColumn($td, array $column, Result\Row $row) |
709 | 709 | { |
710 | - switch ($column[ 'format' ]) { |
|
710 | + switch ($column['format']) { |
|
711 | 711 | default: |
712 | - if (is_callable($column[ 'format' ])) { |
|
713 | - if (is_array($column[ 'field' ])) { |
|
714 | - foreach ($column[ 'field' ] as $field) { |
|
715 | - $args[ $field ] = $row->offsetGet($field); |
|
712 | + if (is_callable($column['format'])) { |
|
713 | + if (is_array($column['field'])) { |
|
714 | + foreach ($column['field'] as $field) { |
|
715 | + $args[$field] = $row->offsetGet($field); |
|
716 | 716 | } |
717 | - $textContent = call_user_func_array($column[ 'format' ], $args); |
|
718 | - } elseif ($row->offsetExists($column[ 'field' ])) { |
|
719 | - $textContent = call_user_func_array($column[ 'format' ], |
|
720 | - [$row->offsetGet($column[ 'field' ])]); |
|
717 | + $textContent = call_user_func_array($column['format'], $args); |
|
718 | + } elseif ($row->offsetExists($column['field'])) { |
|
719 | + $textContent = call_user_func_array($column['format'], |
|
720 | + [$row->offsetGet($column['field'])]); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | $td->textContent->push($textContent); |
724 | 724 | |
725 | - } elseif (strpos($column[ 'format' ], '{{') !== false) { |
|
726 | - $textContent = str_replace(['{{', '}}'], '', $column[ 'format' ]); |
|
727 | - if (is_array($column[ 'field' ])) { |
|
728 | - foreach ($column[ 'field' ] as $field) { |
|
725 | + } elseif (strpos($column['format'], '{{') !== false) { |
|
726 | + $textContent = str_replace(['{{', '}}'], '', $column['format']); |
|
727 | + if (is_array($column['field'])) { |
|
728 | + foreach ($column['field'] as $field) { |
|
729 | 729 | if ($row->offsetExists($field)) { |
730 | 730 | $textContent = str_replace('$' . $field, $row->offsetGet($field), $textContent); |
731 | 731 | } else { |
732 | 732 | $textContent = str_replace('$' . $field, '', $textContent); |
733 | 733 | } |
734 | 734 | } |
735 | - } elseif ($row->offsetExists($column[ 'field' ])) { |
|
736 | - $textContent = str_replace('$' . $column[ 'field' ], $row->offsetGet($column[ 'field' ]), |
|
735 | + } elseif ($row->offsetExists($column['field'])) { |
|
736 | + $textContent = str_replace('$' . $column['field'], $row->offsetGet($column['field']), |
|
737 | 737 | $textContent); |
738 | 738 | } |
739 | 739 | |
@@ -753,18 +753,18 @@ discard block |
||
753 | 753 | case 'text': |
754 | 754 | case 'price': |
755 | 755 | case 'number': |
756 | - if ($row->offsetExists($column[ 'field' ])) { |
|
757 | - $td->textContent->push($row->offsetGet($column[ 'field' ])); |
|
756 | + if ($row->offsetExists($column['field'])) { |
|
757 | + $td->textContent->push($row->offsetGet($column['field'])); |
|
758 | 758 | } |
759 | 759 | break; |
760 | 760 | case 'date': |
761 | - if ($row->offsetExists($column[ 'field' ])) { |
|
761 | + if ($row->offsetExists($column['field'])) { |
|
762 | 762 | print_out('date'); |
763 | 763 | } |
764 | 764 | break; |
765 | 765 | |
766 | 766 | case 'status': |
767 | - if ($row->offsetExists($column[ 'field' ])) { |
|
767 | + if ($row->offsetExists($column['field'])) { |
|
768 | 768 | $options = [ |
769 | 769 | 'PUBLISH' => 'success', |
770 | 770 | 'UNPUBLISH' => 'warning', |
@@ -774,8 +774,8 @@ discard block |
||
774 | 774 | ]; |
775 | 775 | |
776 | 776 | $badge = new Ui\Components\Badge( |
777 | - language()->getLine('TABLE_OPTION_' . $row->offsetGet($column[ 'field' ])), |
|
778 | - $options[ $row->offsetGet($column[ 'field' ]) ] |
|
777 | + language()->getLine('TABLE_OPTION_' . $row->offsetGet($column['field'])), |
|
778 | + $options[$row->offsetGet($column['field'])] |
|
779 | 779 | ); |
780 | 780 | |
781 | 781 | $td->childNodes->push($badge); |
@@ -789,29 +789,29 @@ discard block |
||
789 | 789 | |
790 | 790 | foreach ($this->actions as $key => $action) { |
791 | 791 | |
792 | - if ($action[ 'show' ] === false) { |
|
792 | + if ($action['show'] === false) { |
|
793 | 793 | continue; |
794 | 794 | } |
795 | 795 | |
796 | - if ($action[ 'label' ] === true) { |
|
796 | + if ($action['label'] === true) { |
|
797 | 797 | $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
798 | - if ( ! empty($action[ 'icon' ])) { |
|
799 | - $button->setIcon($action[ 'icon' ]); |
|
798 | + if ( ! empty($action['icon'])) { |
|
799 | + $button->setIcon($action['icon']); |
|
800 | 800 | } |
801 | 801 | } else { |
802 | - $button = $buttons->createButton(new Ui\Contents\Icon($action[ 'icon' ])); |
|
802 | + $button = $buttons->createButton(new Ui\Contents\Icon($action['icon'])); |
|
803 | 803 | $button->attributes->addAttribute('data-toggle', 'tooltip'); |
804 | 804 | $button->attributes->addAttribute('title', |
805 | 805 | language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
806 | 806 | } |
807 | 807 | |
808 | - if (isset($action[ 'attr' ])) { |
|
809 | - foreach ($action[ 'attr' ] as $name => $value) { |
|
808 | + if (isset($action['attr'])) { |
|
809 | + foreach ($action['attr'] as $name => $value) { |
|
810 | 810 | $button->attributes->addAttribute($name, $value); |
811 | 811 | } |
812 | 812 | } |
813 | 813 | |
814 | - $button->setContextualClass($action[ 'contextual' ]); |
|
814 | + $button->setContextualClass($action['contextual']); |
|
815 | 815 | $button->smallSize(); |
816 | 816 | $button->attributes->addAttribute('data-action', $key); |
817 | 817 | } |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | |
192 | 192 | public function setFieldsets(array $fieldsets, $group = 'main') |
193 | 193 | { |
194 | - $this->fieldsets[ $group ] = $fieldsets; |
|
194 | + $this->fieldsets[$group] = $fieldsets; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | public function setFieldset(array $fieldset, $legend = '', $group = 'main') |
198 | 198 | { |
199 | 199 | if (array_key_exists($group, $this->fieldsets)) { |
200 | - $this->fieldsets[ $group ][ $legend ] = $fieldset; |
|
200 | + $this->fieldsets[$group][$legend] = $fieldset; |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function setFields(array $fields = []) |
217 | 217 | { |
218 | - $this->fieldsets[ 'blank' ][ 'fields' ] = $fields; |
|
218 | + $this->fieldsets['blank']['fields'] = $fields; |
|
219 | 219 | |
220 | 220 | return $this; |
221 | 221 | } |
@@ -247,40 +247,40 @@ discard block |
||
247 | 247 | |
248 | 248 | public function render() |
249 | 249 | { |
250 | - $panel[ 'header' ] = new Panel(Panel::DEFAULT_PANEL); |
|
251 | - $panel[ 'header' ]->setTitle($this->title); |
|
252 | - $panel[ 'header' ]->addAttribute('data-role', 'form-panel-header'); |
|
250 | + $panel['header'] = new Panel(Panel::DEFAULT_PANEL); |
|
251 | + $panel['header']->setTitle($this->title); |
|
252 | + $panel['header']->addAttribute('data-role', 'form-panel-header'); |
|
253 | 253 | |
254 | 254 | foreach ($this->fieldsets as $group => $fieldsets) { |
255 | - $panel[ $group ] = new Group(Group::PANEL_GROUP); |
|
255 | + $panel[$group] = new Group(Group::PANEL_GROUP); |
|
256 | 256 | |
257 | 257 | foreach ($fieldsets as $role => $fieldset) { |
258 | - $attr = isset($fieldset[ 'attr' ]) ? $fieldset[ 'attr' ] : []; |
|
259 | - $attr[ 'data-role' ] = $role; |
|
258 | + $attr = isset($fieldset['attr']) ? $fieldset['attr'] : []; |
|
259 | + $attr['data-role'] = $role; |
|
260 | 260 | |
261 | - if (isset($fieldset[ 'collapse' ]) AND $fieldset[ 'collapse' ] === true) { |
|
262 | - $attr[ 'data-state' ] = 'collapse'; |
|
261 | + if (isset($fieldset['collapse']) AND $fieldset['collapse'] === true) { |
|
262 | + $attr['data-state'] = 'collapse'; |
|
263 | 263 | } |
264 | 264 | |
265 | - if (isset($fieldset[ 'type' ])) { |
|
266 | - $panel[ $group ]->addItem( |
|
267 | - (new Fieldset($fieldset[ 'legend' ], Fieldset::PANEL_FIELDSET)) |
|
268 | - ->addItems($fieldset[ 'fields' ]) |
|
265 | + if (isset($fieldset['type'])) { |
|
266 | + $panel[$group]->addItem( |
|
267 | + (new Fieldset($fieldset['legend'], Fieldset::PANEL_FIELDSET)) |
|
268 | + ->addItems($fieldset['fields']) |
|
269 | 269 | ->setAttributes($attr) |
270 | - ->setGroupType($fieldset[ 'type' ])); |
|
270 | + ->setGroupType($fieldset['type'])); |
|
271 | 271 | } else { |
272 | - $panel[ $group ]->addItem( |
|
273 | - (new Fieldset($fieldset[ 'legend' ], Fieldset::PANEL_FIELDSET)) |
|
274 | - ->addItems($fieldset[ 'fields' ]) |
|
272 | + $panel[$group]->addItem( |
|
273 | + (new Fieldset($fieldset['legend'], Fieldset::PANEL_FIELDSET)) |
|
274 | + ->addItems($fieldset['fields']) |
|
275 | 275 | ->setAttributes($attr)); |
276 | 276 | } |
277 | 277 | |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - if (isset($panel[ 'sidebar' ])) { |
|
282 | - $panel[ 'main' ]->addClass('col-sm-8'); |
|
283 | - $panel[ 'sidebar' ]->addClass('col-sm-4'); |
|
281 | + if (isset($panel['sidebar'])) { |
|
282 | + $panel['main']->addClass('col-sm-8'); |
|
283 | + $panel['sidebar']->addClass('col-sm-4'); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return (new Tag('form', implode(PHP_EOL, $panel), $this->attributes))->render(); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $column = 'id'; |
47 | 47 | } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) { |
48 | 48 | $column = 'email'; |
49 | - } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) { |
|
49 | + } elseif (preg_match($this->config['msisdnRegex'], $username)) { |
|
50 | 50 | $column = 'msisdn'; |
51 | 51 | } |
52 | 52 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | |
64 | 64 | foreach ($account as $key => $value) { |
65 | 65 | if (strpos($key, 'record') !== false) { |
66 | - unset($account[ $key ]); |
|
66 | + unset($account[$key]); |
|
67 | 67 | } elseif (in_array($key, ['password', 'pin', 'token', 'sso'])) { |
68 | - unset($account[ $key ]); |
|
68 | + unset($account[$key]); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | $column = 'id'; |
84 | 84 | } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) { |
85 | 85 | $column = 'email'; |
86 | - } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) { |
|
86 | + } elseif (preg_match($this->config['msisdnRegex'], $username)) { |
|
87 | 87 | $column = 'msisdn'; |
88 | - } elseif( strpos($username, 'token-') !== false ) { |
|
88 | + } elseif (strpos($username, 'token-') !== false) { |
|
89 | 89 | $username = str_replace('token-', '', $username); |
90 | 90 | $column = 'token'; |
91 | - } elseif( strpos($username, 'sso-') !== false ) { |
|
91 | + } elseif (strpos($username, 'sso-') !== false) { |
|
92 | 92 | $username = str_replace('sso-', '', $username); |
93 | 93 | $column = 'sso'; |
94 | 94 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | |
99 | 99 | foreach ($account as $key => $value) { |
100 | 100 | if (strpos($key, 'record') !== false) { |
101 | - unset($account[ $key ]); |
|
101 | + unset($account[$key]); |
|
102 | 102 | } elseif (in_array($key, ['password', 'pin', 'token', 'sso'])) { |
103 | - unset($account[ $key ]); |
|
103 | + unset($account[$key]); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if($column === 'token') { |
|
107 | + if ($column === 'token') { |
|
108 | 108 | models('users')->update([ |
109 | 109 | 'id' => $account['id'], |
110 | 110 | 'token' => null, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | public function authorize(ServerRequest $request) |
123 | 123 | { |
124 | - if (isset($_SESSION[ 'account' ][ 'role' ])) { |
|
124 | + if (isset($_SESSION['account']['role'])) { |
|
125 | 125 | $uriSegments = $request->getUri()->getSegments()->getString(); |
126 | - $role = $_SESSION[ 'account' ][ 'role' ]; |
|
126 | + $role = $_SESSION['account']['role']; |
|
127 | 127 | if (in_array($role->code, ['DEVELOPER', 'ADMINISTRATOR'])) { |
128 | 128 | globals()->store('authority', new Authority([ |
129 | 129 | 'permission' => 'GRANTED', |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function getIframeCode() |
156 | 156 | { |
157 | 157 | if ($this->signedOn() && $this->loggedIn() === false) { |
158 | - return '<iframe id="sign-on-iframe" width="1" height="1" src="' . rtrim($this->config[ 'sso' ][ 'server' ], |
|
158 | + return '<iframe id="sign-on-iframe" width="1" height="1" src="' . rtrim($this->config['sso']['server'], |
|
159 | 159 | '/') . '" style="display: none; visibility: hidden;"></iframe>'; |
160 | 160 | } |
161 | 161 |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | foreach ($keys as $key) { |
202 | 202 | if ($this->exists($key)) { |
203 | - $result[ $key ] = $this->get($key, $default); |
|
203 | + $result[$key] = $this->get($key, $default); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | foreach ($values as $key => $value) { |
310 | 310 | if ($this->set($key, $value, $ttl)) { |
311 | - $result[ $key ] = true; |
|
311 | + $result[$key] = true; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function __construct() |
27 | 27 | { |
28 | 28 | $config = config()->get('logger'); |
29 | - $config[ 'path' ] = PATH_CACHE . 'log' . DIRECTORY_SEPARATOR; |
|
29 | + $config['path'] = PATH_CACHE . 'log' . DIRECTORY_SEPARATOR; |
|
30 | 30 | |
31 | 31 | parent::__construct(new Config($config)); |
32 | 32 | } |
@@ -78,14 +78,14 @@ |
||
78 | 78 | 'POST_CONTROLLER', |
79 | 79 | 'POST_COMMANDER', |
80 | 80 | ])) { |
81 | - $this->closures[ $event ][] = $closure; |
|
81 | + $this->closures[$event][] = $closure; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | 85 | public function callEvent($event) |
86 | 86 | { |
87 | 87 | if (array_key_exists($event, $this->closures)) { |
88 | - foreach ($this->closures[ $event ] as $closure) { |
|
88 | + foreach ($this->closures[$event] as $closure) { |
|
89 | 89 | call_user_func($closure); |
90 | 90 | } |
91 | 91 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $item = new SplArrayObject(); |
52 | 52 | foreach ($fields as $field) { |
53 | 53 | if ($row->offsetExists($field)) { |
54 | - $item[ $field ] = $row->offsetGet($field); |
|
54 | + $item[$field] = $row->offsetGet($field); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | $chunks = array_chunk($this->storage, $entries); |
78 | 78 | $offset = $page - 1; |
79 | 79 | |
80 | - if (isset($chunks[ $offset ])) { |
|
81 | - $result = new ArrayIterator($chunks[ $offset ]); |
|
80 | + if (isset($chunks[$offset])) { |
|
81 | + $result = new ArrayIterator($chunks[$offset]); |
|
82 | 82 | |
83 | 83 | if (empty($fields)) { |
84 | 84 | return $this->result = $result; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $item = new SplArrayObject(); |
88 | 88 | foreach ($fields as $field) { |
89 | 89 | if ($row->offsetExists($field)) { |
90 | - $item[ $field ] = $row->offsetGet($field); |
|
90 | + $item[$field] = $row->offsetGet($field); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 |