Quick Search:

View

Revision:

Diff

Diff from 1498 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/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
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
555
13 */
14
15   class osC_Image {
hpdl
608
16     var $_groups;
hpdl
555
17
18     function osC_Image() {
hpdl
608
19       global $osC_Database, $osC_Language;
hpdl
555
20
hpdl
608
21       $this->_groups = array();
22
23       $Qgroups = $osC_Database->query('select * from :table_products_images_groups where language_id = :language_id');
hpdl
556
24       $Qgroups->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
hpdl
608
25       $Qgroups->bindInt(':language_id', $osC_Language->getID());
26       $Qgroups->setCache('images_groups-' . $osC_Language->getID());
hpdl
555
27       $Qgroups->execute();
28
29       while ($Qgroups->next()) {
hpdl
608
30         $this->_groups[$Qgroups->valueInt('id')] = $Qgroups->toArray();
hpdl
555
31       }
32
33       $Qgroups->freeResult();
34     }
35
36     function getID($code) {
hpdl
608
37       foreach ($this->_groups as $group) {
38         if ($group['code'] == $code) {
39           return $group['id'];
40         }
41       }
42
43       return 0;
hpdl
555
44     }
45
hpdl
608
46     function getCode($id) {
47       return $this->_groups[$id]['code'];
48     }
49
hpdl
555
50     function getWidth($code) {
hpdl
608
51       return $this->_groups[$this->getID($code)]['size_width'];
hpdl
555
52     }
53
54     function getHeight($code) {
hpdl
608
55       return $this->_groups[$this->getID($code)]['size_height'];
hpdl
555
56     }
57
hpdl
608
58     function exists($code) {
59       return isset($this->_groups[$this->getID($code)]);
60     }
61
hpdl
613
62     function show($image, $title, $parameters = '', $group = '') {
hpdl
608
63       if (empty($group) || !$this->exists($group)) {
64         $group = $this->getCode(DEFAULT_IMAGE_GROUP_ID);
hpdl
555
65       }
66
hpdl
608
67       $group_id = $this->getID($group);
68
69       $width = $height = '';
70
71       if ( ($this->_groups[$group_id]['force_size'] == '1') || empty($image) ) {
72         $width = $this->_groups[$group_id]['size_width'];
73         $height = $this->_groups[$group_id]['size_height'];
74       }
75
76       if (empty($image)) {
77         $image = 'pixel_trans.gif';
78       } else {
79         $image = 'products/' . $this->_groups[$group_id]['code'] . '/' . $image;
80       }
81
hpdl
754
82       return osc_image(DIR_WS_IMAGES . $image, $title, $width, $height, $parameters);
hpdl
555
83     }
hpdl
608
84
hpdl
910
85     function getAddress($image, $group = 'default') {
hpdl
608
86       $group_id = $this->getID($group);
87
88       return DIR_WS_IMAGES . 'products/' . $this->_groups[$group_id]['code'] . '/' . $image;
89     }
hpdl
555
90   }
hpdl
609
91 ?>
    \ No newline at end of file