Order slides get a "ranking" setting without a correct solution: the stage shows the live average ranking, participants only get a confirmation. The image placement question in the slide form is only shown for an existing image or a chosen file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
85 lines
4.6 KiB
PHP
85 lines
4.6 KiB
PHP
<?php
|
|
/**
|
|
* Image fields of the slide form: upload, alternative text, layout, remove.
|
|
* Not for slide types without image support (YouTube).
|
|
*
|
|
* @var \App\View\AppView $this
|
|
* @var \App\Model\Entity\Slide $slide
|
|
* @var \App\Model\Entity\Poll $poll
|
|
*/
|
|
|
|
use App\Model\Entity\Slide;
|
|
use App\Service\ImageService;
|
|
use Cake\Core\Configure;
|
|
|
|
if (!Slide::supportsImage($slide->type)) {
|
|
return;
|
|
}
|
|
$request = $this->getRequest();
|
|
$posted = $request->is(['post', 'put', 'patch']);
|
|
$hasImage = $slide->hasImage();
|
|
// After a failed save the posted values are shown again.
|
|
$layout = $posted && in_array($request->getData('image_layout'), Slide::IMAGE_LAYOUTS, true)
|
|
? (string)$request->getData('image_layout')
|
|
: $slide->imageLayout();
|
|
$layouts = [
|
|
Slide::IMAGE_TOP => __('Oben (über den Antworten bzw. Ergebnissen)'),
|
|
Slide::IMAGE_SIDE => __('Daneben (Bild links, Text und Ergebnis rechts)'),
|
|
];
|
|
if ($slide->type === Slide::TYPE_CONTENT) {
|
|
$layouts[Slide::IMAGE_FULL] = __('Bildschirm füllen (Bild so groß wie möglich)');
|
|
}
|
|
$imageError = $slide->getError('image');
|
|
$maxMb = (int)round((int)Configure::read('Plenario.images.maxUploadBytes', 10 * 1024 * 1024) / 1024 / 1024);
|
|
?>
|
|
<fieldset class="image-fields" data-image-fields<?= $hasImage ? ' data-has-image' : '' ?>>
|
|
<legend><?= __('Bild (optional)') ?></legend>
|
|
<?php if (!ImageService::isAvailable()) : ?>
|
|
<p class="hint"><?= __('Bilder sind auf diesem Server nicht verfügbar (PHP-Erweiterung GD mit WebP fehlt).') ?></p>
|
|
<?php else : ?>
|
|
<?php if ($hasImage) : ?>
|
|
<figure class="image-fields__current">
|
|
<img src="<?= h($this->Url->build(['_name' => 'participate:image', 'code' => $poll->join_code, 'file' => $slide->image])) ?>"
|
|
alt="<?= h((string)$slide->image_alt) ?>" width="<?= (int)$slide->image_width ?>" height="<?= (int)$slide->image_height ?>">
|
|
</figure>
|
|
<?php // Without JavaScript the checkbox does the job; with it, the button toggles the same checkbox. ?>
|
|
<div class="image-fields__remove" data-image-remove>
|
|
<?= $this->Form->control('remove_image', [
|
|
'type' => 'checkbox',
|
|
'label' => __('Bild entfernen'),
|
|
'value' => '1',
|
|
'hiddenField' => false,
|
|
'checked' => false,
|
|
]) ?>
|
|
<button type="button" class="button button--danger button--small" hidden aria-pressed="false" data-image-remove-button
|
|
data-label-remove="<?= h(__('Bild entfernen')) ?>" data-label-undo="<?= h(__('Entfernen rückgängig machen')) ?>">
|
|
<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
|
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
<path d="M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14M10 11v5M14 11v5"/>
|
|
</svg>
|
|
<span data-label><?= __('Bild entfernen') ?></span>
|
|
</button>
|
|
<span class="hint" role="status" aria-live="polite" data-image-remove-status></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="input file<?= $imageError ? ' error' : '' ?>">
|
|
<label for="image-file"><?= $hasImage ? __('Anderes Bild hochladen') : __('Bild hochladen') ?></label>
|
|
<input type="file" id="image-file" name="image" accept="image/jpeg,image/png,image/webp,image/gif"
|
|
aria-describedby="image-hint<?= $imageError ? ' image-error' : '' ?>" <?= $imageError ? 'aria-invalid="true"' : '' ?>>
|
|
<p class="hint" id="image-hint"><?= __('JPEG, PNG, WebP oder GIF (nicht animiert), bis {0} MB. Das Bild wird automatisch auf höchstens 1600 Pixel verkleinert und als WebP gespeichert, Kameradaten wie der Aufnahmeort werden dabei entfernt.', $maxMb) ?></p>
|
|
<?php if ($imageError) : ?>
|
|
<div class="error-message" id="image-error"><?= h(implode(' ', (array)$imageError)) ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<fieldset class="scale-style image-fields__layout" data-image-layout>
|
|
<legend><?= __('Platzierung in der Präsentation') ?></legend>
|
|
<?= $this->Form->radio('image_layout', array_map(
|
|
fn($value, $text) => ['value' => $value, 'text' => $text],
|
|
array_keys($layouts),
|
|
$layouts,
|
|
), ['value' => $layout]) ?>
|
|
<p class="hint"><?= __('Auf dem Smartphone der Teilnehmenden steht das Bild immer oben.') ?></p>
|
|
</fieldset>
|
|
<?php endif; ?>
|
|
</fieldset>
|