Global Flags Provided
This commit is contained in:
parent
70c74e1233
commit
6a49f55300
|
|
@ -13,6 +13,20 @@ class Locale extends Model implements LocaleContract
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* List of all default locale images for velocity.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultImage = [
|
||||
'de' => 'flags/de.png',
|
||||
'en' => 'flags/en.png',
|
||||
'es' => 'flags/es.png',
|
||||
'fr' => 'flags/fr.png',
|
||||
'nl' => 'flags/nl.png',
|
||||
'tr' => 'flags/tr.png',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
|
@ -46,19 +60,9 @@ class Locale extends Model implements LocaleContract
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function image_url()
|
||||
public function getImageUrlAttribute(): string
|
||||
{
|
||||
if (! $this->locale_image) {
|
||||
$defaultLocaleImagePath = 'themes/velocity/assets/images/flags/' . $this->code . '.png';
|
||||
|
||||
if (file_exists(public_path($defaultLocaleImagePath))) {
|
||||
return asset($defaultLocaleImagePath);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
return Storage::url($this->locale_image);
|
||||
return $this->image_url();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -66,8 +70,24 @@ class Locale extends Model implements LocaleContract
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImageUrlAttribute()
|
||||
public function image_url(): string
|
||||
{
|
||||
return $this->image_url();
|
||||
if (! $this->locale_image) {
|
||||
return $this->getDefaultImageSource();
|
||||
}
|
||||
|
||||
return Storage::url($this->locale_image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default image source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultImageSource(): string
|
||||
{
|
||||
return isset($this->defaultImage[$this->code]) && file_exists($this->defaultImage[$this->code])
|
||||
? asset($this->defaultImage[$this->code])
|
||||
: '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Webkul\Velocity\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Attribute\Repositories\AttributeOptionRepository;
|
||||
use Webkul\Product\Facades\ProductImage;
|
||||
use Webkul\Product\Helpers\Review;
|
||||
|
|
@ -64,20 +63,6 @@ class Helper extends Review
|
|||
*/
|
||||
protected $velocityMetadataRepository;
|
||||
|
||||
/**
|
||||
* List of all default locale images for velocity.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultLocaleImageSources = [
|
||||
'de' => '/themes/velocity/assets/images/flags/de.png',
|
||||
'en' => '/themes/velocity/assets/images/flags/en.png',
|
||||
'es' => '/themes/velocity/assets/images/flags/es.png',
|
||||
'fr' => '/themes/velocity/assets/images/flags/fr.png',
|
||||
'nl' => '/themes/velocity/assets/images/flags/nl.png',
|
||||
'tr' => '/themes/velocity/assets/images/flags/tr.png'
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a helper instance.
|
||||
*
|
||||
|
|
@ -181,7 +166,7 @@ class Helper extends Review
|
|||
}
|
||||
|
||||
foreach ($brandName as $brandKey => $brandvalue) {
|
||||
$brandImplode[$brandKey][] = implode(' | ', array_map("ucfirst", $brandvalue));
|
||||
$brandImplode[$brandKey][] = implode(' | ', array_map('ucfirst', $brandvalue));
|
||||
}
|
||||
|
||||
return $brandImplode;
|
||||
|
|
@ -215,13 +200,13 @@ class Helper extends Review
|
|||
try {
|
||||
$metaData = $this->velocityMetadataRepository->findOneWhere([
|
||||
'locale' => $locale,
|
||||
'channel' => $channel
|
||||
'channel' => $channel,
|
||||
]);
|
||||
|
||||
if (! $metaData && $default) {
|
||||
$metaData = $this->velocityMetadataRepository->findOneWhere([
|
||||
'locale' => 'en',
|
||||
'channel' => 'default'
|
||||
'channel' => 'default',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +276,7 @@ class Helper extends Review
|
|||
if (is_string($path) && is_readable($path)) {
|
||||
return include $path;
|
||||
} else {
|
||||
$currentLocale = "en";
|
||||
$currentLocale = 'en';
|
||||
|
||||
$path = __DIR__ . "/../Resources/lang/$currentLocale/app.php";
|
||||
|
||||
|
|
@ -336,8 +321,8 @@ class Helper extends Review
|
|||
$galleryImages = ProductImage::getGalleryImages($product);
|
||||
$productImage = ProductImage::getProductBaseImage($product, $galleryImages)['medium_image_url'];
|
||||
|
||||
$largeProductImageName = "large-product-placeholder.png";
|
||||
$mediumProductImageName = "meduim-product-placeholder.png";
|
||||
$largeProductImageName = 'large-product-placeholder.png';
|
||||
$mediumProductImageName = 'meduim-product-placeholder.png';
|
||||
|
||||
if (strpos($productImage, $mediumProductImageName) > -1) {
|
||||
$productImageNameCollection = explode('/', $productImage);
|
||||
|
|
@ -368,7 +353,7 @@ class Helper extends Review
|
|||
'product' => $product,
|
||||
'addWishlistClass' => ! (isset($list) && $list) ? '' : '',
|
||||
|
||||
'showCompare' => core()->getConfigData('general.content.shop.compare_option') == "1"
|
||||
'showCompare' => core()->getConfigData('general.content.shop.compare_option') == '1'
|
||||
? true : false,
|
||||
|
||||
'btnText' => (isset($metaInformation['btnText']) && $metaInformation['btnText'])
|
||||
|
|
@ -408,39 +393,9 @@ class Helper extends Review
|
|||
'priceHTML' => $formattedProduct['priceHTML'],
|
||||
'new' => $formattedProduct['new'],
|
||||
'addToCartHtml' => $formattedProduct['addToCartHtml'],
|
||||
'galleryImages' => $formattedProduct['galleryImages']
|
||||
'galleryImages' => $formattedProduct['galleryImages'],
|
||||
]);
|
||||
}
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current locale image source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentLocaleImageSource(): string
|
||||
{
|
||||
$localeImages = core()->getCurrentChannel()->locales()->pluck('locale_image', 'code');
|
||||
|
||||
$currentLocaleImage = $localeImages[app()->getLocale()] ?? null;
|
||||
|
||||
return $currentLocaleImage
|
||||
? Storage::url($currentLocaleImage)
|
||||
: $this->getDefaultImageSourceOfCurrentLocale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default image source of current locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultImageSourceOfCurrentLocale(): string
|
||||
{
|
||||
$currentLocale = app()->getLocale();
|
||||
|
||||
return isset($this->defaultLocaleImageSources[$currentLocale])
|
||||
? asset($this->defaultLocaleImageSources[$currentLocale])
|
||||
: '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Loading…
Reference in New Issue