Quick Search:

View

Revision:

Diff

Diff from 602 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/includes/classes/image.php

Annotated File View

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
583
14     var $_groups;
hpdl
555
15
16     function osC_Image() {
hpdl
583
17       global $osC_Database, $osC_Language;
hpdl
555
18
hpdl
583
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
583
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
583
28         $this->_groups[$Qgroups->valueInt('id')] = $Qgroups->toArray();
hpdl
555
29       }
30
31       $Qgroups->freeResult();
32     }
33
34     function getID($code) {
hpdl
583
35       foreach ($this->_groups as $group) {
36         if ($group['code'] == $code) {
37           return $group['id'];
38         }
39       }
40
hpdl
599
41       return 0;
hpdl
555
42     }
43
hpdl
583
44     function getCode($id) {
45       return $this->_groups[$id]['code'];
46     }
47
hpdl
555
48     function getWidth($code) {
hpdl
583
49       return $this->_groups[$this->getID($code)]['size_width'];
hpdl
555
50     }
51
52     function getHeight($code) {
hpdl
583
53       return $this->_groups[$this->getID($code)]['size_height'];
hpdl
555
54     }
55
hpdl
559
56     function show(&$image, &$title, $parameters = '', $group = 'default') {
hpdl
583
57       $group_id = $this->getID($group);
58
59       $width = $height = '';
60
hpdl
602
61       if ( ($this->_groups[$group_id]['force_size'] == '1') || empty($image) ) {
hpdl
583
62         $width = $this->_groups[$group_id]['size_width'];
63         $height = $this->_groups[$group_id]['size_height'];
hpdl
555
64       }
65
hpdl
602
66       if (empty($image)) {
67         $image = 'pixel_trans.gif';
68       } else {
69         $image = 'products/' . $this->_groups[$group_id]['code'] . '/' . $image;
70       }
71
72       return tep_image(DIR_WS_HTTP_CATALOG . DIR_WS_IMAGES . $image, $title, $width, $height, $parameters);
hpdl
555
73     }
hpdl
583
74
75     function getAddress(&$image, $group = 'default') {
76       $group_id = $this->getID($group);
77
78       return DIR_WS_IMAGES . 'products/' . $this->_groups[$group_id]['code'] . '/' . $image;
79     }
hpdl
555
80   }
hpdl
583
81 ?>
    \ No newline at end of file