2 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
3 include_once(
"Services/Style/System/classes/Utilities/class.ilSystemStyleSkinContainer.php");
4 include_once(
"Services/Style/System/classes/Icons/class.ilSystemStyleIconColorSet.php");
5 include_once(
"Services/Style/System/classes/Icons/class.ilSystemStyleIconFolder.php");
57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->tpl = $DIC[
"tpl"];
60 $this->tabs = $DIC->tabs();
63 $skin_id =
$_GET[
"skin_id"];
65 if ($style_id ==
"") {
66 $style_id =
$_GET[
"style_id"];
69 if ($this->ctrl->getCmd() !=
"reset") {
74 $this->ctrl->setCmd(
"fail");
84 $cmd = $this->ctrl->getCmd();
111 $form = $this->initByColorForm();
112 $this->tpl->setContent(
$form->getHTML());
120 $this->tabs->addSubTab(
'edit', $this->lng->txt(
'edit_by_color'), $this->ctrl->getLinkTarget($this,
'edit'));
121 $this->tabs->addSubTab(
'editIcon', $this->lng->txt(
'edit_by_icon'), $this->ctrl->getLinkTarget($this,
'editIcon'));
122 $this->tabs->addSubTab(
'preview', $this->lng->txt(
'icons_gallery'), $this->ctrl->getLinkTarget($this,
"preview"));
124 if ($active ==
"preview") {
125 $this->tabs->activateSubTab($active);
126 } elseif ($active ==
"cancelIcon"|| $active ==
"editIcon") {
127 $this->tabs->activateSubTab(
"editIcon");
129 $this->tabs->activateSubTab(
"edit");
135 $form = $this->initByColorForm();
137 $this->tpl->setContent(
$form->getHTML());
142 $this->tpl->setContent($this->renderIconsPreviews());
147 public function initByColorForm()
151 $form->setTitle($this->lng->txt(
"adapt_icons"));
152 $form->setDescription($this->lng->txt(
"adapt_icons_description"));
158 $color_set = $this->
getIconFolder()->getColorSet()->getColorsSortedAsArray();
164 foreach ($color_set as
$type => $colors) {
169 $title = $this->lng->txt(
"grey_color");
170 $section->setTitle($this->lng->txt(
"grey_colors"));
171 $section->setInfo($this->lng->txt(
"grey_colors_description"));
172 $section->setSectionAnchor($this->lng->txt(
"grey_colors"));
175 $title = $this->lng->txt(
"red_color");
176 $section->setTitle($this->lng->txt(
"red_colors"));
177 $section->setInfo($this->lng->txt(
"red_colors_description"));
178 $section->setSectionAnchor($this->lng->txt(
"red_colors"));
181 $title = $this->lng->txt(
"green_color");
182 $section->setTitle($this->lng->txt(
"green_colors"));
183 $section->setInfo($this->lng->txt(
"green_colors_description"));
184 $section->setSectionAnchor($this->lng->txt(
"green_colors"));
187 $title = $this->lng->txt(
"blue_color");
188 $section->setTitle($this->lng->txt(
"blue_colors"));
189 $section->setInfo($this->lng->txt(
"blue_colors_description"));
190 $section->setSectionAnchor($this->lng->txt(
"blue_colors"));
194 foreach ($colors as
$id => $color) {
200 $input->setInfo(
"Usages: " . $this->
getIconFolder()->getUsagesOfColorAsString($color->getId()));
201 $form->addItem($input);
208 $form->addCommandButton(
"update", $this->lng->txt(
"update_colors"));
210 $form->addCommandButton(
"reset", $this->lng->txt(
"reset_icons"));
212 $form->addCommandButton(
"cancel", $this->lng->txt(
"cancel"));
218 $form->setFormAction($this->ctrl->getFormAction($this));
232 $colors = $this->
getIconFolder()->getColorSet()->getColors();
233 foreach ($colors as $color) {
234 $id = $color->getId();
235 if ($colors[$color->getId()]) {
236 $values[
$id] = $colors[$color->getId()]->getColor();
238 $values[
$id] = $color->getColor();
254 $this->lng->txt(
"color_reset"),
257 $message_stack->sendMessages(
true);
259 $this->ctrl->redirect($this,
"edit");
264 $form = $this->initByColorForm();
265 if (
$form->checkInput()) {
269 foreach ($this->
getIconFolder()->getColorSet()->getColors() as $old_color) {
270 $new_color =
$form->getInput($old_color->getId());
271 if (!preg_match(
"/[\dabcdef]{6}/i", $new_color)) {
273 $this->lng->txt(
"invalid_color") . $new_color,
276 } elseif ($new_color != $old_color->getId()) {
277 $color_changes[$old_color->getId()] = $new_color;
279 $this->lng->txt(
"color_changed_from") .
" " . $old_color->getId() .
" " .
280 $this->lng->txt(
"color_changed_to") .
" " . $new_color,
288 $skin->getVersionStep($skin->getVersion());
291 $this->lng->txt(
"color_update"),
294 $message_stack->sendMessages(
true);
295 $this->ctrl->redirect($this,
"edit");
297 $form->setValuesByPost();
298 $this->tpl->setContent(
$form->getHTML());
304 $icon_name =
$_POST[
'selected_icon']?
$_POST[
'selected_icon']:
$_GET[
'selected_icon'];
310 $form = $this->initByIconForm($icon);
323 $toolbar = $DIC->toolbar();
329 if ($icon->getType()==
"svg") {
330 $options[$icon->getName()] = $icon->getName();
334 $si->setOptions($options);
336 $si->setValue($icon_name);
338 $toolbar->addInputItem(
$si,
true);
341 $select_btn->setCaption($this->lng->txt(
"select"),
false);
342 $toolbar->addButtonInstance($select_btn);
343 $toolbar->setFormAction($this->ctrl->getLinkTarget($this,
'editIcon'));
354 $form->setTitle($this->lng->txt(
"adapt_icon") .
" " . $icon->
getName());
355 $form->setDescription($this->lng->txt(
"adapt_icon_description"));
361 $color_set = $icon->
getColorSet()->getColorsSortedAsArray();
367 foreach ($color_set as
$type => $colors) {
368 $title = $this->lng->txt(
"color");
370 foreach ($colors as
$id => $color) {
376 $form->addItem($input);
380 $upload =
new ilFileInputGUI($this->lng->txt(
"change_icon"),
"changed_icon");
382 $form->addItem($upload);
386 $form->addItem($hidden_name);
389 $form->addCommandButton(
"updateIcon", $this->lng->txt(
"update_icon"));
390 $form->addCommandButton(
"cancelIcon", $this->lng->txt(
"cancel"));
393 $form->setFormAction($this->ctrl->getFormAction($this));
407 $colors = $this->
getIconFolder()->getColorSet()->getColors();
408 foreach ($icon-> getColorSet()->getColors() as $color) {
409 $id = $color->getId();
410 if ($colors[$color->getId()]) {
411 $values[
$id] = $colors[$color->getId()]->getColor();
413 $values[
$id] = $color->getColor();
416 $values[
"selected_icon"] = $icon->
getName();
421 public function updateIcon()
426 $icon_name =
$_POST[
'selected_icon'];
429 $form = $this->initByIconForm($icon);
431 if (
$form->checkInput()) {
435 foreach ($icon->
getColorSet()->getColors() as $old_color) {
436 $new_color =
$form->getInput($old_color->getId());
437 if (!preg_match(
"/[\dabcdef]{6}/i", $new_color)) {
439 $this->lng->txt(
"invalid_color") . $new_color,
442 } elseif ($new_color != $old_color->getId()) {
443 $color_changes[$old_color->getId()] = $new_color;
446 $this->lng->txt(
"color_changed_from") .
" " . $old_color->getId() .
" " .
447 $this->lng->txt(
"color_changed_to") .
" " . $new_color,
454 if (
$_POST[
"changed_icon"]) {
458 $upload = $DIC->upload();
460 $old_icon = $this->
getIconFolder()->getIconByName($icon_name);
462 $upload->moveOneFileTo(
463 array_pop($upload->getResults()),
464 $old_icon->getDirRelToCustomizing(),
465 Location::CUSTOMIZING,
466 $old_icon->getName(),
473 foreach ($message_stack->getJoinedMessages() as
$type =>
$message) {
476 $skin->getVersionStep($skin->getVersion());
481 $message_stack->sendMessages(
true);
482 $this->ctrl->setParameter($this,
"selected_icon", $icon->
getName());
483 $this->ctrl->redirect($this,
"editIcon");
485 $form->setValuesByPost();
486 $this->tpl->setContent(
$form->getHTML());
497 $f = $DIC->ui()->factory();
499 $icon_image = $f->image()->standard($icon->
getPath(), $icon->
getName());
506 $report = $f->panel()->standard($this->lng->txt(
"preview"), $f->deck([$card]));
508 return $DIC->ui()->renderer()->render($report);
515 protected function renderIconsPreviews()
519 $f = $DIC->ui()->factory();
523 foreach ($this->
getIconFolder()->getIconsSortedByFolder() as $folder_name => $icons) {
526 foreach ($icons as $icon) {
530 $icon_image = $f->image()->standard($icon->getPath(), $icon->getName());
535 $colors = $icon->getColorSet()->asString();
537 $card = $card->withSections(
array(
538 $f->listing()->descriptive(
array($this->lng->txt(
"used_colors")=>$colors))
543 $sub_panels[] = $f->panel()->sub($folder_name, $f->deck($cards));
546 $report = $f->panel()->report($this->lng->txt(
"icons"), $sub_panels);
548 return $DIC->ui()->renderer()->render($report);
addSelectIconToolbar($icon_name)
setIconFolder($icon_folder)
setStyleContainer($style_container)
if(!array_key_exists('StateId', $_REQUEST)) $id
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
catch(Exception $e) $message
if(isset($_POST['submit'])) $form
getByIconValues(ilPropertyFormGUI $form, ilSystemStyleIcon $icon)
__construct($skin_id="", $style_id="")
ilSystemStyleIconsGUI constructor.
Create styles array
The data for the language used.
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
renderIconPreview(ilSystemStyleIcon $icon)
setSubStyleSubTabs($active="")
changeColors(array $color_changes)
Changes colors in the svg file of the icon and updates the icon abstraction by extracting the colors ...
Abstracts a folder containing a set of icons.
Used to stack messages to be shown to the user.
Class for advanced editing exception handling in ILIAS.
getByColorValues(ilPropertyFormGUI $form)
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
executeCommand()
Execute command.