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

60 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;
2016-07-22 20:00:27 +00:00
$this->dataDir = _DATA_DIR .'/'. $app->getName () .'/image';
}
/**
* 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 (
2016-07-22 20:00:27 +00:00
'SELECT id, max_width, max_height, `schema`, `table`, `column`
FROM image_schema WHERE name = #schema'
,['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
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;
}
}
?>