Skip to content

Commit

Permalink
Merge pull request #692 from waynestate/release/8.8.0
Browse files Browse the repository at this point in the history
Release/8.8.0
  • Loading branch information
breakdancingcat committed Feb 2, 2024
2 parents acd4e50 + 97cefbc commit 5896dd9
Show file tree
Hide file tree
Showing 99 changed files with 1,767 additions and 562 deletions.
2 changes: 0 additions & 2 deletions app/Http/Controllers/ChildpageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function index(Request $request): View
$request->data['base']['hero'] = $components['components'][$hero_key]['data'];

unset($components['components'][$hero_key]);

config(['base.hero_full_controllers' => ['ChildpageController']]);
}

return view('childpage', merge($request->data, $components));
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/HomepageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(HomepageRepositoryContract $promo, ArticleRepository
*/
public function index(Request $request): View
{
// $request->data['base']['show_site_menu'] = false;
// $promos = $this->promo->getHomepagePromos();

$articles = $this->article->listing($request->data['base']['site']['news']['application_id']);
Expand Down
43 changes: 41 additions & 2 deletions app/Repositories/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function getEvents($site_id, $limit = 4)
$params = [
'method' => 'calendar.events.listing',
'site' => $site_id,
'limit' => $limit ?? 4,
'end_date' => $end_date ?? date('Y-m-d', strtotime('+6 month')),
'limit' => $limit,
'end_date' => date('Y-m-d', strtotime('+6 month')),
];

$events['events'] = $this->cache->remember($params['method'].md5(serialize($params)), config('cache.ttl'), function () use ($params) {
Expand All @@ -56,4 +56,43 @@ public function getEvents($site_id, $limit = 4)

return $events;
}

/**
* {@inheritdoc}
*/
public function getEventsFullListing($site_id, $limit = 4)
{
$params = [
'method' => 'calendar.events.fulllisting',
'site' => $site_id,
'limit' => 50,
'end_date' => $end_date ?? date('Y-m-d', strtotime('+6 month')),
];

$events['events'] = $this->cache->remember($params['method'].md5(serialize($params)), config('cache.ttl'), function () use ($params, $limit) {
$this->wsuApi->nextRequestProduction();

$events_listing = $this->wsuApi->sendRequest($params['method'], $params);

if (!empty($events_listing['events'])) {
$events = collect($events_listing['events'])
->map(function ($event) {
if (!empty($event['images'])) {
$event['display_image'] = collect($event['images'])->first();
} else {
$event['display_image']['full_url'] = 'https://wayne.edu/opengraph/wsu-social-share-square.jpg';
$event['display_image']['description'] = 'Event on wayne.edu';
}

return $event;
})
->take($limit)
->toArray();
}

return $events ?? [];
});

return $events;
}
}
7 changes: 0 additions & 7 deletions app/Repositories/MenuRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ public function getMenus(array $data, array $menus)
$menus['show_site_menu'] = false;
}

// Add to full hero controllers list if the page has no site menu or its not being shown
if ((!empty($menus['site_menu']) && empty($menus['site_menu']['menu'])) || (!empty($menus['site_menu']['menu']) && $menus['show_site_menu'] === false)) {
$controllers = config('base.hero_full_controllers');
array_push($controllers, $data['page']['controller']);
config(['base.hero_full_controllers' => $controllers]);
}

return $menus;
}

Expand Down
43 changes: 36 additions & 7 deletions app/Repositories/ModularPageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,42 @@ public function getModularComponents(array $data): array
}

$components = $this->parseData($data);
$promos = $this->getPromos($components);
$promos = $this->getPromos($components, $data['site']['id'] ?? '');

foreach($components['components'] as $name => $component) {
if(Str::startsWith($name, 'events')) {
$components['components'][$name]['id'] = $component['id'] ?? $data['site']['id'];
$events = $this->event->getEvents($component['id'] ?? $data['site']['id']);
$limit = $components['components'][$name]['limit'] ?? 4;
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);
}
$modularComponents[$name]['data'] = $events['events'] ?? [];
$modularComponents[$name]['component'] = $components['components'][$name];
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')) {
$components['components'][$name]['id'] = $component['id'] ?? $data['site']['news']['application_id'];
$components['components'][$name]['limit'] = $component['limit'] ?? 4;
$limit = $component['limit'] ?? 4;
$components['components'][$name]['news_route'] = $component['news_route'] ?? config('base.news_listing_route');
if (!empty($component['featured']) && $component['featured'] === true) {
$articles = $this->article->listing($components['components'][$name]['id'], 50, 1, $component['topics'] ?? []);
$articles['articles']['data'] = collect($articles['articles']['data'])->filter(function ($article) {
return !empty($article['featured']['featured']) && $article['featured']['featured'] === 1;
})->take($component['limit'] ?? 4)->toArray();
})->take($limit)->toArray();
} else {
$articles = $this->article->listing($components['components'][$name]['id'], $component['limit'] ?? 4, 1, $component['topics'] ?? []);
$articles = $this->article->listing($components['components'][$name]['id'], $limit, 1, $component['topics'] ?? []);
}
$modularComponents[$name]['data'] = $articles['articles'] ?? [];
$modularComponents[$name]['component'] = $components['components'][$name];
} 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] ?? [];
$modularComponents[$name]['component'] = $components['components'][$name] ?? [];
unset($modularComponents[$name]['component']['heading']);
} else {
$modularComponents[$name]['data'] = $promos[$name]['data'] ?? [];
$modularComponents[$name]['component'] = $promos[$name]['component'] ?? [];
Expand All @@ -145,11 +156,14 @@ public function parseData(array $data)
// Last item cannot have comma at the end of it
$value = preg_replace('(,})', '}', $value);

//if(Str::isJson($value)) { // this isn't working, integers are considered json with this
if(Str::startsWith($value, '{')) {
$components[$name] = json_decode($value, true);
if(!empty($components[$name]['config'])) {
$config = explode('|', $components[$name]['config']);
// Add youtube
if(strpos($components[$name]['config'], 'youtube') === false) {
array_push($config, 'youtube');
}
foreach($config as $key => $value) {
if(Str::startsWith($value, 'page_id')) {
$config[$key] = 'page_id:'.$data['page']['id'];
Expand Down Expand Up @@ -182,7 +196,7 @@ public function parseData(array $data)
];
}

public function getPromos($components)
public function getPromos($components, $site_id)
{
$params = [
'method' => 'cms.promotions.listing',
Expand All @@ -195,6 +209,21 @@ public function getPromos($components)
return $this->wsuApi->sendRequest($params['method'], $params);
});

// TODO Allowing the use of another site's promo items only from base
if (!empty($site_id) && $site_id === 1561) {
$promos['promotions'] = collect($promos['promotions'])->map(function ($promo) {
if (!empty($promo['filename_url'])) {
$promo['relative_url'] = $promo['filename_url'];
}

if (!empty($promo['secondary_filename_url'])) {
$promo['secondary_relative_url'] = $promo['secondary_filename_url'];
}

return $promo;
})->toArray();
}

$promos = $this->parsePromos->parse($promos, $components['group_reference'], $components['group_config']);

foreach ($promos as $name => $data) {
Expand Down
17 changes: 1 addition & 16 deletions config/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,6 @@
*/
'homepage_menu_enabled' => true,

/*
|--------------------------------------------------------------------------
| Hero Full Width
|--------------------------------------------------------------------------
|
| This enables hero images to span 100% across the top of the site. You
| can specify which controllers you want this to work on by adding to
| the array. If a controller is not listed it will be contained
| within the content-area. If a page isn't in the menu and top
| menu is enabled then the controller will automatically act
| as if it was in this array.
|
*/
'hero_full_controllers' => ['HomepageController'],

/*
|--------------------------------------------------------------------------
| Hero Rotating
Expand Down Expand Up @@ -263,7 +248,7 @@
'id' => 3001,
'config' => 'page_id:{$page_id}|randomize|limit:1',
],
'banner' => [
'flag' => [
'id' => 4246,
'config' => 'page_id:{$page_id}|first',
],
Expand Down
61 changes: 61 additions & 0 deletions factories/EventFullListing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Factories;

use Contracts\Factories\FactoryContract;
use Faker\Factory;

class EventFullListing implements FactoryContract
{
/**
* Construct the factory.
*/
public function __construct(Factory $faker)
{
$this->faker = $faker->create();
}

/**
* {@inheritdoc}
*/
public function create($limit = 1, $flatten = false, $options = [])
{
for ($i = 1; $i <= $limit; $i++) {
$date = $this->faker->dateTimeBetween('+10 days', '+15 days')->format('Y-m-d');
$title = $this->faker->sentence(rand(6, 10));
$imagex = $this->faker->randomElement([
'/styleguide/image/600x600?text=600x600:'.$i,
''
]);
$description = $this->faker->text(100);
$image = '/styleguide/image/600x600?text=600x600:'.$i;

$event = [
'event_id' => $i,
'url' => 'https://wayne.edu',
'title' => $title,
'date' => $date,
'start_time' => $this->faker->time('H:i:s', 'now'),
'end_time' => $this->faker->time('H:i:s', '+5 hours'),
'repeat_end_date' => $this->faker->dateTimeBetween('+1 month', '+2 months')->format('Y-m-d'),
'end_date' => $this->faker->dateTimeBetween('+10 days', '+15 days')->format('Y-m-d'),
'images' => [
0 => [
'full_url' => $image,
'description' => $description,
],
],
'display_image' => [
'full_url' => $image,
'description' => $description,
],
'is_all_day' => $this->faker->boolean,
];
$event = array_replace_recursive($event, $options);

$data[$i] = $event;
}

return $data;
}
}
46 changes: 46 additions & 0 deletions factories/EventFullListingNoImage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Factories;

use Contracts\Factories\FactoryContract;
use Faker\Factory;

class EventFullListingNoImage implements FactoryContract
{
/**
* Construct the factory.
*/
public function __construct(Factory $faker)
{
$this->faker = $faker->create();
}

/**
* {@inheritdoc}
*/
public function create($limit = 1, $flatten = false, $options = [])
{
for ($i = 1; $i <= $limit; $i++) {
$date = $this->faker->dateTimeBetween('+10 days', '+15 days')->format('Y-m-d');
$title = $this->faker->sentence(rand(6, 10));

$event = [
'event_id' => $i,
'url' => 'https://wayne.edu',
'title' => $title,
'date' => $date,
'start_time' => $this->faker->time('H:i:s', 'now'),
'end_time' => $this->faker->time('H:i:s', '+5 hours'),
'repeat_end_date' => $this->faker->dateTimeBetween('+1 month', '+2 months')->format('Y-m-d'),
'end_date' => $this->faker->dateTimeBetween('+10 days', '+15 days')->format('Y-m-d'),
'images' => '',
'is_all_day' => $this->faker->boolean,
];
$event = array_replace_recursive($event, $options);

$data[$i] = $event;
}

return $data;
}
}
4 changes: 2 additions & 2 deletions factories/Banner.php → factories/Flag.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Contracts\Factories\FactoryContract;
use Faker\Factory;

class Banner implements FactoryContract
class Flag implements FactoryContract
{
/**
* Construct the factory.
Expand All @@ -22,7 +22,7 @@ public function create($limit = 1, $flatten = false, $options = [])
{
for ($i = 1; $i <= $limit; $i++) {
$data[$i] = [
'class' => 'banner',
'class' => 'flag',
'title' => 'Make a',
'link' => 'https://wayne.edu',
'excerpt' => 'Gift',
Expand Down
2 changes: 2 additions & 0 deletions factories/HeroImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function create($limit = 1, $flatten = false, $options = [])
'description' => '<p>' . $this->faker->text(100) . ' <a href="https://wayne.edu">'. $this->faker->sentence(3) .'</a></p>',
'link' => 'https://wayne.edu',
'relative_url' => '/styleguide/image/1600x580?text=1600x580%20('.$i.')',
'filename_url' => '/styleguide/image/1600x580?text=1600x580%20('.$i.')',
'filename_alt_text' => 'Example background image',
'secondary_filename_url' => '/styleguide/image/1600x580?text=Secondary%201600x580%20('.$i.')',
'secondary_relative_url' => '/styleguide/image/1600x580?text=Secondary%201600x580%20('.$i.')',
'secondary_alt_text' => 'Example secondary image',
];
Expand Down
46 changes: 46 additions & 0 deletions factories/HeroImageRotate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Factories;

use Contracts\Factories\FactoryContract;
use Faker\Factory;

class HeroImageRotate implements FactoryContract
{
/**
* Construct the factory.
*/
public function __construct(Factory $faker)
{
$this->faker = $faker->create();
}

/**
* {@inheritdoc}
*/
public function create($limit = 1, $flatten = false, $options = [])
{
for ($i = 1; $i <= $limit; $i++) {
$data[$i] = [
'title' => $this->faker->sentence(3),
'description' => '<p>' . $this->faker->text(100) . ' <a href="https://wayne.edu">'. $this->faker->sentence(3) .'</a></p>',
'link' => 'https://wayne.edu',
'relative_url' => '/styleguide/image/1600x580?text=Primary%20image%20('.$i.')',
'filename_url' => '/styleguide/image/1600x580?text=Primary%20image%20('.$i.')',
'filename_alt_text' => 'Example background image',
'secondary_filename_url' => '/styleguide/image/400x250?text=Secondary%20image%20('.$i.')',
'secondary_relative_url' => '/styleguide/image/400x250?text=Secondary%20image%20('.$i.')',
'secondary_alt_text' => 'Example secondary image',
'option' => $this->faker->randomElement(['Text Overlay', 'Half', 'Logo Overlay', 'Banner large']),
];

$data[$i] = array_replace_recursive($data[$i], $options);
}

if ($limit === 1 && $flatten === true) {
return current($data);
}

return $data;
}
}

0 comments on commit 5896dd9

Please sign in to comment.