ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjTalkTemplateGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
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");
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'] = !$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(!$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 public function getAdminTabs(): void
176 {
177 $this->getTabs();
178 }
179
180 protected function addAdminLocatorItems(bool $do_not_add_object = false): void
181 {
182 parent::addAdminLocatorItems(true);
183
184 $this->ctrl->setParameterByClass(
185 strtolower(ilObjTalkTemplateAdministrationGUI::class),
186 'ref_id',
188 );
189 $this->locator->addItem(
190 $this->lng->txt('obj_tala'),
191 $this->ctrl->getLinkTargetByClass(
192 ilObjTalkTemplateAdministrationGUI::class,
193 ControlFlowCommand::INDEX
194 )
195 );
196 $this->ctrl->clearParameterByClass(
197 strtolower(ilObjTalkTemplateAdministrationGUI::class),
198 'ref_id'
199 );
200
201 $this->locator->addItem(
203 ilObject::_lookupObjId($this->object->getRefId())
204 ),
205 $this->ctrl->getLinkTargetByClass([
206 strtolower(ilAdministrationGUI::class),
207 strtolower(ilObjTalkTemplateAdministrationGUI::class),
208 strtolower(self::class),
209 ], ControlFlowCommand::INDEX)
210 );
211 }
212
213 public static function _goto(string $refId): void
214 {
218 $container = $GLOBALS['DIC'];
219 if (!ilObject::_exists((int) $refId, true)) {
220 $container["tpl"]->setOnScreenMessage(
221 'failure',
222 $container->language()->txt("permission_denied"),
223 true
224 );
225 $container->ctrl()->redirectByClass(ilDashboardGUI::class, "");
226 }
227 $container->ctrl()->setParameterByClass(strtolower(self::class), 'ref_id', $refId);
228 $container->ctrl()->redirectByClass([
229 strtolower(ilAdministrationGUI::class),
230 strtolower(ilObjTalkTemplateAdministrationGUI::class),
231 strtolower(self::class),
232 ], ControlFlowCommand::INDEX);
233 }
234}
This class represents a checkbox property in a property form.
Class ilContainerGUI This is a base GUI class for all container objects in ILIAS: root folder,...
ilPropertyFormGUI $form
This class represents a section header in a property form.
Class ilInfoScreenGUI.
loadLanguageModule(string $a_module)
Load language module.
Class ilObjTalkTemplateGUI.
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
infoScreenObject()
infoScreen redirect handling of ObjListGUI
MetadataHandlerInterface $md_handler
getAdminTabs()
administration tabs show only permissions and trash folder
initEditCustomForm(ilPropertyFormGUI $a_form)
Add custom fields to update form.
getEditFormCustomValues(array &$a_values)
Add values to custom edit fields.
addAdminLocatorItems(bool $do_not_add_object=false)
should be overwritten to add object specific items (repository items are preloaded)
updateCustom(ilPropertyFormGUI $form)
Insert custom update form values into object.
getTabs()
@abstract overwrite in derived GUI class of your object type
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
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
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-...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$container
@noRector
Definition: wac.php:37
$GLOBALS["DIC"]
Definition: wac.php:54
$refId
Definition: xapitoken.php:58