ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilMDEditorGUI Class Reference
+ Collaboration diagram for ilMDEditorGUI:

Public Member Functions

 __construct (int $obj_id, int $sub_id, string $type, int $ref_id=0)
 
 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 ()
 
 getButtonToControlCenter ()
 
 checkAccess ()
 

Protected Attributes

FullEditorServices $full_editor_services
 
DigestServices $digest_services
 
PublishingServices $publishing_services
 
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
 
int $ref_id
 

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

@ilCtrl_Calls ilMDEditorGUI: ILIAS\MetaData\OERHarvester\ControlCenter\ControlCenterGUI

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

Constructor & Destructor Documentation

◆ __construct()

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

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

81 {
82 global $DIC;
83
84 $services = new InternalServices($DIC);
85
86 $this->full_editor_services = $services->editor()->fullEditor();
87 $this->digest_services = $services->editor()->digest();
88 $this->publishing_services = $services->OERHarvester();
89
90 $this->ctrl = $services->dic()->ctrl();
91 $this->tpl = $services->dic()->ui()->mainTemplate();
92 $this->ui_renderer = $services->dic()->ui()->renderer();
93 $this->presenter = $services->editor()->internal()->presenter();
94 $this->request_parser = $services->editor()->internal()->requestParser();
95 $this->repository = $services->repository()->repository();
96 $this->observer_handler = $services->editor()->internal()->observerHandler();
97 $this->access = $services->dic()->access();
98 $this->toolbar = $services->dic()->toolbar();
99 $this->global_screen = $services->dic()->globalScreen();
100 $this->tabs = $services->dic()->tabs();
101 $this->ui_factory = $services->dic()->ui()->factory();
102 $this->xml_writer = $services->xml()->standardWriter();
103
104 $this->obj_id = $obj_id;
105 $this->sub_id = $sub_id === 0 ? $obj_id : $sub_id;
106 $this->ref_id = $ref_id;
107 $this->type = $type;
108 }
global $DIC
Definition: shib_login.php:26

References $DIC, $obj_id, $ref_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 407 of file class.ilMDEditorGUI.php.

407 : void
408 {
409 $editor = $this->ui_factory->button()->standard(
410 $this->presenter->utilities()->txt('meta_button_to_full_editor_label'),
411 $this->ctrl->getLinkTarget($this, 'fullEditor')
412 );
413 $this->toolbar->addComponent($editor);
414 if (DEVMODE) {
415 $debug = $this->ui_factory->button()->standard(
416 'Debug',
417 $this->ctrl->getLinkTarget($this, 'debug')
418 );
419 $this->toolbar->addComponent($debug);
420 }
421 }

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 464 of file class.ilMDEditorGUI.php.

464 : void
465 {
466 $this->observer_handler->addObserver($a_class, $a_method, $a_element);
467 }

◆ callListeners()

ilMDEditorGUI::callListeners ( string  $a_element)

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

469 : void
470 {
471 $this->observer_handler->callObservers($a_element);
472 }

Referenced by updateQuickEdit().

+ Here is the caller graph for this function:

◆ checkAccess()

ilMDEditorGUI::checkAccess ( )
protected

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

445 : void
446 {
447 // if there is no fixed parent (e.g. mob), then skip
448 if ($this->obj_id === 0 || $this->ref_id === 0) {
449 return;
450 }
451 if ($this->access->checkAccess(
452 'write',
453 '',
454 $this->ref_id,
455 '',
456 $this->obj_id
457 )) {
458 return;
459 }
460 throw new ilPermissionException($this->presenter->utilities()->txt('permission_denied'));
461 }

References 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 129 of file class.ilMDEditorGUI.php.

129 : bool
130 {
131 $xml = $this->xml_writer->write($this->repository->getMD($this->obj_id, $this->sub_id, $this->type));
132 $dom = new DOMDocument('1.0');
133 $dom->formatOutput = true;
134 $dom->preserveWhiteSpace = false;
135 $dom->loadXML($xml->asXML());
136
137 $this->addButtonToFullEditor();
138 $this->tpl->setContent('<pre>' . htmlentities($dom->saveXML()) . '</pre>');
139 return true;
140 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilMDEditorGUI::executeCommand ( )

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

110 : void
111 {
112 $next_class = $this->ctrl->getNextClass($this);
113
114 $cmd = $this->ctrl->getCmd();
115 switch ($next_class) {
116 case strtolower(ControlCenterGUI::class):
117 $back_link = $this->ctrl->getLinkTarget($this, 'listQuickEdit');
118 $gui = $this->publishing_services->controlCenterGUI($back_link);
119 $this->ctrl->forwardCommand($gui);
120 break;
121
122 default:
123 $valid_cmd = (Command::tryFrom($cmd) ?? Command::SHOW_DIGEST)->value;
124 $this->$valid_cmd();
125 break;
126 }
127 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ fullEditor()

ilMDEditorGUI::fullEditor ( )
protected

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

327 : void
328 {
329 $this->setTabsForFullEditor();
330
331 // get the paths from the http request
332 $base_path = $this->request_parser->fetchBasePath();
333
334 // get and prepare the MD
335 $set = $this->repository->getMD(
336 $this->obj_id,
337 $this->sub_id,
338 $this->type
339 );
340 $editor = $this->full_editor_services->fullEditor();
341 $manipulator = $this->full_editor_services->manipulatorAdapter();
342 $set = $manipulator->prepare($set, $base_path);
343
344 // add content for element
345 $this->renderFullEditor($set, $base_path, $editor);
346 }
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 219 of file class.ilMDEditorGUI.php.

219 : void
220 {
221 $this->fullEditorEdit(true);
222 }
fullEditorEdit(bool $create)

◆ fullEditorDelete()

ilMDEditorGUI::fullEditorDelete ( )
protected

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

286 : void
287 {
288 $this->checkAccess();
289
290 // get the paths from the http request
291 $base_path = $this->request_parser->fetchBasePath();
292 $delete_path = $this->request_parser->fetchActionPath();
293
294 // get the MD
295 $set = $this->repository->getMD(
296 $this->obj_id,
297 $this->sub_id,
298 $this->type
299 );
300 $editor = $this->full_editor_services->fullEditor();
301 $manipulator = $this->full_editor_services->manipulatorAdapter();
302
303 // delete
304 $base_path = $manipulator->deleteAndTrimBasePath(
305 $set,
306 $base_path,
307 $delete_path
308 );
309
310 // call listeners
311 $this->observer_handler->callObserversByPath($delete_path);
312
313 // redirect back to the full editor
314 $this->tpl->setOnScreenMessage(
315 'success',
316 $this->presenter->utilities()->txt('meta_delete_element_success'),
317 true
318 );
319 $this->ctrl->setParameter(
320 $this,
321 Parameter::BASE_PATH->value,
322 urlencode($base_path->toString())
323 );
324 $this->ctrl->redirect($this, 'fullEditor');
325 }

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 229 of file class.ilMDEditorGUI.php.

229 : void
230 {
231 $this->checkAccess();
232
233 // get the paths from the http request
234 $base_path = $this->request_parser->fetchBasePath();
235 $action_path = $this->request_parser->fetchActionPath();
236
237 // get and prepare the MD
238 $set = $this->repository->getMD(
239 $this->obj_id,
240 $this->sub_id,
241 $this->type
242 );
243 $editor = $this->full_editor_services->fullEditor();
244 $manipulator = $this->full_editor_services->manipulatorAdapter();
245 $set = $manipulator->prepare($set, $base_path);
246
247 // update or create
248 $request = $this->request_parser->fetchRequestForForm(true);
249 $success = $manipulator->createOrUpdate(
250 $set,
251 $base_path,
252 $action_path,
253 $request
254 );
255 if (!$success) {
256 $this->tpl->setOnScreenMessage(
257 'failure',
258 $this->presenter->utilities()->txt('msg_form_save_error'),
259 true
260 );
261 $this->renderFullEditor($set, $base_path, $editor, $request);
262 return;
263 }
264
265 // call listeners
266 $this->observer_handler->callObserversByPath($action_path);
267
268 // redirect back to the full editor
269 $this->tpl->setOnScreenMessage(
270 'success',
271 $this->presenter->utilities()->txt(
272 $create ?
273 'meta_add_element_success' :
274 'meta_edit_element_success'
275 ),
276 true
277 );
278 $this->ctrl->setParameter(
279 $this,
280 Parameter::BASE_PATH->value,
281 urlencode($base_path->toString())
282 );
283 $this->ctrl->redirect($this, 'fullEditor');
284 }

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 224 of file class.ilMDEditorGUI.php.

224 : void
225 {
226 $this->fullEditorEdit(false);
227 }

◆ getButtonToControlCenter()

ilMDEditorGUI::getButtonToControlCenter ( )
protected
Returns
array{0:MessageBox, 1:Prompt}

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

426 : array
427 {
428 // will also exclude subtypes
429 if (!$this->publishing_services->stateInfoFetcher()->isPublishingRelevantForObject(
430 $this->ref_id,
431 $this->type,
432 $this->obj_id
433 )) {
434 return [];
435 }
436 $status = $this->publishing_services->stateInfoFetcher()->getStatusForObject($this->obj_id);
437 return $this->publishing_services->controlCenterComponentFactory()->getButtonToControlCenter(
438 $status,
439 $this->ref_id,
440 $this->obj_id,
441 $this->type
442 );
443 }

◆ listQuickEdit()

ilMDEditorGUI::listQuickEdit ( )

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

147 : void
148 {
149 $digest = $this->digest_services->digest();
150 $set = $this->repository->getMD(
151 $this->obj_id,
152 $this->sub_id,
153 $this->type
154 );
155
156 $this->renderDigest($set, $digest);
157 }
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 142 of file class.ilMDEditorGUI.php.

142 : void
143 {
144 $this->listQuickEdit();
145 }

References listQuickEdit().

+ Here is the call graph for this function:

◆ renderDigest()

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

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

200 : void {
201 $content = $digest->getContent($set, $request);
202 $template_content = $this->getButtonToControlCenter();
203 foreach ($content as $type => $entity) {
204 switch ($type) {
205 case DigestContentType::FORM:
207 $template_content[] = $entity;
208 break;
209
210 case DigestContentType::JS_SOURCE:
211 $this->tpl->addJavaScript($entity);
212 break;
213 }
214 }
215 $this->addButtonToFullEditor();
216 $this->tpl->setContent($this->ui_renderer->render($template_content));
217 }
getContent(SetInterface $set, ?RequestForFormInterface $request=null)
Definition: Digest.php:42

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 348 of file class.ilMDEditorGUI.php.

353 : void {
354 // add slate with tree
355 $this->global_screen->tool()->context()->current()->addAdditionalData(
356 self::SET_FOR_TREE,
357 $set
358 );
359 $this->global_screen->tool()->context()->current()->addAdditionalData(
360 self::PATH_FOR_TREE,
361 $base_path
362 );
363
364 // render toolbar, modals and main content
365 $content = $full_editor->getContent($set, $base_path, $request);
366 $template_content = [];
367 foreach ($content as $type => $entity) {
368 switch ($type) {
369 case FullContentType::MAIN:
370 if ($entity instanceof Table) {
371 $entity = $this->ui_factory->legacy()->content(
372 $entity->getHTML()
373 );
374 }
375 $template_content[] = $entity;
376 break;
377
379 if ($modal = $entity->getModal()) {
380 $template_content[] = $modal;
381 }
382 break;
383
384 case FullContentType::TOOLBAR:
385 $this->toolbar->addComponent($entity);
386 break;
387 }
388 }
389 $this->tpl->setContent($this->ui_renderer->render($template_content));
390 }
getContent(SetInterface $set, PathInterface $base_path, ?RequestForFormInterface $request=null)
Definition: FullEditor.php:57

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 392 of file class.ilMDEditorGUI.php.

392 : void
393 {
394 $this->tabs->clearSubTabs();
395 foreach ($this->tabs->target as $tab) {
396 if (($tab['id'] ?? null) !== $this->tabs->getActiveTab()) {
397 $this->tabs->removeTab($tab['id']);
398 }
399 }
400 $this->tabs->removeNonTabbedLinks();
401 $this->tabs->setBackTarget(
402 $this->presenter->utilities()->txt('back'),
403 $this->ctrl->getLinkTarget($this, 'listQuickEdit')
404 );
405 }

References ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ updateQuickEdit()

ilMDEditorGUI::updateQuickEdit ( )

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

159 : void
160 {
161 $this->checkAccess();
162
163 $digest = $this->digest_services->digest();
164 $manipulator = $this->digest_services->manipulatorAdapter();
165 $set = $this->repository->getMD(
166 $this->obj_id,
167 $this->sub_id,
168 $this->type
169 );
170
171 $request = $this->request_parser->fetchRequestForForm(false);
172 if (!$manipulator->update($set, $request)) {
173 $this->tpl->setOnScreenMessage(
174 'failure',
175 $this->presenter->utilities()->txt('msg_form_save_error'),
176 true
177 );
178 $this->renderDigest($set, $digest, $request);
179 return;
180 }
181
182 $this->callListeners('General');
183 $this->callListeners('Rights');
184 $this->callListeners('Educational');
185 $this->callListeners('Lifecycle');
186
187 // Redirect here to read new title and description
188 $this->tpl->setOnScreenMessage(
189 'success',
190 $this->presenter->utilities()->txt("saved_successfully"),
191 true
192 );
193 $this->ctrl->redirect($this, 'listQuickEdit');
194 }
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 68 of file class.ilMDEditorGUI.php.

◆ $ctrl

ilCtrl ilMDEditorGUI::$ctrl
protected

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

◆ $digest_services

DigestServices ilMDEditorGUI::$digest_services
protected

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

◆ $full_editor_services

FullEditorServices ilMDEditorGUI::$full_editor_services
protected

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

◆ $global_screen

GlobalScreen ilMDEditorGUI::$global_screen
protected

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

◆ $obj_id

int ilMDEditorGUI::$obj_id
protected

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

Referenced by __construct().

◆ $observer_handler

ObserverHandler ilMDEditorGUI::$observer_handler
protected

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

◆ $presenter

PresenterInterface ilMDEditorGUI::$presenter
protected

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

◆ $publishing_services

PublishingServices ilMDEditorGUI::$publishing_services
protected

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

◆ $ref_id

int ilMDEditorGUI::$ref_id
protected

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

Referenced by __construct().

◆ $repository

RepositoryInterface ilMDEditorGUI::$repository
protected

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

◆ $request_parser

RequestParserInterface ilMDEditorGUI::$request_parser
protected

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

◆ $sub_id

int ilMDEditorGUI::$sub_id
protected

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

Referenced by __construct().

◆ $tabs

ilTabsGUI ilMDEditorGUI::$tabs
protected

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

◆ $toolbar

ilToolbarGUI ilMDEditorGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilMDEditorGUI::$tpl
protected

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

◆ $type

string ilMDEditorGUI::$type

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

Referenced by __construct().

◆ $ui_factory

UIFactory ilMDEditorGUI::$ui_factory
protected

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

◆ $ui_renderer

Renderer ilMDEditorGUI::$ui_renderer
protected

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

◆ $xml_writer

XMLWriter ilMDEditorGUI::$xml_writer
protected

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