ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
trait.ilTableCommandHelper.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
34trait ilTableCommandHelper
35{
45 protected function getMultiCommandPostArray(): array
46 {
47 global $DIC;
48
49 $refinery = $DIC->refinery();
50 $post_parameters = $DIC->http()->wrapper()->post();
51 $fake_post_array = [];
52
53 if ($post_parameters->has('table_top_cmd')) {
54 // this var contains the pressed table-top or -bottom command.
55 $multi_cmd = $post_parameters->retrieve(
56 'table_top_cmd',
57 $refinery->custom()->transformation(
58 static function ($post_array): ?string {
59 return is_array($post_array) ? key($post_array) : null;
60 }
61 )
62 );
63
64 // this var contains the bottom or top value key according to
65 // which command has been pressed.
66 $multi_value_key = $post_parameters->retrieve(
67 'cmd_sv',
68 $refinery->custom()->transformation(
69 static function ($post_array) use ($multi_cmd): ?string {
70 return is_array($post_array) ? $post_array[$multi_cmd] : null;
71 }
72 )
73 );
74
75 // this builds a fake post array similarly in ILIAS 7, where
76 // bottom and top values are set to the submitted one.
77 $fake_post_array[$multi_value_key] =
78 $fake_post_array[$multi_value_key . "_2"] =
79 $post_parameters->has($multi_value_key) ?
80 $post_parameters->retrieve($multi_value_key, $refinery->to()->string()) :
81 '';
82 }
83
84 return $fake_post_array;
85 }
86
95 protected function getSelectAllPostArray(): array
96 {
97 global $DIC;
98
99 $transformation = $DIC->refinery()->kindlyTo()->bool();
100 $post_parameters = $DIC->http()->wrapper()->post();
101 $fake_post_array = [
102 'select_cmd_all' => $post_parameters->has('select_cmd_all') ?
103 $post_parameters->retrieve('select_cmd_all', $transformation) :
104 false,
105 'select_cmd_all2' => $post_parameters->has('select_cmd_all2') ?
106 $post_parameters->retrieve('select_cmd_all2', $transformation) :
107 false,
108 ];
109
110 if ($post_parameters->has('select_cmd2')) {
111 if ($post_parameters->has('select_cmd_all2')) {
112 $fake_post_array["select_cmd_all"] = $fake_post_array["select_cmd_all2"];
113 } else {
114 $fake_post_array["select_cmd_all"] = $fake_post_array["select_cmd_all2"] = false;
115 }
116 }
117
118 if ($post_parameters->has('select_cmd')) {
119 if ($post_parameters->has('select_cmd_all')) {
120 $fake_post_array["select_cmd_all2"] = $fake_post_array["select_cmd_all"];
121 } else {
122 $fake_post_array["select_cmd_all"] = $fake_post_array["select_cmd_all2"] = false;
123 }
124 }
125
126 return $fake_post_array;
127 }
128}
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
$post_array
Definition: webdav.php:33