From 9a3be241e775926318f3100a3f28caee98faffc7 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Mon, 19 Aug 2024 06:26:53 +0000 Subject: [PATCH] correctly display original name, fixes #4419 Closes #4419 Merge request studip/studip!3277 --- app/controllers/course/contentmodules.php | 3 +++ app/views/course/contentmodules/rename.php | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/course/contentmodules.php b/app/controllers/course/contentmodules.php index 2a661cf01cc..99f5fc31aa7 100644 --- a/app/controllers/course/contentmodules.php +++ b/app/controllers/course/contentmodules.php @@ -214,6 +214,9 @@ class Course_ContentmodulesController extends AuthenticatedController $this->module = PluginManager::getInstance()->getPluginById($module_id); $this->metadata = $this->module->getMetadata(); + + $this->original_name = $this->metadata['diplayname'] ?? $this->module->getPluginName(); + PageLayout::setTitle(_('Werkzeug umbenennen')); $this->tool = ToolActivation::find([$context->id, $module_id]); diff --git a/app/views/course/contentmodules/rename.php b/app/views/course/contentmodules/rename.php index f2ee2488a6b..f92ef7b7cb3 100644 --- a/app/views/course/contentmodules/rename.php +++ b/app/views/course/contentmodules/rename.php @@ -1,3 +1,12 @@ +<?php +/** + * @var Course_ContentmodulesController $controller + * @var StudipModule $module + * @var string $original_name + * @var array $metadata + * @var ToolActivation $tool + */ +?> <form class="default" action="<?= $controller->link_for('course/contentmodules/rename/' . $module->getPluginId()) ?>" method="post"> @@ -7,17 +16,17 @@ <?= _('Neuer Name des Werkzeugs') ?> <input type="text" name="displayname" - value="<?= $tool && $tool['metadata'] ? htmlReady($tool['metadata']['displayname']) : ''?>" - placeholder="<?= htmlReady($metadata['displayname'] ?? '') ?>"> + value="<?= htmlReady($tool['metadata']['displayname'] ?? '') ?>" + placeholder="<?= htmlReady($original_name) ?>"> </label> <div> - <?= htmlReady(sprintf(_('Ursprünglicher Werkzeugname ist "%s".'), $metadata['displayname'] ?? '')) ?> + <?= htmlReady(sprintf(_('Ursprünglicher Werkzeugname ist "%s".'), $original_name)) ?> </div> </fieldset> <div data-dialog-button> <?= \Studip\Button::create(_('Speichern'))?> - <? if ($tool && $tool['metadata'] && $tool['metadata']['displayname']) : ?> + <? if (!empty($tool['metadata']['displayname'])) : ?> <?= \Studip\Button::create(_('Namen löschen'), 'delete') ?> <? endif ?> </div> -- GitLab