ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Help.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30
31class Help implements SettingDefinition
32{
33 private readonly ?\ilHelpGUI $help;
34
35 public function __construct()
36 {
37 global $DIC;
38 $this->help = $DIC['ilHelp'] ?? null;
39 }
40
41 public function getIdentifier(): string
42 {
43 return 'help';
44 }
45
46 public function isAvailable(): bool
47 {
48 return $this->help->areTooltipsActive();
49 }
50
51 public function getLabel(Language $lng): string
52 {
53 return $lng->txt($this->getIdentifier());
54 }
55
57 {
58 return AvailablePages::MainSettings;
59 }
60
61 public function getSection(): AvailableSections
62 {
64 }
65
66 public function getInput(
67 FieldFactory $field_factory,
70 \ilSetting $settings,
71 ?\ilObjUser $user = null
72 ): Input {
73 $lng->loadLanguageModule('help');
74 return $field_factory->checkbox(
75 $lng->txt('help_toggle_tooltips'),
76 $lng->txt('help_toggle_tooltips_info')
77 )->withValue(
78 $user !== null
79 ? $this->retrieveValueFromUser($user)
80 : false
81 );
82 }
83
84 public function getLegacyInput(
86 \ilSetting $settings,
87 ?\ilObjUser $user = null
89 $lng->loadLanguageModule('help');
90 $input = new \ilCheckboxInputGUI($lng->txt('help_toggle_tooltips'));
91 $input->setInfo($lng->txt('help_toggle_tooltips_info'));
92 $input->setChecked(
93 $user !== null
94 ? $this->retrieveValueFromUser($user)
95 : false
96 );
97 return $input;
98 }
99
102 \ilSetting $settings
103 ): string {
104 return $lng->txt('active');
105 }
106
108 \ilSetting $settings,
109 \ilObjUser $user
110 ): bool {
111 return $this->retrieveValueFromUser($user) === true;
112 }
113
114 public function persistUserInput(
115 \ilObjUser $user,
116 mixed $input
117 ): \ilObjUser {
118 if ($this->help->areTooltipsActive()) {
119 $user->setPref('hide_help_tt', (string) (int) $input);
120 }
121 return $user;
122 }
123
124 public function retrieveValueFromUser(\ilObjUser $user): bool
125 {
126 return $user->getPref('hide_help_tt') !== '1';
127 }
128}
Builds data types.
Definition: Factory.php:36
hasUserPersonalizedSetting(\ilSetting $settings, \ilObjUser $user)
Definition: Help.php:107
retrieveValueFromUser(\ilObjUser $user)
Definition: Help.php:124
getLegacyInput(Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
Definition: Help.php:84
readonly ilHelpGUI $help
Definition: Help.php:33
getInput(FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
Definition: Help.php:66
persistUserInput(\ilObjUser $user, mixed $input)
Definition: Help.php:114
getDefaultValueForDisplay(Language $lng, \ilSetting $settings)
Definition: Help.php:100
getLabel(Language $lng)
Definition: Help.php:51
isAvailable()
If this function returns false the setting will not be shown, even if it's PropertyAttributes would a...
Definition: Help.php:46
return true
This class represents a property in a property form.
Help GUI class.
User class.
setPref(string $a_keyword, ?string $a_value)
getPref(string $a_keyword)
ILIAS Setting Class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes commonalities between all inputs.
Definition: Input.php:47
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26