257 lines
5.5 KiB
PHP
257 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Helpers\AccessHelper;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use App\Models\Tag;
|
|
use App\Models\Document;
|
|
use App\Logic\Document\DocumentRepository;
|
|
use App\Models\User;
|
|
use App\Helpers\StringHelper;
|
|
|
|
class PageController extends PostController
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->middleware(['auth' => 'pagePermissions'])->except('index', 'show');
|
|
|
|
// Model
|
|
$this->modelType = StringHelper::toURL(__('models.page'));
|
|
$this->modelData = [
|
|
'category' => [
|
|
'type' => 'inputSelect',
|
|
'name' => 'tags',
|
|
'label' => __('models.category'),
|
|
'foreign' => [
|
|
'class' => Tag::class,
|
|
'model' => 'tags',
|
|
'column' => 'name',
|
|
'order' => [
|
|
'column' => 'order',
|
|
'direction' => 'ASC'
|
|
],
|
|
'conditions' => [
|
|
[
|
|
'column' => 'type',
|
|
'value' => 'seitenkategorie',
|
|
],
|
|
],
|
|
'linkedList' => [
|
|
]
|
|
],
|
|
],
|
|
'title' => [
|
|
'type' => 'inputText',
|
|
'label' => __('models.title'),
|
|
'placeholder' => __('models.title'),
|
|
'validation' => [
|
|
'rules' => 'required|min:3',
|
|
]
|
|
],
|
|
'content' => [
|
|
'type' => 'inputTextarea',
|
|
'label' => __('models.text'),
|
|
'placeholder' => __('models.text'),
|
|
'toolbar' => [
|
|
[
|
|
'insertfile',
|
|
'undo',
|
|
'redo',
|
|
],
|
|
[
|
|
'bold',
|
|
'italic',
|
|
'strikethrough'
|
|
],
|
|
[
|
|
'alignleft',
|
|
'aligncenter',
|
|
'alignright',
|
|
'alignjustify'
|
|
],
|
|
[
|
|
'bullist',
|
|
'numlist'
|
|
],
|
|
[
|
|
'link',
|
|
'image',
|
|
'media'
|
|
]
|
|
],
|
|
'plugins' =>
|
|
[
|
|
'paste',
|
|
'lists',
|
|
'media',
|
|
'link',
|
|
'image',
|
|
'imagetools',
|
|
'contextmenu'
|
|
],
|
|
'validation' => [
|
|
'rules' => 'required',
|
|
]
|
|
],
|
|
];
|
|
if(AccessHelper::hasPermissionRoles(['Seitendesigner']))
|
|
{
|
|
$this->modelData['content']['plugins'] = array_merge($this->modelData['content']['plugins'], [
|
|
'preview',
|
|
'fullpage',
|
|
'searchreplace',
|
|
'autolink',
|
|
'directionality',
|
|
'visualblocks',
|
|
'visualchars',
|
|
'fullscreen',
|
|
'template',
|
|
'codesample',
|
|
'table',
|
|
'charmap',
|
|
'hr',
|
|
'pagebreak',
|
|
'nonbreaking',
|
|
'anchor',
|
|
'toc',
|
|
'insertdatetime',
|
|
'advlist',
|
|
'lists',
|
|
'textcolor',
|
|
'wordcount',
|
|
'contextmenu',
|
|
'colorpicker',
|
|
'textpattern'
|
|
]);
|
|
}
|
|
|
|
// URL options
|
|
$this->url = 'page';
|
|
$this->route = StringHelper::toURL(__('models.page'));
|
|
|
|
$this->indexOptions = [
|
|
'orderBy' => 'title',
|
|
'orderDirection' => 'ASC',
|
|
'paginate' => 9,
|
|
'view' => 'inc.views.cardPreviewContainer2',
|
|
'filter' => [
|
|
'year' => [
|
|
'type' => 'select',
|
|
'label' => __('general.year'),
|
|
'name' => strtolower(__('general.year'))
|
|
],
|
|
'month' => [
|
|
'type' => 'select',
|
|
'label' => __('general.month'),
|
|
'name' => strtolower(__('general.month'))
|
|
],
|
|
]
|
|
];
|
|
|
|
$this->detailsOptions = [
|
|
'view' => 'inc.views.details',
|
|
];
|
|
|
|
$this->adminIndexOptions = [
|
|
'orderBy' => 'title',
|
|
'orderDirection' => 'ASC',
|
|
'paginate' => 10,
|
|
'listdata' => [
|
|
'category' => [],
|
|
'title' => [],
|
|
'user' => [
|
|
'label' => __('general.author'),
|
|
'foreign' => [
|
|
'model' => 'audits',
|
|
'column' => 'name',
|
|
'index' => 'last'
|
|
],
|
|
],
|
|
'datetime' => [
|
|
'label' => __('general.datetime'),
|
|
'format' => __('general.datetime_format_short')
|
|
],
|
|
'published' => [
|
|
'label' => __('admin.published'),
|
|
]
|
|
]
|
|
];
|
|
|
|
// Publishing
|
|
$this->publishOptions = [];
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
public function show(Request $request, $slug)
|
|
{
|
|
$this->prepareModelData('SHOW');
|
|
$model = (new $this->modelClass())
|
|
->where('slug', $slug)
|
|
->isPublished()
|
|
->getDocuments()
|
|
->first();
|
|
if($model == null)
|
|
{
|
|
abort(404);
|
|
}
|
|
|
|
$model->documents = DocumentRepository::getEntityFiles($model->type, $model->id);
|
|
|
|
// View auswählen
|
|
$viewName = "inc.views.detail";
|
|
if(key_exists('view', $this->detailsOptions))
|
|
{
|
|
$viewName = $this->detailsOptions['view'];
|
|
}
|
|
$view = view($viewName);
|
|
|
|
// Sidebar erstellen
|
|
$sidebar = array();
|
|
|
|
// Überprüfe, ob die Seite einer Abteilung angehört.
|
|
// Falls das der Fall ist, werden in der Sidebar die Funktionsträger angezeigt
|
|
$members = User::select('users.*')
|
|
->addSelect('tags1.name as title')
|
|
->join('user_tag as user_tag1', function($join){
|
|
$join->on('user_tag1.user_id', 'users.id');
|
|
})
|
|
->join('tags as tags1', function($join){
|
|
$join->on('user_tag1.tag_id', 'tags1.id')
|
|
->where('tags1.type', 'mitgliedsart-abteilung');
|
|
})
|
|
->addSelect('tags2.name as department')
|
|
->join('user_tag as user_tag2', function ($join)
|
|
{
|
|
$join->on('user_tag2.user_id', 'users.id');
|
|
})
|
|
->join('tags as tags2', function ($join) use ($model)
|
|
{
|
|
$join->on('user_tag2.tag_id', 'tags2.id')
|
|
->where('tags2.type', 'abteilung')
|
|
->where('tags2.name', $model->title);
|
|
})
|
|
->orderBy('tags1.order')
|
|
->get();
|
|
$members->each(function($m)
|
|
{
|
|
$m->type = 'benutzer';
|
|
});
|
|
if(count($members))
|
|
{
|
|
$members->member = true;
|
|
}
|
|
|
|
$this->prepareModel2($model);
|
|
$model->isMainPost = true;
|
|
$view->with('sidebar', $members);
|
|
$view->with('config', $this->modelData);
|
|
$view->with('model', $model);
|
|
$view->with('url', $this->route);
|
|
|
|
return $view;
|
|
}
|
|
}
|