Start of using Attribute objects, rendering jpegphoto
This commit is contained in:
parent
dabca67fc8
commit
10a2d2161b
@ -95,6 +95,11 @@ class Attribute
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine how we render this attribute's value
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return join('<br>',$this->values);
|
return join('<br>',$this->values);
|
||||||
|
@ -6,55 +6,7 @@ use App\Classes\LDAP\Attribute;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an attribute whose values are binary
|
* Represents an attribute whose values are binary
|
||||||
*
|
|
||||||
* @package phpLDAPadmin
|
|
||||||
* @subpackage Templates
|
|
||||||
*/
|
*/
|
||||||
class Binary extends Attribute
|
class Binary extends Attribute
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
protected $filepaths;
|
|
||||||
protected $filenames;
|
|
||||||
|
|
||||||
public function __construct($name,$values,$server_id,$source=null) {
|
|
||||||
parent::__construct($name,$values,$server_id,$source);
|
|
||||||
|
|
||||||
$this->filepaths = array();
|
|
||||||
$this->filenames = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFileNames() {
|
|
||||||
return $this->filenames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFileName($i) {
|
|
||||||
if (isset($this->filenames[$i])) return $this->filenames[$i];
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFileName($name, $i = -1) {
|
|
||||||
if ($i < 0) {
|
|
||||||
$this->filenames[] = $name;
|
|
||||||
} else {
|
|
||||||
$this->filenames[$i] = $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilePaths() {
|
|
||||||
return $this->filepaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilePath($i) {
|
|
||||||
if (isset($this->filepaths[$i])) return $this->filepaths[$i];
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addFilePath($path, $i = -1) {
|
|
||||||
if ($i < 0) {
|
|
||||||
$this->filepaths[] = $path;
|
|
||||||
} else {
|
|
||||||
$this->filepaths[$i] = $path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
@ -7,18 +7,19 @@ use App\Classes\LDAP\Attribute\Binary;
|
|||||||
/**
|
/**
|
||||||
* Represents an attribute whose values are jpeg pictures
|
* Represents an attribute whose values are jpeg pictures
|
||||||
*/
|
*/
|
||||||
class JpegPhoto extends Binary
|
final class JpegPhoto extends Binary
|
||||||
{
|
{
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
|
// We'll use finfo to try and figure out what type of image is stored
|
||||||
$f = new \finfo;
|
$f = new \finfo;
|
||||||
|
|
||||||
foreach ($this->values as $value) {
|
foreach ($this->values as $value) {
|
||||||
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
|
switch ($x=$f->buffer($value,FILEINFO_MIME_TYPE)) {
|
||||||
case 'image/jpeg':
|
case 'image/jpeg':
|
||||||
default:
|
default:
|
||||||
$result .= sprintf("<img style='display:block; width:100px;height:100px;' src='data:%s;base64, %s' />",$x,base64_encode($value));
|
$result .= sprintf('<img class="jpegphoto" src="data:%s;base64, %s" />',$x,base64_encode($value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,19 +7,24 @@ use Illuminate\Support\Facades\Log;
|
|||||||
|
|
||||||
use App\Classes\LDAP\{Attribute};
|
use App\Classes\LDAP\{Attribute};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This factory is used to return LDAP attributes as an object
|
||||||
|
*
|
||||||
|
* If there is no specific Attribute defined, then the default Attribute::class is return
|
||||||
|
*/
|
||||||
class Factory
|
class Factory
|
||||||
{
|
{
|
||||||
private const LOGKEY = 'LAf';
|
private const LOGKEY = 'LAf';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array event type to event class mapping
|
* Map of attributes to appropriate class
|
||||||
*/
|
*/
|
||||||
public const map = [
|
public const map = [
|
||||||
'jpegphoto'=>Attribute\Binary\JpegPhoto::class,
|
'jpegphoto'=>Attribute\Binary\JpegPhoto::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns new event instance
|
* Create the new Object for an attribute
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param array $values
|
* @param array $values
|
||||||
|
5
public/css/custom.css
vendored
Normal file
5
public/css/custom.css
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
img.jpegphoto {
|
||||||
|
display:block;
|
||||||
|
max-width:100px;
|
||||||
|
height:100px;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user