ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\File\Icon\IconFormUI Class Reference
+ Collaboration diagram for ILIAS\File\Icon\IconFormUI:

Public Member Functions

 __construct (Icon $icon, string $mode, IconRepositoryInterface $icon_repo)
 
 getIconForm ()
 
 transformCheckboxInputValueToBool ($checkbox_input_value)
 

Data Fields

const MODE_CREATE = 'create'
 
const MODE_EDIT = 'edit'
 
const FORM_ICON_CREATION = 'form_icon_creation'
 
const FORM_ICON_UPDATING = 'form_icon_updating'
 
const INPUT_ICON = 'input_icon'
 
const INPUT_DESC_ICON = 'input_desc_icon'
 
const INPUT_ACTIVE = 'input_active'
 
const INPUT_DESC_ACTIVE = 'input_desc_active'
 
const INPUT_SUFFIXES = 'input_suffixes'
 
const INPUT_DESC_SUFFIXES = 'input_desc_suffixes'
 

Protected Member Functions

 initIconForm ()
 

Private Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilTabsGUI $tabs
 
ILIAS UI Factory $ui_factory
 
WrapperFactory $wrapper
 
ILIAS UI Component Input Container Form Standard $icon_form
 
ILIAS Refinery Factory $refinery
 
Icon $icon
 
string $mode
 
IconRepositoryInterface $icon_repo
 

Detailed Description

Author
Lukas Zehnder lukas.nosp@m.@sr..nosp@m.solut.nosp@m.ions

Definition at line 29 of file IconFormUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\File\Icon\IconFormUI::__construct ( Icon  $icon,
string  $mode,
IconRepositoryInterface  $icon_repo 
)

Definition at line 53 of file IconFormUI.php.

References $DIC, ILIAS\File\Icon\IconFormUI\$icon, ILIAS\File\Icon\IconFormUI\$icon_repo, ILIAS\File\Icon\IconFormUI\$mode, ILIAS\Repository\ctrl(), ILIAS\File\Icon\IconFormUI\initIconForm(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\tabs().

57  {
58  $this->icon = $icon;
59  $this->mode = $mode;
60  $this->icon_repo = $icon_repo;
61  global $DIC;
62  $this->ctrl = $DIC->ctrl();
63  $this->lng = $DIC->language();
64  $this->tabs = $DIC->tabs();
65  $this->ui_factory = $DIC->ui()->factory();
66  $this->wrapper = $DIC->http()->wrapper();
67  $this->refinery = $DIC->refinery();
68 
69  $this->initIconForm();
70  }
global $DIC
Definition: shib_login.php:25
IconRepositoryInterface $icon_repo
Definition: IconFormUI.php:51
+ Here is the call graph for this function:

Member Function Documentation

◆ getIconForm()

ILIAS\File\Icon\IconFormUI::getIconForm ( )

Definition at line 165 of file IconFormUI.php.

References ILIAS\File\Icon\IconFormUI\$icon_form.

165  : \ILIAS\UI\Component\Input\Container\Form\Standard
166  {
167  return $this->icon_form;
168  }
ILIAS UI Component Input Container Form Standard $icon_form
Definition: IconFormUI.php:47

◆ initIconForm()

ILIAS\File\Icon\IconFormUI::initIconForm ( )
protected

Definition at line 72 of file IconFormUI.php.

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\File\Icon\ilObjFileIconsOverviewGUI\CMD_CREATE, ILIAS\File\Icon\ilObjFileIconsOverviewGUI\CMD_INDEX, ILIAS\File\Icon\ilObjFileIconsOverviewGUI\CMD_UPDATE, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\File\Icon\IconFormUI\transformCheckboxInputValueToBool(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by ILIAS\File\Icon\IconFormUI\__construct().

72  : void
73  {
74  $this->tabs->clearSubTabs();
75  $this->tabs->clearTargets();
76  $back_target = $this->ctrl->getLinkTargetByClass(
77  ilObjFileIconsOverviewGUI::class,
79  );
80  $this->tabs->setBackTarget($this->lng->txt('back'), $back_target);
81 
82  if ($this->mode == self::MODE_EDIT) {
83  $form_title = $this->lng->txt(self::FORM_ICON_UPDATING);
84  $form_action = $this->ctrl->getFormActionByClass(
85  ilObjFileIconsOverviewGUI::class,
87  );
88  } else {
89  $form_title = $this->lng->txt(self::FORM_ICON_CREATION);
90  $form_action = $this->ctrl->getFormActionByClass(
91  ilObjFileIconsOverviewGUI::class,
93  );
94  }
95 
96  $rid = $this->icon->getRid();
97  $this->ctrl->setParameterByClass(ilIconUploadHandlerGUI::class, 'rid', $rid);
98  $icon_input = $this->ui_factory->input()->field()->file(
99  new ilIconUploadHandlerGUI(),
100  $this->lng->txt(self::INPUT_ICON),
101  $this->lng->txt(self::INPUT_DESC_ICON)
102  )->withAcceptedMimeTypes(
103  [MimeType::IMAGE__SVG_XML]
104  )->withRequired(
105  true
106  );
107  if ($rid !== "") {
108  $icon_input = $icon_input->withValue([$rid]);
109  }
110 
111  $active_input = $this->ui_factory->input()->field()->checkbox(
112  $this->lng->txt(self::INPUT_ACTIVE),
113  $this->lng->txt(self::INPUT_DESC_ACTIVE)
114  )->withValue(
115  $this->icon->isActive()
116  );
117 
118  $suffix_input = $this->ui_factory->input()->field()->text(
119  $this->lng->txt(self::INPUT_SUFFIXES),
120  $this->lng->txt(self::INPUT_DESC_SUFFIXES)
121  )->withRequired(
122  true
123  )->withValue(
124  $this->icon_repo->turnSuffixesArrayIntoString($this->icon->getSuffixes())
125  )->withAdditionalTransformation(
126  $this->refinery->custom()->transformation(function ($suffixes_input): array {
127  return $this->icon_repo->turnSuffixesStringIntoArray($suffixes_input);
128  })
129  )->withAdditionalTransformation(
130  $this->refinery->custom()->constraint(function ($suffixes_input): bool {
131  return $this->icon_repo->hasSuffixInputOnlyAllowedCharacters($suffixes_input);
132  }, $this->lng->txt('msg_error_suffixes_with_forbidden_characters'))
133  )->withAdditionalTransformation(
134  $this->refinery->custom()->constraint(function ($suffixes_input): bool {
135  return $this->icon_repo->hasSuffixInputNoDuplicatesToItsOwnEntries($suffixes_input);
136  }, $this->lng->txt('msg_error_duplicate_suffix_entries'))
137  )->withAdditionalTransformation(
138  $this->refinery->custom()->constraint(function ($suffixes_input): bool {
139  //retrieve the value of the active_input as it is needed for the causesNoActiveSuffixesConflict validation
140  $section = $this->icon_form->getInputs()[0];
141  $inputs = $section->getInputs();
142  $input_active = $inputs[self::INPUT_ACTIVE];
143  $field_is_active = $input_active->getName();
144  $to_bool = $this->refinery->custom()->transformation(function ($checkbox_input_value): bool {
145  return $this->transformCheckboxInputValueToBool($checkbox_input_value);
146  });
147  $post_is_active_value = $this->wrapper->post()->retrieve($field_is_active, $to_bool);
148 
149  return $this->icon_repo->causesNoActiveSuffixesConflict(
150  $suffixes_input,
151  $post_is_active_value,
152  $this->icon
153  );
154  }, $this->lng->txt('msg_error_active_suffixes_conflict'))
155  );
156 
157  $section = $this->ui_factory->input()->field()->section([
158  self::INPUT_ICON => $icon_input,
159  self::INPUT_ACTIVE => $active_input,
160  self::INPUT_SUFFIXES => $suffix_input
161  ], $form_title);
162  $this->icon_form = $this->ui_factory->input()->container()->form()->standard($form_action, [$section]);
163  }
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
transformCheckboxInputValueToBool($checkbox_input_value)
Definition: IconFormUI.php:170
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformCheckboxInputValueToBool()

ILIAS\File\Icon\IconFormUI::transformCheckboxInputValueToBool (   $checkbox_input_value)

Definition at line 170 of file IconFormUI.php.

References ILIAS\Repository\refinery().

Referenced by ILIAS\File\Icon\IconFormUI\initIconForm().

170  : bool
171  {
172  if ($checkbox_input_value !== null) {
173  $checkbox_input_value_str = $this->refinery->kindlyTo()->string()->transform($checkbox_input_value);
174  if ($checkbox_input_value_str == "checked") {
175  return true;
176  }
177  }
178  return false;
179  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ILIAS\File\Icon\IconFormUI::$ctrl
private

Definition at line 42 of file IconFormUI.php.

◆ $icon

Icon ILIAS\File\Icon\IconFormUI::$icon
private

Definition at line 49 of file IconFormUI.php.

Referenced by ILIAS\File\Icon\IconFormUI\__construct().

◆ $icon_form

ILIAS UI Component Input Container Form Standard ILIAS\File\Icon\IconFormUI::$icon_form
private

Definition at line 47 of file IconFormUI.php.

Referenced by ILIAS\File\Icon\IconFormUI\getIconForm().

◆ $icon_repo

IconRepositoryInterface ILIAS\File\Icon\IconFormUI::$icon_repo
private

Definition at line 51 of file IconFormUI.php.

Referenced by ILIAS\File\Icon\IconFormUI\__construct().

◆ $lng

ilLanguage ILIAS\File\Icon\IconFormUI::$lng
private

Definition at line 43 of file IconFormUI.php.

◆ $mode

string ILIAS\File\Icon\IconFormUI::$mode
private

Definition at line 50 of file IconFormUI.php.

Referenced by ILIAS\File\Icon\IconFormUI\__construct().

◆ $refinery

ILIAS Refinery Factory ILIAS\File\Icon\IconFormUI::$refinery
private

Definition at line 48 of file IconFormUI.php.

◆ $tabs

ilTabsGUI ILIAS\File\Icon\IconFormUI::$tabs
private

Definition at line 44 of file IconFormUI.php.

◆ $ui_factory

ILIAS UI Factory ILIAS\File\Icon\IconFormUI::$ui_factory
private

Definition at line 45 of file IconFormUI.php.

◆ $wrapper

WrapperFactory ILIAS\File\Icon\IconFormUI::$wrapper
private

Definition at line 46 of file IconFormUI.php.

◆ FORM_ICON_CREATION

const ILIAS\File\Icon\IconFormUI::FORM_ICON_CREATION = 'form_icon_creation'

Definition at line 33 of file IconFormUI.php.

◆ FORM_ICON_UPDATING

const ILIAS\File\Icon\IconFormUI::FORM_ICON_UPDATING = 'form_icon_updating'

Definition at line 34 of file IconFormUI.php.

◆ INPUT_ACTIVE

const ILIAS\File\Icon\IconFormUI::INPUT_ACTIVE = 'input_active'

◆ INPUT_DESC_ACTIVE

const ILIAS\File\Icon\IconFormUI::INPUT_DESC_ACTIVE = 'input_desc_active'

Definition at line 38 of file IconFormUI.php.

◆ INPUT_DESC_ICON

const ILIAS\File\Icon\IconFormUI::INPUT_DESC_ICON = 'input_desc_icon'

Definition at line 36 of file IconFormUI.php.

◆ INPUT_DESC_SUFFIXES

const ILIAS\File\Icon\IconFormUI::INPUT_DESC_SUFFIXES = 'input_desc_suffixes'

Definition at line 40 of file IconFormUI.php.

◆ INPUT_ICON

const ILIAS\File\Icon\IconFormUI::INPUT_ICON = 'input_icon'

◆ INPUT_SUFFIXES

const ILIAS\File\Icon\IconFormUI::INPUT_SUFFIXES = 'input_suffixes'

◆ MODE_CREATE

const ILIAS\File\Icon\IconFormUI::MODE_CREATE = 'create'

◆ MODE_EDIT

const ILIAS\File\Icon\IconFormUI::MODE_EDIT = 'edit'

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