ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
ILIAS\Style\System\UserSettings\Style Class Reference
+ Inheritance diagram for ILIAS\Style\System\UserSettings\Style:
+ Collaboration diagram for ILIAS\Style\System\UserSettings\Style:

Public Member Functions

 __construct ()
 
 getIdentifier ()
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getLabel (Language $lng)
 
 getSettingsPage ()
 
 getSection ()
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 getLegacyInput (Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
 You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 retrieveValueFromUser (\ilObjUser $user)
 
 isAvailable ()
 If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be. More...
 
 getSettingsPage ()
 
 getDefaultValueForDisplay (Language $lng, \ilSetting $settings)
 
 hasUserPersonalizedSetting (\ilSetting $settings, \ilObjUser $user)
 
 getInput (FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
 
 getLegacyInput (Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
 You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed. More...
 
 persistUserInput (\ilObjUser $user, mixed $input)
 
 getIdentifier ()
 
 getLabel (Language $lng)
 
 getSection ()
 
 retrieveValueFromUser (\ilObjUser $user)
 

Private Member Functions

 buildStyleOptions ()
 
 buildStyleIdFromUserOrDefault (?\ilObjUser $user)
 

Private Attributes

readonly ilStyleDefinition $style_definition
 

Detailed Description

Definition at line 31 of file Style.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\System\UserSettings\Style::__construct ( )

Definition at line 35 of file Style.php.

36 {
37 global $DIC;
38 $this->style_definition = $DIC['styleDefinition'];
39 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ buildStyleIdFromUserOrDefault()

ILIAS\Style\System\UserSettings\Style::buildStyleIdFromUserOrDefault ( ?\ilObjUser  $user)
private

Definition at line 158 of file Style.php.

160 : string {
161 if ($user !== null) {
162 ['style' => $style, 'skin' => $skin] = $this->retrieveValueFromUser($user);
163 } else {
164 $style = $this->style_definition->getSystemStylesConf()->getDefaultStyleId();
165 $skin = $this->style_definition->getSystemStylesConf()->getDefaultSkinId();
166 }
167 return "{$skin}:{$style}";
168 }
retrieveValueFromUser(\ilObjUser $user)
Definition: Style.php:132

◆ buildStyleOptions()

ILIAS\Style\System\UserSettings\Style::buildStyleOptions ( )
private

Definition at line 140 of file Style.php.

140 : array
141 {
142 $options = [];
143 foreach ($this->style_definition::getAllSkins() as $skin) {
144 foreach ($skin->getStyles() as $style) {
145 if (
146 !\ilSystemStyleSettings::_lookupActivatedStyle($skin->getId(), $style->getId()) ||
147 $style->isSubstyle()
148 ) {
149 continue;
150 }
151
152 $options[$skin->getId() . ':' . $style->getId()] = $skin->getName() . ' / ' . $style->getName();
153 }
154 }
155 return $options;
156 }
static _lookupActivatedStyle(string $a_skin, string $a_style)
lookup if a style is activated

References ILIAS\UI\Implementation\Component\Input\Field\$options, and ilSystemStyleSettings\_lookupActivatedStyle().

+ Here is the call graph for this function:

◆ getDefaultValueForDisplay()

ILIAS\Style\System\UserSettings\Style::getDefaultValueForDisplay ( Language  $lng,
\ilSetting  $settings 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 97 of file Style.php.

100 : string {
101 $default_skin = $this->style_definition->getSkin();
102 return "{$default_skin->getName()} / {$default_skin->getDefaultStyle()->getName()}";
103 }

◆ getIdentifier()

ILIAS\Style\System\UserSettings\Style::getIdentifier ( )

Implements ILIAS\User\Property.

Definition at line 41 of file Style.php.

41 : string
42 {
43 return 'style';
44 }

Referenced by ILIAS\Style\System\UserSettings\Style\getLabel().

+ Here is the caller graph for this function:

◆ getInput()

ILIAS\Style\System\UserSettings\Style::getInput ( FieldFactory  $field_factory,
Language  $lng,
Refinery  $refinery,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 66 of file Style.php.

72 : Input {
73 $lng->loadLanguageModule('style');
74
75 return $field_factory->select(
76 $lng->txt('usr_skin_style'),
77 $this->buildStyleOptions(),
78 )->withRequired(true)
79 ->withValue(
81 );
82 }
buildStyleIdFromUserOrDefault(?\ilObjUser $user)
Definition: Style.php:158
global $lng
Definition: privfeed.php:26

◆ getLabel()

ILIAS\Style\System\UserSettings\Style::getLabel ( Language  $lng)

Implements ILIAS\User\Property.

Definition at line 51 of file Style.php.

51 : string
52 {
53 return $lng->txt($this->getIdentifier());
54 }

References $lng, and ILIAS\Style\System\UserSettings\Style\getIdentifier().

+ Here is the call graph for this function:

◆ getLegacyInput()

ILIAS\Style\System\UserSettings\Style::getLegacyInput ( Language  $lng,
\ilSetting  $settings,
?\ilObjUser  $user = null 
)

You don't need to add a post_var to the input as the User will handle this for you, thus you can also not rely on the post_var anywhere else, as it will be changed.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 84 of file Style.php.

89 $lng->loadLanguageModule('style');
90
91 $input = new \ilSelectInputGUI($lng->txt('usr_skin_style'));
92 $input->setOptions($this->buildStyleOptions());
93 $input->setValue($this->buildStyleIdFromUserOrDefault($user));
94 return $input;
95 }
This class represents a property in a property form.

◆ getSection()

ILIAS\Style\System\UserSettings\Style::getSection ( )

◆ getSettingsPage()

ILIAS\Style\System\UserSettings\Style::getSettingsPage ( )

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 56 of file Style.php.

57 {
58 return AvailablePages::MainSettings;
59 }

◆ hasUserPersonalizedSetting()

ILIAS\Style\System\UserSettings\Style::hasUserPersonalizedSetting ( \ilSetting  $settings,
\ilObjUser  $user 
)

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 105 of file Style.php.

108 : bool {
109 $system_style_config = $this->style_definition->getSystemStylesConf();
110 ['style' => $user_style, 'skin' => $user_skin] = $this->retrieveValueFromUser($user);
111 return $user_style !== $system_style_config->getDefaultStyleId()
112 || $user_skin !== $system_style_config->getDefaultSkinId();
113 }

◆ isAvailable()

ILIAS\Style\System\UserSettings\Style::isAvailable ( )

If this function returns false the setting will not be shown, even if it's PropertyAttributes would allow it to be.

This is meant e.g. to check if the chat server is configured or the badges enabled. Settings that are not available will also not be available on the table to define their PropertyAttributes

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 46 of file Style.php.

46 : bool
47 {
48 return true;
49 }

◆ persistUserInput()

ILIAS\Style\System\UserSettings\Style::persistUserInput ( \ilObjUser  $user,
mixed  $input 
)
Parameters
mixed$inputNull will be handed in, if the user wants to use the system default. If you are able to set the preference on the user without saving it, you can rely on the User-object being saved after the call to this function. If your input has different structures depending on its provenience (KS-Input, Legacy-Input, ...), the function needs to be able to handle them all.

Implements ILIAS\User\Settings\SettingDefinition.

Definition at line 115 of file Style.php.

118 : \ilObjUser {
119 if ($input === null) {
120 $system_style_config = $this->style_definition->getSystemStylesConf();
121 $user->setPref('style', $system_style_config->getDefaultStyleId());
122 $user->setPref('skin', $system_style_config->getDefaultSkinId());
123 return $user;
124 }
125
126 $sknst = explode(':', $input);
127 $user->setPref('skin', $sknst[0]);
128 $user->setPref('style', $sknst[1]);
129 return $user;
130 }
User class.
setPref(string $a_keyword, ?string $a_value)

References ilObjUser\setPref().

+ Here is the call graph for this function:

◆ retrieveValueFromUser()

ILIAS\Style\System\UserSettings\Style::retrieveValueFromUser ( \ilObjUser  $user)

Implements ILIAS\User\Property.

Definition at line 132 of file Style.php.

132 : array
133 {
134 return [
135 'style' => $user->getPref('style'),
136 'skin' => $user->getSkin()
137 ];
138 }

References ilObjUser\getPref(), and ilObjUser\getSkin().

+ Here is the call graph for this function:

Field Documentation

◆ $style_definition

readonly ilStyleDefinition ILIAS\Style\System\UserSettings\Style::$style_definition
private

Definition at line 33 of file Style.php.


The documentation for this class was generated from the following file: