mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
PHRAS-1260_INDEX-WIDTH-HEIGHT
- new : added size (filesize) of document to es - new : methods getWidth(),... to record_adapter - fix : template
This commit is contained in:
@@ -98,6 +98,13 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
/** @var DateTime */
|
||||
private $updated;
|
||||
|
||||
/** @var bool|null|integer */
|
||||
private $width;
|
||||
/** @var bool|null|integer */
|
||||
private $height;
|
||||
/** @var bool|null|integer */
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param integer $sbas_id
|
||||
@@ -111,6 +118,8 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
$this->reference = RecordReference::createFromDataboxIdAndRecordId($sbas_id, $record_id);
|
||||
$this->number = (int)$number;
|
||||
|
||||
$this->width = $this->height = $this->size = false; // means unknown for now
|
||||
|
||||
if ($load) {
|
||||
$this->load();
|
||||
}
|
||||
@@ -171,6 +180,42 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
public function getWidth()
|
||||
{
|
||||
$this->getDocInfos();
|
||||
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
public function getHeight()
|
||||
{
|
||||
$this->getDocInfos();
|
||||
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
$this->getDocInfos();
|
||||
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
private function getDocInfos()
|
||||
{
|
||||
if($this->width === false) { // strict false means unknown
|
||||
try {
|
||||
$doc = $this->get_subdef('document');
|
||||
$this->width = $doc->get_width();
|
||||
$this->height = $doc->get_height();
|
||||
$this->size = $doc->get_size();
|
||||
} catch (\Exception $e) {
|
||||
// failing once is failing ever
|
||||
$this->width = $this->height = $this->size = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
* @deprecated use {@link self::getUpdated} instead
|
||||
|
Reference in New Issue
Block a user