147 lines
3.8 KiB
PHP
147 lines
3.8 KiB
PHP
<?php
|
|
|
|
use App\Services\AboHelper;
|
|
use App\Domain\DomainContext;
|
|
use App\Services\DomainService;
|
|
|
|
if (! function_exists('make_old_url')) {
|
|
function make_old_url($path)
|
|
{
|
|
return config('app.old_url') . $path;
|
|
}
|
|
}
|
|
|
|
|
|
if (! function_exists('make_old_url')) {
|
|
function make_old_url($path)
|
|
{
|
|
return config('app.old_url') . $path;
|
|
}
|
|
}
|
|
|
|
if (! function_exists('get_file_last_time')) {
|
|
function get_file_last_time($value)
|
|
{
|
|
if (file_exists($value)) {
|
|
return filemtime($value);
|
|
}
|
|
return date("Ymd-is", time());
|
|
}
|
|
}
|
|
|
|
if (! function_exists('get_user_attr')) {
|
|
function get_user_attr($key)
|
|
{
|
|
if ($user = Auth::user()) {
|
|
return $user->getSetting($key);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
if (! function_exists('set_user_attr')) {
|
|
function set_user_attr($key, $value)
|
|
{
|
|
if ($user = Auth::user()) {
|
|
return $user->setSetting([$key => $value]);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
if (! function_exists('get_active_badge')) {
|
|
function get_active_badge($active, $tooltip = false, $pos = "top")
|
|
{
|
|
if ($tooltip) {
|
|
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="' . $tooltip . '"';
|
|
}
|
|
return $active ? '<span class="badge badge-pill badge-success" ' . $tooltip . '><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger" ' . $tooltip . '><i class="fa fa-times"></i></span>';
|
|
}
|
|
}
|
|
|
|
if (! function_exists('formatNumber')) {
|
|
function formatNumber($number, $dec = 2)
|
|
{
|
|
return !$number ? $number : Util::formatNumber($number, $dec);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('reFormatNumber')) {
|
|
function reFormatNumber($number)
|
|
{
|
|
return !$number ? $number : Util::reFormatNumber($number);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('cleanNumberFormat')) {
|
|
function cleanNumberFormat($number)
|
|
{
|
|
return !$number ? $number : Util::cleanNumberFormat($number);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('formatDate')) {
|
|
function formatDate($date)
|
|
{
|
|
return Carbon::parse($date)->format(\Util::formatDateDB());
|
|
}
|
|
}
|
|
|
|
if (! function_exists('maxStrLength')) {
|
|
function maxStrLength($str, $lenght = 40)
|
|
{
|
|
return !$str ? $str : Util::maxStrLength($str, $lenght);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('get_abo_type_badge_by_product')) {
|
|
function get_abo_type_badge_by_product($product)
|
|
{
|
|
return AboHelper::getAboTypeBadge(AboHelper::getAboShowOn($product));
|
|
}
|
|
}
|
|
|
|
if (! function_exists('get_abo_type_badge')) {
|
|
function get_abo_type_badge($type)
|
|
{
|
|
return AboHelper::getAboTypeBadge($type);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('cleanIntegerFromString')) {
|
|
function cleanIntegerFromString($value)
|
|
{
|
|
return Util::cleanIntegerFromString($value);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('formatTextWithLineBreaks')) {
|
|
function formatTextWithLineBreaks($text, $translate = false)
|
|
{
|
|
return Util::formatTextWithLineBreaks($text, $translate);
|
|
}
|
|
}
|
|
|
|
if (! function_exists('legal_url')) {
|
|
/**
|
|
* Generate URL for legal pages that should always point to shop domain from checkout
|
|
*/
|
|
function legal_url($path)
|
|
{
|
|
try {
|
|
// HOTFIX: DomainContext temporär deaktiviert
|
|
// TODO: Nach Claude v2 Implementation wieder aktivieren
|
|
// $context = app(DomainContext::class);
|
|
// if ($context->type === 'checkout') {
|
|
// $domainService = app(DomainService::class);
|
|
// return $domainService->buildUrl('main', $path);
|
|
// }
|
|
|
|
// Temporär: Verwende immer normale URL generation
|
|
return url($path);
|
|
} catch (Exception $e) {
|
|
// Fallback to normal URL if something goes wrong
|
|
return url($path);
|
|
}
|
|
}
|
|
}
|