19 declare(strict_types=1);
44 public const string RIGHTS =
'rights';
77 $this->ui_factory = $factory;
98 if ($type === ContentType::FORM) {
99 $sections[self::RIGHTS] = $entity;
102 yield $type => $entity;
105 $form = $this->ui_factory->input()->container()->form()->standard(
106 (
string) $this->link_factory->custom(Command::UPDATE_DIGEST)->get(),
110 if (isset($request)) {
111 $form = $request->applyRequestToForm($form);
113 yield ContentType::FORM => $form;
119 $ff = $this->ui_factory->input()->field();
123 $title_el = $this->navigator_factory->navigator(
124 $path = $this->path_collection->title(),
126 )->lastElementAtFinalStep();
128 ->text($this->presenter->utilities()->txt(
'meta_title'))
130 ->withValue($title_el?->getData()?->value() ??
'');
132 $descr_els = $this->navigator_factory->navigator(
133 $descr_path = $this->path_collection->descriptions(),
135 )->elementsAtFinalStep();
136 $descr_els = iterator_to_array($descr_els);
137 $label = $this->presenter->utilities()->txt(
'meta_description');
139 foreach ($descr_els as $el) {
140 $empty_descr =
false;
141 $label_with_lang = $label;
142 foreach ($el->getSuperElement()->getSubElements() as $sub) {
144 $sub->getDefinition()->name() !==
'language' ||
145 ($value = $sub->getData()->value()) ===
'' 149 $label_with_lang .=
' (' . $this->presenter->data()->language($value) .
')';
151 $inputs[$this->path_factory->toElement($el,
true)->toString()] = $ff
152 ->textarea($label_with_lang)
153 ->withValue($el->getData()->value());
156 $inputs[$descr_path->toString()] = $ff
161 foreach ($this->data_helper->getAllLanguages() as $key) {
162 $langs[$key] = $this->presenter->data()->language($key);
164 $lang_input = $ff->select(
165 $this->presenter->utilities()->txt(
'meta_language'),
168 $lang_els = $this->navigator_factory->navigator(
169 $langs_path = $this->path_collection->languages(),
171 )->elementsAtFinalStep();
173 foreach ($lang_els as $el) {
174 $empty_langs =
false;
175 $inputs[$this->path_factory->toElement($el,
true)->toString()] = (clone $lang_input)
179 $inputs[$langs_path->toString()] = clone $lang_input;
183 $keyword_els = $this->navigator_factory->navigator(
184 $keywords_path = $this->path_collection->keywords(),
186 )->elementsAtFinalStep();
187 foreach ($keyword_els as $el) {
188 if (!$el->isScaffold()) {
189 $keywords[] = $el->getData()->value();
192 $inputs[self::KEYWORDS] = $ff->tag(
193 $this->presenter->utilities()->txt(
'keywords'),
199 $this->presenter->utilities()->txt(
'meta_general')
206 $ff = $this->ui_factory->input()->field();
210 $this->path_collection->firstAuthor(),
211 $this->path_collection->secondAuthor(),
212 $this->path_collection->thirdAuthor()
215 $this->presenter->utilities()->txt(
'meta_first_author'),
216 $this->presenter->utilities()->txt(
'meta_second_author'),
217 $this->presenter->utilities()->txt(
'meta_third_author')
224 foreach ($paths as
$path) {
225 $el = $this->navigator_factory->navigator(
228 )->lastElementAtFinalStep();
229 $inputs[array_shift($post_keys)] = $ff
230 ->text(array_shift($labels))
231 ->withValue($el?->getData()?->value() ??
'');
236 $this->presenter->utilities()->txt(
'meta_authors')
246 if (!$this->copyright_handler->isCPSelectionActive()) {
251 $signal = $modal->getShowSignal();
252 $signal_with_oer_warning = $modal_with_oer_warning->getShowSignal();
255 yield ContentType::MODAL => $modal_with_oer_warning;
256 yield ContentType::JS_SOURCE =>
'assets/js/ilMetaCopyrightListener.js';
260 $signal_with_oer_warning
266 $message = $this->presenter->utilities()->txt(
"meta_copyright_change_info");
267 if ($with_oer_warning) {
268 $message .=
"<br/><br/>" . $this->presenter->utilities()->txt(
"meta_copyright_change_oer_info");
270 $modal = $this->ui_factory->modal()->interruptive(
271 $this->presenter->utilities()->txt(
"meta_copyright_change_warning_title"),
273 (string) $this->link_factory->custom(Command::UPDATE_DIGEST)->get()
282 Signal $signal_with_oer_warning
284 $ff = $this->ui_factory->input()->field();
286 $cp_description_el = $this->navigator_factory->navigator(
287 $this->path_collection->copyright(),
289 )->lastElementAtFinalStep();
290 $cp_description = $cp_description_el?->getData()->value();
292 $current_id = $this->copyright_handler->extractCPEntryID((
string) $cp_description);
296 $potential_oer_values = [];
297 $current_id_exists =
false;
298 $is_custom = !is_null($cp_description) && !$current_id;
300 foreach ($this->copyright_handler->getCPEntries() as $entry) {
301 if ($entry->isDefault()) {
302 $default_id = $entry->id();
304 if ($current_id === $entry->id()) {
305 $current_id_exists =
true;
308 $identifier = $this->copyright_handler->createIdentifierForID($entry->id());
313 $this->copyright_handler->isObjectTypeHarvested($set->
getRessourceID()->type()) &&
314 $this->copyright_handler->isCopyrightTemplateActive($entry)
316 $sub_inputs[self::OER_BLOCKED] = $ff
318 $this->presenter->utilities()->txt(
'meta_oer_blocked'),
319 $this->presenter->utilities()->txt(
'meta_oer_blocked_info')
322 $this->copyright_handler->isOerHarvesterBlocked($set->
getRessourceID()->objID())
324 $potential_oer_values[] = $identifier;
327 $option = $ff->group($sub_inputs, $entry->title(), $entry->description());
330 if ($entry->isOutdated()) {
331 $option = $option->withLabel(
332 '(' . $this->presenter->utilities()->txt(
'meta_copyright_outdated') .
333 ') ' . $entry->title()
335 $outdated[] = $identifier;
337 $options[$identifier] = $option;
342 ->textarea($this->presenter->utilities()->txt(
'meta_description'))
343 ->
withValue($is_custom ? (
string) $cp_description :
'');
344 $custom = $ff->group(
345 [self::CUSTOM_CP_DESCRIPTION => $custom_text],
346 $this->presenter->utilities()->txt(
'meta_cp_own')
348 $options[self::CUSTOM_CP] = $custom;
350 $value = self::CUSTOM_CP;
352 $id = ($current_id && $current_id_exists) ? $current_id : $default_id;
353 $value = $this->copyright_handler->createIdentifierForID(
$id);
359 $this->presenter->utilities()->txt(
'meta_copyright')
362 ->withAdditionalOnLoadCode(
363 function (
$id) use ($signal, $signal_with_oer_warning, $potential_oer_values) {
364 return 'il.MetaDataCopyrightListener.init(\'' .
366 $signal_with_oer_warning .
'\',\
'' .
367 json_encode($potential_oer_values) .
'\',\
'' .
370 )->withAdditionalTransformation( 371 $this->refinery->custom()->constraint( 372 function ($v) use ($outdated) { 373 if (in_array($v[0], $outdated, true)) { 378 $this->presenter->utilities()->txt('meta_copyright_outdated_error
') 384 $this->presenter->utilities()->txt('meta_rights
') 388 protected function getTypicalLearningTimeSection( 391 $ff = $this->ui_factory->input()->field(); 394 $tlt_el = $this->navigator_factory->navigator( 395 $path = $this->path_collection->firstTypicalLearningTime(), 397 )->lastElementAtFinalStep(); 398 $matches = iterator_to_array( 399 $this->data_helper->durationToIterator($tlt_el?->getData()?->value() ?? '') 401 $num = $ff->numeric('placeholder
') 402 ->withAdditionalTransformation($this->refinery->int()->isGreaterThanOrEqual(0)); 404 $this->presenter->utilities()->txt('years
'), 405 $this->presenter->utilities()->txt('months
'), 406 $this->presenter->utilities()->txt('days
'), 407 $this->presenter->utilities()->txt('hours
'), 408 $this->presenter->utilities()->txt('minutes
'), 409 $this->presenter->utilities()->txt('seconds
') 412 foreach ($labels as $key => $label) { 413 $inputs[] = (clone $num) 415 ->withValue($matches[$key] ?? null); 417 $dh = $this->data_helper; 420 )->withAdditionalTransformation( 421 $this->refinery->custom()->transformation(function ($vs) use ($dh) { 422 $vs = array_map(fn($v) => is_null($v) ? $v : (int) $v, $vs); 423 return $dh->durationFromIntegers(...$vs); 428 [$path->toString() => $group], 429 $this->presenter->utilities()->txt('meta_typical_learning_time
')
getAuthorsSection(SetInterface $set)
PresenterInterface $presenter
getChangeCopyrightModal(bool $with_oer_warning)
DataHelperInterface $data_helper
PathCollection $path_collection
const string THIRD_AUTHOR
const string FIRST_AUTHOR
__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)
getTypicalLearningTimeSection(SetInterface $set)
NavigatorFactoryInterface $navigator_factory
getCopyrightSection(SetInterface $set, Signal $signal, Signal $signal_with_oer_warning)
getCopyrightContent(SetInterface $set)
const string SECOND_AUTHOR
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getGeneralSection(SetInterface $set)
LinkFactory $link_factory
const string TYPICAL_LEARNING_TIME
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
const string CUSTOM_CP_DESCRIPTION
CopyrightHandler $copyright_handler
PathFactory $path_factory