Merge pull request #2008 from jygaulier/PHRAS-1260_INDEX-WIDTH-HEIGHT

Phras 1260 index width height
This commit is contained in:
Thibaud Fabre
2016-11-03 16:22:26 +01:00
committed by GitHub
8 changed files with 147 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