Skip to content

Commit

Permalink
Merge branch 'release/8.12.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdenardis committed Oct 14, 2024
2 parents 5c0560a + 765272c commit 1d2589a
Show file tree
Hide file tree
Showing 15 changed files with 1,645 additions and 1,667 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public function show(Request $request): View|Redirector|RedirectResponse
abort('404');
}

if(!empty($article['article']['data']['link'])) {
if (!empty($article['article']['data']['link'])) {
$linkURL = parse_url($article['article']['data']['link']);

if(!empty($linkURL['host'])) {
if (!empty($linkURL['host'])) {
return redirect($article['article']['data']['link']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomepageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function index(Request $request): View

$modularComponents['modularComponents'] = [];

if(!empty($request->data['base']['data'])) {
if (!empty($request->data['base']['data'])) {
$modularComponents['modularComponents'] = $this->modularComponent->getModularComponents($request->data['base']);
$promos['components'] = $modularComponents['modularComponents'];
}
Expand Down
40 changes: 20 additions & 20 deletions app/Repositories/ModularPageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
*/
public function getModularComponents(array $data): array
{
if(empty($data['data'])) {
if (empty($data['data'])) {
return [];
}

Expand Down Expand Up @@ -97,11 +97,11 @@ public function getModularComponents(array $data): array
$components = $this->parseData($data);
$promos = $this->getPromos($components, $data['site']['id'] ?? '');

foreach($components['components'] as $name => $component) {
if(Str::startsWith($name, 'events')) {
foreach ($components['components'] as $name => $component) {
if (Str::startsWith($name, 'events')) {
$components['components'][$name]['id'] = $component['id'] ?? $data['site']['id'];
$limit = $components['components'][$name]['limit'] ?? 4;
if(strpos($name, 'events-column') !== false) {
if (strpos($name, 'events-column') !== false) {
$events = $this->event->getEvents($component['id'] ?? $data['site']['id'], $limit);
} else {
$events = $this->event->getEventsFullListing($component['id'] ?? $data['site']['id'], $limit);
Expand All @@ -111,7 +111,7 @@ public function getModularComponents(array $data): array
if (empty($modularComponents[$name]['component']['cal_name']) && !empty($data['site']['events']['path'])) {
$modularComponents[$name]['component']['cal_name'] = $data['site']['events']['path'];
}
} elseif(Str::startsWith($name, 'news')) {
} elseif (Str::startsWith($name, 'news')) {
$components['components'][$name]['id'] = $component['id'] ?? $data['site']['news']['application_id'];
$limit = $component['limit'] ?? 4;
$components['components'][$name]['news_route'] = $component['news_route'] ?? config('base.news_listing_route');
Expand All @@ -125,7 +125,7 @@ public function getModularComponents(array $data): array
}
$modularComponents[$name]['data'] = $articles['articles'] ?? [];
$modularComponents[$name]['component'] = $components['components'][$name];
} elseif(Str::startsWith($name, 'page-content') || Str::startsWith($name, 'heading')) {
} elseif (Str::startsWith($name, 'page-content') || Str::startsWith($name, 'heading')) {
// If there's JSON but no news, events or promo data, assign the component array as data
// Page-content and heading components
$modularComponents[$name]['data'][] = $components['components'][$name] ?? [];
Expand All @@ -146,8 +146,8 @@ public function parseData(array $data)
$group_reference = [];
$group_config = [];

foreach($data['data'] as $pageField => $value) {
if(Str::startsWith($pageField, 'modular-')) {
foreach ($data['data'] as $pageField => $value) {
if (Str::startsWith($pageField, 'modular-')) {
$name = Str::replaceFirst('modular-', '', $pageField);

// Remove all spaces and line breaks
Expand All @@ -156,20 +156,20 @@ public function parseData(array $data)
// Last item cannot have comma at the end of it
$value = preg_replace('(,})', '}', $value);

if(Str::startsWith($value, '{')) {
if (Str::startsWith($value, '{')) {
$components[$name] = json_decode($value, true);
if(!empty($components[$name]['config'])) {
if (!empty($components[$name]['config'])) {
$config = explode('|', $components[$name]['config']);
// Add youtube
if(strpos($components[$name]['config'], 'youtube') === false) {
if (strpos($components[$name]['config'], 'youtube') === false) {
array_push($config, 'youtube');
}
foreach($config as $key => $value) {
if(Str::startsWith($value, 'page_id')) {
foreach ($config as $key => $value) {
if (Str::startsWith($value, 'page_id')) {
$config[$key] = 'page_id:'.$data['page']['id'];
}

if(Str::startsWith($value, 'first')) {
if (Str::startsWith($value, 'first')) {
unset($config[$key]);
}
}
Expand All @@ -180,9 +180,9 @@ public function parseData(array $data)
$components[$name]['id'] = (int)$value;
}

if(!Str::startsWith($name, ['events', 'news']) && !empty($components[$name]['id'])) {
if (!Str::startsWith($name, ['events', 'news']) && !empty($components[$name]['id'])) {
$group_reference[$components[$name]['id']] = $name;
if(!empty($components[$name]['config'])) {
if (!empty($components[$name]['config'])) {
$group_config[$name] = $components[$name]['config'];
}
}
Expand Down Expand Up @@ -235,7 +235,7 @@ public function getPromos($components, $site_id)
})->toArray();

// Organize by option
if(!empty($components['components'][$name]['groupByOptions']) && $components['components'][$name]['groupByOptions'] === true && Str::startsWith($name, 'catalog')) {
if (!empty($components['components'][$name]['groupByOptions']) && $components['components'][$name]['groupByOptions'] === true && Str::startsWith($name, 'catalog')) {
$data = $this->organizePromoItemsByOption($data);
}

Expand All @@ -251,15 +251,15 @@ public function getPromos($components, $site_id)

public function adjustPromoData($data, $component)
{
if(isset($component['singlePromoView']) && $component['singlePromoView'] === true) {
if (isset($component['singlePromoView']) && $component['singlePromoView'] === true) {
$data['link'] = 'view/'.Str::slug($data['title']).'-'.$data['promo_item_id'];
}

if(isset($component['showExcerpt']) && $component['showExcerpt'] === false) {
if (isset($component['showExcerpt']) && $component['showExcerpt'] === false) {
unset($data['excerpt']);
}

if(isset($component['showDescription']) && $component['showDescription'] === false) {
if (isset($component['showDescription']) && $component['showDescription'] === false) {
unset($data['description']);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/PromoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function manipulateGlobalPromos(array $promos, array $groups, array $data
return !str_contains($component_name, 'hero');
})->toArray();

if(!empty($hero)) {
if (!empty($hero)) {
$hero_key = array_key_first($hero);
$promos['hero'] = $promos['components'][$hero_key]['data'];
config(['base.hero_full_controllers' => [$data['page']['controller']]]);
Expand Down
Loading

0 comments on commit 1d2589a

Please sign in to comment.