Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Jul 15, 2020
2 parents f670ed8 + 68e6aea commit 0d4effd
Show file tree
Hide file tree
Showing 112 changed files with 1,939 additions and 644 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.15
6.16
5 changes: 5 additions & 0 deletions app/Helpers/ImageHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,3 +653,8 @@ function aic_gridListingImageSizes($data) {

return $sizes;
}

function aic_getIconClass($key = 0) {
$icons = \App\Models\Page::getIconTypes();
return Str::kebab($icons[$key]);
}
25 changes: 25 additions & 0 deletions app/Helpers/StringHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,28 @@ function rightTrim($string, $needle) {
return $string;
}
}

if (!function_exists('summation')) {

/**
* Helper method that converts `['item', 'hey', 'wow']` to `item, hey, and wow`.
* Per request from communications, we use the Oxford comma.
*
* @return string
*/
function summation(array $array = []) {
switch (count($array)) {
case 0;
return null;
case 1;
return array_pop($array);
break;
case 2;
return implode(' and ', $array);
break;
default;
$last = array_pop($array);
return implode(', ', $array) . ', and ' . $last;
}
}
}
10 changes: 5 additions & 5 deletions app/Http/Controllers/Admin/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public function visit(PageRepository $pages)

$additionalFieldsets = [
['fieldset' => 'hours', 'label' => 'Hours'],
['fieldset' => 'call-to-action', 'label' => 'CTA'],
['fieldset' => 'expect', 'label' => 'What to Expect'],
['fieldset' => 'admissions', 'label' => 'Admissions'],
['fieldset' => 'featured_offer', 'label' => 'Featured offer'],
['fieldset' => 'directions', 'label' => 'Museum address'],
['fieldset' => 'dining_hours', 'label' => 'Dining'],
['fieldset' => 'faq', 'label' => 'FAQ'],
['fieldset' => 'tourpages', 'label' => 'Tours'],
['fieldset' => 'families', 'label' => 'Families, teens and educators'],
['fieldset' => 'accessibility', 'label' => 'Accessibility'],
['fieldset' => 'directions', 'label' => 'Directions'],
['fieldset' => 'explore', 'label' => 'Ways to Explore'],
];

$fields = $this->form($page->id);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function autocomplete()
break;
case 'Artist':
$item->url = route('artists.show', $item);
$item->section = 'Artists';
$item->section = 'Artists/Cultures';
break;
case 'Event':
$item->url = route('events.show', $item);
Expand Down Expand Up @@ -405,7 +405,7 @@ protected function buildSearchLinks($all, $active = 'all')
array_push($links, $this->buildLabel('All', $all->getMetadata('pagination')->total, route('search', ['q' => request('q')]), $active == 'all'));

if (extractAggregation($aggregations, 'agents')) {
array_push($links, $this->buildLabel('Artist', extractAggregation($aggregations, 'agents'), route('search.artists', ['q' => request('q')]), $active == 'artists'));
array_push($links, $this->buildLabel('Artists/Cultures', extractAggregation($aggregations, 'agents'), route('search.artists', ['q' => request('q')]), $active == 'artists'));
}
if (extractAggregation($aggregations, 'generic-pages')) {
array_push($links, $this->buildLabel('Pages', extractAggregation($aggregations, 'generic-pages'), route('search.pages', ['q' => request('q')]), $active == 'generic-pages'));
Expand Down
60 changes: 30 additions & 30 deletions app/Http/Controllers/VisitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ public function index()
'primary' => $page->visit_hour_header,
'secondary' => $page->visit_hour_subheader,
'sections' => $page->featured_hours,
'intro' => $page->visit_hour_intro
);

$expects = array();
foreach ($page->whatToExpects as $item) {
array_push($expects, array(
'iconType' => $item->icon_type,
'text' => $item->text,
));
};
$whatToExpect = array(
'more_link' => $page->visit_what_to_expect_more_link,
'more_text' => $page->visit_what_to_expect_more_text,
'items' => $expects,
);

// Get prices grid for admissions
Expand Down Expand Up @@ -109,14 +123,6 @@ public function index()
'link' => $page->visit_buy_tickets_link,
),
);
$dining = array();
foreach ($page->dining_hours as $hour) {
array_push($dining, array(
'image' => $hour->imageFront('dining_cover'),
'title' => $hour->name,
'text' => $hour->accessible_hours,
));
};

$directions = array(
'intro' => __('Located in the heart of Chicago—across from Millennium Park and steps from Lake Michigan—the Art Institute welcomes visitors at two entrances.'),
Expand All @@ -126,6 +132,10 @@ public function index()
'href' => $page->visit_parking_link,
'label' => __('Directions, Parking, and Public Transportation'),
),
'accessibility_link' => array(
'href' => $page->visit_parking_accessibility_link,
'label' => __('Visitors with Mobility Needs'),
),
);

$questions = array();
Expand All @@ -142,9 +152,16 @@ public function index()
'questions' => $questions,
);

$families = array();
$accessibility = array(
'image' => $page->imageFront('visit_accessibility'),
'text' => $page->visit_accessibility_text,
'link_text' => $page->visit_accessibility_link_text,
'link_url' => $page->visit_accessibility_link_url,
);

$explore = array();
foreach ($page->families as $item) {
array_push($families, array(
array_push($explore, array(
'image' => $item->imageFront('family_cover'),
'title' => $item->title,
'text' => $item->text,
Expand All @@ -156,23 +173,6 @@ public function index()
));
};

$tours = [];
foreach ($page->visitTourPages as $item) {
$links = [];
foreach ($item->children()->orderBy('position')->published()->get() as $child) {
array_push($links, array(
'href' => $child->url,
'label' => $child->title,
));
}
array_push($tours, array(
'title' => $item->title,
'titleLink' => $item->url,
'image' => $item->imageFront('listing'),
'links' => $links,
));
}

$itemprops = [
'name' => 'Art Institute of Chicago',
'telephone' => '+13124433600',
Expand All @@ -187,12 +187,12 @@ public function index()
'filledLogo' => true,
'headerMedia' => $headerMedia,
'hours' => $hours,
'whatToExpect' => $whatToExpect,
'admission' => $admission,
'dining' => $dining,
'directions' => $directions,
'faq' => $faq,
'families' => $families,
'tours' => $tours,
'accessibility' => $accessibility,
'explore' => $explore,
'itemprops' => $itemprops,
]);
}
Expand Down
6 changes: 4 additions & 2 deletions app/Models/Behaviors/HasApiRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ public function loadRelatedWithApiModels($browser_name, $apiModelsDefinitions, $
return $items->map(function ($relatedElement) {
$element = $relatedElement->related;
$element->position = $relatedElement->position;

if (!$element->isListed ?? false) {
if ($element->isListed === false) {
return false;
}
if ($element->isPublished === false) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions app/Models/MagazineIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class MagazineIssue extends AbstractModel
{
use HasSlug, HasRevisions, HasBlocks, HasMedias, HasMediasEloquent, HasRelated;

protected $presenter = 'App\Presenters\Admin\GenericPresenter';
protected $presenterAdmin = 'App\Presenters\Admin\GenericPresenter';
protected $presenter = 'App\Presenters\Admin\MagazineIssuePresenter';
protected $presenterAdmin = 'App\Presenters\Admin\MagazineIssuePresenter';

protected $fillable = [
'title',
Expand Down
48 changes: 41 additions & 7 deletions app/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,34 +80,38 @@ class Page extends AbstractModel
'resources_landing_title',
'resources_landing_intro',

// Visit page
'visit_dining_link',

'visit_transportation_link',

'visit_parking_link',

'visit_buy_tickets_link',

'visit_become_member_link',

'visit_faq_accessibility_link',

'visit_faq_more_link',

'visit_accessibility_link_url',
'visit_cta_module_action_url',
'visit_what_to_expect_more_link',
];

public $translatedAttributes = [
// Visit
'visit_intro',
'visit_hour_header',
'visit_hour_subheader',
'visit_hour_intro',
'visit_city_pass_title',
'visit_city_pass_text',
'visit_city_pass_button_label',
'visit_city_pass_link',
'visit_admission_description',
'visit_buy_tickets_label',
'visit_become_member_label',
'visit_accessibility_text',
'visit_accessibility_link_text',
'visit_cta_module_header',
'visit_cta_module_body',
'visit_cta_module_button_text',
'visit_what_to_expect_more_text',
'active'
];

Expand Down Expand Up @@ -142,6 +146,14 @@ class Page extends AbstractModel
],
],
],
'visit_accessibility' => [
'default' => [
[
'name' => 'default',
'ratio' => 16 / 9,
],
],
],
'visit_map' => [
'default' => [
[
Expand Down Expand Up @@ -199,6 +211,18 @@ class Page extends AbstractModel
];
public $filesParams = ['video']; // a list of file roles

public static $iconTypes = [
0 => 'Face Coverings',
1 => 'Physical Distancing',
2 => 'Mobile Ticket',
3 => 'Showing Symptoms',
4 => 'No Checkroom',
5 => 'No Dining',
6 => 'Caution',
7 => 'Floor Icon',
8 => 'Virtual Queue',
];

public function scopeForType($query, $type)
{
return $query->where('type', array_flip(self::$types)[$type]);
Expand Down Expand Up @@ -302,6 +326,11 @@ public function featured_hours()
return $this->hasMany(FeaturedHour::class)->orderBy('position');
}

public function whatToExpects()
{
return $this->hasMany(WhatToExpect::class)->orderBy('position');
}

public function articlesCategories()
{
return $this->belongsToMany('App\Models\Category', 'page_article_category')->withPivot('position')->orderBy('position');
Expand Down Expand Up @@ -357,6 +386,11 @@ public function researchResourcesStudyRoomMore()
return $this->belongsToMany('App\Models\GenericPage', 'research_resource_study_room_more_pages')->withPivot('position')->orderBy('research_resource_study_room_more_pages.position', 'asc');
}

public static function getIconTypes()
{
return collect(self::$iconTypes);
}

protected function transformMappingInternal()
{
return [
Expand Down
10 changes: 10 additions & 0 deletions app/Models/Revisions/WhatToExpectRevision.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models\Revisions;

use A17\Twill\Models\Revision;

class WhatToExpectRevision extends Revision
{
protected $table = "what_to_expect_revisions";
}
7 changes: 7 additions & 0 deletions app/Models/Translations/PageTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ class PageTranslation extends Model
'visit_intro',
'visit_hour_header',
'visit_hour_subheader',
'visit_hour_intro',
'visit_city_pass_title',
'visit_city_pass_text',
'visit_city_pass_button_label',
'visit_city_pass_link',
'visit_admission_description',
'visit_buy_tickets_label',
'visit_become_member_label',
'visit_accessibility_text',
'visit_accessibility_link_text',
'visit_cta_module_header',
'visit_cta_module_body',
'visit_cta_module_button_text',
'visit_what_to_expect_more_text',
'active',
'locale',
];
Expand Down
13 changes: 13 additions & 0 deletions app/Models/Translations/WhatToExpectTranslation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Models\Translations;

use A17\Twill\Models\Model;

class WhatToExpectTranslation extends Model
{
protected $fillable = [
'text',
'active',
];
}
31 changes: 31 additions & 0 deletions app/Models/WhatToExpect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models;

use A17\Twill\Models\Behaviors\HasTranslation;
use A17\Twill\Models\Behaviors\HasRevisions;
use A17\Twill\Models\Behaviors\HasPosition;
use A17\Twill\Models\Behaviors\Sortable;
use A17\Twill\Models\Model;

class WhatToExpect extends Model implements Sortable
{
use HasTranslation, HasRevisions, HasPosition;

protected $fillable = [
'published',
'icon_type',
'position',
'page_id'
];

public $translatedAttributes = [
'text',
];

// add checkbox fields names here (published toggle is itself a checkbox)
public $checkboxes = [
'published'
];

}
Loading

0 comments on commit 0d4effd

Please sign in to comment.