ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMMBaseGUI Class Reference
+ Inheritance diagram for ilMMBaseGUI:
+ Collaboration diagram for ilMMBaseGUI:

Public Member Functions

 __construct (protected Pons $pons)
 
 getCurrentItem ()
 
 getMutlipleItems ()
 
 getTokensToKeep ()
 
 executeCommand ()
 
 getCurrentItem ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\GUI\PonsGUI
 __construct (Pons $pons)
 
 executeCommand ()
 
 getTokensToKeep ()
 

Data Fields

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

 keepTokens ()
 
 delete ()
 
 confirmDelete ()
 
 activate ()
 
 deactivate ()
 
 toggle (bool $activation)
 
 saveOrder ()
 

Protected Attributes

ilMMItemRepository $repository
 
UIServices $ui
 
Translator $lng
 
Access $access
 
Flow $flow
 
ilToolbarGUI $toolbar
 

Private Member Functions

 add ()
 
 edit ()
 
 create ()
 
 update ()
 

Detailed Description

Definition at line 30 of file class.ilMMBaseGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMMBaseGUI::__construct ( protected Pons  $pons)

Definition at line 82 of file class.ilMMBaseGUI.php.

83 {
84 $this->ui = $this->pons->out()->ui();
85 $this->lng = $this->pons->i18n();
86 $this->repository = new ilMMItemRepository();
87 $this->access = $this->pons->access();
88 $this->flow = $this->pons->flow();
89 $this->toolbar = $this->pons->out()->toolbar();
90 }

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

+ Here is the call graph for this function:

Member Function Documentation

◆ activate()

ilMMBaseGUI::activate ( )
protected

Definition at line 182 of file class.ilMMBaseGUI.php.

182 : void
183 {
184 $this->toggle(true);
185 }
toggle(bool $activation)

References toggle().

Referenced by executeCommand().

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

◆ add()

ilMMBaseGUI::add ( )
private

Definition at line 125 of file class.ilMMBaseGUI.php.

125 : void
126 {
127 $this->form(false);
128 }
form( $class_path, string $cmd, string $submit_caption="")

References ILIAS\Repository\form().

Referenced by executeCommand().

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

◆ confirmDelete()

ilMMBaseGUI::confirmDelete ( )
protected

Definition at line 161 of file class.ilMMBaseGUI.php.

161 : void
162 {
163 $this->keepTokens();
164 $items = [];
165 foreach ($this->getMutlipleItems() as $item) {
166 $items[] = $this->ui->factory()->modal()->interruptiveItem()->standard(
167 $this->hash($item->identification()->serialize()),
168 $item->getDefaultTitle()
169 );
170 }
171
172 $this->pons->out()->outAsyncAsConfirmation(
173 $this->lng->txt('delete'),
174 $this->lng->txt('confirm_delete'),
175 $this->lng->txt('delete'),
176 $this->flow->getHereAsURI(self::CMD_DELETE),
177 ...$items
178 );
179 }

References getMutlipleItems(), 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:

◆ create()

ilMMBaseGUI::create ( )
private

Definition at line 137 of file class.ilMMBaseGUI.php.

137 : void
138 {
139 $this->form(true);
140 }

References ILIAS\Repository\form().

Referenced by executeCommand().

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

◆ deactivate()

ilMMBaseGUI::deactivate ( )
protected

Definition at line 188 of file class.ilMMBaseGUI.php.

188 : void
189 {
190 $this->toggle(false);
191 }

References toggle().

Referenced by executeCommand().

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

◆ delete()

ilMMBaseGUI::delete ( )
protected

Definition at line 149 of file class.ilMMBaseGUI.php.

149 : void
150 {
151 foreach ($this->getMutlipleItems() as $item) {
152 if ($item->isDeletable()) {
153 $this->repository->deleteItem($item);
154 }
155 }
156 $this->pons->out()->success($this->lng->txt("msg_topitem_deleted"), true);
157 $this->pons->flow()->redirect(self::CMD_DEFAULT);
158 }

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

+ Here is the call graph for this function:

◆ edit()

ilMMBaseGUI::edit ( )
private

Definition at line 131 of file class.ilMMBaseGUI.php.

131 : void
132 {
133 $this->form(false);
134 }

References ILIAS\Repository\form().

Referenced by executeCommand().

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

◆ executeCommand()

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

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Reimplemented in ilMMSubItemGUI, and ilMMTopItemGUI.

Definition at line 106 of file class.ilMMBaseGUI.php.

106 : bool
107 {
108 match ($cmd = $this->pons->flow()->getCommand(self::CMD_DEFAULT)) {
109 self::CMD_DEFAULT => $this->index(),
110 self::CMD_ADD => $this->add(),
111 self::CMD_EDIT => $this->edit(),
112 self::CMD_CREATE => $this->create(),
113 self::CMD_UPDATE => $this->update(),
114 self::CMD_ACTIVATE => $this->activate(),
115 self::CMD_DEACTIVATE => $this->deactivate(),
116 self::CMD_CONFIRM_DELETE => $this->confirmDelete(),
117 self::CMD_DELETE => $this->delete(),
118 self::CMD_SAVE_ORDER => $this->saveOrder(),
119 default => $this->pons->out()->outString('Command not found:' . $cmd)
120 };
121 return true;
122 }

References activate(), add(), confirmDelete(), create(), deactivate(), edit(), saveOrder(), and update().

+ Here is the call graph for this function:

◆ getCurrentItem()

ilMMBaseGUI::getCurrentItem ( )
abstract

◆ getMutlipleItems()

ilMMBaseGUI::getMutlipleItems ( )
abstract
Returns
ilMMItemFacadeInterface[]

Reimplemented in ilMMSubItemGUI, and ilMMTopItemGUI.

Referenced by confirmDelete(), delete(), and toggle().

+ Here is the caller graph for this function:

◆ getTokensToKeep()

ilMMBaseGUI::getTokensToKeep ( )
abstract

Implements ILIAS\GlobalScreen\GUI\PonsGUI.

Reimplemented in ilMMSubItemGUI, and ilMMTopItemGUI.

◆ keepTokens()

ilMMBaseGUI::keepTokens ( )
protected

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

92 : void
93 {
94 $this->pons->in()->keepTokens($this);
95 }

Referenced by confirmDelete(), ilMMSubItemGUI\confirmMove(), and ilMMTopItemGUI\selectParent().

+ Here is the caller graph for this function:

◆ saveOrder()

ilMMBaseGUI::saveOrder ( )
protected

Definition at line 225 of file class.ilMMBaseGUI.php.

225 : void
226 {
227 foreach ($this->pons->in()->request()->getParsedBody() as $hashed_id => $position) {
228 $item = $this->repository->getItemFacadeForIdentificationString($this->unhash($hashed_id));
229 $item->setPosition((int) $position);
230 $this->repository->updateItem($item);
231 }
232 $this->pons->out()->success($this->pons->i18n()->translate('order_saved'));
233 $this->pons->flow()->redirect(self::CMD_DEFAULT);
234 }

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

Referenced by executeCommand().

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

◆ toggle()

ilMMBaseGUI::toggle ( bool  $activation)
protected

Definition at line 194 of file class.ilMMBaseGUI.php.

194 : void
195 {
196 $not_changed = [];
197 $changed = [];
198
199 foreach ($this->getMutlipleItems() as $item) {
200 if (!$item->canBeDeactivated()) {
201 $not_changed[] = $item->getDefaultTitle();
202 continue;
203 }
204 $item->setActiveStatus($activation);
205 $item->update();
206 $changed[] = $item->getDefaultTitle();
207 }
208 if ($changed !== []) {
209 $this->pons->out()->success(
210 $this->lng->t('msg_success'),
211 true
212 );
213 }
214
215 if ($not_changed !== []) {
216 $this->pons->out()->error(
217 $this->lng->t('msg_not_changed', null, [implode(', ', $not_changed)]),
218 true
219 );
220 }
221 $this->flow->redirect(self::CMD_DEFAULT);
222 }

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

Referenced by activate(), and deactivate().

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

◆ update()

ilMMBaseGUI::update ( )
private

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

143 : void
144 {
145 $this->form(true);
146 }

References ILIAS\Repository\form().

Referenced by executeCommand().

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

Field Documentation

◆ $access

Access ilMMBaseGUI::$access
protected

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

◆ $flow

Flow ilMMBaseGUI::$flow
protected

Definition at line 79 of file class.ilMMBaseGUI.php.

◆ $lng

Translator ilMMBaseGUI::$lng
protected

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

◆ $repository

ilMMItemRepository ilMMBaseGUI::$repository
protected

Definition at line 75 of file class.ilMMBaseGUI.php.

◆ $toolbar

ilToolbarGUI ilMMBaseGUI::$toolbar
protected

Definition at line 80 of file class.ilMMBaseGUI.php.

◆ $ui

UIServices ilMMBaseGUI::$ui
protected

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

◆ CMD_ACTIVATE

const ilMMBaseGUI::CMD_ACTIVATE = 'activate'

◆ CMD_ADD

const ilMMBaseGUI::CMD_ADD = 'add'

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

◆ CMD_CONFIRM_DELETE

const ilMMBaseGUI::CMD_CONFIRM_DELETE = 'confirmDelete'

◆ CMD_CREATE

const ilMMBaseGUI::CMD_CREATE = 'create'

◆ CMD_DEACTIVATE

const ilMMBaseGUI::CMD_DEACTIVATE = 'deactivate'

◆ CMD_DEFAULT

const ilMMBaseGUI::CMD_DEFAULT = 'index'

◆ CMD_DELETE

const ilMMBaseGUI::CMD_DELETE = 'delete'

Definition at line 53 of file class.ilMMBaseGUI.php.

◆ CMD_EDIT

const ilMMBaseGUI::CMD_EDIT = 'edit'

◆ CMD_SAVE_ORDER

const ilMMBaseGUI::CMD_SAVE_ORDER = 'saveOrder'

◆ CMD_UPDATE

const ilMMBaseGUI::CMD_UPDATE = 'update'

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