Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

556
 
608
 
608
 
image.php
_> 1111 */
  1212 
  1313   class osC_Image {
<> 14 -    var $_data;
   14+    var $_groups;
1515 
  1616     function osC_Image() {
<> 17 -      global $osC_Database;
   17+      global $osC_Database, $osC_Language;
1818 
<> 19 -      $Qgroups = $osC_Database->query('select distinct id, code, size_height as height, size_width as width from :table_products_images_groups');
   19+      $this->_groups = array();
   20+
   21+      $Qgroups = $osC_Database->query('select * from :table_products_images_groups where language_id = :language_id');
2022       $Qgroups->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
<> 21 -      $Qgroups->setCache('images_groups');
   23+      $Qgroups->bindInt(':language_id', $osC_Language->getID());
   24+      $Qgroups->setCache('images_groups-' . $osC_Language->getID());
2225       $Qgroups->execute();
  2326 
  2427       while ($Qgroups->next()) {
<> 25 -        $this->_data[$Qgroups->value('code')] = $Qgroups->toArray();
   28+        $this->_groups[$Qgroups->valueInt('id')] = $Qgroups->toArray();
2629       }
  2730 
  2831       $Qgroups->freeResult();
  2932     }
  3033 
  3134     function getID($code) {
<> 32 -      return $this->_data[$code]['id'];
   35+      foreach ($this->_groups as $group) {
   36+        if ($group['code'] == $code) {
   37+          return $group['id'];
   38+        }
   39+      }
   40+
   41+      return 0;
3342     }
  3443 
<>  44+    function getCode($id) {
   45+      return $this->_groups[$id]['code'];
   46+    }
   47+
3548     function getWidth($code) {
<> 36 -      return $this->_data[$code]['width'];
   49+      return $this->_groups[$this->getID($code)]['size_width'];
3750     }
  3851 
  3952     function getHeight($code) {
<> 40 -      return $this->_data[$code]['height'];
   53+      return $this->_groups[$this->getID($code)]['size_height'];
4154     }
  4255 
<> 43 -    function show(&$image, &$title = '', $parameters = '', $group = 'default') {
  44 -      if (isset($this->_data[$group]) === false) {
  45 -        $group = 'default';
   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);
4663       }
  4764 
<> 48 -      return tep_image(DIR_WS_IMAGES . $image, $title, $this->_data[$group]['width'], $this->_data[$group]['height'], $parameters);
   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);
4981     }
<>  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+    }
<_ 5088   }
  5189 ?>