ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMMTopItemGUI Class Reference

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

+ Inheritance diagram for ilMMTopItemGUI:
+ Collaboration diagram for ilMMTopItemGUI:

Public Member Functions

 __construct (Pons $pons)
 
 executeCommand ()
 
 getMutlipleItems ()
 
 getCurrentItem ()
 
 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_RESTORE = 'restore'
 
const CMD_SELECT_PARENT = 'selectParent'
 
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

 selectParent ()
 
 move ()
 
 getMoveForm ()
 
 restore ()
 

Private Attributes

TokenContainer $top_token
 

Additional Inherited Members

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

Detailed Description

@ilCtrl_IsCalledBy ilMMTopItemGUI: ilObjMainMenuGUI @ilCtrl_Calls ilMMTopItemGUI: 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 33 of file class.ilMMTopItemGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMMTopItemGUI::__construct ( Pons  $pons)

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Definition at line 41 of file class.ilMMTopItemGUI.php.

42 {
44 $this->top_token = $this->pons->in()->buildToken('top', 'id');
45 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildForm()

ilMMTopItemGUI::buildForm ( )
protected

Definition at line 90 of file class.ilMMTopItemGUI.php.

91 {
92 $item = $this->repository->getItemFacadeForIdentificationString(
93 $this->pons->in()->getFirstFromRequest($this->top_token->token())
94 );
95 return new ilMMTopItemFormGUI(
96 $this->flow->ctrl(),
97 $this->ui->factory(),
98 $this->ui->renderer(),
99 $this->lng,
100 $this->pons->in()->request(),
101 $item,
102 $this->repository
103 );
104 }
Class ilMMTopItemFormGUI.

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:

◆ executeCommand()

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

Reimplemented from ilMMBaseGUI.

Definition at line 48 of file class.ilMMTopItemGUI.php.

48 : bool
49 {
50 if ($this->pons->handle('top_items')) {
51 return true;
52 }
53
54 $command = $this->flow->getCommand(self::CMD_DEFAULT);
55 match ($command) {
56 self::CMD_SELECT_PARENT => $this->selectParent(),
57 self::CMD_MOVE => $this->move(),
58 self::CMD_RESTORE => $this->restore(),
59 default => parent::executeCommand()
60 };
61 return true;
62 }

References move(), restore(), and selectParent().

+ Here is the call graph for this function:

◆ form()

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

Definition at line 107 of file class.ilMMTopItemGUI.php.

107 : void
108 {
109 if (!$save) {
110 $this->pons->in()->keep($this->top_token->token());
111 }
112
113 $form = $this->buildForm();
114
115 if ($save && $form->save()) {
116 $this->pons->out()->success($this->lng->t('item_updated'), true);
117 $this->pons->flow()->redirect(self::CMD_DEFAULT);
118 }
119
120 $this->pons->out()->outAsyncAsModal(
121 $this->pons->i18n()->txt('edit'),
122 $this->flow->getLinkTarget($this, self::CMD_UPDATE),
123 $form->get()
124 );
125 }

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

+ Here is the call graph for this function:

◆ getCurrentItem()

ilMMTopItemGUI::getCurrentItem ( )

Reimplemented from ilMMBaseGUI.

Definition at line 76 of file class.ilMMTopItemGUI.php.

77 {
78 return $this->repository->getItemFacadeForIdentificationString(
79 $this->pons->in()->getFirstFromRequest($this->top_token->token())
80 );
81 }
Interface ilMMItemFacadeInterface.

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

Referenced by move().

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

◆ getMoveForm()

ilMMTopItemGUI::getMoveForm ( )
private

Definition at line 216 of file class.ilMMTopItemGUI.php.

216 : Standard
217 {
218 $f = $this->ui->factory();
219 $parent = $f->input()
220 ->field()
221 ->select(
222 $this->lng->txt('select_parent'),
223 $this->repository->getPossibleParentsForFormAndTable()
224 )
225 ->withRequired(true);
226
227 return $f->input()
228 ->container()
229 ->form()
230 ->standard(
231 $this->flow->getLinkTarget($this, self::CMD_MOVE),
232 [$parent]
233 );
234 }
This describes a standard form.
Definition: Standard.php:29

References Vendor\Package\$f, ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by move().

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

◆ getMutlipleItems()

ilMMTopItemGUI::getMutlipleItems ( )
Returns
ilMMItemFacadeInterface[]

Reimplemented from ilMMBaseGUI.

Definition at line 64 of file class.ilMMTopItemGUI.php.

64 : array
65 {
66 $ids = $this->pons->in()->getAllFromRequest($this->top_token->token());
67 if (($ids[0] ?? null) === Input::ALL_OBJECTS) {
68 return array_map(
69 fn(array $data): \ilMMItemFacadeInterface => $this->repository->getItemFacadeForIdentificationString($data['identification']),
70 $this->repository->getTopItems()
71 );
72 }
73 return $this->repository->getItemFacadesForIdentificationStrings($ids);
74 }

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

+ Here is the call graph for this function:

◆ getTokensToKeep()

ilMMTopItemGUI::getTokensToKeep ( )

Reimplemented from ilMMBaseGUI.

Definition at line 83 of file class.ilMMTopItemGUI.php.

83 : array
84 {
85 return [
86 $this->top_token->token(),
87 ];
88 }

◆ index()

ilMMTopItemGUI::index ( )
protected

Definition at line 128 of file class.ilMMTopItemGUI.php.

128 : void
129 {
130 $write_access = $this->access->hasUserPermissionTo('write');
131 if ($write_access) {
132 // ADD NEW
133 $form = $this->buildForm();
134 $add_modal = $this->ui->factory()->modal()->roundtrip(
135 $this->lng->t('topitem_add'),
136 null,
137 $form->get()->getInputs(),
138 $this->flow->getLinkTarget($this, self::CMD_CREATE)
139 );
140
141 $btn_add = $this->ui->factory()->button()->primary(
142 $this->lng->t('topitem_add'),
143 $add_modal->getShowSignal()
144 );
145 $this->toolbar->addComponent($add_modal);
146 $this->toolbar->addComponent($btn_add);
147
148 // RESTORE
149 $restoration_modal = $this->ui->factory()->modal()->interruptive(
150 $this->lng->t(self::CMD_RESTORE),
151 $this->lng->t('msg_restore_confirm'),
152 $this->flow->getLinkTarget($this, self::CMD_RESTORE)
153 )->withActionButtonLabel($this->lng->t('restore'));
154 $btn_restore = $this->ui->factory()->button()->standard(
155 $this->lng->t(self::CMD_RESTORE),
156 ''
157 )->withOnClick(
158 $restoration_modal->getShowSignal()
159 );
160 $this->toolbar->addComponent($btn_restore);
161 $this->toolbar->addComponent($restoration_modal);
162
163 // REMOVE LOST ITEMS
164 if ($this->repository->hasLostItems()) {
165 $btn_flush = $this->ui->factory()->button()->standard(
166 $this->lng->txt(self::CMD_FLUSH),
167 $this->flow->getLinkTarget($this, self::CMD_FLUSH)
168 );
169 $this->toolbar->addComponent($btn_flush);
170 }
171 }
172
173 $table = new ilMMTopItemTableComponent(
174 $this->pons,
175 $this->top_token,
176 $this->repository,
177 $write_access
178 );
179
180 $this->pons->out()->out(...$table->get());
181 }

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()

ilMMTopItemGUI::move ( )
private

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

196 : void
197 {
198 $item = $this->getCurrentItem();
199
200 $data = $this->getMoveForm()
201 ->withRequest($this->pons->in()->request())
202 ->getData();
203
204 if (isset($data[0]) && $item->isInterchangeable()) {
205 $f = $this->repository->getItemFacadeForIdentificationString($data[0]);
206 $item->setParent($data[0]);
207 $this->repository->updateItem($item);
208 $this->pons->out()->success($this->lng->txt('msg_moved'), true);
209 } else {
210 $this->pons->out()->error($this->lng->txt('msg_not_moved'), true);
211 }
212
213 $this->pons->flow()->redirect(self::CMD_DEFAULT);
214 }

References $data, Vendor\Package\$f, getCurrentItem(), getMoveForm(), 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:

◆ restore()

ilMMTopItemGUI::restore ( )
private

Definition at line 237 of file class.ilMMTopItemGUI.php.

237 : void
238 {
243
244 $this->pons->out()->success($this->lng->txt('msg_restored'), true);
245 $this->flow->redirect(self::CMD_DEFAULT);
246 }
static flushDB()
@depracated never use in ILIAS Core, Plugins only

References ActiveRecord\flushDB(), and ILIAS\Repository\lng().

Referenced by executeCommand().

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

◆ selectParent()

ilMMTopItemGUI::selectParent ( )
private

Definition at line 184 of file class.ilMMTopItemGUI.php.

184 : string
185 {
186 $this->keepTokens();
187
188 $this->pons->out()->outAsyncAsModal(
189 $this->lng->txt('select_parent'),
190 $this->flow->getLinkTarget($this, self::CMD_MOVE),
191 $this->getMoveForm()
192 );
193 }

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

Referenced by executeCommand().

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

Field Documentation

◆ $top_token

TokenContainer ilMMTopItemGUI::$top_token
private

Definition at line 39 of file class.ilMMTopItemGUI.php.

◆ CMD_MOVE

const ilMMTopItemGUI::CMD_MOVE = 'move'

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

◆ CMD_RESTORE

const ilMMTopItemGUI::CMD_RESTORE = 'restore'

Definition at line 35 of file class.ilMMTopItemGUI.php.

◆ CMD_SELECT_PARENT

const ilMMTopItemGUI::CMD_SELECT_PARENT = 'selectParent'

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

Referenced by ilMMTopItemTableComponent\get().


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