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:
Jean-Yves Gaulier
2016-11-03 15:27:57 +01:00
parent 68ab86d9d4
commit 229c80fe74
8 changed files with 140 additions and 20 deletions

View File

@@ -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