19declare(strict_types=1);
49 private readonly UIFactory $ui_factory,
58 self::PARAMETER_NAMESPACE,
59 self::CONFIGURATION_TOKEN_STRING
62 $this->current_configuration = $query_wrapper->
retrieve(
63 $this->configuration_token->getName(),
64 $this->refinery->custom()->transformation(
65 function (mixed $values): array {
67 DefaultView::getIdentifier()
69 if (!is_array($values)) {
73 $available_capabilities = [
74 AsyncView::getIdentifier(),
75 DefaultView::getIdentifier(),
76 TextFeedback::getIdentifier(),
77 SuggestedLearningContent::getIdentifier(),
78 MarkingAllowingPartialPoints::getIdentifier()
83 function (array
$c,
string $v) use ($available_capabilities): array {
84 if ($v === AsyncView::getIdentifier()
85 || $v === DefaultView::getIdentifier()) {
88 fn(
string $v):
bool => $v !== DefaultView::getIdentifier()
89 && $v !== AsyncView::getIdentifier()
93 if (in_array($v, $available_capabilities)
94 && !in_array($v,
$c)) {
110 AsyncView::getIdentifier(),
111 $this->current_configuration
128 self::PARAMETER_NAMESPACE,
129 self::CONFIGURATION_TOKEN_STRING
138 $this->current_configuration
144 $configuration_without_view = array_filter(
145 $this->current_configuration,
146 fn(
string $v):
bool => $v !== DefaultView::getIdentifier() && $v !== AsyncView::getIdentifier()
149 $this->ui_factory->viewControl()->mode(
151 $this->lng->txt(
'default_view') => $this->url_builder->withParameter(
152 $this->configuration_token,
153 [...$configuration_without_view, DefaultView::getIdentifier()]
154 )->buildURI()->__toString(),
155 $this->lng->txt(
'async_view') => $this->url_builder->withParameter(
156 $this->configuration_token,
157 [...$configuration_without_view, AsyncView::getIdentifier()]
158 )->buildURI()->__toString()
160 $this->lng->txt(
'select_view')
162 in_array(DefaultView::getIdentifier(), $this->current_configuration)
163 ? $this->
lng->txt(
'default_view')
164 : $this->lng->txt(
'async_view')
169 $this->buildToolbarButton(
170 MarkingAllowingPartialPoints::getIdentifier()
175 $this->buildToolbarButton(
176 TextFeedback::getIdentifier()
181 $this->buildToolbarButton(
182 SuggestedLearningContent::getIdentifier()
190 $capability_activated = in_array($identifier, $this->current_configuration);
191 $filtered_configuration = array_filter(
192 $this->current_configuration,
193 fn(
string $v):
bool => $v !== $identifier
196 return $this->ui_factory->button()->standard(
197 $this->buildButtonLabel($identifier, $capability_activated),
198 $this->url_builder->withParameter(
199 $this->configuration_token,
200 $capability_activated
201 ? $filtered_configuration
202 : [...$filtered_configuration, $identifier]
203 )->buildURI()->__toString()
211 $identifier_lng_string = strtolower($identifier);
214 ? $this->
lng->txt(
"disable_{$identifier_lng_string}")
215 : $this->
lng->txt(
"enable_{$identifier_lng_string}");
Builds a Color from either hex- or rgb values.
buildButtonLabel(string $identifier, bool $enabled)
const array PARAMETER_NAMESPACE
getCurrentConfiguration()
const string CONFIGURATION_TOKEN_STRING
readonly array $current_configuration
buildToolbarButton(string $identifier)
getURLBuilderWithPreservedConfigurationParameter(?URLBuilder $url_builder=null)
readonly URLBuilderToken $configuration_token
readonly URLBuilder $url_builder
__construct(private readonly Language $lng, private readonly Refinery $refinery, private readonly UIFactory $ui_factory, RequestWrapper $query_wrapper, URLBuilder $url_builder, private readonly \ilToolbarGUI $toolbar)
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
acquireParameter(array $namespace, string $name, ?string $initial_value=null)
Add a new parameter with a namespace and get its token for subsequent changes.
Interface RequestWrapper.
retrieve(string $key, Transformation $transformation)
@ SuggestedLearningContent
if(!file_exists('../ilias.ini.php'))