CMXX - dealers

This commit is contained in:
“VeLiTi”
2025-05-08 13:42:19 +02:00
parent c3e5873912
commit da78217dd9
6 changed files with 226 additions and 50 deletions

View File

@@ -4013,7 +4013,7 @@ function getDomainName($hostname) {
// encode ID to UUID
//=======================================
function encodeUuid($number) {
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&?-';
$base = strlen($alphabet);
$encoded = '';
@@ -4035,7 +4035,9 @@ function encodeUuid($number) {
// decode UUID to ID
//=======================================
function decodeUuid($encoded) {
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$encoded = strtoupper($encoded);
$alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&?-';
$base = strlen($alphabet);
$number = 0;
@@ -4398,3 +4400,76 @@ function generateDealerInformation($token){
return false;
}
function removeTrailingElement($string,$element) {
// Trim whitespace from the end
$trimmed = rtrim($string);
// Check if the trimmed string is not empty and ends with a comma
if (!empty($trimmed) && substr($trimmed, -1) === $element) {
// Remove the last character (the comma)
return substr($trimmed, 0, -1);
}
// Return original string if it doesn't end with a comma
return $trimmed;
}
function processPostContent(array $post_content): array
{
// Use provided values if they exist and are not empty
if (isset($post_content['budget']) && !empty($post_content['budget'])) {
$budget = $post_content['budget'];
}
if (isset($post_content['showroom_quality']) && !empty($post_content['showroom_quality'])) {
$showroom_quality = $post_content['showroom_quality'];
}
if (isset($post_content['brand_category']) && !empty($post_content['brand_category'])) {
$brand_category = $post_content['brand_category'];
}
// Check if 'focus_offering' is available and not empty
if (isset($post_content['focus_offering']) && !empty($post_content['focus_offering'])) {
// 1. Add budget based on focus_offering if budget wasn't provided
if (!isset($budget)) {
$post_content['budget'] = $post_content['focus_offering'];
}
// Ensure 'dealer_type' is available for showroom_quality logic
if (isset($post_content['dealer_type'])) {
$dealer_type = $post_content['dealer_type'];
// 2, 3, 4. Determine showroom_quality if it wasn't provided
if (!isset($showroom_quality)) {
if ($post_content['focus_offering'] == 0 && $dealer_type == 0) {
$post_content['showroom_quality'] = 0;
} elseif (($post_content['focus_offering'] == 0 && $dealer_type == 1) || ($post_content['focus_offering'] == 1 && $dealer_type == 0)) {
$post_content['showroom_quality'] = 1;
} elseif ($post_content['focus_offering'] == 1 && $dealer_type == 1) {
$post_content['showroom_quality'] = 2;
}
}
}
}
// 5. Determine brand_category based on showroom_quality if it exists and brand_category wasn't provided
if (isset($post_content['showroom_quality']) && !isset($brand_category)) {
if ($post_content['showroom_quality'] == 2){
$post_content['brand_category'] = 2;
} elseif ($post_content['showroom_quality'] == 0){
$post_content['brand_category'] = 0;
} else {
$post_content['brand_category'] = 1;
}
}
if (isset($post_content['name']) && (isset($post_content['dealer_slug']) && $post_content['dealer_slug'] == '')){
$trimmedString = trim($post_content['name']);
$post_content['dealer_slug'] = str_replace(" ", "_", $trimmedString);
}
return $post_content;
}