ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 159 of file Style.php.

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

◆ buildStyleOptions()

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

Definition at line 141 of file Style.php.

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

References 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 $system_style_config = $this->style_definition->getSystemStylesConf();
102 return "{$this->style_definition->getStyle($system_style_config->getDefaultStyleId())->getName()} - "
103 . "{$this->style_definition->getSkin($system_style_config->getDefaultSkinId())->getName()} ";
104 }

◆ 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:159
global $lng
Definition: privfeed.php:31

◆ 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 106 of file Style.php.

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

◆ 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 116 of file Style.php.

119 : \ilObjUser {
120 if ($input === null) {
121 $system_style_config = $this->style_definition->getSystemStylesConf();
122 $user->setPref('style', $system_style_config->getDefaultStyleId());
123 $user->setPref('skin', $system_style_config->getDefaultSkinId());
124 return $user;
125 }
126
127 $sknst = explode(':', $input);
128 $user->setPref('skin', $sknst[0]);
129 $user->setPref('style', $sknst[1]);
130 return $user;
131 }
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 133 of file Style.php.

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

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: