forked from koala-framework/koala-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Welcome.php
41 lines (40 loc) · 1.4 KB
/
Welcome.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
class Kwf_Util_Model_Welcome extends Kwf_Model_Db
implements Kwf_Media_Output_Interface
{
protected $_table = 'kwf_welcome';
protected $_rowClass = 'Kwf_Util_Model_Row_Welcome';
protected $_referenceMap = array(
'WelcomeImage' => array(
'column' => 'kwf_upload_id',
'refModelClass' => 'Kwf_Uploads_Model',
),
'LoginImage' => array(
'column' => 'login_kwf_upload_id',
'refModelClass' => 'Kwf_Uploads_Model',
)
);
public static function getImageDimensions($type)
{
if ($type == 'LoginImageLarge') {
return array(350, 150, 'cover' => false);
} else if ($type == 'LoginImage') {
return array(300, 80, 'cover' => false);
} else if ($type == 'WelcomeImage') {
return array(300, 100, 'cover' => false);
}
}
public static function getMediaOutput($id, $type, $className)
{
$row = Kwf_Model_Abstract::getInstance($className)->getRow($id);
$dim = self::getImageDimensions($type);
if ($type == 'LoginImageLarge') {
$type = 'LoginImage';
}
$uploadRow = $row->getParentRow($type);
return array(
'contents'=>Kwf_Media_Image::scale($uploadRow, $dim, $uploadRow->id),
'mimeType' => $row->getParentRow($type)->mime_type
);
}
}