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

Public Member Functions

 __construct (int $obj_id, int $sub_id, string $type)
 
 executeCommand ()
 
 debug ()
 
 listSection ()
 
 listQuickEdit ()
 
 updateQuickEdit ()
 
 addObserver (object $a_class, string $a_method, string $a_element)
 
 callListeners (string $a_element)
 

Data Fields

const string SET_FOR_TREE = 'md_set_for_tree'
 
const string PATH_FOR_TREE = 'md_path_for_tree'
 
string $type
 

Protected Member Functions

 renderDigest (SetInterface $set, Digest $digest, ?RequestForFormInterface $request=null)
 
 fullEditorCreate ()
 
 fullEditorUpdate ()
 
 fullEditorEdit (bool $create)
 
 fullEditorDelete ()
 
 fullEditor ()
 
 renderFullEditor (SetInterface $set, PathInterface $base_path, FullEditor $full_editor, ?RequestForFormInterface $request=null)
 
 setTabsForFullEditor ()
 
 addButtonToFullEditor ()
 
 checkAccess ()
 

Protected Attributes

FullEditorInitiator $full_editor_initiator
 
DigestInitiator $digest_initiator
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
Renderer $ui_renderer
 
PresenterInterface $presenter
 
RepositoryInterface $repository
 
RequestParserInterface $request_parser
 
ObserverHandler $observer_handler
 
ilAccessHandler $access
 
ilToolbarGUI $toolbar
 
GlobalScreen $global_screen
 
ilTabsGUI $tabs
 
UIFactory $ui_factory
 
XMLWriter $xml_writer
 
int $obj_id
 
int $sub_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMDEditorGUI::__construct ( int  $obj_id,
int  $sub_id,
string  $type 
)

Definition at line 71 of file class.ilMDEditorGUI.php.

72 {
73 global $DIC;
74
75 $services = new InternalServices($DIC);
76 $this->full_editor_initiator = new FullEditorInitiator($services);
77 $this->digest_initiator = new DigestInitiator($services);
78
79 $this->ctrl = $services->dic()->ctrl();
80 $this->tpl = $services->dic()->ui()->mainTemplate();
81 $this->ui_renderer = $services->dic()->ui()->renderer();
82 $this->presenter = $services->editor()->presenter();
83 $this->request_parser = $services->editor()->requestParser();
84 $this->repository = $services->repository()->repository();
85 $this->observer_handler = $services->editor()->observerHandler();
86 $this->access = $services->dic()->access();
87 $this->toolbar = $services->dic()->toolbar();
88 $this->global_screen = $services->dic()->globalScreen();
89 $this->tabs = $services->dic()->tabs();
90 $this->ui_factory = $services->dic()->ui()->factory();
91 $this->xml_writer = $services->xml()->standardWriter();
92
93 $this->obj_id = $obj_id;
94 $this->sub_id = $sub_id === 0 ? $obj_id : $sub_id;
95 $this->type = $type;
96 }
global $DIC
Definition: shib_login.php:26

References $DIC, $obj_id, $sub_id, $type, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ILIAS\UI\examples\Deck\repository(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ addButtonToFullEditor()

ilMDEditorGUI::addButtonToFullEditor ( )
protected

Definition at line 387 of file class.ilMDEditorGUI.php.

387 : void
388 {
389 $editor = $this->ui_factory->button()->standard(
390 $this->presenter->utilities()->txt('meta_button_to_full_editor_label'),
391 $this->ctrl->getLinkTarget($this, 'fullEditor')
392 );
393 $this->toolbar->addComponent($editor);
394 if (DEVMODE) {
395 $debug = $this->ui_factory->button()->standard(
396 'Debug',
397 $this->ctrl->getLinkTarget($this, 'debug')
398 );
399 $this->toolbar->addComponent($debug);
400 }
401 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\toolbar().

Referenced by debug().

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

◆ addObserver()

ilMDEditorGUI::addObserver ( object  $a_class,
string  $a_method,
string  $a_element 
)

Definition at line 429 of file class.ilMDEditorGUI.php.

429 : void
430 {
431 $this->observer_handler->addObserver($a_class, $a_method, $a_element);
432 }

◆ callListeners()

ilMDEditorGUI::callListeners ( string  $a_element)

Definition at line 434 of file class.ilMDEditorGUI.php.

434 : void
435 {
436 $this->observer_handler->callObservers($a_element);
437 }

Referenced by updateQuickEdit().

+ Here is the caller graph for this function:

◆ checkAccess()

ilMDEditorGUI::checkAccess ( )
protected

Definition at line 403 of file class.ilMDEditorGUI.php.

403 : void
404 {
405 // if there is no fixed parent (e.g. mob), then skip
406 if ($this->obj_id === 0) {
407 return;
408 }
409 $ref_ids = ilObject::_getAllReferences($this->obj_id);
410 // if there are no references (e.g. in workspace), then skip
411 if (empty($ref_ids)) {
412 return;
413 }
414 foreach ($ref_ids as $ref_id) {
415 if ($this->access->checkAccess(
416 'write',
417 '',
418 $ref_id,
419 '',
420 $this->obj_id
421 )) {
422 return;
423 }
424 }
425 throw new ilPermissionException($this->presenter->utilities()->txt('permission_denied'));
426 }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66

References $ref_id, ilObject\_getAllReferences(), and ILIAS\Repository\access().

Referenced by updateQuickEdit().

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

◆ debug()

ilMDEditorGUI::debug ( )

Definition at line 113 of file class.ilMDEditorGUI.php.

113 : bool
114 {
115 $xml = $this->xml_writer->write($this->repository->getMD($this->obj_id, $this->sub_id, $this->type));
116 $dom = new DOMDocument('1.0');
117 $dom->formatOutput = true;
118 $dom->preserveWhiteSpace = false;
119 $dom->loadXML($xml->asXML());
120
121 $this->addButtonToFullEditor();
122 $this->tpl->setContent('<pre>' . htmlentities($dom->saveXML()) . '</pre>');
123 return true;
124 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilMDEditorGUI::executeCommand ( )

Definition at line 98 of file class.ilMDEditorGUI.php.

98 : void
99 {
100 $next_class = $this->ctrl->getNextClass($this);
101
102 $cmd = $this->ctrl->getCmd();
103 switch ($next_class) {
104 default:
105 if (!$cmd) {
106 $cmd = "listQuickEdit";
107 }
108 $this->$cmd();
109 break;
110 }
111 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ fullEditor()

ilMDEditorGUI::fullEditor ( )
protected

Definition at line 308 of file class.ilMDEditorGUI.php.

308 : void
309 {
310 $this->setTabsForFullEditor();
311
312 // get the paths from the http request
313 $base_path = $this->request_parser->fetchBasePath();
314
315 // get and prepare the MD
316 $set = $this->repository->getMD(
317 $this->obj_id,
318 $this->sub_id,
319 $this->type
320 );
321 $editor = $this->full_editor_initiator->init();
322 $set = $editor->manipulateMD()->prepare($set, $base_path);
323
324 // add content for element
325 $this->renderFullEditor($set, $base_path, $editor);
326 }
renderFullEditor(SetInterface $set, PathInterface $base_path, FullEditor $full_editor, ?RequestForFormInterface $request=null)

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

+ Here is the call graph for this function:

◆ fullEditorCreate()

ilMDEditorGUI::fullEditorCreate ( )
protected

Definition at line 202 of file class.ilMDEditorGUI.php.

202 : void
203 {
204 $this->fullEditorEdit(true);
205 }
fullEditorEdit(bool $create)

◆ fullEditorDelete()

ilMDEditorGUI::fullEditorDelete ( )
protected

Definition at line 268 of file class.ilMDEditorGUI.php.

268 : void
269 {
270 $this->checkAccess();
271
272 // get the paths from the http request
273 $base_path = $this->request_parser->fetchBasePath();
274 $delete_path = $this->request_parser->fetchActionPath();
275
276 // get the MD
277 $set = $this->repository->getMD(
278 $this->obj_id,
279 $this->sub_id,
280 $this->type
281 );
282 $editor = $this->full_editor_initiator->init();
283
284 // delete
285 $base_path = $editor->manipulateMD()->deleteAndTrimBasePath(
286 $set,
287 $base_path,
288 $delete_path
289 );
290
291 // call listeners
292 $this->observer_handler->callObserversByPath($delete_path);
293
294 // redirect back to the full editor
295 $this->tpl->setOnScreenMessage(
296 'success',
297 $this->presenter->utilities()->txt('meta_delete_element_success'),
298 true
299 );
300 $this->ctrl->setParameter(
301 $this,
302 Parameter::BASE_PATH->value,
303 urlencode($base_path->toString())
304 );
305 $this->ctrl->redirect($this, 'fullEditor');
306 }

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

+ Here is the call graph for this function:

◆ fullEditorEdit()

ilMDEditorGUI::fullEditorEdit ( bool  $create)
protected

Definition at line 212 of file class.ilMDEditorGUI.php.

212 : void
213 {
214 $this->checkAccess();
215
216 // get the paths from the http request
217 $base_path = $this->request_parser->fetchBasePath();
218 $action_path = $this->request_parser->fetchActionPath();
219
220 // get and prepare the MD
221 $set = $this->repository->getMD(
222 $this->obj_id,
223 $this->sub_id,
224 $this->type
225 );
226 $editor = $this->full_editor_initiator->init();
227 $set = $editor->manipulateMD()->prepare($set, $base_path);
228
229 // update or create
230 $request = $this->request_parser->fetchRequestForForm(true);
231 $success = $editor->manipulateMD()->createOrUpdate(
232 $set,
233 $base_path,
234 $action_path,
235 $request
236 );
237 if (!$success) {
238 $this->tpl->setOnScreenMessage(
239 'failure',
240 $this->presenter->utilities()->txt('msg_form_save_error'),
241 true
242 );
243 $this->renderFullEditor($set, $base_path, $editor, $request);
244 return;
245 }
246
247 // call listeners
248 $this->observer_handler->callObserversByPath($action_path);
249
250 // redirect back to the full editor
251 $this->tpl->setOnScreenMessage(
252 'success',
253 $this->presenter->utilities()->txt(
254 $create ?
255 'meta_add_element_success' :
256 'meta_edit_element_success'
257 ),
258 true
259 );
260 $this->ctrl->setParameter(
261 $this,
262 Parameter::BASE_PATH->value,
263 urlencode($base_path->toString())
264 );
265 $this->ctrl->redirect($this, 'fullEditor');
266 }

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

+ Here is the call graph for this function:

◆ fullEditorUpdate()

ilMDEditorGUI::fullEditorUpdate ( )
protected

Definition at line 207 of file class.ilMDEditorGUI.php.

207 : void
208 {
209 $this->fullEditorEdit(false);
210 }

◆ listQuickEdit()

ilMDEditorGUI::listQuickEdit ( )

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

131 : void
132 {
133 $digest = $this->digest_initiator->init();
134 $set = $this->repository->getMD(
135 $this->obj_id,
136 $this->sub_id,
137 $this->type
138 );
139
140 $this->renderDigest($set, $digest);
141 }
renderDigest(SetInterface $set, Digest $digest, ?RequestForFormInterface $request=null)

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

Referenced by listSection().

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

◆ listSection()

ilMDEditorGUI::listSection ( )

Definition at line 126 of file class.ilMDEditorGUI.php.

126 : void
127 {
128 $this->listQuickEdit();
129 }

References listQuickEdit().

+ Here is the call graph for this function:

◆ renderDigest()

ilMDEditorGUI::renderDigest ( SetInterface  $set,
Digest  $digest,
?RequestForFormInterface  $request = null 
)
protected

Definition at line 179 of file class.ilMDEditorGUI.php.

183 : void {
184 $content = $digest->getContent($set, $request);
185 $template_content = [];
186 foreach ($content as $type => $entity) {
187 switch ($type) {
188 case DigestContentType::FORM:
190 $template_content[] = $entity;
191 break;
192
193 case DigestContentType::JS_SOURCE:
194 $this->tpl->addJavaScript($entity);
195 break;
196 }
197 }
198 $this->addButtonToFullEditor();
199 $this->tpl->setContent($this->ui_renderer->render($template_content));
200 }
getContent(SetInterface $set, ?RequestForFormInterface $request=null)
Definition: Digest.php:44

References $type, and ILIAS\MetaData\Editor\Digest\MODAL.

Referenced by listQuickEdit(), and updateQuickEdit().

+ Here is the caller graph for this function:

◆ renderFullEditor()

ilMDEditorGUI::renderFullEditor ( SetInterface  $set,
PathInterface  $base_path,
FullEditor  $full_editor,
?RequestForFormInterface  $request = null 
)
protected

Definition at line 328 of file class.ilMDEditorGUI.php.

333 : void {
334 // add slate with tree
335 $this->global_screen->tool()->context()->current()->addAdditionalData(
336 self::SET_FOR_TREE,
337 $set
338 );
339 $this->global_screen->tool()->context()->current()->addAdditionalData(
340 self::PATH_FOR_TREE,
341 $base_path
342 );
343
344 // render toolbar, modals and main content
345 $content = $full_editor->getContent($set, $base_path, $request);
346 $template_content = [];
347 foreach ($content as $type => $entity) {
348 switch ($type) {
349 case FullContentType::MAIN:
350 if ($entity instanceof Table) {
351 $entity = $this->ui_factory->legacy()->content(
352 $entity->getHTML()
353 );
354 }
355 $template_content[] = $entity;
356 break;
357
359 if ($modal = $entity->getModal()) {
360 $template_content[] = $modal;
361 }
362 break;
363
364 case FullContentType::TOOLBAR:
365 $this->toolbar->addComponent($entity);
366 break;
367 }
368 }
369 $this->tpl->setContent($this->ui_renderer->render($template_content));
370 }
getContent(SetInterface $set, PathInterface $base_path, ?RequestForFormInterface $request=null)
Definition: FullEditor.php:79

References ILIAS\MetaData\Editor\Digest\MODAL, and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

◆ setTabsForFullEditor()

ilMDEditorGUI::setTabsForFullEditor ( )
protected

Definition at line 372 of file class.ilMDEditorGUI.php.

372 : void
373 {
374 $this->tabs->clearSubTabs();
375 foreach ($this->tabs->target as $tab) {
376 if (($tab['id'] ?? null) !== $this->tabs->getActiveTab()) {
377 $this->tabs->removeTab($tab['id']);
378 }
379 }
380 $this->tabs->removeNonTabbedLinks();
381 $this->tabs->setBackTarget(
382 $this->presenter->utilities()->txt('back'),
383 $this->ctrl->getLinkTarget($this, 'listQuickEdit')
384 );
385 }

References ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ updateQuickEdit()

ilMDEditorGUI::updateQuickEdit ( )

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

143 : void
144 {
145 $this->checkAccess();
146
147 $digest = $this->digest_initiator->init();
148 $set = $this->repository->getMD(
149 $this->obj_id,
150 $this->sub_id,
151 $this->type
152 );
153
154 $request = $this->request_parser->fetchRequestForForm(false);
155 if (!$digest->updateMD($set, $request)) {
156 $this->tpl->setOnScreenMessage(
157 'failure',
158 $this->presenter->utilities()->txt('msg_form_save_error'),
159 true
160 );
161 $this->renderDigest($set, $digest, $request);
162 return;
163 }
164
165 $this->callListeners('General');
166 $this->callListeners('Rights');
167 $this->callListeners('Educational');
168 $this->callListeners('Lifecycle');
169
170 // Redirect here to read new title and description
171 $this->tpl->setOnScreenMessage(
172 'success',
173 $this->presenter->utilities()->txt("saved_successfully"),
174 true
175 );
176 $this->ctrl->redirect($this, 'listQuickEdit');
177 }
callListeners(string $a_element)

References callListeners(), checkAccess(), ILIAS\Repository\ctrl(), renderDigest(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilMDEditorGUI::$access
protected

Definition at line 60 of file class.ilMDEditorGUI.php.

◆ $ctrl

ilCtrl ilMDEditorGUI::$ctrl
protected

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

◆ $digest_initiator

DigestInitiator ilMDEditorGUI::$digest_initiator
protected

Definition at line 51 of file class.ilMDEditorGUI.php.

◆ $full_editor_initiator

FullEditorInitiator ilMDEditorGUI::$full_editor_initiator
protected

Definition at line 50 of file class.ilMDEditorGUI.php.

◆ $global_screen

GlobalScreen ilMDEditorGUI::$global_screen
protected

Definition at line 62 of file class.ilMDEditorGUI.php.

◆ $obj_id

int ilMDEditorGUI::$obj_id
protected

Definition at line 67 of file class.ilMDEditorGUI.php.

Referenced by __construct().

◆ $observer_handler

ObserverHandler ilMDEditorGUI::$observer_handler
protected

Definition at line 59 of file class.ilMDEditorGUI.php.

◆ $presenter

PresenterInterface ilMDEditorGUI::$presenter
protected

Definition at line 56 of file class.ilMDEditorGUI.php.

◆ $repository

RepositoryInterface ilMDEditorGUI::$repository
protected

Definition at line 57 of file class.ilMDEditorGUI.php.

◆ $request_parser

RequestParserInterface ilMDEditorGUI::$request_parser
protected

Definition at line 58 of file class.ilMDEditorGUI.php.

◆ $sub_id

int ilMDEditorGUI::$sub_id
protected

Definition at line 68 of file class.ilMDEditorGUI.php.

Referenced by __construct().

◆ $tabs

ilTabsGUI ilMDEditorGUI::$tabs
protected

Definition at line 63 of file class.ilMDEditorGUI.php.

◆ $toolbar

ilToolbarGUI ilMDEditorGUI::$toolbar
protected

Definition at line 61 of file class.ilMDEditorGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilMDEditorGUI::$tpl
protected

Definition at line 54 of file class.ilMDEditorGUI.php.

◆ $type

string ilMDEditorGUI::$type

Definition at line 69 of file class.ilMDEditorGUI.php.

Referenced by __construct(), and renderDigest().

◆ $ui_factory

UIFactory ilMDEditorGUI::$ui_factory
protected

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

◆ $ui_renderer

Renderer ilMDEditorGUI::$ui_renderer
protected

Definition at line 55 of file class.ilMDEditorGUI.php.

◆ $xml_writer

XMLWriter ilMDEditorGUI::$xml_writer
protected

Definition at line 65 of file class.ilMDEditorGUI.php.

◆ PATH_FOR_TREE

const string ilMDEditorGUI::PATH_FOR_TREE = 'md_path_for_tree'

◆ SET_FOR_TREE

const string ilMDEditorGUI::SET_FOR_TREE = 'md_set_for_tree'

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