ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
ilMMSubItemGUI Class Reference

@ilCtrl_IsCalledBy ilMMSubItemGUI: ilMMTopItemGUI @ilCtrl_Calls ilMMSubItemGUI: ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI More...

+ Inheritance diagram for ilMMSubItemGUI:
+ Collaboration diagram for ilMMSubItemGUI:

Public Member Functions

 __construct (Pons $pons)
 
 executeCommand ()
 
 getCurrentItem ()
 
 getMutlipleItems ()
 
 getTokensToKeep ()
 
- Public Member Functions inherited from ilMMBaseGUI
 __construct (protected Pons $pons)
 
 getCurrentItem ()
 
 getMutlipleItems ()
 
 getTokensToKeep ()
 
 executeCommand ()
 
 getCurrentItem ()
 
 __construct (Pons $pons)
 
 executeCommand ()
 
 getTokensToKeep ()
 

Data Fields

const CMD_CONFIRM_MOVE = 'confirmMove'
 
const CMD_MOVE = 'MOVE'
 
- Data Fields inherited from ilMMBaseGUI
const CMD_DEFAULT = 'index'
 
const CMD_ADD = 'add'
 
const CMD_CREATE = 'create'
 
const CMD_EDIT = 'edit'
 
const CMD_DELETE = 'delete'
 
const CMD_CONFIRM_DELETE = 'confirmDelete'
 
const CMD_UPDATE = 'update'
 
const CMD_ACTIVATE = 'activate'
 
const CMD_DEACTIVATE = 'deactivate'
 
const CMD_SAVE_ORDER = 'saveOrder'
 
- Data Fields inherited from ILIAS\GlobalScreen\GUI\PonsGUI
const CMD_DEFAULT = 'index'
 

Protected Member Functions

 buildForm ()
 
 form (bool $save=false)
 
 index ()
 
- Protected Member Functions inherited from ilMMBaseGUI
 keepTokens ()
 
 delete ()
 
 confirmDelete ()
 
 activate ()
 
 deactivate ()
 
 toggle (bool $activation)
 
 saveOrder ()
 

Private Member Functions

 confirmMove ()
 
 move ()
 

Private Attributes

TokenContainer $sub_token
 
TokenContainer $top_token
 
ilMMItemFacadeInterface $parent_item = null
 

Additional Inherited Members

- Protected Attributes inherited from ilMMBaseGUI
ilMMItemRepository $repository
 
UIServices $ui
 
Translator $lng
 
Access $access
 
Flow $flow
 
ilToolbarGUI $toolbar
 

Detailed Description

@ilCtrl_IsCalledBy ilMMSubItemGUI: ilMMTopItemGUI @ilCtrl_Calls ilMMSubItemGUI: ILIAS\GlobalScreen\GUI\I18n\MultiLanguageGUI

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

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

Constructor & Destructor Documentation

◆ __construct()

ilMMSubItemGUI::__construct ( Pons  $pons)

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

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

41 {
43 $this->sub_token = $this->pons->in()->buildToken('sub', 'id');
44 $this->top_token = $this->pons->in()->buildToken('top', 'id');
45 $identification = $this->pons->in()->getFirstFromRequest($this->top_token->token());
46 if ($identification === 'lost_items' || $identification === null) {
47 $this->parent_item = null;
48 } else {
49 $this->parent_item = $this->repository->getItemFacadeForIdentificationString(
50 $identification
51 );
52 }
53 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildForm()

ilMMSubItemGUI::buildForm ( )
protected

Definition at line 100 of file class.ilMMSubItemGUI.php.

101 {
102 $item = $this->repository->getItemFacadeForIdentificationString(
103 $this->pons->in()->getFirstFromRequest($this->sub_token->token())
104 );
105 return new ilMMSubitemFormGUI(
106 $this->flow->ctrl(),
107 $this->ui->factory(),
108 $this->ui->renderer(),
109 $this->lng,
110 $this->pons->in()->request(),
111 $item,
112 $this->repository,
113 $this->parent_item
114 );
115 }
Class ilMMSubitemFormGUI.

References ILIAS\UI\examples\Deck\repository().

Referenced by form(), and index().

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

◆ confirmMove()

ilMMSubItemGUI::confirmMove ( )
private

Definition at line 175 of file class.ilMMSubItemGUI.php.

175 : void
176 {
177 $this->keepTokens();
178
179 $items = [];
180 foreach ($this->getMutlipleItems() as $item) {
181 $items[] = $this->ui->factory()->modal()->interruptiveItem()->standard(
182 $this->hash($item->getId()),
183 $item->getDefaultTitle(),
184 );
185 }
186
187 $this->pons->out()->outAsyncAsConfirmation(
188 $this->lng->t('move'),
189 $this->lng->t('confirm_move'),
190 $this->lng->t('move'),
191 $this->flow->getLinkTarget($this, self::CMD_MOVE),
192 ...$items
193 );
194 }

References getMutlipleItems(), ilMMBaseGUI\keepTokens(), ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by executeCommand().

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

◆ executeCommand()

ilMMSubItemGUI::executeCommand ( )
Returns
bool true if you handled this command aka you were the CtrlClass, otherwise false

Reimplemented from ilMMBaseGUI.

Definition at line 56 of file class.ilMMSubItemGUI.php.

56 : bool
57 {
58 $this->pons->in()->keep($this->top_token->token());
59 if ($this->pons->handle('sub_items')) {
60 return true;
61 }
62
63 match ($this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
64 self::CMD_CONFIRM_MOVE => $this->confirmMove(),
65 self::CMD_MOVE => $this->move(),
66 default => parent::executeCommand()
67 };
68 return true;
69 }

References confirmMove(), and move().

+ Here is the call graph for this function:

◆ form()

ilMMSubItemGUI::form ( bool  $save = false)
protected

Definition at line 117 of file class.ilMMSubItemGUI.php.

117 : void
118 {
119 if (!$save) {
120 $this->pons->in()->keep($this->sub_token->token());
121 }
122
123 $form = $this->buildForm();
124
125 if ($save) {
126 if ($form->save()) {
127 $this->pons->out()->success($this->lng->t('item_updated'), true);
128 $this->pons->flow()->redirect(self::CMD_DEFAULT);
129 } else {
130 $this->pons->in()->keep($this->sub_token->token());
131 $this->pons->out()->out($form->get());
132 return;
133 }
134 }
135
136 $this->pons->out()->outAsyncAsModal(
137 $this->lng->txt('subitem'),
138 $this->flow->getLinkTarget($this, self::CMD_UPDATE),
139 $form->get()
140 );
141 }

References buildForm(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getCurrentItem()

ilMMSubItemGUI::getCurrentItem ( )

Reimplemented from ilMMBaseGUI.

Definition at line 71 of file class.ilMMSubItemGUI.php.

72 {
73 return $this->repository->getItemFacadeForIdentificationString(
74 $this->pons->in()->getFirstFromRequest($this->sub_token->token())
75 );
76 }
Interface ilMMItemFacadeInterface.

References ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ getMutlipleItems()

ilMMSubItemGUI::getMutlipleItems ( )
Returns
ilMMItemFacadeInterface[]

Reimplemented from ilMMBaseGUI.

Definition at line 78 of file class.ilMMSubItemGUI.php.

78 : array
79 {
80 $ids = $this->pons->in()->getAllFromRequest($this->sub_token->token());
81 if (($ids[0] ?? null) === Input::ALL_OBJECTS) {
82 return array_map(
83 fn(array $data): \ilMMItemFacadeInterface => $this->repository->getItemFacadeForIdentificationString(
84 $data['identification']
85 ),
86 $this->repository->getSubItemsForTable($this->parent_item)
87 );
88 }
89 return $this->repository->getItemFacadesForIdentificationStrings($ids);
90 }

References $data, and ILIAS\UI\examples\Deck\repository().

Referenced by confirmMove(), and move().

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

◆ getTokensToKeep()

ilMMSubItemGUI::getTokensToKeep ( )

Reimplemented from ilMMBaseGUI.

Definition at line 92 of file class.ilMMSubItemGUI.php.

92 : array
93 {
94 return [
95 $this->top_token->token(),
96 $this->sub_token->token(),
97 ];
98 }

◆ index()

ilMMSubItemGUI::index ( )
protected

Definition at line 143 of file class.ilMMSubItemGUI.php.

143 : void
144 {
145 $write_access = $this->access->hasUserPermissionTo('write');
146 if ($write_access && $this->parent_item !== null) {
147 // ADD NEW
148 $form = $this->buildForm();
149 $add_modal = $this->ui->factory()->modal()->roundtrip(
150 $this->lng->t('subitem_add'),
151 null,
152 $form->get()->getInputs(),
153 $this->flow->getLinkTarget($this, self::CMD_CREATE)
154 );
155
156 $btn_add = $this->ui->factory()->button()->primary(
157 $this->lng->t('subitem_add'),
158 $add_modal->getShowSignal()
159 );
160 $this->toolbar->addComponent($add_modal);
161 $this->toolbar->addComponent($btn_add);
162 }
163
164 $table = new ilMMSubItemTableComponent(
165 $this->pons,
166 $this->sub_token,
167 $this->repository,
168 $this->parent_item,
169 $write_access
170 );
171
172 $this->pons->out()->out(...$table->get());
173 }

References ILIAS\Repository\access(), buildForm(), ILIAS\Repository\lng(), ILIAS\UI\examples\Deck\repository(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ move()

ilMMSubItemGUI::move ( )
private

Definition at line 196 of file class.ilMMSubItemGUI.php.

196 : void
197 {
198 $mutliple_items = $this->getMutlipleItems();
199 if (empty($mutliple_items)) {
200 $this->pons->out()->error($this->lng->t('msg_not_moved'), true);
201 $this->pons->flow()->redirect(self::CMD_DEFAULT);
202 return;
203 }
204 foreach ($mutliple_items as $item) {
205 $item->setParent('');
206 $this->repository->updateItem($item);
207 }
208
209 $this->pons->out()->success($this->lng->t('msg_moved'), true);
210 $this->pons->flow()->redirect(self::CMD_DEFAULT);
211 }

References getMutlipleItems(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Deck\repository().

Referenced by executeCommand().

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

Field Documentation

◆ $parent_item

ilMMItemFacadeInterface ilMMSubItemGUI::$parent_item = null
private

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

◆ $sub_token

TokenContainer ilMMSubItemGUI::$sub_token
private

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

◆ $top_token

TokenContainer ilMMSubItemGUI::$top_token
private

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

◆ CMD_CONFIRM_MOVE

const ilMMSubItemGUI::CMD_CONFIRM_MOVE = 'confirmMove'

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

Referenced by ilMMSubItemTableComponent\get().

◆ CMD_MOVE

const ilMMSubItemGUI::CMD_MOVE = 'MOVE'

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


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