/** * Delete the product image from disk and remove the containing folder if empty * Handles both legacy and new image filesystems * @param bool $force_delete * @return bool */ public function deleteImage($force_delete = false) { if (!$this->image_id) { return false; } // Delete base image if (file_exists($this->image_dir . $this->getExistingImagePath() . '.' . $this->image_format)) { unlink($this->image_dir . $this->getExistingImagePath() . '.' . $this->image_format); } else { return false; } $files_to_delete = array(); // Delete auto-generated images $image_types = JeproshopImageTypeModelImageType::getImagesTypes(); foreach ($image_types as $image_type) { $files_to_delete[] = $this->image_dir . $this->getExistingImagePath() . '-' . $image_type->name . '.' . $this->image_format; } // Delete watermark image $files_to_delete[] = $this->image_dir . $this->getExistingImagePath() . '_watermark.' . $this->image_format; // delete index.php $files_to_delete[] = $this->image_dir . $this->getImageFolder() . 'index.php'; // Delete tmp images $files_to_delete[] = COM_JEPROSHOP_TEMP_IMAGE_DIR . 'product_' . $this->product_id . '.' . $this->image_format; $files_to_delete[] = COM_JEPROSHOP_TEMP_IMAGE_DIR . 'product_mini_' . $this->product_id . '.' . $this->image_format; foreach ($files_to_delete as $file) { if (file_exists($file) && !@unlink($file)) { return false; } } // Can we delete the image folder? if (is_dir($this->image_dir . $this->getImageFolder())) { $delete_folder = true; foreach (scandir($this->image_dir . $this->getImageFolder()) as $file) { if ($file != '.' && $file != '..') { $delete_folder = false; break; } } } if (isset($delete_folder) && $delete_folder) { @rmdir($this->image_dir . $this->getImageFolder()); } return true; }
/** * Assign scenes template vars */ protected function assignScenes() { // Scenes (could be externalised to another controller if you need them) $scenes = JeproshopSceneModelScene::getScenes($this->category->category_id, $this->context->language->lang_id, true, false); $this->assignRef('scenes', $scenes); // Scenes images formats if ($scenes && ($sceneImageTypes = JeproshopImageTypeModelImageType::getImagesTypes('scenes'))) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType->name == JeproshopImageTypeModelImageType::getFormatedName('m_scene')) { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType->name == JeproshopImageTypeModelImageType::getFormatedName('scene')) { $largeSceneImageType = $sceneImageType; } } $this->assignRef('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : null); $this->assignRef('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : null); } }
private function initInformationsForm() { if (!$this->context->controller->default_form_language) { $this->languages = $this->context->controller->getLanguages(); } $app = JFactory::getApplication(); $product_name_redirected = JeproshopProductModelProduct::getProductName((int) $this->product->product_redirected_id, null, (int) $this->context->language->lang_id); $this->assignRef('product_name_redirected', $product_name_redirected); /* * Form for adding a virtual product like software, mp3, etc... */ $product_download = new JeproshopProductDownloadModelProductDownload(); $product_download_id = $product_download->getIdFromProductId($this->product->product_id); if ($product_download_id) { $product_download = new JeproshopProductDownloadModelProductDownload($product_download_id); } $this->product->productDownload = $product_download; $cache_default_attribute = (int) $this->product->cache_default_attribute; $product_props = array(); // global informations array_push($product_props, 'reference', 'ean13', 'upc', 'available_for_order', 'show_price', 'online_only', 'manufacturer_id'); // specific / detailed information array_push($product_props, 'width', 'height', 'weight', 'published', 'is_virtual', 'cache_default_attribute', 'uploadable_files', 'text_fields'); // prices array_push($product_props, 'price', 'wholesale_price', 'tax_rules_group_id', 'unit_price_ratio', 'on_sale', 'unity', 'minimal_quantity', 'additional_shipping_cost', 'available_now', 'available_later', 'available_date'); if (JeproshopSettingModelSetting::getValue('use_eco_tax')) { array_push($product_props, 'ecotax'); } $this->product->name['class'] = 'updateCurrentText'; if (!$this->product->product_id || JeproshopSettingModelSetting::getValue('force_friendly_product')) { $this->product->name['class'] .= ' copy2friendlyUrl'; } $images = JeproshopImageModelImage::getImages($this->context->language->lang_id, $this->product->product_id); if (is_array($images)) { foreach ($images as $k => $image) { //$images[$k]->src = $this->context->controller->getImageLink($this->product->link_rewrite[$this->context->language->lang_id], $this->product->product_id.'-'.$image->image_id, 'small_default'); echo $images[$k]->src; } $this->assignRef('product_images', $images); } $imagesTypes = JeproshopImageTypeModelImageType::getImagesTypes('products'); $this->assignRef('imagesTypes', $imagesTypes); $this->product->tags = JeproshopTagModelTag::getProductTags($this->product->product_id); $product_type = (int) $app->input->get('product_type', $this->product->getType()); $this->assignRef('product_type', $product_type); $is_in_pack = (int) JeproshopProductPack::isPacked($this->product->product_id); $this->assignRef('is_in_pack', $is_in_pack); $check_product_association_ajax = false; if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_ALL) { $check_product_association_ajax = true; } $iso_tiny_mce = $this->context->language->iso_code; $iso_tiny_mce = file_exists(JURI::base() . '/components/com_jeproshop/assets/javascript/tiny_mce/langs/' . $iso_tiny_mce . '.js') ? $iso_tiny_mce : 'en'; $this->assignRef('iso_tiny_mce', $iso_tiny_mce); $this->assignRef('check_product_association_ajax', $check_product_association_ajax); $combinationImageJs = $this->getCombinationImagesJs(); $this->assignRef('combinationImagesJs', $combinationImageJs); }