2021-12-08 12:26:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\LDAP\Attribute\Binary;
|
|
|
|
|
|
|
|
use App\Classes\LDAP\Attribute\Binary;
|
|
|
|
|
|
|
|
/**
|
2023-03-02 07:21:53 +00:00
|
|
|
* Represents an JpegPhoto Attribute
|
2021-12-08 12:26:12 +00:00
|
|
|
*/
|
2021-12-10 11:39:09 +00:00
|
|
|
final class JpegPhoto extends Binary
|
2021-12-08 12:26:12 +00:00
|
|
|
{
|
2023-03-01 22:54:30 +00:00
|
|
|
public function __construct(string $name,array $values)
|
|
|
|
{
|
|
|
|
parent::__construct($name,$values);
|
|
|
|
|
|
|
|
$this->internal = FALSE;
|
|
|
|
}
|
|
|
|
|
2021-12-08 12:26:12 +00:00
|
|
|
public function __toString(): string
|
|
|
|
{
|
2021-12-10 11:39:09 +00:00
|
|
|
// We'll use finfo to try and figure out what type of image is stored
|
2021-12-08 12:26:12 +00:00
|
|
|
$f = new \finfo;
|
|
|
|
|
2023-03-01 22:54:30 +00:00
|
|
|
$result = '<table class="table table-borderless p-0 m-0"><tr>';
|
|
|
|
|
2021-12-08 12:26:12 +00:00
|
|
|
foreach ($this->values as $value) {
|
|
|
|
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
|
|
|
|
case 'image/jpeg':
|
|
|
|
default:
|
2023-03-01 22:54:30 +00:00
|
|
|
$result .= sprintf('<td><img class="jpegphoto" src="data:%s;base64, %s" />%s</td>',
|
|
|
|
$x,
|
|
|
|
base64_encode($value),
|
2023-03-02 03:41:38 +00:00
|
|
|
$this->is_deletable ? sprintf('<br><span class="btn btn-sm btn-danger"><i class="fas fa-trash-alt"></i> %s</span>',__('Delete')) : '');
|
2021-12-08 12:26:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-01 22:54:30 +00:00
|
|
|
$result .= '</tr></table>';
|
|
|
|
|
2021-12-08 12:26:12 +00:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|