SpreadQuiz/class/Tasks/PicturedTask.php
2025-10-14 17:55:25 +02:00

53 lines
1.2 KiB
PHP

<?php
require_once "class/Task.php";
class PicturedTask extends Task
{
private string $image_data; // image data or the URL
private string $image_type; // the type of the image
function __construct(string $type, array &$a = null)
{
parent::__construct($type, $a);
$this->image_data = $a["image_data"] ?? ($a["image_url"] ?? "");
$this->image_type = $a["image_type"] ?? "none";
}
function setImageData(string $image_data): void
{
$this->image_data = $image_data;
}
function getImageData(): string
{
return $this->image_data;
}
function setImageType(string $image_type): void {
$this->image_type = $image_type;
}
function getImageType(): string {
return $this->image_type;
}
function setUrlData(string $url_data): void {
$this->setImageData($url_data);
$this->setImageType("url");
}
function setHtmlData(string $svg_data): void {
$this->setImageData($svg_data);
$this->setImageType("html");
}
function toArray(string $mode = "all"): array
{
$a = parent::toArray($mode);
$a["image_data"] = $this->image_data;
$a["image_type"] = $this->image_type;
return $a;
}
}