0
1
Fork 0
hedera-web-mindshore/rest/image/util.php

59 lines
1020 B
PHP
Raw Normal View History

2016-07-22 20:00:27 +00:00
<?php
require_once (__DIR__.'/image.php');
/**
* Base class for image methods.
**/
2016-08-25 10:47:09 +00:00
class Util
2016-07-22 20:00:27 +00:00
{
2016-08-25 10:47:09 +00:00
var $app;
var $dataDir;
2016-07-22 20:00:27 +00:00
function __construct ($app)
{
2016-08-25 10:47:09 +00:00
$this->app = $app;
$this->dataDir = _DATA_DIR .'/'. $app->getName () .'/image-db';
2016-07-22 20:00:27 +00:00
}
/**
* Loads information for specified schema.
*
* @param string $schema The schema name
**/
function loadInfo ($schema)
{
2016-08-25 10:47:09 +00:00
$db = $this->app->getSysConn ();
2016-07-22 20:00:27 +00:00
2016-08-25 10:47:09 +00:00
$info = $db->getRow (
2017-12-20 11:34:04 +00:00
'SELECT id, maxWidth, maxHeight, `schema`, `table`, `column`
FROM imageCollection WHERE name = #schema'
2016-07-22 20:00:27 +00:00
,['schema' => $schema]
);
if (!$info)
return NULL;
2016-08-25 10:47:09 +00:00
$res = $db->query (
2016-07-22 20:00:27 +00:00
'SELECT width, height, crop
2017-12-20 11:34:04 +00:00
FROM imageCollectionSize WHERE collectionFk = #id'
2016-07-22 20:00:27 +00:00
,['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;
}
}
2016-10-11 14:45:10 +00:00