hpdl
|
555
|
1
|
<?php
|
|
2
|
/*
|
|
3
|
$Id: $
|
|
4
|
|
|
5
|
osCommerce, Open Source E-Commerce Solutions
|
|
6
|
http://www.oscommerce.com
|
|
7
|
|
|
8
|
Copyright (c) 2006 osCommerce
|
|
9
|
|
|
10
|
Released under the GNU General Public License
|
|
11
|
*/
|
|
12
|
|
|
13
|
class osC_Image {
|
hpdl
|
608
|
14
|
var $_groups;
|
hpdl
|
555
|
15
|
|
|
16
|
function osC_Image() {
|
hpdl
|
608
|
17
|
global $osC_Database, $osC_Language;
|
hpdl
|
555
|
18
|
|
hpdl
|
608
|
19
|
$this->_groups = array();
|
|
20
|
|
|
21
|
$Qgroups = $osC_Database->query('select * from :table_products_images_groups where language_id = :language_id');
|
hpdl
|
556
|
22
|
$Qgroups->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
|
hpdl
|
608
|
23
|
$Qgroups->bindInt(':language_id', $osC_Language->getID());
|
|
24
|
$Qgroups->setCache('images_groups-' . $osC_Language->getID());
|
hpdl
|
555
|
25
|
$Qgroups->execute();
|
|
26
|
|
|
27
|
while ($Qgroups->next()) {
|
hpdl
|
608
|
28
|
$this->_groups[$Qgroups->valueInt('id')] = $Qgroups->toArray();
|
hpdl
|
555
|
29
|
}
|
|
30
|
|
|
31
|
$Qgroups->freeResult();
|
|
32
|
}
|
|
33
|
|
|
34
|
function getID($code) {
|
hpdl
|
608
|
35
|
foreach ($this->_groups as $group) {
|
|
36
|
if ($group['code'] == $code) {
|
|
37
|
return $group['id'];
|
|
38
|
}
|
|
39
|
}
|
|
40
|
|
|
41
|
return 0;
|
hpdl
|
555
|
42
|
}
|
|
43
|
|
hpdl
|
608
|
44
|
function getCode($id) {
|
|
45
|
return $this->_groups[$id]['code'];
|
|
46
|
}
|
|
47
|
|
hpdl
|
555
|
48
|
function getWidth($code) {
|
hpdl
|
608
|
49
|
return $this->_groups[$this->getID($code)]['size_width'];
|
hpdl
|
555
|
50
|
}
|
|
51
|
|
|
52
|
function getHeight($code) {
|
hpdl
|
608
|
53
|
return $this->_groups[$this->getID($code)]['size_height'];
|
hpdl
|
555
|
54
|
}
|
|
55
|
|
hpdl
|
608
|
56
|
function exists($code) {
|
|
57
|
return isset($this->_groups[$this->getID($code)]);
|
|
58
|
}
|
|
59
|
|
|
60
|
function show(&$image, &$title, $parameters = '', $group = '') {
|
|
61
|
if (empty($group) || !$this->exists($group)) {
|
|
62
|
$group = $this->getCode(DEFAULT_IMAGE_GROUP_ID);
|
hpdl
|
555
|
63
|
}
|
|
64
|
|
hpdl
|
608
|
65
|
$group_id = $this->getID($group);
|
|
66
|
|
|
67
|
$width = $height = '';
|
|
68
|
|
|
69
|
if ( ($this->_groups[$group_id]['force_size'] == '1') || empty($image) ) {
|
|
70
|
$width = $this->_groups[$group_id]['size_width'];
|
|
71
|
$height = $this->_groups[$group_id]['size_height'];
|
|
72
|
}
|
|
73
|
|
|
74
|
if (empty($image)) {
|
|
75
|
$image = 'pixel_trans.gif';
|
|
76
|
} else {
|
|
77
|
$image = 'products/' . $this->_groups[$group_id]['code'] . '/' . $image;
|
|
78
|
}
|
|
79
|
|
|
80
|
return tep_image(DIR_WS_HTTP_CATALOG . DIR_WS_IMAGES . $image, $title, $width, $height, $parameters);
|
hpdl
|
555
|
81
|
}
|
hpdl
|
608
|
82
|
|
|
83
|
function getAddress(&$image, $group = 'default') {
|
|
84
|
$group_id = $this->getID($group);
|
|
85
|
|
|
86
|
return DIR_WS_IMAGES . 'products/' . $this->_groups[$group_id]['code'] . '/' . $image;
|
|
87
|
}
|
hpdl
|
555
|
88
|
}
|
|
89
|
?>
|