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");
55 $this->ctrl = $DIC->ctrl();
56 $this->lng = $DIC->language();
57 $this->tpl = $DIC[
"tpl"];
58 $this->tabs = $DIC->tabs();
61 $skin_id =
$_GET[
"skin_id"];
64 $style_id =
$_GET[
"style_id"];
67 if($this->ctrl->getCmd() !=
"reset"){
72 $this->ctrl->setCmd(
"fail");
83 $cmd = $this->ctrl->getCmd();
110 $form = $this->initByColorForm();
111 $this->tpl->setContent($form->getHTML());
118 $this->tabs->addSubTab(
'edit', $this->lng->txt(
'edit_by_color'), $this->ctrl->getLinkTarget($this,
'edit'));
119 $this->tabs->addSubTab(
'editIcon', $this->lng->txt(
'edit_by_icon'), $this->ctrl->getLinkTarget($this,
'editIcon'));
120 $this->tabs->addSubTab(
'preview', $this->lng->txt(
'icons_gallery'), $this->ctrl->getLinkTarget($this,
"preview"));
122 if($active ==
"preview"){
123 $this->tabs->activateSubTab($active);
124 }
else if($active ==
"cancelIcon"|| $active ==
"editIcon"){
125 $this->tabs->activateSubTab(
"editIcon");
128 $this->tabs->activateSubTab(
"edit");
134 $form = $this->initByColorForm();
136 $this->tpl->setContent($form->getHTML());
140 $this->tpl->setContent($this->renderIconsPreviews());
145 public function initByColorForm()
149 $form->setTitle($this->lng->txt(
"adapt_icons"));
150 $form->setDescription($this->lng->txt(
"adapt_icons_description"));
156 $color_set = $this->
getIconFolder()->getColorSet()->getColorsSortedAsArray();
162 foreach($color_set as $type => $colors){
167 $title = $this->lng->txt(
"grey_color");
168 $section->setTitle($this->lng->txt(
"grey_colors"));
169 $section->setInfo($this->lng->txt(
"grey_colors_description"));
170 $section->setSectionAnchor($this->lng->txt(
"grey_colors"));
173 $title = $this->lng->txt(
"red_color");
174 $section->setTitle($this->lng->txt(
"red_colors"));
175 $section->setInfo($this->lng->txt(
"red_colors_description"));
176 $section->setSectionAnchor($this->lng->txt(
"red_colors"));
179 $title = $this->lng->txt(
"green_color");
180 $section->setTitle($this->lng->txt(
"green_colors"));
181 $section->setInfo($this->lng->txt(
"green_colors_description"));
182 $section->setSectionAnchor($this->lng->txt(
"green_colors"));
185 $title = $this->lng->txt(
"blue_color");
186 $section->setTitle($this->lng->txt(
"blue_colors"));
187 $section->setInfo($this->lng->txt(
"blue_colors_description"));
188 $section->setSectionAnchor($this->lng->txt(
"blue_colors"));
192 foreach($colors as $id => $color){
198 $input->setInfo(
"Usages: ".$this->
getIconFolder()->getUsagesOfColorAsString($color->getId()));
199 $form->addItem($input);
206 $form->addCommandButton(
"update", $this->lng->txt(
"update_colors"));
208 $form->addCommandButton(
"reset", $this->lng->txt(
"reset_icons"));
210 $form->addCommandButton(
"cancel", $this->lng->txt(
"cancel"));
216 $form->setFormAction($this->ctrl->getFormAction($this));
230 $colors = $this->
getIconFolder()->getColorSet()->getColors();
231 foreach($colors as $color){
232 $id = $color->getId();
233 if($colors[$color->getId()]){
234 $values[$id] = $colors[$color->getId()]->getColor();
236 $values[$id] = $color->getColor();
251 $message_stack->sendMessages(
true);
253 $this->lng->txt(
"color_reset"),
255 $this->ctrl->redirect($this,
"edit");
260 $form = $this->initByColorForm();
261 if ($form->checkInput())
266 foreach($this->
getIconFolder()->getColorSet()->getColors() as $old_color){
267 $new_color = $form->getInput($old_color->getId());
268 if(!preg_match(
"/[\dabcdef]{6}/i",$new_color)){
269 $message_stack->addMessage(
new ilSystemStyleMessage($this->lng->txt(
"invalid_color").$new_color,
271 }
else if($new_color != $old_color->getId()){
272 $color_changes[$old_color->getId()] = $new_color;
274 $this->lng->txt(
"color_changed_from").
" ".$old_color->getId().
" ".
275 $this->lng->txt(
"color_changed_to").
" ".$new_color,
282 $skin->getVersionStep($skin->getVersion());
284 $message_stack->sendMessages(
true);
285 $this->ctrl->redirect($this,
"edit");
287 $form->setValuesByPost();
288 $this->tpl->setContent($form->getHTML());
293 $icon_name =
$_POST[
'selected_icon']?
$_POST[
'selected_icon']:
$_GET[
'selected_icon'];
299 $form = $this->initByIconForm($icon);
301 $this->tpl->setContent($form->getHTML().$this->renderIconPreview($icon));
311 $toolbar = $DIC->toolbar();
317 if($icon->getType()==
"svg"){
318 $options[$icon->getName()] = $icon->getName();
322 $si->setOptions($options);
324 $si->setValue($icon_name);
326 $toolbar->addInputItem(
$si,
true);
329 $select_btn->setCaption($this->lng->txt(
"select"),
false);
330 $toolbar->addButtonInstance($select_btn);
331 $toolbar->setFormAction($this->ctrl->getLinkTarget($this,
'editIcon'));
342 $form->setTitle($this->lng->txt(
"adapt_icon").
" ".$icon->
getName());
343 $form->setDescription($this->lng->txt(
"adapt_icon_description"));
349 $color_set = $icon->
getColorSet()->getColorsSortedAsArray();
355 foreach($color_set as $type => $colors){
357 $title = $this->lng->txt(
"color");
359 foreach($colors as $id => $color){
365 $form->addItem($input);
369 $upload =
new ilFileInputGUI($this->lng->txt(
"change_icon"),
"changed_icon");
371 $form->addItem($upload);
375 $form->addItem($hidden_name);
378 $form->addCommandButton(
"updateIcon", $this->lng->txt(
"update_icon"));
379 $form->addCommandButton(
"cancelIcon", $this->lng->txt(
"cancel"));
382 $form->setFormAction($this->ctrl->getFormAction($this));
396 $colors = $this->
getIconFolder()->getColorSet()->getColors();
397 foreach($icon-> getColorSet()->getColors() as $color){
398 $id = $color->getId();
399 if($colors[$color->getId()]){
400 $values[$id] = $colors[$color->getId()]->getColor();
402 $values[$id] = $color->getColor();
405 $values[
"selected_icon"] = $icon->
getName();
413 $icon_name =
$_POST[
'selected_icon'];
416 $form = $this->initByIconForm($icon);
418 if ($form->checkInput())
423 foreach($icon->
getColorSet()->getColors() as $old_color){
424 $new_color = $form->getInput($old_color->getId());
425 if(!preg_match(
"/[\dabcdef]{6}/i",$new_color)){
426 $message_stack->addMessage(
new ilSystemStyleMessage($this->lng->txt(
"invalid_color").$new_color,
428 }
else if($new_color != $old_color->getId()){
429 $color_changes[$old_color->getId()] = $new_color;
432 $this->lng->txt(
"color_changed_from").
" ".$old_color->getId().
" ".
433 $this->lng->txt(
"color_changed_to").
" ".$new_color,
439 if(
$_POST[
"changed_icon"]){
440 $old_icon = $this->
getIconFolder()->getIconByName($icon_name);
441 move_uploaded_file(
$_POST[
"changed_icon"][
"tmp_name"],$old_icon->getPath());
445 foreach ($message_stack->getJoinedMessages() as $type => $message) {
448 $skin->getVersionStep($skin->getVersion());
453 $message_stack->sendMessages(
true);
454 $this->ctrl->setParameter($this,
"selected_icon",$icon->
getName());
455 $this->ctrl->redirect($this,
"editIcon");
457 $form->setValuesByPost();
458 $this->tpl->setContent($form->getHTML());
468 $f = $DIC->ui()->factory();
470 $icon_image = $f->image()->standard($icon->
getPath(),$icon->
getName());
477 $report = $f->panel()->standard($this->lng->txt(
"preview"),$f->deck([$card]));
479 return $DIC->ui()->renderer()->render($report);
486 protected function renderIconsPreviews(){
489 $f = $DIC->ui()->factory();
493 foreach($this->
getIconFolder()->getIconsSortedByFolder() as $folder_name => $icons){
496 foreach($icons as $icon){
500 $icon_image = $f->image()->standard($icon->getPath(),$icon->getName());
505 $colors = $icon->getColorSet()->asString();
507 $card = $card->withSections(
array(
508 $f->listing()->descriptive(
array($this->lng->txt(
"used_colors")=>$colors))
513 $sub_panels[] = $f->panel()->sub($folder_name,$f->deck($cards));
516 $report = $f->panel()->report($this->lng->txt(
"icons"),$sub_panels);
518 return $DIC->ui()->renderer()->render($report);
addSelectIconToolbar($icon_name)
setIconFolder($icon_folder)
setStyleContainer($style_container)
Abstracts an Icon and the necessary actions to get all colors out of an svg Icon. ...
if(!is_array($argv)) $options
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)
executeCommand()
Execute command.