ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSystemStyleOverviewGUI Class Reference
+ Collaboration diagram for ilSystemStyleOverviewGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, Language $lng, ilGlobalTemplateInterface $tpl, Factory $ui_factory, Renderer $renderer, WrapperFactory $request_wrapper, ilToolbarGUI $toolbar, Refinery $refinery, ilSkinFactory $skin_factory, FileUpload $upload, ilTabsGUI $tabs, ilHelpGUI $help, string $skin_id, string $style_id, string $ref_id, bool $read_only, bool $management_enabled)
 
 executeCommand ()
 
 getAssignmentCreationModal (string $style_name="")
 
 edit ()
 
 saveStyleSettings ()
 
 moveUserStyles ()
 
 isReadOnly ()
 
 setReadOnly (bool $read_only)
 
 isManagementEnabled ()
 
 setManagementEnabled (bool $management_enabled)
 

Protected Member Functions

 view ()
 
 cancel ()
 
 checkStyleSettings (ilSystemStyleMessageStack $message_stack, ?array $active_styles)
 
 export ()
 

Protected Attributes

ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
Language $lng
 
ilGlobalTemplateInterface $tpl
 
ilSkinFactory $skin_factory
 
ilSkinStyleContainer $style_container
 
ilSystemStyleMessageStack $message_stack
 
Factory $ui_factory
 
Renderer $renderer
 
WrapperFactory $request_wrapper
 
Refinery $refinery
 
ilSystemStyleConfig $config
 
ilTabsGUI $tabs
 
ilHelpGUI $help
 
FileUpload $upload
 
string $ref_id
 
bool $read_only = true
 
bool $management_enabled = false
 
string $style_id
 

Detailed Description

Definition at line 28 of file class.ilSystemStyleOverviewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSystemStyleOverviewGUI::__construct ( ilCtrl  $ctrl,
Language  $lng,
ilGlobalTemplateInterface  $tpl,
Factory  $ui_factory,
Renderer  $renderer,
WrapperFactory  $request_wrapper,
ilToolbarGUI  $toolbar,
Refinery  $refinery,
ilSkinFactory  $skin_factory,
FileUpload  $upload,
ilTabsGUI  $tabs,
ilHelpGUI  $help,
string  $skin_id,
string  $style_id,
string  $ref_id,
bool  $read_only,
bool  $management_enabled 
)

Definition at line 51 of file class.ilSystemStyleOverviewGUI.php.

69 {
70 $this->ctrl = $ctrl;
71 $this->lng = $lng;
72 $this->tpl = $tpl;
73 $this->ui_factory = $ui_factory;
74 $this->renderer = $renderer;
75 $this->request_wrapper = $request_wrapper;
76 $this->toolbar = $toolbar;
77 $this->refinery = $refinery;
78 $this->tabs = $tabs;
79 $this->style_id = $style_id;
80 $this->message_stack = new ilSystemStyleMessageStack($this->tpl);
81 $this->skin_factory = $skin_factory;
82 $this->style_container = $this->skin_factory->skinStyleContainerFromId($skin_id, $this->message_stack);
83 $this->help = $help;
84 $this->ref_id = $ref_id;
85 $this->upload = $upload;
86 $this->config = new ilSystemStyleConfig();
87 $this->setReadOnly($read_only);
89 }
renderer()
skinStyleContainerFromId(string $skin_id, ilSystemStyleMessageStack $message_stack)
Get container class is responsible for all file system related actions related actions of a skin such...
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
Used to stack messages to be shown to the user.
setManagementEnabled(bool $management_enabled)

References $ctrl, $help, $lng, $ref_id, $refinery, $renderer, $request_wrapper, $skin_factory, $style_id, $tabs, $toolbar, $tpl, $ui_factory, $upload, ILIAS\Repository\ctrl(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), renderer(), setManagementEnabled(), setReadOnly(), ilSkinFactory\skinStyleContainerFromId(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\upload().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancel()

ilSystemStyleOverviewGUI::cancel ( )
protected

Definition at line 174 of file class.ilSystemStyleOverviewGUI.php.

174 : void
175 {
176 $this->edit();
177 }

References edit().

+ Here is the call graph for this function:

◆ checkStyleSettings()

ilSystemStyleOverviewGUI::checkStyleSettings ( ilSystemStyleMessageStack  $message_stack,
?array  $active_styles 
)
protected

Definition at line 253 of file class.ilSystemStyleOverviewGUI.php.

253 : bool
254 {
255 $passed = true;
256
257 if (!$active_styles || count($active_styles) < 1) {
258 $passed = false;
260 $this->lng->txt('at_least_one_style'),
262 ));
263 }
264
265 if ($this->request_wrapper->post()->has('default_skin_style')) {
266 $default_style = $this->request_wrapper->post()->retrieve(
267 'default_skin_style',
268 $this->refinery->kindlyTo()->string()
269 );
270 } else {
271 $default_style = $this->config->getDefaultStyleId();
272 }
273
274
275
276 if (!isset($active_styles[$default_style])) {
277 $passed = false;
279 $this->lng->txt('cant_deactivate_default_style'),
281 ));
282 }
283
284 // check if a style should be deactivated, that still has
285 // a user assigned to
287
288 foreach ($all_styles as $style) {
289 if (!isset($active_styles[$style['id']])) {
290 if (ilObjUser::_getNumberOfUsersForStyle($style['template_id'], $style['style_id']) > 0) {
291 $passed = false;
293 $style['style_name'] . ': ' . $this->lng->txt('cant_deactivate_if_users_assigned'),
295 ));
296 }
297 }
298 }
299 return $passed;
300 }
static _getNumberOfUsersForStyle(string $a_skin, string $a_style)
static getAllSkinStyles()
Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this ar...
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
ilSystemStyleMessageStack $message_stack

References $message_stack, ilObjUser\_getNumberOfUsersForStyle(), ilSystemStyleMessageStack\addMessage(), ilStyleDefinition\getAllSkinStyles(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ilSystemStyleMessage\TYPE_ERROR.

Referenced by saveStyleSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit()

ilSystemStyleOverviewGUI::edit ( )

Definition at line 179 of file class.ilSystemStyleOverviewGUI.php.

179 : void
180 {
181 $table = new ilSystemStylesTableGUI($this, 'edit');
182 $table->addActions($this->isManagementEnabled());
183 $this->tpl->setContent($table->getHTML().$table->getModalsHtml());
184 }
TableGUI class for system styles.

References isManagementEnabled().

Referenced by cancel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilSystemStyleOverviewGUI::executeCommand ( )

Definition at line 91 of file class.ilSystemStyleOverviewGUI.php.

91 : void
92 {
93 $cmd = $this->ctrl->getCmd();
94
95 if ($cmd == '') {
96 $cmd = $this->isReadOnly() ? 'view' : 'edit';
97 }
98
99 switch ($cmd) {
100 case 'addSystemStyle':
101 case 'addSubStyle':
102 case 'saveNewSystemStyle':
103 case 'saveNewSubStyle':
104 case 'copyStyle':
105 case 'importStyle':
106 case 'deleteStyles':
107 case 'deleteStyle':
108 case 'confirmDelete':
109 if (!$this->isManagementEnabled()) {
110 throw new ilObjectException($this->lng->txt('permission_denied'));
111 }
112 $this->$cmd();
113 break;
114 case 'cancel':
115 case 'edit':
116 case 'export':
117 case 'moveUserStyles':
118 case 'saveStyleSettings':
119 if ($this->isReadOnly()) {
120 throw new ilObjectException($this->lng->txt('permission_denied'));
121 }
122 $this->$cmd();
123 break;
124 case 'view':
125 $this->$cmd();
126 break;
127 }
128 $this->message_stack->sendMessages();
129 }
Base exception class for object service.

References ILIAS\Repository\ctrl(), isManagementEnabled(), isReadOnly(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ export()

ilSystemStyleOverviewGUI::export ( )
protected

Definition at line 303 of file class.ilSystemStyleOverviewGUI.php.

303 : void
304 {
305 try {
306 $this->style_container->export();
307 } catch (Exception $e) {
308 $this->message_stack->addMessage(new ilSystemStyleMessage(
309 $this->lng->txt('zip_export_failed') . ' ' . $e->getMessage(),
311 ));
312 }
313 }

References Vendor\Package\$e, ILIAS\Repository\lng(), and ilSystemStyleMessage\TYPE_ERROR.

+ Here is the call graph for this function:

◆ getAssignmentCreationModal()

ilSystemStyleOverviewGUI::getAssignmentCreationModal ( string  $style_name = "")

Definition at line 137 of file class.ilSystemStyleOverviewGUI.php.

138 {
139 $options = [];
140 foreach (ilStyleDefinition::getAllSkinStyles() as $id => $skin_style) {
141 if (!$skin_style['substyle_of'] && $style_name != $skin_style['style_name']) {
142 $options[$id] = $skin_style['title'];
143 }
144 }
145
146 $default = "default:delos";
147 if ($style_name == "Delos") {
148 $default = key($options);
149 }
150
151 if (count($options) == 0) {
152 return null;
153 }
154
155 $txt = $this->lng->txt('sty_move_user_styles').' '.$this->lng->txt('sty_to');
156
157 $byline = $this->lng->txt('sty_move_user_styles') . ' ' .
158 $this->lng->txt('sty_from') . ' ' . $style_name;
159
160 $select = $this->ui_factory->input()->field()
161 ->select($txt, $options, $byline)
162 ->withValue($default)
163 ->withAdditionalTransformation($this->refinery->string()->splitString(':'))
164 ->withRequired(true);
165
166 return $this->ui_factory->modal()->roundtrip(
167 $this->lng->txt('change_assignment'),
168 [],
169 ["new_style" => $select],
170 $this->ctrl->getLinkTargetByClass(ilSystemStyleOverviewGUI::class, 'moveUserStyles')
171 );
172 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$txt
Definition: error.php:31

References $id, $txt, ilStyleDefinition\getAllSkinStyles(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by moveUserStyles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isManagementEnabled()

ilSystemStyleOverviewGUI::isManagementEnabled ( )

Definition at line 326 of file class.ilSystemStyleOverviewGUI.php.

326 : bool
327 {
329 }

References $management_enabled.

Referenced by edit(), and executeCommand().

+ Here is the caller graph for this function:

◆ isReadOnly()

ilSystemStyleOverviewGUI::isReadOnly ( )

Definition at line 316 of file class.ilSystemStyleOverviewGUI.php.

316 : bool
317 {
318 return $this->read_only;
319 }

References $read_only.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ moveUserStyles()

ilSystemStyleOverviewGUI::moveUserStyles ( )

Definition at line 217 of file class.ilSystemStyleOverviewGUI.php.

217 : void
218 {
219 global $DIC;
220
221 $request = $DIC->http()->request();
222
223 $modal = $this->getAssignmentCreationModal()->withRequest($request);
224 [$new_skin, $new_style] = $modal->getData()["new_style"];
225
226 $old_skin = $this->request_wrapper->query()->retrieve('old_skin_id', $this->refinery->kindlyTo()->string());
227 $old_style = $this->request_wrapper->query()->retrieve('old_style_id', $this->refinery->kindlyTo()->string());
228
229
230
231 if ($old_style == 'other') {
232 // get all user assigned styles
233 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
234
235 // move users that are not assigned to
236 // currently existing style
237 foreach ($all_user_styles as $style) {
238 if (!ilStyleDefinition::styleExists($style)) {
239 [$old_skin, $old_style] = explode(':', $style);
240 ilObjUser::_moveUsersToStyle($old_skin, $old_style, $new_skin, $new_style);
241 }
242 }
243 } else {
244 ilObjUser::_moveUsersToStyle($old_skin, $old_style, $new_skin, $new_style);
245 }
246 $message = sprintf($this->lng->txt('sty_move_user_styles_saved'), $old_skin, $new_skin);
247
248 $this->message_stack->addMessage(new ilSystemStyleMessage($message, ilSystemStyleMessage::TYPE_SUCCESS));
249 $this->message_stack->sendMessages();
250 $this->ctrl->redirect($this, 'edit');
251 }
static _getAllUserAssignedStyles()
static _moveUsersToStyle(string $a_from_skin, string $a_from_style, string $a_to_skin, string $a_to_style)
static styleExists(string $style_id)
getAssignmentCreationModal(string $style_name="")
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31

References $DIC, $message, ilObjUser\_getAllUserAssignedStyles(), ilObjUser\_moveUsersToStyle(), ILIAS\Repository\ctrl(), getAssignmentCreationModal(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilStyleDefinition\styleExists(), and ilSystemStyleMessage\TYPE_SUCCESS.

+ Here is the call graph for this function:

◆ saveStyleSettings()

ilSystemStyleOverviewGUI::saveStyleSettings ( )

Definition at line 186 of file class.ilSystemStyleOverviewGUI.php.

186 : void
187 {
188 $active_styles = $this->request_wrapper->post()->retrieve('st_act', $this->refinery->identity());
189
190 if ($this->checkStyleSettings($this->message_stack, $active_styles)) {
192 foreach ($all_styles as $style) {
193 if (!isset($active_styles[$style['id']])) {
194 ilSystemStyleSettings::_deactivateStyle($style['template_id'], $style['style_id']);
195 } else {
196 ilSystemStyleSettings::_activateStyle($style['template_id'], $style['style_id']);
197 }
198 }
199
200 //set default skin and style
201 if ($this->request_wrapper->post()->has('default_skin_style')) {
202 $sknst = $this->request_wrapper->post()->retrieve(
203 'default_skin_style',
204 $this->refinery->string()->splitString(':')
205 );
207 }
208 $this->message_stack->addMessage(new ilSystemStyleMessage(
209 $this->lng->txt('msg_obj_modified'),
211 ));
212 }
213 $this->message_stack->sendMessages();
214 $this->ctrl->redirect($this, 'edit');
215 }
checkStyleSettings(ilSystemStyleMessageStack $message_stack, ?array $active_styles)
static _activateStyle(string $a_skin, string $a_style)
activate system style
static _deactivateStyle(string $a_skin, string $a_style)
deactivate system style
static setCurrentDefaultStyle(string $skin_id, string $style_id)
Sets the default style of the system.

References ilSystemStyleSettings\_activateStyle(), ilSystemStyleSettings\_deactivateStyle(), checkStyleSettings(), ILIAS\Repository\ctrl(), ilStyleDefinition\getAllSkinStyles(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ilSystemStyleSettings\setCurrentDefaultStyle(), and ilSystemStyleMessage\TYPE_SUCCESS.

+ Here is the call graph for this function:

◆ setManagementEnabled()

ilSystemStyleOverviewGUI::setManagementEnabled ( bool  $management_enabled)

Definition at line 331 of file class.ilSystemStyleOverviewGUI.php.

331 : void
332 {
333 $this->management_enabled = $management_enabled;
334 }

References $management_enabled.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setReadOnly()

ilSystemStyleOverviewGUI::setReadOnly ( bool  $read_only)

Definition at line 321 of file class.ilSystemStyleOverviewGUI.php.

321 : void
322 {
323 $this->read_only = $read_only;
324 }

References $read_only.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ view()

ilSystemStyleOverviewGUI::view ( )
protected

Definition at line 131 of file class.ilSystemStyleOverviewGUI.php.

131 : void
132 {
133 $table = new ilSystemStylesTableGUI($this, 'edit');
134 $this->tpl->setContent($table->getHTML().$table->getModalsHtml());
135 }

Field Documentation

◆ $config

ilSystemStyleConfig ilSystemStyleOverviewGUI::$config
protected

Definition at line 41 of file class.ilSystemStyleOverviewGUI.php.

◆ $ctrl

ilCtrl ilSystemStyleOverviewGUI::$ctrl
protected

Definition at line 30 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $help

ilHelpGUI ilSystemStyleOverviewGUI::$help
protected

Definition at line 43 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $lng

Language ilSystemStyleOverviewGUI::$lng
protected

Definition at line 32 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $management_enabled

bool ilSystemStyleOverviewGUI::$management_enabled = false
protected

Definition at line 47 of file class.ilSystemStyleOverviewGUI.php.

Referenced by isManagementEnabled(), and setManagementEnabled().

◆ $message_stack

ilSystemStyleMessageStack ilSystemStyleOverviewGUI::$message_stack
protected

Definition at line 36 of file class.ilSystemStyleOverviewGUI.php.

Referenced by checkStyleSettings().

◆ $read_only

bool ilSystemStyleOverviewGUI::$read_only = true
protected

Definition at line 46 of file class.ilSystemStyleOverviewGUI.php.

Referenced by isReadOnly(), and setReadOnly().

◆ $ref_id

string ilSystemStyleOverviewGUI::$ref_id
protected

Definition at line 45 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $refinery

Refinery ilSystemStyleOverviewGUI::$refinery
protected

Definition at line 40 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $renderer

Renderer ilSystemStyleOverviewGUI::$renderer
protected

Definition at line 38 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $request_wrapper

WrapperFactory ilSystemStyleOverviewGUI::$request_wrapper
protected

Definition at line 39 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $skin_factory

ilSkinFactory ilSystemStyleOverviewGUI::$skin_factory
protected

Definition at line 34 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $style_container

ilSkinStyleContainer ilSystemStyleOverviewGUI::$style_container
protected

Definition at line 35 of file class.ilSystemStyleOverviewGUI.php.

◆ $style_id

string ilSystemStyleOverviewGUI::$style_id
protected

Definition at line 49 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $tabs

ilTabsGUI ilSystemStyleOverviewGUI::$tabs
protected

Definition at line 42 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilSystemStyleOverviewGUI::$toolbar
protected

Definition at line 31 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $tpl

ilGlobalTemplateInterface ilSystemStyleOverviewGUI::$tpl
protected

Definition at line 33 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $ui_factory

Factory ilSystemStyleOverviewGUI::$ui_factory
protected

Definition at line 37 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().

◆ $upload

FileUpload ilSystemStyleOverviewGUI::$upload
protected

Definition at line 44 of file class.ilSystemStyleOverviewGUI.php.

Referenced by __construct().


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