ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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'
 
const string CMD_FLUSH = 'flush'
 
- 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 42 of file class.ilMMTopItemGUI.php.

43 {
45 $this->top_token = $this->pons->in()->buildToken('top', 'id');
46 }
__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 91 of file class.ilMMTopItemGUI.php.

92 {
93 $item = $this->repository->getItemFacadeForIdentificationString(
94 $this->pons->in()->getFirstFromRequest($this->top_token->token())
95 );
96 return new ilMMTopItemFormGUI(
97 $this->flow->ctrl(),
98 $this->ui->factory(),
99 $this->ui->renderer(),
100 $this->lng,
101 $this->pons->in()->request(),
102 $item,
103 $this->repository
104 );
105 }
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 49 of file class.ilMMTopItemGUI.php.

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

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

+ Here is the call graph for this function:

◆ form()

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

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

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

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

+ Here is the call graph for this function:

◆ getCurrentItem()

ilMMTopItemGUI::getCurrentItem ( )

Reimplemented from ilMMBaseGUI.

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

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

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

+ Here is the call graph for this function:

◆ getMoveForm()

ilMMTopItemGUI::getMoveForm ( )
private

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

223 : Standard
224 {
225 $f = $this->ui->factory();
226 $parent = $f->input()
227 ->field()
228 ->select(
229 $this->lng->txt('select_parent'),
230 $this->repository->getPossibleParentsForFormAndTable()
231 )
232 ->withRequired(true);
233
234 return $f->input()
235 ->container()
236 ->form()
237 ->standard(
238 $this->flow->getLinkTarget($this, self::CMD_MOVE),
239 [$parent]
240 );
241 }
This describes a standard form.
Definition: Standard.php:30

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 65 of file class.ilMMTopItemGUI.php.

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

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

Referenced by move().

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

◆ getTokensToKeep()

ilMMTopItemGUI::getTokensToKeep ( )

Reimplemented from ilMMBaseGUI.

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

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

◆ index()

ilMMTopItemGUI::index ( )
protected

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

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

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 203 of file class.ilMMTopItemGUI.php.

203 : void
204 {
205 $data = $this->getMoveForm()
206 ->withRequest($this->pons->in()->request())
207 ->getData();
208
209 foreach ($this->getMutlipleItems() as $item) {
210 if (isset($data[0]) && $item->isInterchangeable()) {
211 $f = $this->repository->getItemFacadeForIdentificationString($data[0]);
212 $item->setParent($data[0]);
213 $this->repository->updateItem($item);
214 $this->pons->out()->success($this->lng->txt('msg_moved'), true);
215 } else {
216 $this->pons->out()->error($this->lng->txt('msg_not_moved'), true);
217 }
218
219 $this->pons->flow()->redirect(self::CMD_DEFAULT);
220 }
221 }

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

◆ restore()

ilMMTopItemGUI::restore ( )
private

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

244 : void
245 {
250
251 $this->pons->out()->success($this->lng->txt('msg_restored'), true);
252 $this->flow->redirect(self::CMD_DEFAULT);
253 }
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 191 of file class.ilMMTopItemGUI.php.

191 : string
192 {
193 $this->keepTokens();
194
195 $this->pons->out()->outAsyncAsModal(
196 $this->lng->txt('select_parent'),
197 $this->flow->getLinkTarget($this, self::CMD_MOVE),
198 $this->getMoveForm()
199 );
200 }

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 40 of file class.ilMMTopItemGUI.php.

◆ CMD_FLUSH

const string ilMMTopItemGUI::CMD_FLUSH = 'flush'

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