Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Aug 4, 2023
2 parents bd715cc + d508698 commit deb85f6
Show file tree
Hide file tree
Showing 113 changed files with 4,940 additions and 315 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.41
6.42
42 changes: 42 additions & 0 deletions app/Events/UpdateLandingPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Console\Command;
use App\Models\LandingPage;
use Illuminate\Support\Facades\Artisan;

class UpdateLandingPage
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;

public $item;
public $urls = [];

public $output;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct(LandingPage $item)
{
$this->item = $item;

if ($item->is_published) {
$landingPageModel = LandingPage::byId($item->id)->first();

if ($landingPageModel) {
$this->urls = [
'/' . $landingPageModel->slug,
];
}
}
}
}
17 changes: 17 additions & 0 deletions app/Helpers/StringHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,21 @@ public static function summation(array $array = [])
return implode(', ', $array) . ', and ' . $last;
}
}

public static function pageBlades($typeString) // Pass in the type string from $types after matching page->type to index of string in LP $types
{
$pageTitle = strtolower($typeString);
$words = explode(' ', $pageTitle); // Split into array of words for evaluation of first word
$firstWord = $words[0];

if ($firstWord === 'art' && strpos($pageTitle, 'ideas') !== false) { // If the first word is 'art' and the page title contains 'ideas' (i.e. 'Art & Ideas')
$pageString = 'collection-landing'; // Rename the first word to 'collection-landing'
} elseif (strpos($pageTitle, 'and') !== false) { // If the page title contains 'and' (i.e. 'Research and Resources')
$pageString = $firstWord . '-landing'; // Rename the first word to 'research-landing'
} else {
$pageString = $firstWord; // Otherwise, just use the first word
}

return $pageString;
}
}
9 changes: 7 additions & 2 deletions app/Helpers/UrlHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,20 @@ public static function secureRoute($routeName)
{
$url = url();
$defaultScheme = Request::getScheme();
$url->forceScheme('https');
if (app()->environment(['production', 'staging'])) {
$url->forceScheme('https');
}
$route = $url->route($routeName);
$url->forceScheme($defaultScheme);
if (app()->environment(['production', 'staging'])) {
$url->forceScheme($defaultScheme);
}

return $route;
}

/**
* Whether a module route exists
*
* @see moduleRoute
*/
public static function moduleRouteExists($moduleName, $prefix, $action)
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Controllers/API/LandingPagesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace App\Http\Controllers\API;

class LandingPagesController extends BaseController
{
protected $model = \App\Models\LandingPage::class;
protected $transformer = \App\Http\Transformers\LandingPageTransformer::class;
}
4 changes: 4 additions & 0 deletions app/Http/Controllers/Admin/GenericPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ protected function formData($request)

protected function transformIndexItems($items)
{
// If we're in the browser, don't transform the items
if (property_exists($items, 'path')) {
return $items;
}
return $items->toTree();
}

Expand Down
30 changes: 30 additions & 0 deletions app/Http/Controllers/Admin/LandingPageCategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Controllers\Admin;

use A17\Twill\Http\Controllers\Admin\ModuleController;

class LandingPageCategoryController extends ModuleController
{
protected $moduleName = 'landingPageCategories';

protected $indexOptions = [
'publish' => false,
'editInModal' => true,
'permalink' => false,
];

protected $titleColumnKey = 'name';

protected $indexColumns = [
'name' => [
'title' => 'Name',
'edit_link' => true,
'field' => 'name',
],
];

protected $defaultOrders = [
'name' => 'asc',
];
}
68 changes: 68 additions & 0 deletions app/Http/Controllers/Admin/LandingPageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace App\Http\Controllers\Admin;

use A17\Twill\Http\Controllers\Admin\ModuleController;
use App\Repositories\LandingPageRepository;
use App\Models\LandingPageType;
use Session;

class LandingPageController extends ModuleController
{
protected $moduleName = 'landingPages';

protected $indexColumns = [
'title' => [
'title' => 'Title',
'edit_link' => true,
'sort' => true,
'field' => 'title',
],
];

protected $indexWith = [];

protected $defaultOrders = [];

protected $previewView = 'site.landingPageDetail';

protected function indexData($request)
{
$types = LandingPageType::all()->pluck('page_type', 'id')->toArray();
$typesOptions = $this->getTypesOptions($types);

return [
'types' => $types,
'typesOptions' => $typesOptions,
];
}

protected function formData($request)
{
$types = LandingPageType::all()->pluck('page_type', 'id')->toArray();
$typesOptions = $this->getTypesOptions($types);

$baseUrl = '//' . config('app.url') . '/';

return [
'types' => $types,
'typesOptions' => $typesOptions,
'baseUrl' => $baseUrl,
];
}

public function getTypesOptions($types)
{
$list = [];

foreach ($types as $value => $label) {
$list[] = ['value' => $value, 'label' => $label];
}

return $list;
}
protected function getRoutePrefix()
{
return null;
}
}
8 changes: 4 additions & 4 deletions app/Http/Controllers/Admin/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ public function research(PageRepository $pages)
return view('admin.pages.form', $fields);
}

protected function getRoutePrefix()
protected function moduleHas($behavior)
{
return null;
return $behavior === 'revisions' ? false : parent::moduleHas($behavior);
}

protected function moduleHas($behavior)
protected function getRoutePrefix()
{
return $behavior === 'revisions' ? false : parent::moduleHas($behavior);
return null;
}
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/ExhibitionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ protected function show($id, $slug = null)
->findOrFail((int) $id);

// If the exhibition has not started or not ended, check if its augmented model is published before showing
// WEB-2499: If the start and end dates are not set, err on the side of publishing the exhibition
// WEB-1796: Consider adding a global `getPublishedAttribute` method that checks preview mode status?
if (!config('aic.is_preview_mode') && !$item->published && (Carbon::now()->lt($item->dateStart) || Carbon::now()->lt($item->dateEnd))) {
if (!config('aic.is_preview_mode') && !$item->published && ((isset($item->dateStart) && Carbon::now()->isBefore($item->dateStart)) || (isset($item->dateEnd) && Carbon::now()->isBefore($item->dateEnd)))) {
abort(404);
}

Expand Down
Loading

0 comments on commit deb85f6

Please sign in to comment.