ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjTalkTemplateGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
24 
37 {
39 
40  public function __construct()
41  {
45  $container = $GLOBALS['DIC'];
46  $lng = $container->language();
48  ->http()
49  ->wrapper()
50  ->query()
51  ->retrieve("ref_id", $container->refinery()->kindlyTo()->int());
52  parent::__construct([], $refId, true, false);
53 
54 
55  $this->type = 'talt';
56 
57  $lng->loadLanguageModule("etal");
58  $lng->loadLanguageModule("meta");
59  $lng->loadLanguageModule("rep");
60 
61  $this->md_handler = new MetadataHandler();
62  }
63 
64  public function executeCommand(): void
65  {
66  $cmd = $this->ctrl->getCmd();
67  $next_class = $this->ctrl->getNextClass($this);
68 
69  if (!$next_class && ($cmd === 'create' || $cmd === 'save')) {
70  $this->setCreationMode();
71  }
72 
73  switch ($next_class) {
74  case 'ilinfoscreengui':
75  parent::prepareOutput();
76  $this->tabs_gui->activateTab('info_short');
77  $ilInfoScreenGUI = new ilInfoScreenGUI($this);
78  $this->ctrl->forwardCommand($ilInfoScreenGUI);
79  break;
80  default:
81  parent::executeCommand();
82  }
83  }
84 
85  public function viewObject(): void
86  {
87  $this->tabs_gui->activateTab('view_content');
88 
89  $form = $this->md_handler->getDisabledEditForm(
90  $this->object->getType(),
91  $this->object->getId(),
93  0
94  );
95 
96  $this->tpl->setContent($form->render());
97  }
98 
99  protected function initEditForm(): ilPropertyFormGUI
100  {
101  $form = parent::initEditForm();
102  $form->addCommandButton("view", $this->lng->txt("cancel"));
103  return $form;
104  }
105 
106  protected function initEditCustomForm(ilPropertyFormGUI $a_form): void
107  {
108  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'activation_online');
109  $online->setInfo($this->lng->txt('talt_activation_online_info'));
110  $a_form->addItem($online);
111 
112  parent::initEditCustomForm($a_form);
113  }
114 
115  protected function getEditFormCustomValues(array &$a_values): void
116  {
117  $a_values['activation_online'] = !boolval($this->object->getOfflineStatus());
118 
119  parent::getEditFormCustomValues($a_values);
120  }
121 
123  {
124  $header = new ilFormSectionHeaderGUI();
125  $header->setParentForm($form);
126  $header->setTitle("Metadata");
127 
128  $this->md_handler->attachSelectionToForm(
129  $this->object->getType(),
130  $this->object->getId(),
132  0,
133  $form
134  );
135 
136  parent::addExternalEditFormCustom($form);
137  }
138 
139  protected function updateCustom(ilPropertyFormGUI $form): void
140  {
141  $this->object->setOfflineStatus(!boolval($form->getInput('activation_online')));
142 
143  $this->md_handler->saveSelectionFromForm(
144  $this->object->getType(),
145  $this->object->getId(),
147  0,
148  $form
149  );
150 
151  parent::updateCustom($form);
152  }
153 
157  public function infoScreenObject(): void
158  {
159  $this->ctrl->redirectByClass(strtolower(ilInfoScreenGUI::class), "showSummary");
160  }
161 
162  protected function getTabs(): void
163  {
164  $read_access_ref_id = $this->rbacsystem->checkAccess('visible,read', $this->object->getRefId());
165  if ($read_access_ref_id) {
166  $this->tabs_gui->addTab('view_content', $this->lng->txt("content"), $this->ctrl->getLinkTarget($this, "view"));
167  $this->tabs_gui->addTab("info_short", "Info", $this->ctrl->getLinkTargetByClass(strtolower(ilInfoScreenGUI::class), "showSummary"));
168  }
169 
170  if ($this->rbacsystem->checkAccess('write', $this->object->getRefId(), $this->type)) {
171  $this->tabs_gui->addTab('settings', $this->lng->txt("settings"), $this->ctrl->getLinkTarget($this, "edit"));
172  }
173  }
174 
175  protected function initCreationForms(string $new_type): array
176  {
177  return [
178  self::CFORM_NEW => $this->initCreateForm($new_type)
179  ];
180  }
181 
182  public function getAdminTabs(): void
183  {
184  $this->getTabs();
185  }
186 
187  protected function addAdminLocatorItems(bool $do_not_add_object = false): void
188  {
189  parent::addAdminLocatorItems(true);
190 
191  $this->ctrl->setParameterByClass(
192  strtolower(ilObjTalkTemplateAdministrationGUI::class),
193  'ref_id',
195  );
196  $this->locator->addItem(
197  $this->lng->txt('obj_tala'),
198  $this->ctrl->getLinkTargetByClass(
199  ilObjTalkTemplateAdministrationGUI::class,
200  ControlFlowCommand::INDEX
201  )
202  );
203  $this->ctrl->clearParameterByClass(
204  strtolower(ilObjTalkTemplateAdministrationGUI::class),
205  'ref_id'
206  );
207 
208  $this->locator->addItem(
210  ilObject::_lookupObjId($this->object->getRefId())
211  ),
212  $this->ctrl->getLinkTargetByClass([
213  strtolower(ilAdministrationGUI::class),
214  strtolower(ilObjTalkTemplateAdministrationGUI::class),
215  strtolower(self::class),
216  ], ControlFlowCommand::INDEX)
217  );
218  }
219 
220  public static function _goto(string $refId): void
221  {
225  $container = $GLOBALS['DIC'];
226  if (!ilObject::_exists((int) $refId, true)) {
227  $container["tpl"]->setOnScreenMessage(
228  'failure',
229  $container->language()->txt("permission_denied"),
230  true
231  );
232  $container->ctrl()->redirectByClass(ilDashboardGUI::class, "");
233  }
234  $container->ctrl()->setParameterByClass(strtolower(self::class), 'ref_id', $refId);
235  $container->ctrl()->redirectByClass([
236  strtolower(ilAdministrationGUI::class),
237  strtolower(ilObjTalkTemplateAdministrationGUI::class),
238  strtolower(self::class),
239  ], ControlFlowCommand::INDEX);
240  }
241 }
Class ilInfoScreenGUI.
infoScreenObject()
infoScreen redirect handling of ObjListGUI
__construct($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
$refId
Definition: xapitoken.php:58
loadLanguageModule(string $a_module)
Load language module.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
$container
Definition: wac.php:14
static _lookupObjId(int $ref_id)
addExternalEditFormCustom(ilPropertyFormGUI $form)
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
ilLanguage $lng
Class ilObjTalkTemplateGUI.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
__construct(VocabulariesInterface $vocabularies)
static _lookupTitle(int $obj_id)
$GLOBALS["DIC"]
Definition: wac.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
ilPropertyFormGUI $form
initCreateForm(string $new_type)
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder...
initEditCustomForm(ilPropertyFormGUI $a_form)
addAdminLocatorItems(bool $do_not_add_object=false)
getEditFormCustomValues(array &$a_values)
updateCustom(ilPropertyFormGUI $form)
MetadataHandlerInterface $md_handler