forked from verdnatura/hedera-web
59 lines
1018 B
PHP
59 lines
1018 B
PHP
<?php
|
|
|
|
require_once (__DIR__.'/image.php');
|
|
|
|
/**
|
|
* Base class for image methods.
|
|
*/
|
|
class Util
|
|
{
|
|
var $app;
|
|
var $dataDir;
|
|
|
|
function __construct ($app)
|
|
{
|
|
$this->app = $app;
|
|
$this->dataDir = _DATA_DIR .'/'. $app->getName () .'/image-db';
|
|
}
|
|
|
|
/**
|
|
* Loads information for specified schema.
|
|
*
|
|
* @param string $schema The schema name
|
|
*/
|
|
function loadInfo ($schema)
|
|
{
|
|
$db = $this->app->getSysConn ();
|
|
|
|
$info = $db->getRow (
|
|
'SELECT id, maxWidth, maxHeight, `schema`, `table`, `column`
|
|
FROM imageCollection WHERE name = #schema'
|
|
,['schema' => $schema]
|
|
);
|
|
|
|
if (!$info)
|
|
return NULL;
|
|
|
|
$res = $db->query (
|
|
'SELECT width, height, crop
|
|
FROM imageCollectionSize WHERE collectionFk = #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;
|
|
}
|
|
}
|
|
|