public function __construct($image_id = null, $lang_id = null) { //parent::__construct($id, $id_lang); if ($lang_id !== null) { $this->lang_id = JeproshopSettingModelSetting::getLanguage($lang_id) !== false ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($image_id) { $cache_id = 'jeproshop_image_model_' . (int) $image_id . '_' . (int) $lang_id; if (!JeproshopCache::isStored($cache_id)) { $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_image') . " AS image "; if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_image_lang') . " AS image_lang ON "; $query .= "(image." . $db->quoteName('image_id') . " = image_lang." . $db->quoteName('image_id'); $query .= " AND image." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") "; } $query .= "WHERE image." . $db->quoteName('image_id') . " = " . (int) $image_id; $db->setQuery($query); $image_data = $db->loadObject(); if ($image_data) { if (!$lang_id && isset($this->multilang) && $this->multilang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_image_lang'); $query .= " WHERE image_id = " . (int) $image_id; $db->setQuery($query); $image_lang_data = $db->loadObjectList(); if ($image_lang_data) { foreach ($image_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'image_id') { if (!isset($image_data->{$key}) || !is_array($image_data->{$key})) { $image_data->{$key} = array(); } $image_data->{$key}[$row->lang_id] = $value; } } } } JeproshopCache::store($cache_id, $image_data); } } } else { $image_data = JeproshopCache::retrieve($cache_id); } if ($image_data) { $image_data->image_id = $image_id; foreach ($image_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } $this->image_dir = COM_JEPROSHOP_PRODUCT_IMAGE_DIR; $this->source_index = COM_JEPROSHOP_PRODUCT_IMAGE_DIR . 'index.php'; }