ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\File\Icon\IconFormUI Class Reference
+ Collaboration diagram for ILIAS\File\Icon\IconFormUI:

Public Member Functions

 __construct (private Icon $icon, private string $mode, private 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
 
Factory $ui_factory
 
WrapperFactory $wrapper
 
Standard $icon_form
 
ILIAS Refinery Factory $refinery
 

Detailed Description

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

Definition at line 31 of file IconFormUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 52 of file IconFormUI.php.

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

56  {
57  global $DIC;
58  $this->ctrl = $DIC->ctrl();
59  $this->lng = $DIC->language();
60  $this->tabs = $DIC->tabs();
61  $this->ui_factory = $DIC->ui()->factory();
62  $this->wrapper = $DIC->http()->wrapper();
63  $this->refinery = $DIC->refinery();
64 
65  $this->initIconForm();
66  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getIconForm()

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

Definition at line 153 of file IconFormUI.php.

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

153  : Standard
154  {
155  return $this->icon_form;
156  }

◆ initIconForm()

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

Definition at line 68 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().

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

References null, and ILIAS\Repository\refinery().

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

158  : bool
159  {
160  if ($checkbox_input_value !== null) {
161  $checkbox_input_value_str = $this->refinery->kindlyTo()->string()->transform($checkbox_input_value);
162  if ($checkbox_input_value_str == "checked") {
163  return true;
164  }
165  }
166  return false;
167  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 44 of file IconFormUI.php.

◆ $icon_form

Standard ILIAS\File\Icon\IconFormUI::$icon_form
private

Definition at line 49 of file IconFormUI.php.

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

◆ $lng

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

Definition at line 45 of file IconFormUI.php.

◆ $refinery

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

Definition at line 50 of file IconFormUI.php.

◆ $tabs

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

Definition at line 46 of file IconFormUI.php.

◆ $ui_factory

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

Definition at line 47 of file IconFormUI.php.

◆ $wrapper

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

Definition at line 48 of file IconFormUI.php.

◆ FORM_ICON_CREATION

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

Definition at line 35 of file IconFormUI.php.

◆ FORM_ICON_UPDATING

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

Definition at line 36 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 40 of file IconFormUI.php.

◆ INPUT_DESC_ICON

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

Definition at line 38 of file IconFormUI.php.

◆ INPUT_DESC_SUFFIXES

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

Definition at line 42 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: