19 declare(strict_types=1);
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()) {
250 $signal = $modal->getShowSignal();
253 yield ContentType::JS_SOURCE =>
'Services/MetaData/js/ilMetaCopyrightListener.js';
259 $modal = $this->ui_factory->modal()->interruptive(
260 $this->presenter->utilities()->txt(
"meta_copyright_change_warning_title"),
261 $this->presenter->utilities()->txt(
"meta_copyright_change_info"),
262 (string) $this->link_factory->custom(Command::UPDATE_DIGEST)->get()
272 $ff = $this->ui_factory->input()->field();
274 $cp_description_el = $this->navigator_factory->navigator(
275 $this->path_collection->copyright(),
277 )->lastElementAtFinalStep();
278 $cp_description = $cp_description_el?->getData()->value();
280 $current_id = $this->copyright_handler->extractCPEntryID((
string) $cp_description);
284 $current_id_exists =
false;
285 $is_custom = !is_null($cp_description) && !$current_id;
287 foreach ($this->copyright_handler->getCPEntries() as $entry) {
288 if ($entry->isDefault()) {
289 $default_id = $entry->id();
291 if ($current_id === $entry->id()) {
292 $current_id_exists =
true;
298 $this->copyright_handler->doesObjectTypeSupportHarvesting($set->
getRessourceID()->type()) &&
299 $this->copyright_handler->isCopyrightTemplateActive($entry)
301 $sub_inputs[self::OER_BLOCKED] = $ff
303 $this->presenter->utilities()->txt(
'meta_oer_blocked'),
304 $this->presenter->utilities()->txt(
'meta_oer_blocked_info')
307 $this->copyright_handler->isOerHarvesterBlocked($set->
getRessourceID()->objID())
311 $option = $ff->group($sub_inputs, $entry->title());
312 $identifier = $this->copyright_handler->createIdentifierForID($entry->id());
315 if ($entry->isOutdated()) {
316 $option = $option->withLabel(
317 '(' . $this->presenter->utilities()->txt(
'meta_copyright_outdated') .
318 ') ' . $entry->title()
320 $outdated[] = $identifier;
322 $options[$identifier] = $option;
327 ->textarea($this->presenter->utilities()->txt(
'meta_description'))
328 ->
withValue($is_custom ? (
string) $cp_description :
'');
329 $custom = $ff->group(
330 [self::CUSTOM_CP_DESCRIPTION => $custom_text],
331 $this->presenter->utilities()->txt(
'meta_cp_own')
333 $options[self::CUSTOM_CP] = $custom;
335 $value = self::CUSTOM_CP;
337 $id = ($current_id && $current_id_exists) ? $current_id : $default_id;
338 $value = $this->copyright_handler->createIdentifierForID(
$id);
344 $this->presenter->utilities()->txt(
'meta_copyright')
347 ->withAdditionalOnLoadCode(
348 function (
$id) use ($signal) {
349 return 'il.MetaDataCopyrightListener.init("' .
350 $signal .
'","' .
$id .
'");';
353 $this->
refinery->custom()->constraint(
354 function ($v) use ($outdated) {
355 if (in_array($v[0], $outdated,
true)) {
360 $this->presenter->utilities()->txt(
'meta_copyright_outdated_error')
366 $this->presenter->utilities()->txt(
'meta_rights')
373 $ff = $this->ui_factory->input()->field();
376 $tlt_el = $this->navigator_factory->navigator(
377 $path = $this->path_collection->firstTypicalLearningTime(),
379 )->lastElementAtFinalStep();
380 $matches = iterator_to_array(
381 $this->data_helper->durationToIterator($tlt_el?->getData()?->value() ??
'')
383 $num = $ff->numeric(
'placeholder')
384 ->withAdditionalTransformation($this->
refinery->int()->isGreaterThanOrEqual(0));
386 $this->presenter->utilities()->txt(
'years'),
387 $this->presenter->utilities()->txt(
'months'),
388 $this->presenter->utilities()->txt(
'days'),
389 $this->presenter->utilities()->txt(
'hours'),
390 $this->presenter->utilities()->txt(
'minutes'),
391 $this->presenter->utilities()->txt(
'seconds')
394 foreach ($labels as
$key => $label) {
397 ->withValue($matches[
$key] ?? null);
402 )->withAdditionalTransformation(
403 $this->
refinery->custom()->transformation(
function ($vs) use ($dh) {
404 $vs = array_map(fn ($v) => is_null($v) ? $v : (
int) $v, $vs);
405 return $dh->durationFromIntegers(...$vs);
410 [
$path->toString() => $group],
411 $this->presenter->utilities()->txt(
'meta_typical_learning_time')
getAuthorsSection(SetInterface $set)
PresenterInterface $presenter
DataHelperInterface $data_helper
PathCollection $path_collection
__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
getCopyrightContent(SetInterface $set)
getGeneralSection(SetInterface $set)
LinkFactory $link_factory
const TYPICAL_LEARNING_TIME
getChangeCopyrightModal()
const CUSTOM_CP_DESCRIPTION
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
CopyrightHandler $copyright_handler
PathFactory $path_factory
getCopyrightSection(SetInterface $set, Signal $signal)