19 declare(strict_types=1);
64 public const string RIGHTS =
'rights';
90 VocabularyAdapter $vocabulary_adapter
94 $this->ui_factory = $factory;
117 if ($type === ContentType::FORM) {
118 $sections[self::RIGHTS] = $entity;
121 yield $type => $entity;
123 $form = $this->ui_factory->input()->container()->form()->standard(
124 (
string) $this->link_factory->custom(Command::UPDATE_DIGEST)->get(),
128 if (isset($request)) {
129 $form = $request->applyRequestToForm($form);
131 yield ContentType::FORM => $form;
137 $ff = $this->ui_factory->input()->field();
141 $title_el = $this->navigator_factory->navigator(
142 $path = $this->path_collection->title(),
144 )->lastElementAtFinalStep();
146 ->text($this->presenter->utilities()->txt(
'meta_title'))
148 ->withValue($title_el?->getData()?->value() ??
'');
150 $descr_els = $this->navigator_factory->navigator(
151 $descr_path = $this->path_collection->descriptions(),
153 )->elementsAtFinalStep();
154 $descr_els = iterator_to_array($descr_els);
155 $label = $this->presenter->utilities()->txt(
'meta_description');
157 foreach ($descr_els as $el) {
158 $empty_descr =
false;
159 $label_with_lang = $label;
160 foreach ($el->getSuperElement()->getSubElements() as $sub) {
162 $sub->getDefinition()->name() !==
'language' ||
163 ($value = $sub->getData()->value()) ===
'' 167 $label_with_lang .=
' (' . $this->presenter->data()->language($value) .
')';
169 $inputs[$this->path_factory->toElement($el,
true)->toString()] = $ff
170 ->textarea($label_with_lang)
171 ->withValue($el->getData()->value());
174 $inputs[$descr_path->toString()] = $ff
179 foreach ($this->data_helper->getAllLanguages() as $key) {
180 $langs[$key] = $this->presenter->data()->language($key);
182 $lang_input = $ff->select(
183 $this->presenter->utilities()->txt(
'meta_language'),
186 $lang_els = $this->navigator_factory->navigator(
187 $langs_path = $this->path_collection->languages(),
189 )->elementsAtFinalStep();
191 foreach ($lang_els as $el) {
192 $empty_langs =
false;
193 $inputs[$this->path_factory->toElement($el,
true)->toString()] = (clone $lang_input)
197 $inputs[$langs_path->toString()] = clone $lang_input;
201 $keyword_els = $this->navigator_factory->navigator(
202 $keywords_path = $this->path_collection->keywords(),
204 )->elementsAtFinalStep();
205 foreach ($keyword_els as $el) {
206 if (!$el->isScaffold()) {
207 $keywords[] = $el->getData()->value();
210 $inputs[self::KEYWORDS] = $ff->tag(
211 $this->presenter->utilities()->txt(
'keywords'),
217 $this->presenter->utilities()->txt(
'meta_general')
224 $ff = $this->ui_factory->input()->field();
227 $type_el = $this->navigator_factory->navigator(
228 $this->path_collection->firstLearningResourceType(),
230 )->lastElementAtFinalStep();
231 $data = !$type_el?->isScaffold() ? $type_el?->getData()?->value() :
null;
233 $raw_values = $this->vocabulary_adapter->valuesInVocabulariesForSlot(
234 SlotIdentifier::EDUCATIONAL_LEARNING_RESOURCE_TYPE,
237 foreach ($this->presenter->data()->vocabularyValues(
238 SlotIdentifier::EDUCATIONAL_LEARNING_RESOURCE_TYPE,
240 ) as $labelled_value) {
241 $values[$labelled_value->value()] = $labelled_value->label();
243 $input = $this->ui_factory->input()->field()->select(
244 $this->presenter->utilities()->txt(
'meta_learning_resource_type'),
248 $input = $input->withValue(
$data);
250 $inputs[self::LEARNING_RESOURCE_TYPE] = $input;
252 $discipline_el = $this->navigator_factory->navigator(
253 $this->path_collection->firstDiscipline(),
255 )->lastElementAtFinalStep();
257 $this->presenter->utilities()->txt(
'meta_discipline'),
259 !$discipline_el?->isScaffold() ? $discipline_el?->getData()?->value() :
null 264 $this->presenter->utilities()->txt(
'meta_classification')
271 $ff = $this->ui_factory->input()->field();
275 $this->path_collection->firstAuthor(),
276 $this->path_collection->secondAuthor(),
277 $this->path_collection->thirdAuthor()
280 $this->presenter->utilities()->txt(
'meta_first_author'),
281 $this->presenter->utilities()->txt(
'meta_second_author'),
282 $this->presenter->utilities()->txt(
'meta_third_author')
290 foreach ($paths as
$path) {
291 $el = $this->navigator_factory->navigator(
294 )->lastElementAtFinalStep();
295 $inputs[array_shift($post_keys)] = $ff
296 ->text(array_shift($labels))
297 ->withValue($el?->getData()?->value() ??
'');
300 $publisher_el = $this->navigator_factory->navigator(
301 $this->path_collection->firstPublisher(),
303 )->lastElementAtFinalStep();
305 $this->presenter->utilities()->txt(
'meta_publisher'),
306 SlotIdentifier::LIFECYCLE_CONTRIBUTE_PUBLISHER,
307 $publisher_el?->getData()?->value()
312 $this->presenter->utilities()->txt(
'meta_authors')
322 if (!$this->copyright_handler->isCPSelectionActive()) {
327 $signal = $modal->getShowSignal();
328 $signal_with_oer_warning = $modal_with_oer_warning->getShowSignal();
331 yield ContentType::MODAL => $modal_with_oer_warning;
332 yield ContentType::JS_SOURCE =>
'assets/js/ilMetaCopyrightListener.js';
336 $signal_with_oer_warning
342 $message = $this->presenter->utilities()->txt(
"meta_copyright_change_info");
343 if ($with_oer_warning) {
344 $message .=
"<br/><br/>" . $this->presenter->utilities()->txt(
"meta_copyright_change_oer_info");
346 $modal = $this->ui_factory->modal()->interruptive(
347 $this->presenter->utilities()->txt(
"meta_copyright_change_warning_title"),
349 (string) $this->link_factory->custom(Command::UPDATE_DIGEST)->get()
358 Signal $signal_with_oer_warning
360 $ff = $this->ui_factory->input()->field();
362 $cp_description_el = $this->navigator_factory->navigator(
363 $this->path_collection->copyright(),
365 )->lastElementAtFinalStep();
366 $cp_description = $cp_description_el?->getData()->value();
368 $current_id = $this->copyright_handler->extractCPEntryID((
string) $cp_description);
372 $potential_oer_values = [];
373 $current_id_exists =
false;
374 $is_custom = !is_null($cp_description) && !$current_id;
376 foreach ($this->copyright_handler->getCPEntries() as $entry) {
377 if ($entry->isDefault()) {
378 $default_id = $entry->id();
380 if ($current_id === $entry->id()) {
381 $current_id_exists =
true;
384 $identifier = $this->copyright_handler->createIdentifierForID($entry->id());
389 $this->copyright_handler->isObjectTypeHarvested($set->
getRessourceID()->type()) &&
390 $this->copyright_handler->isCopyrightTemplateActive($entry)
392 $sub_inputs[self::OER_BLOCKED] = $ff
394 $this->presenter->utilities()->txt(
'meta_oer_blocked'),
395 $this->presenter->utilities()->txt(
'meta_oer_blocked_info')
398 $this->copyright_handler->isOerHarvesterBlocked($set->
getRessourceID()->objID())
400 $potential_oer_values[] = $identifier;
403 $option = $ff->group($sub_inputs, $entry->title(), $entry->description());
406 if ($entry->isOutdated()) {
407 $option = $option->withLabel(
408 '(' . $this->presenter->utilities()->txt(
'meta_copyright_outdated') .
409 ') ' . $entry->title()
410 )->withDisabled(
true);
411 $outdated[] = $identifier;
413 $options[$identifier] = $option;
418 ->textarea($this->presenter->utilities()->txt(
'meta_description'))
419 ->
withValue($is_custom ? (
string) $cp_description :
'');
420 $custom = $ff->group(
421 [self::CUSTOM_CP_DESCRIPTION => $custom_text],
422 $this->presenter->utilities()->txt(
'meta_cp_own')
424 $options[self::CUSTOM_CP] = $custom;
426 $value = self::CUSTOM_CP;
428 $id = ($current_id && $current_id_exists) ? $current_id : $default_id;
429 $value = $this->copyright_handler->createIdentifierForID(
$id);
435 $this->presenter->utilities()->txt(
'meta_copyright')
438 ->withAdditionalOnLoadCode(
439 function (
$id) use ($signal, $signal_with_oer_warning, $potential_oer_values) {
440 return 'il.MetaDataCopyrightListener.init(\'' .
442 $signal_with_oer_warning .
'\',\
'' .
443 json_encode($potential_oer_values) .
'\',\
'' .
446 )->withAdditionalTransformation( 447 $this->refinery->custom()->constraint( 448 function ($v) use ($outdated) { 449 if (in_array($v[0], $outdated, true)) { 454 $this->presenter->utilities()->txt('meta_copyright_outdated_error
') 460 $this->presenter->utilities()->txt('meta_rights
') 464 protected function buildStringFromControlledVocabInput( 466 SlotIdentifier $slot, 469 if (!$this->vocabulary_adapter->doesSlotHaveVocabularies($slot)) { 470 $input = $this->ui_factory->input()->field()->text($label); 472 $input = $input->withValue($data); 478 $raw_values = iterator_to_array($this->vocabulary_adapter->valuesInVocabulariesForSlot( 480 !$this->vocabulary_adapter->doesSlotAllowCustomInput($slot) ? $data : null 482 foreach ($this->presenter->data()->vocabularyValues($slot, ...$raw_values) as $labelled_value) { 483 $values[$labelled_value->value()] = $labelled_value->label(); 486 if (!$this->vocabulary_adapter->doesSlotAllowCustomInput($slot)) { 487 $input = $this->ui_factory->input()->field()->select($label, $values); 489 $input = $input->withValue($data); 494 $value_label = $this->presenter->utilities()->txt('md_editor_value
'); 495 $text_input = $this->ui_factory->input()->field()->text($value_label); 496 $select_input = $this->ui_factory->input()->field()->select($value_label, $values); 498 $radio_value = 'from_vocab
'; 500 if (in_array($data, $raw_values)) { 501 $select_input = $select_input->withValue($data); 502 $radio_value = 'from_vocab
'; 504 $text_input = $text_input->withValue($data); 509 $input = $this->ui_factory->input()->field()->switchableGroup( 511 'from_vocab
' => $this->ui_factory->input()->field()->group( 512 ['value
' => $select_input], 513 $this->presenter->utilities()->txt('md_editor_from_vocab_input
') 515 'custom' => $this->ui_factory->input()->field()->group( 516 ['value
' => $text_input], 517 $this->presenter->utilities()->txt('md_editor_custom_input
') 522 if (isset($radio_value)) { 523 $input = $input->withValue($radio_value); 525 return $input->withAdditionalTransformation( 526 $this->refinery->custom()->transformation(function ($vs) { 527 return $vs[1]['value
'] ?? null;
VocabularyAdapter $vocabulary_adapter
getAuthorsSection(SetInterface $set)
PresenterInterface $presenter
getChangeCopyrightModal(bool $with_oer_warning)
DataHelperInterface $data_helper
__construct(PathFactory $path_factory, NavigatorFactoryInterface $navigator_factory, UIFactory $factory, Refinery $refinery, PresenterInterface $presenter, PathCollection $path_collection, LinkFactory $link_factory, CopyrightHandler $copyright_handler, DataHelperInterface $data_helper, VocabularyAdapter $vocabulary_adapter)
buildStringFromControlledVocabInput(string $label, SlotIdentifier $slot, ?string $data=null)
PathCollection $path_collection
const string THIRD_AUTHOR
const string FIRST_AUTHOR
const string GENERAL
POST VARS.
NavigatorFactoryInterface $navigator_factory
getClassificationSection(SetInterface $set)
getCopyrightSection(SetInterface $set, Signal $signal, Signal $signal_with_oer_warning)
getCopyrightContent(SetInterface $set)
const string LEARNING_RESOURCE_TYPE
const string SECOND_AUTHOR
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getGeneralSection(SetInterface $set)
LinkFactory $link_factory
const string CLASSIFICATION
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
const string CUSTOM_CP_DESCRIPTION
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
CopyrightHandler $copyright_handler
PathFactory $path_factory