forked from verdnatura/hedera-web
60 lines
1.1 KiB
PHP
60 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
require_once ('vn/web/json-request.php');
|
||
|
require_once (__DIR__.'/image.php');
|
||
|
|
||
|
/**
|
||
|
* Base class for image methods.
|
||
|
**/
|
||
|
abstract class ImageRequest extends Vn\Web\JsonRequest
|
||
|
{
|
||
|
protected $dataDir;
|
||
|
|
||
|
function __construct ($app)
|
||
|
{
|
||
|
parent::__construct ($app);
|
||
|
$this->dataDir = _DATA_DIR .'/'. $app->getName () .'/image';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Loads information for specified schema.
|
||
|
*
|
||
|
* @param string $schema The schema name
|
||
|
**/
|
||
|
function loadInfo ($schema)
|
||
|
{
|
||
|
$db = $this->getSysConn ();
|
||
|
|
||
|
$info = $conn->getRow (
|
||
|
'SELECT id, max_width, max_height, `schema`, `table`, `column`
|
||
|
FROM image_schema WHERE name = #schema'
|
||
|
,['schema' => $schema]
|
||
|
);
|
||
|
|
||
|
if (!$info)
|
||
|
return NULL;
|
||
|
|
||
|
$res = $conn->query (
|
||
|
'SELECT width, height, crop
|
||
|
FROM image_schema_size WHERE image_schema_id = #id'
|
||
|
,['id' => $info['id']]
|
||
|
);
|
||
|
|
||
|
$info['sizes'] = [];
|
||
|
|
||
|
while ($r = $res->fetch_assoc ())
|
||
|
{
|
||
|
$size = "{$r['width']}x{$r['height']}";
|
||
|
$info['sizes'][$size] = [
|
||
|
'width' => $r['width'],
|
||
|
'height' => $r['height'],
|
||
|
'crop' => $r['crop']
|
||
|
];
|
||
|
}
|
||
|
|
||
|
return $info;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|