Merge branch 'dev' into module_profiler

This commit is contained in:
Michal Kváček
2017-09-23 00:45:51 +02:00
711 changed files with 14073 additions and 84301 deletions
-12
View File
@@ -1,12 +0,0 @@
<?php
return [
'name' => 'Articles',
'translatedName' => 'article::module.name',
'translatedDescription' => 'article::module.description',
'alias' => 'article',
'handler' => \Modules\Blog\Article\Handlers\Article::class,
'providers' => [\Modules\Blog\Article\Providers\ArticleServiceProvider::class],
'files' => ['start.php'],
'order' => 0,
];
-15
View File
@@ -1,15 +0,0 @@
<?php
namespace Modules\Blog\Article\Entities;
use App\Models\Content\Content;
class Article extends Content
{
protected $table = 'contents';
public function comments()
{
return $this->hasMany(Comment::class, 'content_id')
->where('approved', true);
}
}
-27
View File
@@ -1,27 +0,0 @@
<?php namespace Modules\Blog\Article\Entities;
use App\Models\Content\Content;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
protected $fillable = [
'user_id',
'content_id',
'content',
'email',
'name',
'approved'
];
public function author()
{
return $this->belongsTo(User::class, 'user_id');
}
public function article()
{
return $this->belongsTo(Content::class, 'content_id');
}
}
@@ -1,20 +0,0 @@
<?php
namespace Modules\Blog\Article\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Modules\Blog\Article\Entities\Comment;
class ApprovedComment extends Event
{
use SerializesModels;
/**
* @var Comment
*/
public $comment;
public function __construct(Comment $comment)
{
$this->comment = $comment;
}
}
@@ -1,20 +0,0 @@
<?php
namespace Modules\Blog\Article\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Modules\Blog\Article\Entities\Comment;
class CreatedComment extends Event
{
use SerializesModels;
/**
* @var Comment
*/
public $comment;
public function __construct(Comment $comment)
{
$this->comment = $comment;
}
}
@@ -1,20 +0,0 @@
<?php
namespace Modules\Blog\Article\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
use Modules\Blog\Article\Entities\Comment;
class DeletedComment extends Event
{
use SerializesModels;
/**
* @var Comment
*/
public $comment;
public function __construct(Comment $comment)
{
$this->comment = $comment;
}
}
-153
View File
@@ -1,153 +0,0 @@
<?php
namespace Modules\Blog\Article\Handlers;
use App\CMS\Contracts\Content\AdvancedContentModifier;
use App\CMS\Contracts\Content\ContentTitles;
use App\CMS\Contracts\Modules\InstallableModule;
use App\CMS\Handlers\Handler;
use App\Http\Controllers\Controller;
use App\Http\Requests\Request;
use App\Models\ActionLog\ActionLogType;
use App\Models\Content\Content;
use App\Models\Module;
use App\Models\User;
use Illuminate\Support\Collection;
use Modules\Blog\Article\Entities\Comment;
class Article extends Handler implements ContentTitles, AdvancedContentModifier, InstallableModule
{
public static function getExtendedFormInputsCreate()
{
$sections = parent::getExtendedFormInputsCreate();
$sections['basicInfo'] = 'article::admin.content.basicInfo';
return $sections;
}
public static function getExtendedFormInputsEdit()
{
return self::getExtendedFormInputsCreate();
}
/**
* Register admin menu
*
* @param User $user
*/
public static function registerAdminMenu(User $user)
{
$menu = \Menu::instance('mainMenu');
$blogSubmenu = $menu->whereTitle(trans('article::module.blog'));
if (!$blogSubmenu) {
$blogSubmenu = $menu->dropdown(trans('article::module.blog'), function ($sub) {
}, 20, ['icon' => 'fa fa-fw fa-book']);
}
$blogSubmenu->dropdown(trans('article::module.name'), function ($sub) {
$sub->route('content.new', trans('article::article.new'), ['id' => config('article.alias')], 10, ['icon' => 'fa fa-fw fa-pencil']);
$sub->route('content.overview', trans('article::article.overview'), ['id' => config('article.alias')], 30, ['icon' => 'fa fa-fw fa-book']);
}, 10, ['icon' => 'fa fa-fw fa-book']);
$blogSubmenu->route('comments.overview', trans('article::module.commentsOverview'), [], 20, ['icon' => 'fa fa-fw fa-commenting-o']);
}
/**
* Install module
*/
public static function install()
{
$types = [
[
'string_id' => 'commentCreated',
'name' => 'article::comments.events.names.commentCreated',
'value' => 'article::comments.events.descriptions.commentCreated',
],
[
'string_id' => 'commentDeleted',
'name' => 'article::comments.events.names.commentDeleted',
'value' => 'article::comments.events.descriptions.commentDeleted',
],
[
'string_id' => 'commentApproved',
'name' => 'article::comments.events.names.commentApproved',
'value' => 'article::comments.events.descriptions.commentApproved',
],
];
foreach ($types as $type) {
ActionLogType::create($type);
}
}
/**
* Uninstalls module
*
* @param Module $module
*
* @return mixed|void
*/
public static function uninstall(Module $module)
{
ActionLogType::whereIn('string_id', ['commentCreated', 'commentDeleted', 'commentApproved'])
->delete();
}
/**
* Get translated title for pages overview of given type.
*
* This value is used for rendering list of all content pages of given type in administration.
*
* @return string
*/
public static function getOverviewTitle()
{
return trans('article::module.allArticles');
}
/**
* Title displayed above for for creating new content page
*
* @return string
*/
public static function getCreateNewTitle()
{
return trans('article::module.newArticle');
}
/**
* Title for form displayed for editin content page
*
* @param Content $content
*
* @return mixed
*/
public static function getEditTitle(Content $content)
{
return trans('article::module.editArticle');
}
/**
* Method called right after content page is marked as deleted
*
* This method is supposed to clean after "deleted" page.
*
* @param Content $content
*
* @return mixed
*/
public static function delete(Content $content)
{
}
/**
* Does this module support categories?
*
* @return boolean
*/
public static function supportCategories()
{
return true;
}
}
@@ -1,19 +0,0 @@
<?php
namespace Modules\Blog\Article\Http\Controllers\Admin;
use Modules\Blog\Article\Entities\Comment;
use Pingpong\Modules\Routing\Controller;
class CommentsOverview extends Controller
{
public function getOverview()
{
$comments = Comment::with('article')
->with('author')
->orderBy('approved')
->orderBy('created_at', 'DESC')
->paginate(25);
return view('article::admin/comments.overview', ['comments' => $comments]);
}
}
@@ -1,37 +0,0 @@
<?php
namespace Modules\Blog\Article\Http\Controllers\Admin;
use Illuminate\Support\Facades\Event;
use Modules\Blog\Article\Entities\Comment;
use Modules\Blog\Article\Events\ApprovedComment;
use Modules\Blog\Article\Events\DeletedComment;
use Pingpong\Modules\Routing\Controller;
class EditComment extends Controller
{
public function approve($id)
{
$comment = Comment::findOrFail($id);
$comment->approved = 1;
$comment->save();
Event::fire(new ApprovedComment($comment));
return redirect()
->back()
->with('success', trans('article::comments.approved'));
}
public function delete($id)
{
$comment = Comment::findOrFail($id);
Event::fire(new DeletedComment($comment));
$comment->delete();
return redirect()
->back()
->with('success', trans('article::comments.deleted'));
}
}
@@ -1,48 +0,0 @@
<?php
namespace Modules\Blog\Article\Http\Controllers\Visitor;
use App\Models\Content\Content;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Modules\Blog\Article\Entities\Comment;
use Modules\Blog\Article\Events\CreatedComment;
use Modules\Blog\Article\Handlers\Article;
use Pingpong\Modules\Routing\Controller;
class CreateNewComment extends Controller
{
public function store(\Modules\Blog\Article\Http\Requests\CreateNewComment $request, \Modules\Blog\Article\Entities\Article $article)
{
if (!isset($article->moduleSettings['allowComments']) || !$article->moduleSettings['allowComments']) {
return redirect()
->route('page.content', ['url' => $article->url])
->with('error', trans('article::comments.disabledComments'));
}
$content = $request->message;
$user = Auth::user();
if ($user) {
$name = is_null($user->name) ? $user->email : $user->name;
$email = $user->email;
} else {
$name = $request->name;
$email = $request->email;
}
$comment = Comment::create([
'user_id' => $user ? $user->id : null,
'content_id' => $article->id,
'name' => $name,
'email' => $email,
'content' => $content,
'approved' => !is_null($user)
]);
// fire event about new comment
Event::fire(new CreatedComment($comment));
return redirect()
->route('page.content', ['url' => $article->url])
->with('success', trans('article::comments.saved'));
}
}
@@ -1,28 +0,0 @@
<?php
namespace Modules\Blog\Article\Http\Requests;
use App\Http\Requests\Request;
use Illuminate\Support\Facades\Auth;
class CreateNewComment extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$user = Auth::user();
$required = ['message' => 'required'];
if (!$user) {
$required['name'] = 'required';
$required['email'] = 'required|email';
}
return $required;
}
}
-28
View File
@@ -1,28 +0,0 @@
<?php
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'namespace' => 'Modules\Blog\Article\Http\Controllers'
], function () {
Route::group([
'middleware' => ['admin'],
'prefix' => 'admin/comments',
'namespace' => 'Admin'
], function () {
Route::get('/', 'CommentsOverview@getOverview')
->name('comments.overview');
Route::get('/delete/{id}', 'EditComment@delete')
->name('comments.delete');
Route::get('/approve/{id}', 'EditComment@approve')
->name('comments.approve');
});
// public routes
Route::group(['middleware' => ['web'], 'namespace' => 'Visitor'], function () {
Route::post('comments/new/{article}', 'CreateNewComment@store')
->name('comments.new');
});
});
@@ -1,35 +0,0 @@
<?php
namespace Modules\Blog\Article\Listeners;
use App\Listeners\Loggers\Logger;
use Modules\Blog\Article\Events\ApprovedComment;
class LogCommentApproval extends Logger
{
/**
* Handle the event.
*
* @param ApprovedComment $event
*/
public function handle(ApprovedComment $event)
{
$parameters = [
'author' => $event->comment->name,
'email' => $event->comment->email,
'content' => $event->comment->content
];
$this->saveLog($parameters);
}
/**
* Getter for action name. Used only internally
*
* @return mixed
*/
protected function getName()
{
return 'commentApproved';
}
}
@@ -1,35 +0,0 @@
<?php
namespace Modules\Blog\Article\Listeners;
use App\Listeners\Loggers\Logger;
use Modules\Blog\Article\Events\DeletedComment;
class LogDeletedComment extends Logger
{
/**
* Handle the event.
*
* @param DeletedComment $event
*/
public function handle(DeletedComment $event)
{
$parameters = [
'author' => $event->comment->name,
'email' => $event->comment->email,
'content' => $event->comment->content
];
$this->saveLog($parameters);
}
/**
* Getter for action name. Used only internally
*
* @return mixed
*/
protected function getName()
{
return 'commentDeleted';
}
}
@@ -1,40 +0,0 @@
<?php
namespace Modules\Blog\Article\Listeners;
use App\Listeners\Loggers\Logger;
use Modules\Blog\Article\Events\CreatedComment;
class LogNewComment extends Logger
{
/**
* Handle the event.
*
* @param CreatedComment $event
*/
public function handle(CreatedComment $event)
{
// log only logged-in users
if (!$event->comment->user_id) {
return;
}
$parameters = [
'author' => $event->comment->name,
'email' => $event->comment->email,
'content' => $event->comment->content
];
$this->saveLog($parameters);
}
/**
* Getter for action name. Used only internally
*
* @return mixed
*/
protected function getName()
{
return 'commentCreated';
}
}
@@ -1,60 +0,0 @@
<?php
namespace Modules\Blog\Modificators;
class PerexCreator
{
/**
* @var \DOMDocument
*/
protected $DOMDocument;
protected $perex;
public function __construct()
{
$this->DOMDocument = new \DOMDocument('1.0', 'UTF-8');
$this->maxLength = 300;
$this->maxImages = 2;
$this->perex = '';
}
private function addHtml($node)
{
$this->perex .= strip_tags($this->DOMDocument->saveHTML($node), '<p><strong><em><b><i><u>');
}
public function create($html)
{
if (empty($html)) {
return null;
}
$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
$this->DOMDocument->loadHTML($html);
$texts = $this->DOMDocument->getElementsByTagName('p');
$images = $this->DOMDocument->getElementsByTagName('img');
$iframes = $this->DOMDocument->getElementsByTagName('iframe');
$textId = 0;
$imgId = 0;
if ($texts->length > 1) {
$this->addHtml($texts[$textId++]);
}
if (mb_strlen($this->perex) < $this->maxLength) {
if ($iframes->length > 0) {
$this->perex .= $this->DOMDocument->saveHTML($iframes[0]);
} elseif ($images->length > 0) {
while ($imgId < $images->length && $imgId < $this->maxImages) {
$this->perex .= $this->DOMDocument->saveHTML($images[$imgId++]);
}
} else {
while (mb_strlen($this->perex) < $this->maxLength && $textId < $texts->length) {
$this->addHtml($texts[$textId++]);
}
}
}
return $this->perex;
}
}
@@ -1,33 +0,0 @@
<?php
namespace Modules\Blog\Article\Pipeline\DisplayContent;
use App\CMS\Contracts\Content\DisplayPipeline\Process;
use App\Models\Content\Content;
use Illuminate\Support\Collection;
use Modules\Blog\Article\Entities\Comment;
use Modules\Blog\Article\Handlers\Article;
class LoadCommentsForBlogpost implements Process
{
/**
* Process and modify given page
*
* @param Content $content
*
* @return void
*/
function handle(Content & $content)
{
if ($content->moduleHandler != Article::class)
return;
$content->comments = new Collection();
if (isset($content->moduleSettings['allowComments']) && $content->moduleSettings['allowComments']) {
$content->comments = Comment::where('content_id', $content->id)
->with('author')
->where('approved', 1)
->orderBy('created_at')
->get();
}
}
}
@@ -1,29 +0,0 @@
<?php
namespace Modules\Blog\Article\Pipeline\SaveContent;
use App\CMS\Contracts\Content\SavePipeline\Process;
use App\Models\Content\Content;
use Modules\Blog\Article\Handlers\Article;
class TurnCommentsOnOrOff implements Process
{
/**
* Process and modify given page
*
* @param Content $content
* @param array $input
*
* @return void
*/
function handle(Content & $content, array & $input)
{
if (trim($content->moduleHandler, '\\') !== Article::class) {
return;
}
$settings = $content->moduleSettings;
$settings['allowComments'] = isset($input['allowComments']) ? (int)$input['allowComments'] : 0;
$content->moduleSettings = $settings;
$content->save();
}
}
@@ -1,36 +0,0 @@
<?php
namespace Modules\Blog\Article\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Modules\Blog\Article\Events\ApprovedComment;
use Modules\Blog\Article\Events\CreatedComment;
use Modules\Blog\Article\Events\DeletedComment;
use Modules\Blog\Article\Listeners\LogCommentApproval;
use Modules\Blog\Article\Listeners\LogDeletedComment;
use Modules\Blog\Article\Listeners\LogNewComment;
class ArticleEventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
ApprovedComment::class => [LogCommentApproval::class],
DeletedComment::class => [LogDeletedComment::class],
CreatedComment::class => [LogNewComment::class],
];
public function boot(DispatcherContract $events)
{
parent::boot($events);
}
protected function setModulePath()
{
$this->path = __DIR__;
}
}
@@ -1,35 +0,0 @@
<?php namespace Modules\Blog\Article\Providers;
use App\Providers\ModuleServiceProvider;
use Modules\Blog\Article\Pipeline\DisplayContent\LoadCommentsForBlogpost;
use Modules\Blog\Article\Pipeline\SaveContent\TurnCommentsOnOrOff;
class ArticleServiceProvider extends ModuleServiceProvider
{
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
parent::boot();
$this->app->register(ArticleEventServiceProvider::class);
// load comments for blogpost
app('displayPipeline')->add(LoadCommentsForBlogpost::class);
app('saveContentPipeline')->add(TurnCommentsOnOrOff::class);
}
protected function setModuleAlias()
{
$this->alias = 'article';
}
protected function setModulePath()
{
$this->path = __DIR__;
}
}
@@ -1,6 +0,0 @@
<?php
return [
"allowComments" => "Povolit komentáře?",
"new" => "Napsat",
"overview" => "Všechny články",
];
@@ -1,22 +0,0 @@
<?php
return [
"approve" => "Schválit komentář a zobrazovat ho u článku",
"approved" => "Komentář úspěšně schválen",
"commentedArticle" => "Komentovaný článek",
"createdAt" => "Vloženo :date",
"deleted" => "Komentář smazán",
"events" => [
"descriptions" => [
"commentApproved" => "Schválen komentář od autora :authro (:email) s následujícím obsahem: :content",
"commentCreated" => "Přidán komentář od autora :author (e-mail :e-mail) s následujícím obsahem: :content",
"commentDeleted" => "Smazán komentář od autora :author (:email) s následujícím obsahem: :content",
],
"names" => [
"commentApproved" => "Komentář schválen",
"commentCreated" => "Komentář úspěšně přidán.",
"commentDeleted" => "Smazán komentář",
],
],
"noComments" => "Nejsou dostupné žádné komentáře",
"unknownArticle" => "Neznámý článek",
];
@@ -1,12 +0,0 @@
<?php
return [
"allArticles" => "Všechny články",
"blog" => "Blog",
"comments" => "Komentáře",
"commentsOverview" => "Všechny komentáře",
"description" => "Základní submodul pro blog. Tento modul umožňuje psát články.",
"editArticle" => "Upravuji článek",
"name" => "Články",
"newArticle" => "Napsat nový článek",
"templatePath" => "Články",
];
@@ -1,6 +0,0 @@
<?php
return [
'allowComments' => 'Allow comments?',
'new' => 'Write new',
'overview' => 'All articles'
];
@@ -1,22 +0,0 @@
<?php
return [
'createdAt' => 'Created at :date',
'commentedArticle' => 'Article',
'approve' => 'Approve comment',
'approved' => 'Comment successfully approved',
'deleted' => 'Comment deleted',
'unknownArticle' => 'Unknown article',
'noComments' => 'No comments available',
'events' => [
'names' => [
'commentCreated' => 'Added comment',
'commentApproved' => 'Approved comment',
'commentDeleted' => 'Deleted comment',
],
'descriptions' => [
'commentCreated' => 'Added comment from author :author with e-mail :email and following content: :content',
'commentApproved' => 'Approved comment from author :author with e-mail :email and following content: :content',
'commentDeleted' => 'Deleted comment from author :author with e-mail :email and following content: :content',
],
]
];
@@ -1,12 +0,0 @@
<?php
return [
'name' => 'Articles',
'description' => 'Base submodule for blog',
'comments' => 'Comments',
'commentsOverview' => 'All comments',
'blog' => 'Blog',
'allArticles' => 'All articles',
'newArticle' => 'Write new article',
'editArticle' => 'Editing article',
'templatePath' => 'Articles',
];
@@ -1,6 +0,0 @@
<?php
return [
"allowComments" => "Povoliť komentáre?",
"new" => " Napísať nový",
"overview" => "Všetky články",
];
@@ -1,8 +0,0 @@
<?php
return [
"approve" => "Schváliť komentár",
"approved" => "Komentár úspešne schválený.",
"commentedArticle" => "Článok",
"createdAt" => "Vytvorené: :date",
"deleted" => "Komentár zmazaný.",
];
@@ -1,9 +0,0 @@
<?php
return [
"allArticles" => "Všetky články",
"blog" => "Blog",
"comments" => "Komentáre",
"commentsOverview" => "Všetky komentáre",
"description" => "Základný submodul pre blog",
"name" => "Články",
];
@@ -1,56 +0,0 @@
@extends('admin.layoutWithNavigation')
@section('pageHeading', trans('article::module.comments'))
@section('content')
@if (count($comments))
@foreach($comments as $comment)
<div class="card @if(!$comment->approved) card-warning @else card-default @endif">
<div class="card-header">
<div class="header-block">
<p class="title">
<img src="@gravatar($comment->email, 25)" class="img-rounded" alt="">
{{$comment->name}} ({{$comment->email}})
</p>
</div>
</div>
<div class="card-block">
<p>
{{$comment->content}}
</p>
</div>
<div class="card-footer">
@lang('article::comments.createdAt', ['date' => \App\CMS\Helpers\Date::date($comment->created_at)])
|
@lang('article::comments.commentedArticle'):
@if(!is_null($comment->article))
<a href="{{route('page.content', ['url' => $comment->article->url])}}" target="_blank">
{{$comment->article->title}}
</a>
@else
@lang('article::comments.unknownArticle')
@endif
<div class="pull-right">
@if (!$comment->approved)
<a href="{{route('comments.approve', ['id' => $comment->id])}}"
class="btn btn-sm btn-success" title="@lang('article::comments.approve')"
data-toggle="tooltip"><i class="fa fa-fw fa-check"></i></a>
@endif
<a href="{{route('comments.delete', ['id' => $comment->id])}}"
class="btn btn-sm confirm btn-warning"><i class="fa fa-fw fa-trash"></i></a>
</div>
</div>
</div>
@endforeach
@else
<div class="alert alert-info">
@lang('article::comments.noComments')
</div>
@endif
@endsection
@@ -1,89 +0,0 @@
<div class="row">
<div class="col-lg-6">
<input type="text" name="title" required class="form-control slug-source"
placeholder="@lang('admin/contents.field_title')"
value="{{old('title', $page->title)}}" />
@include('admin.snippets.hasError', ['field' => 'title'])
</div>
<div class="col-lg-4">
<input type="text" name="url" required class="form-control slug-target"
placeholder="@lang('admin/contents.field_url')"
value="{{old('url', $page->url)}}" />
@include('admin.snippets.hasError', ['field' => 'url'])
</div>
<div class="col-lg-2 text-center">
<label>
<input class="checkbox" value="1" id="lockUrl"
@if(old('lockUrl') || ($page->id > 0 && \Illuminate\Support\Str::slug($page->title) != $page->url)) checked
@endif name="lockUrl" type="checkbox">
<span>@lang('admin/contents.lockUrl')</span>
</label>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<select class="form-control" name="status">
@foreach($contentStatuses as $status => $translation)
<option value="{{$status}}" @if(old('status', $page->status) == $status) selected @endif>
{{$translation}}
</option>
@endforeach
</select>
@include('admin.snippets.hasError', ['field' => 'status'])
</div>
<div class="col-lg-4">
<select class="form-control" name="parentId">
<option value="">@lang('admin/contents.noParentPage')</option>
@foreach($rootPages as $rootPage)
<option value="{{$rootPage->id}}"
@if(old('parentId', $page->parentId) == $rootPage->id) selected @endif>
{{$rootPage->title}}
</option>
@endforeach
</select>
@include('admin.snippets.hasError', ['field' => 'parentPage'])
</div>
<div class="col-lg-2 text-center">
<label>
<input class="checkbox" value="1"
@if(old('allowComments', isset($page->moduleSettings->allowComments) ? $page->moduleSettings->allowComments : true)) checked
@endif name="allowComments" type="checkbox">
<span>@lang('article::article.allowComments')</span>
</label>
</div>
@if($module->support_categories && count($categories))
<div class="col-lg-12">
<select class="form-control" name="categoryId">
<option value="">@lang('admin/contents.noCategory')</option>
@foreach($categories as $category)
<option value="{{$category->id}}"
@if($category->id == old('categoryId', $page->categoryId)) selected @endif>
{{str_repeat(' - ', $category->real_depth)}} {{$category->name}}
</option>
@endforeach
</select>
</div>
@endif
</div>
<div class="row">
<div class="col-lg-12">
<textarea name="pageContent" id="pageContent" class="wysiwyg-editor">
{{old('pageContent', $page->pageContent)}}
</textarea>
</div>
</div>
-15
View File
@@ -1,15 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Register Namespaces And Routes
|--------------------------------------------------------------------------
|
| When a module starting, this file will executed automatically. This helps
| to register some namespaces like translator or view. Also this file
| will load the routes file for each module. You may also modify
| this file as you want.
|
*/
require __DIR__ . DIRECTORY_SEPARATOR.'Http'.DIRECTORY_SEPARATOR.'routes.php';
@@ -1,12 +0,0 @@
<?php
return [
'name' => 'Article list',
'translatedName' => 'articlelist::module.name',
'translatedDescription' => 'articlelist::module.description',
'alias' => 'articlelist',
'handler' => \Modules\Blog\ArticleList\Handlers\ArticleList::class,
'providers' => [\Modules\Blog\ArticleList\Providers\ArticleListServiceProvider::class],
'files' => ['start.php'],
'order' => 0,
];
@@ -1,28 +0,0 @@
<?php
namespace Modules\Blog\ArticleList\Handlers;
use App\CMS\Handlers\Handler;
use App\Models\User;
class ArticleList extends Handler
{
public static function registerAdminMenu(User $user)
{
parent::registerAdminMenu($user);
$menu = \Menu::instance('mainMenu');
$blogSubmenu = $menu->whereTitle(trans('article::module.blog'));
if (!$blogSubmenu) {
$blogSubmenu = $menu->dropdown(trans('article::module.blog'), function ($sub) {
}, 20, ['icon' => 'fa fa-fw fa-book']);
}
$blogSubmenu->route('content.new', trans('articlelist::module.name'), ['id' => config('articlelist.alias')], 100, ['icon' => 'fa fa-fw fa-list-alt']);
}
public static function supportCategories()
{
return false;
}
}
@@ -1,12 +0,0 @@
<?php namespace Modules\Blog\ArticleList\Http\Controllers;
use Pingpong\Modules\Routing\Controller;
class ArticleListController extends Controller {
public function index()
{
return view('articlelist::index');
}
}
-1
View File
@@ -1 +0,0 @@
<?php
@@ -1,120 +0,0 @@
<?php
namespace Modules\Blog\ArticleList\Pipeline\DisplayContent;
use App\CMS\Contracts\Content\DisplayPipeline\Process;
use App\CMS\Contracts\Repositories\Content as IContent;
use App\Models\Content\Content;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Modules\Blog\Article\Entities\Article as ArticleModel;
use Modules\Blog\Article\Handlers\Article;
use Modules\Blog\ArticleList\Handlers\ArticleList;
class LoadArticlesForList implements Process
{
/**
* Process and modify given page
*
* @param Content $page
*
* @return mixed
*/
function handle(Content & $page)
{
// load articles only for article list
if ($page->moduleHandler != ArticleList::class)
return;
$articles = ArticleModel::where('moduleHandler', Article::class)
->with('comments')
->with('category')
->where(function ($query) {
$query->where('publishedFrom', '<', Carbon::now())
->orWhereNull('publishedFrom');
})
->where(function ($query) {
$query->where('publishedTo', '>', Carbon::now())
->orWhereNull('publishedTo');
})
->orderBy('publishedFrom', 'DESC')
->orderBy('created_at', 'DESC');
// show articles for not-logged users of even for logged onew?
$articles = !Auth::user() ? $articles->where('status', IContent::STATUS_PUBLIC) : $articles->whereIn('status', [
IContent::STATUS_PUBLIC,
IContent::STATUS_PROTECTED
]);
// selected articles from archive?
$this->archive($articles);
// is given any category?
$this->category($articles);
// show articles only from specified user
$author = Input::get('author');
if ($author) {
$user = User::findOrFail($author);
$articles = $articles->where('user_id', $user->id);
}
$page->articles = $articles->paginate(setting('articlesPerPage', 20));
}
/**
* Filter articles on article list using archive
*
* @param $articles
*/
protected function archive(&$articles)
{
$year = Input::get('y');
$month = Input::get('m');
$day = Input::get('d');
if ($year) {
$articles = $articles->where(DB::raw('YEAR(created_at)'), $year);
}
if ($month) {
$articles = $articles->where(DB::raw('MONTH(created_at)'), $month);
}
if ($day) {
$articles = $articles->where(DB::raw('DAY(created_at)'), $day);
}
}
/**
* Filter article list to some specified category
*
* Category URL is specified as GET attribute "category"
*
* @param $articles
*/
protected function category(&$articles)
{
$categoryUrl = Input::get('category');
$categoriesEnabled = \Module::get('Categories')
->enabled();
if ($categoryUrl && $categoriesEnabled) {
$category = Category::where('url', $categoryUrl)
->firstOrFail();
$subcategories = $category->getChildren()
->toArray();
$categories = [$category->id];
$categories = array_merge($categories, array_map(function ($cat) {
return $cat['id'];
}, $subcategories));
$articles = $articles->whereIn('category_id', $categories);
}
}
}
@@ -1,24 +0,0 @@
<?php namespace Modules\Blog\ArticleList\Providers;
use App\Providers\ModuleServiceProvider;
use Modules\Blog\ArticleList\Pipeline\DisplayContent\LoadArticlesForList;
class ArticleListServiceProvider extends ModuleServiceProvider
{
protected function setModuleAlias()
{
$this->alias = 'articlelist';
}
protected function setModulePath()
{
$this->path = __DIR__;
}
public function boot()
{
parent::boot();
app('displayPipeline')->add(LoadArticlesForList::class);
}
}
@@ -1,6 +0,0 @@
<?php
return [
"description" => "Modul pro zobrazování seznamu článků na webu.",
"name" => "Seznam článků",
"templatePath" => "Seznam článků",
];
@@ -1,6 +0,0 @@
<?php
return [
'name' => 'Article list',
'description' => 'Module for displaying list of articles on web',
'templatePath' => 'Article list',
];
@@ -1,5 +0,0 @@
<?php
return [
"description" => "Modul pre zobrazenie zoznamu článkov na webe",
"name" => "Zoznam článkov",
];
-15
View File
@@ -1,15 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Register Namespaces And Routes
|--------------------------------------------------------------------------
|
| When a module starting, this file will executed automatically. This helps
| to register some namespaces like translator or view. Also this file
| will load the routes file for each module. You may also modify
| this file as you want.
|
*/
require __DIR__ . DIRECTORY_SEPARATOR.'Http'.DIRECTORY_SEPARATOR.'routes.php';
@@ -1,51 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateComments extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('user_id')
->nullable(true)
->default(null)
->comment('When comment was inserted by logged user, save his ID here');
$table->integer('content_id');
$table->string('email');
$table->string('name');
$table->text('content');
$table->boolean('approved');
$table->foreign('content_id')
->references('id')
->on('contents')
->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('set null')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('comments');
}
}
@@ -1,34 +0,0 @@
<?php
use App\Models\Module;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UpdateAliasForSubdomodules extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Module::where('alias', 'blog-articlelist')
->update(['alias' => 'articlelist']);
Module::where('alias', 'blog-article')
->update(['alias' => 'article']);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Module::where('alias', 'articlelist')
->update(['alias' => 'blog-articlelist']);
Module::where('alias', 'article')
->update(['alias' => 'blog-article']);
}
}
-7
View File
@@ -1,7 +0,0 @@
<?php
return [
'name' => 'Blog',
'translatedName' => 'article::module.blog',
'description' => 'article.module.blogDescription',
'hasSubmodules' => true,
];
-12
View File
@@ -1,12 +0,0 @@
<?php
return [
'name' => 'Categories',
'translatedName' => 'categories::module.name',
'translatedDescription' => 'categories::module.description',
'alias' => 'categories',
'handler' => \Modules\Categories\Handlers\Categories::class,
'providers' => [\Modules\Categories\Providers\CategoriesServiceProvider::class],
'files' => ['start.php'],
'order' => 0,
];
@@ -1,9 +0,0 @@
<?php
namespace Modules\Categories\Contracts\Repositories;
use App\CMS\Contracts\Repositories\BaseRepository;
use App\Models\Module;
interface Category {
public function getForModule(Module $module);
}
@@ -1,61 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCategoriesTable extends Migration
{
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('parent_id')
->unsigned()
->nullable();
$table->integer('position', false, true);
$table->integer('real_depth', false, true);
$table->integer('user_id')
->comment('Author of this category');
$table->integer('module_id')
->comment('ID of module, where this category is used');
$table->string('name')
->comment('Human readable name of category');
$table->string('url')
->index()
->comment('URL slug of category');
$table->text('description');
$table->unique(['url', 'module_id']);
});
Schema::table('categories', function (Blueprint $table) {
$table->foreign('parent_id')
->references('id')
->on('categories')
->onDelete('set null');
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade')
->onUpdate('cascade');
$table->foreign('module_id')
->references('id')
->on('modules')
->onDelete('cascade')
->onUpdate('cascade');
});
}
public function down()
{
Schema::table('categories', function (Blueprint $table) {
Schema::dropIfExists('categories');
});
}
}
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCategoryClosuresTable extends Migration
{
public function up()
{
Schema::create('category_closure', function (Blueprint $table) {
$table->increments('closure_id');
$table->integer('ancestor', false, true);
$table->integer('descendant', false, true);
$table->integer('depth', false, true);
$table->foreign('ancestor')
->references('id')
->on('categories')
->onDelete('cascade');
$table->foreign('descendant')
->references('id')
->on('categories')
->onDelete('cascade');
});
}
public function down()
{
Schema::table('category_closure', function (Blueprint $table) {
Schema::dropIfExists('category_closure');
});
}
}
@@ -1,20 +0,0 @@
<?php namespace Modules\Categories\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class CategoriesDatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace Modules\Categories\Entities;
use App\Models\Content\Content;
use App\Models\Module;
use Franzose\ClosureTable\Models\Entity;
class Category extends Entity
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'categories';
public $timestamps = true;
/**
* ClosureTable model instance.
*
* @var categoryClosure
*/
protected $closure = 'Modules\Categories\Entities\CategoryClosure';
public function module()
{
return $this->belongsTo(Module::class);
}
public function content()
{
return $this->hasMany(Content::class, 'categoryId');
}
}
@@ -1,14 +0,0 @@
<?php
namespace Modules\Categories\Entities;
use Franzose\ClosureTable\Models\ClosureTable;
class CategoryClosure extends ClosureTable
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'category_closure';
}
@@ -1,26 +0,0 @@
<?php
namespace Modules\Categories\Handlers;
use App\CMS\Contracts\Modules\BaseModuleHandler;
use App\Models\User;
class Categories implements BaseModuleHandler
{
/**
* Register admin menu (or multiple ones)
*
* This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before
* starting any middleware..
*
* @param User $user model of logged user
*/
public static function registerAdminMenu(User $user)
{
// register links in admin menu
$menu = \Menu::instance('mainMenu');
$menu->dropdown(trans('categories::categories.name'), function ($sub) {
$sub->route('categories.new', trans('categories::categories.new'), [], 10, ['icon' => 'fa fa-fw fa-plus']);
$sub->route('categories.overview', trans('categories::categories.overview'), [], 30, ['icon' => 'fa fa-fw fa-tags']);
}, 55, ['icon' => 'fa fa-fw fa-tags']);
}
}
@@ -1,23 +0,0 @@
<?php namespace Modules\Categories\Http\Controllers;
use App\CMS\Enumerations\ModuleNamesWithIds;
use App\Models\Module;
use Modules\Categories\Entities\Category;
use Pingpong\Modules\Routing\Controller;
class CategoriesOverview extends Controller
{
public function getOverview()
{
// get list of all categories
$categories = Category::getTree()
->toArray();
$modules = ModuleNamesWithIds::getWithTranslations();
return view('categories::admin.overview', [
'categories' => $categories,
'modules' => $modules
]);
}
}
@@ -1,61 +0,0 @@
<?php namespace Modules\Categories\Http\Controllers;
use App\Http\Requests\Request;
use App\Models\Module;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Modules\Categories\Entities\Category;
use Pingpong\Modules\Routing\Controller;
class CreateNewCategory extends Controller
{
/**
* Display form for new category
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getNew()
{
// get list of all categories
$categories = Category::getTree()
->toArray();
// get list of modules which supports categories
$modules = Module::where('enabled', true)
->where('support_categories', true)
->get();
return view('categories::admin.new', [
'category' => new Category(),
'categories' => $categories,
'modules' => $modules
]);
}
/**
* Create new category
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postNew(Request $request)
{
$category = new Category();
$category->user_id = Auth::user()->id;
$category->module_id = $request->moduleId;
$category->name = $request->name;
$category->url = Str::slug($request->url);
$category->description = $request->description;
if ((int)$request->parentCategory) {
$category->parent_id = $request->parentCategory;
}
$category->save();
return redirect()
->route('categories.overview')
->with('success', trans('categories::categories.saveSuccessfull'));
}
}
@@ -1,77 +0,0 @@
<?php namespace Modules\Categories\Http\Controllers;
use App\Http\Requests\Request;
use App\Models\Module;
use Illuminate\Support\Str;
use Modules\Categories\Entities\Category;
use Pingpong\Modules\Routing\Controller;
class EditCategory extends Controller
{
/**
* Display form for editing category
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getEdit($id)
{
$category = Category::findOrFail($id);
// get list of all categories
$categories = Category::getTree()
->toArray();
// get list of modules which supports categories
$modules = Module::where('enabled', true)
->where('support_categories', true)
->get();
return view('categories::admin.edit', [
'category' => $category,
'categories' => $categories,
'modules' => $modules
]);
}
/**
* Create new category
*
* @param Request $request
* @param $id
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postEdit(Request $request, $id)
{
$category = Category::findOrFail($id);
$category->name = $request->name;
$category->url = Str::slug($request->url);
$category->description = $request->description;
$category->save();
if ($category->parent_id !== $request->parentCategory) {
$category->parent_id = empty($request->parentCategory) ? null : $request->parentCategory;
$category->save();
if (empty($request->parentCategory)) {
$category->makeRoot($category->position);
}
}
return redirect()
->route('categories.edit', ['id' => $id])
->with('success', trans('categories::categories.saveSuccessfull'));
}
public function delete($id) {
$category = Category::findOrFail($id);
$category->delete();
return redirect()
->route('categories.overview')
->with('success', trans('categories::categories.deleteSuccessfull'));
}
}
-23
View File
@@ -1,23 +0,0 @@
<?php
Route::group([
'prefix' => LaravelLocalization::setLocale() . '/admin/categories',
'middleware' => ['admin'],
'namespace' => 'Modules\Categories\Http\Controllers'
], function () {
Route::get('/', 'CategoriesOverview@getOverview')
->name('categories.overview');
Route::get('/new', 'CreateNewCategory@getNew')
->name('categories.new');
Route::post('/new', 'CreateNewCategory@postNew')
->name('categories.postNew');
Route::get('/edit/{id}', 'EditCategory@getEdit')
->name('categories.edit');
Route::post('/edit/{id}', 'EditCategory@postEdit')
->name('categories.postEdit');
Route::get('/delete/{id}', 'EditCategory@delete')
->name('categories.delete');
});
@@ -1,26 +0,0 @@
<?php
namespace Modules\Categories\Providers;
use App\Providers\ModuleServiceProvider;
use Modules\Categories\Contracts\Repositories\Category as ICategory;
use Modules\Categories\Repositories\Category as Category;
class CategoriesServiceProvider extends ModuleServiceProvider
{
protected function setModuleAlias()
{
$this->alias = 'categories';
}
public function boot()
{
parent::boot();
$this->app->bind(ICategory::class, Category::class);
}
protected function setModulePath()
{
$this->path = __DIR__;
}
}
@@ -1,22 +0,0 @@
<?php
namespace Modules\Categories\Repositories;
use App\Models\Module;
use Modules\Categories\Entities\Category as CategoryModel;
use Modules\Categories\Contracts\Repositories\Category as ICategory;
use Pingpong\Modules\Facades\Module as ModuleInstance;
class Category implements ICategory
{
public function getForModule(Module $module)
{
$categoryModule = ModuleInstance::get('categories');
$categories = [];
if ($module->support_categories && !is_null($categoryModule) && $categoryModule->enabled()) {
$categories = CategoryModel::where('module_id', $module->id)
->get();
}
return $categories;
}
}
@@ -1,20 +0,0 @@
<?php
return [
"actions" => "Akce",
"deleteSuccessfull" => "Kategorie úspěšně smazána",
"description" => "Modul pro správu a kategorizaci obsahu.",
"edit" => "Úprava kategorie",
"fields" => ["description" => "Popis",
"module" => "Modul",
"name" => "Jméno",
"parentCategory" => "Rodičovská kategorie",
"save" => "Uložit",
"url" => "URL",
],
"module" => "Modul",
"name" => "Kategorie",
"new" => "Nová kategorie",
"noCategories" => "Žádná vytvořená kategorie.",
"overview" => "Všechny kategorie",
"saveSuccessfull" => "Kategorie úspěšně uložena",
];
@@ -1,21 +0,0 @@
<?php
return [
'name' => 'Categories',
'description' => 'Module for category management and content categorization.',
'new' => 'New category',
'overview' => 'All categories',
'fields' => [
'name' => 'Name',
'description' => 'Description',
'url' => 'URL',
'module' => 'Module',
'parentCategory' => 'Parent category',
'save' => 'Save category'
],
'edit' => 'Edit category',
'saveSuccessfull' => 'Category successfully saved',
'deleteSuccessfull' => 'Category successfully deleted',
'module' => 'Module',
'actions' => 'Actions',
'noCategories' => 'No categories available'
];
@@ -1,20 +0,0 @@
<?php
return [
"actions" => "Akcie",
"deleteSuccessfull" => "Kategória úspešne zmazaná.",
"description" => "Modul pre správu kategórií a kategorizovanie obsahu",
"edit" => "Upraviť kategóriu",
"fields" => ["description" => "Popis",
"module" => "Modul",
"name" => "Názov",
"parentCategory" => "Rodičovská kategória",
"save" => "Uložiť kategóriu",
"url" => "URL",
],
"module" => "Modul",
"name" => "Kategórie",
"new" => "Nová kategória",
"noCategories" => "Žiadne kategórie nie sú dostupné.",
"overview" => "Všetky kategórie",
"saveSuccessfull" => "Kategória úspešne uložená.",
];
@@ -1,7 +0,0 @@
@extends('admin.layoutWithNavigation')
@section('pageHeading', trans('categories::categories.edit'))
@section('content')
@include('categories::admin.form', ['action' => route('categories.postEdit', ['id' => $category->id])])
@endsection
@@ -1,67 +0,0 @@
<form action="{{$action}}" method="post">
{!! csrf_field() !!}
<div class="row">
<div class="col-lg-5">
<label class="label-control">
@lang('categories::categories.fields.name')
</label>
<input type="text" name="name" class="form-control slug-source" value="{{old('name', $category->name)}}">
</div>
<div class="col-lg-5">
<label>
@lang('categories::categories.fields.url')
</label>
<input type="text" name="url" class="form-control slug-target" value="{{old('url', $category->url)}}">
</div>
<div class="col-lg-2 text-center">
<div>
<label>
<input class="checkbox" value="1" id="lockUrl"
@if(old('lockUrl') || ($category->id > 0 && \Illuminate\Support\Str::slug($category->name) != $category->url)) checked
@endif name="lockUrl" type="checkbox">
<span>@lang('admin/contents.lockUrl')</span>
</label>
</div>
</div>
</div>
<label class="label-control">
@lang('categories::categories.fields.description')
</label>
<textarea class="form-control" name="description">{{old('description', $category->description)}}</textarea>
<div class="row">
<div class="col-lg-6">
<label class="label-control">
@lang('categories::categories.fields.module')
</label>
<select class="form-control" name="moduleId" @if($category->id) disabled @endif>
@foreach($modules as $module)
<option @if($module->id == $category->module_id) selected
@endif value="{{$module->id}}">{{trans($module->name)}}</option>
@endforeach
</select>
</div>
<div class="col-lg-6">
@if(count($categories))
<label class="label-control">
@lang('categories::categories.fields.parentCategory')
</label>
<select class="form-control" name="parentCategory">
<option value="">@lang('admin/contents.noCategory')</option>
@foreach($categories as $parentCategory)
@include('categories::admin.snippets.optionParentCategories', ['level' => 0, 'selectedCategory' => $category, 'currentCategory' => $parentCategory])
@endforeach
</select>
@endif
</div>
</div>
<button type="submit" class="btn btn-primary">@lang('categories::categories.fields.save')</button>
</form>
@@ -1,7 +0,0 @@
@extends('admin.layoutWithNavigation')
@section('pageHeading', trans('categories::categories.new'))
@section('content')
@include('categories::admin.form', ['action' => route('categories.postNew')])
@endsection
@@ -1,26 +0,0 @@
@extends('admin.layoutWithNavigation')
@section('pageHeading', trans('categories::categories.overview'))
@section('content')
@if(count($categories))
<table class="table table-striped">
<thead>
<tr>
<th>@lang('categories::categories.name')</th>
<th>@lang('categories::categories.module')</th>
<th>@lang('categories::categories.actions')</th>
</tr>
</thead>
<tbody>
@foreach($categories as $category)
@include('categories::admin.snippets.overviewRow', ['level' => 0, 'currentCategory' => $category])
@endforeach
</tbody>
</table>
@else
<div class="alert alert-info">
@lang('categories::categories.noCategories')
</div>
@endif
@stop
@@ -1,9 +0,0 @@
<option @if($currentCategory['id'] == $selectedCategory->parent_id) selected @endif value="{{$currentCategory['id']}}">
{{str_repeat('-', $level)}} {{$currentCategory['name']}}
</option>
@if(isset($currentCategory['children']))
@foreach($currentCategory['children'] as $category)
@include('categories::admin.snippets.optionParentCategories', ['selectedCategory' => $selectedCategory, 'currentCategory' => $category, 'level' => $level+1])
@endforeach
@endif
@@ -1,17 +0,0 @@
<tr>
<td>
{{str_repeat('-', $level)}} {{$currentCategory['name']}}
</td>
<td>@lang($modules[$currentCategory['module_id']])</td>
<td>
<a href="{{route('categories.edit', ['id' => $currentCategory['id']])}}"><i class="fa fa-fw fa-edit"></i></a>
<a class="confirm" href="{{route('categories.delete', ['id' => $currentCategory['id']])}}"><i class="fa fa-fw fa-remove"></i></a>
</td>
</tr>
@if(isset($currentCategory['children']))
@foreach($currentCategory['children'] as $category)
@include('categories::admin.snippets.overviewRow', ['currentCategory' => $category, 'level' => $level+1])
@endforeach
@endif
-15
View File
@@ -1,15 +0,0 @@
{
"name": "pingpong-modules/categories",
"description": "",
"authors": [
{
"name": "Pingpong Labs",
"email": "pingpong.labs@gmail.com"
}
],
"autoload": {
"psr-4": {
"Modules\\Categories\\": ""
}
}
}
-15
View File
@@ -1,15 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Register Namespaces And Routes
|--------------------------------------------------------------------------
|
| When a module starting, this file will executed automatically. This helps
| to register some namespaces like translator or view. Also this file
| will load the routes file for each module. You may also modify
| this file as you want.
|
*/
require __DIR__ . DIRECTORY_SEPARATOR.'Http'.DIRECTORY_SEPARATOR.'routes.php';
View File
-12
View File
@@ -1,12 +0,0 @@
<?php
return [
'name' => 'ContactForm',
'translatedName' => 'contactform::module.name',
'translatedDescription' => 'contactform::module.description',
'alias' => 'contactform',
'handler' => '\\Modules\\ContactForm\\Handlers\\ContactForm',
'providers' => [\Modules\ContactForm\Providers\ContactFormServiceProvider::class],
'files' => ['start.php'],
'order' => 0,
];
@@ -1,152 +0,0 @@
<?php
namespace Modules\ContactForm\Handlers;
use App\CMS\Contracts\Content\AdvancedContentModifier;
use App\CMS\Contracts\Content\ContentTitles;
use App\CMS\Enumerations\ModulesHandlerToId;
use App\CMS\Handlers\Handler;
use App\Http\Requests\Request;
use App\Models\Content\Content;
use App\Models\User;
class ContactForm extends Handler implements ContentTitles, AdvancedContentModifier
{
public static function getHistoryHandler()
{
return ContactFormHistory::class;
}
public static function getModuleId()
{
$handler = config('contactform.handler');
$allModules = ModulesHandlerToId::getWithTranslations();
$moduleId = isset($allModules[$handler]) ? $allModules[$handler] : null;
return $moduleId;
}
/**
* Getter for section names in creating/editing content resource
*
* @return mixed
*/
public static function getExtendedFormSections()
{
$sections = parent::getExtendedFormSections();
$sections['content'] = trans('contactform::admin/content.content');
return $sections;
}
/**
* Getter for views used in extended part of form for creating new content
*
* This method should return pairs <section, view-name>. View is returned only as name in plain text
*
* @return array of views/templates/html codes divided into section
*/
public static function getExtendedFormInputsCreate()
{
return [
'basicInfo' => 'contactform::admin.form.basicInfo',
'content' => 'contactform::admin.form.content',
'meta' => 'admin.content.formParts.metaInformation',
'appearance' => 'admin.content.formParts.appearance',
'publication' => 'admin.content.formParts.publicationSetup',
'files' => 'admin.content.formParts.files',
];
}
public static function getExtendedFormInputsEdit()
{
return self::getExtendedFormInputsCreate();
}
/**
* Register admin menu (or multiple ones)
*
* This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before
* starting any middleware..
*
* @param User $user model of logged user
*/
public static function registerAdminMenu(User $user)
{
// register links in admin menu
$menu = \Menu::instance('mainMenu');
$submenu = $menu->whereTitle(trans('admin/mainMenu.contentPages'));
$submenu->dropdown(trans('contactform::admin/adminMenu.contactForm'), function ($submenu) use ($user) {
$submenu->route('content.new', trans('contactform::admin/adminMenu.new'), ['moduleId' => self::getModuleId()], 10, ['icon' => 'fa fa-plus']);
$submenu->route('content.overview', trans('contactform::admin/adminMenu.overview'), ['moduleId' => self::getModuleId()], 20, ['icon' => 'fa fa-list']);
// $submenu->route('emails.sent', trans('contactform::admin/adminMenu.sentMessages'), [], 30, ['icon' => 'fa fa-send']);
}, 25, ['icon' => 'fa fa-envelope-o']);
}
/**
* Does given module manage content? Or is it just module with widgets/something internal/something absolutely else?
*
* @return bool
*/
public static function managesContent()
{
return true;
}
/**
* Get translated title for pages overview of given type.
*
* This value is used for rendering list of all content pages of given type in administration.
*
* @return string
*/
public static function getOverviewTitle()
{
return trans('contactform::module.allForms');
}
/**
* Title displayed above for for creating new content page
*
* @return string
*/
public static function getCreateNewTitle()
{
return trans('contactform::module.newForm');
}
/**
* Title for form displayed for editin content page
*
* @param Content $content
*
* @return mixed
*/
public static function getEditTitle(Content $content)
{
return trans('contactform::module.editForm');
}
/**
* Does this module support categories?
*
* @return boolean
*/
public static function supportCategories()
{
return true;
}
/**
* Method called right after content page is marked as deleted
*
* This method is supposed to clean after "deleted" page.
*
* @param Content $content
*
* @return mixed
*/
public static function delete(Content $content)
{
}
}
@@ -1,28 +0,0 @@
<?php
namespace Modules\ContactForm\Handlers;
use App\CMS\Handlers\History;
class ContactFormHistory extends History
{
/**
* Translate column name for history view
*
* @param $column
*
* @return mixed
*/
public static function parseColumnName($column)
{
// try to translate as contact form field
$translationString = 'contactform::admin/history.column' . ucfirst($column);
$translation = trans($translationString);
// when translation is not available, try to fallback into core fields
if ($translation == $translationString) {
return parent::parseColumnName($column);
}
return $translation;
}
}
@@ -1,60 +0,0 @@
<?php
namespace Modules\ContactForm\Http\Controllers\Visitor;
use App\CMS\Helpers\Template;
use App\Models\Content\Content;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Mail;
use Modules\ContactForm\Http\Requests\SendNewEmailRequest;
use Pingpong\Modules\Routing\Controller;
class CreateNewMessage extends Controller
{
/**
* Method for sending emails via contact form
*
* @param SendNewEmailRequest $request
* @param $formId
*
* @return mixed
*/
public function postMessage(SendNewEmailRequest $request, $formId)
{
// load form settings
$form = Content::where('moduleHandler', config('contactform.handler'))
->findOrFail($formId);
// select template
$template = isset($form->moduleSettings['emailTemplate']) ? $form->moduleSettings['emailTemplate'] : 'contactform::emails.default';
// send email
$status = Mail::send(Template::name($template), ['data' => $request], function (Message $message) use ($request, $form) {
$message->from($request->email, $request->name);
// get message subject
$subject = isset($form->moduleSettings['subject']) ? $form->moduleSettings['subject'] : trans('contactform::admin/contents.defaultSubject');
$message->to($form->moduleSettings['email'])
->subject($subject);
});
// inform user about success or failure
return $this->sendResponse($status, $request, $form);
}
private function sendResponse($status, SendNewEmailRequest $request, $form)
{
// send response for ajax
if ($request->ajax()) {
return response()->json([
'status' => $status ? 'success' : 'failed',
'redirectUrl' => $form->url
]);
} else {
// redirect user to previous form
$response = redirect()->back();
return $status ? $response->with('success', 'sent') : $response->with('error', 'cannotSend');
}
}
}
@@ -1,20 +0,0 @@
<?php namespace Modules\ContactForm\Http\Requests;
use App\Http\Requests\Request;
class SendNewEmailRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'email' => 'required|email',
'message' => 'required',
];
}
}
-12
View File
@@ -1,12 +0,0 @@
<?php
Route::group([
'middleware' => ['web'],
'namespace' => '\Modules\ContactForm\Http\Controllers\Visitor',
'prefix' => LaravelLocalization::setLocale() . '/contactform'
], function () {
// method for sending new message
Route::post('/message/{formId}', 'CreateNewMessage@postMessage')
->name('email.send');
});
@@ -1,39 +0,0 @@
<?php
namespace Modules\ContactForm\Pipeline\SavePipeline;
use App\CMS\Contracts\Content\SavePipeline\Process;
use App\Models\Content\Content;
use Modules\ContactForm\Handlers\ContactForm;
class SaveContactInformation implements Process
{
/**
* Process and modify given page
*
* @param Content $page
* @param array $input
*
* @return void>
*/
function handle(Content & $page, array & $input)
{
if (trim($page->moduleHandler, '\\') != ContactForm::class) {
return;
}
$settings = [
'phone' => $input['phone'],
'email' => $input['email'],
'contactEmail' => $input['contactEmail'],
'subject' => $input['subject'],
'companyName' => $input['companyName'],
'address' => $input['address'],
'gpsLat' => $input['gpsLat'],
'gpsLng' => $input['gpsLng'],
];
// save settings
$page->moduleSettings = $settings;
$page->save();
}
}
@@ -1,52 +0,0 @@
<?php namespace Modules\ContactForm\Providers;
use App\Providers\ModuleServiceProvider;
use Modules\ContactForm\Handlers\ContactForm;
use Modules\ContactForm\Pipeline\SavePipeline\SaveContactInformation;
use Modules\ContactForm\Widgets\Address\Address;
use Modules\ContactForm\Widgets\Form\Form;
class ContactFormServiceProvider extends ModuleServiceProvider
{
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
parent::boot();
$this->registerWidgets();
app('saveContentPipeline')->add(SaveContactInformation::class);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$registrator = $this->app->make('registerSettingsExtension');
$registrator->register('contactForm', 'contactform::module.name', 'contactform::admin.settings.form');
}
private function registerWidgets()
{
$registrator = $this->app->make('registerWidget');
$registrator->register(Address::class, null, ContactForm::getModuleId());
$registrator->register(Form::class, null, ContactForm::getModuleId());
}
protected function setModuleAlias()
{
$this->alias = 'contactform';
}
protected function setModulePath()
{
$this->path = __DIR__;
}
}
@@ -1,9 +0,0 @@
<?php
return [
"contactForm" => "Kontaktní formulář",
"emails" => "E-mailové šablony",
"new" => "Nový",
"overview" => "Všechny formuláře",
"sentMessages" => "Zprávy",
"templatePath" => "Kontaktní formulář",
];
@@ -1,15 +0,0 @@
<?php
return [
"address" => "Adresa",
"compName" => "Jméno zobrazené nad adresou",
"contactEmail" => "E-mail, kam budou doručovány zprávy z tohoto formuláře",
"contactInformation" => "Kontaktní informace",
"content" => "Obsah kontaktního formuláře",
"defaultSubject" => "Nová zpráva z kontaktního formuláře",
"email" => "E-mail",
"emailList" => "Odesílat zprávy na tyto adresy",
"gpsLat" => "GPS šířka",
"gpsLng" => "GPS délka",
"phone" => "Kontaktní telefon",
"subject" => "Předmět zprávy",
];
@@ -1,11 +0,0 @@
<?php
return [
"columnAddress" => "Adresa",
"columnCompanyName" => "Jméno společnosti",
"columnContactEmail" => "Kontaktní e-mail",
"columnEmail" => "E-mail",
"columnGpsLat" => "GPS šířka",
"columnGpsLng" => "GPS délka",
"columnPhone" => "Telefon",
"columnSubject" => "Předmět",
];
@@ -1,5 +0,0 @@
<?php
return [
"recaptchaSecret" => "Application secret kez pro reCaptcha",
"recaptchaSiteKey" => "Site key pro reCaptcha",
];
@@ -1,16 +0,0 @@
<?php
return [
"address" => [
"description" => "Malý widget určený pro zobrazení adresy, která byla uložena u vybraného kontaktního formuláře.",
"edit" => "Upravuji blok s adresou",
"name" => "Blok s adresou",
"new" => "Nový blok s adresou",
],
"form" => [
"description" => "Widget pro zobrazení kontaktního formuláře kdekoliv na webu - v obsahu stránky, menu, patičce, ...",
"name" => "Kontaktní formulář",
"new" => "Nový widget s kontaktním formulářem",
],
"noContactForms" => "Vypadá to, že v systému nebyl vytvořen žádný kontaktní formulář. Z toho důvodu není možné vytvořit ani tento widget. Vytvořte nejprve nějaký kontaktní formulář a pak opakujte tento pokus.",
"selectContactForm" => "Vybrat kontaktní formulář",
];
@@ -1,8 +0,0 @@
<?php
return [
"allForms" => "Všechny formuláře",
"description" => "Jednoduchý kontaktní formulář",
"editForm" => "Upravuji formulář",
"name" => "Kontaktní formulář",
"newForm" => "Vytvořit nový kontaktní formulář",
];
@@ -1,9 +0,0 @@
<?php
return [
'contactForm' => 'Contact form',
'new' => 'New',
'overview' => 'All contact forms',
'sentMessages' => 'Messages',
'templatePath' => 'Contact form',
'emails' => 'E-mail templates',
];
@@ -1,15 +0,0 @@
<?php
return [
'content' => 'Contact form content',
'address' => 'Address',
'emailList' => 'Send emails to these addresses',
'gpsLat' => 'GPS latitude',
'gpsLng' => 'GPS longitude',
'compName' => 'Name displayed above address',
'phone' => 'Contact phone',
'email' => 'E-mail',
'contactEmail' => 'E-mail, where messages from this form will be delivered',
'contactInformation' => 'Contact information',
'subject' => 'Subject',
'defaultSubject' => 'New message from contact form'
];
@@ -1,12 +0,0 @@
<?php
return [
'columnPhone' => 'Phone',
'columnAddress' => 'Address',
'columnEmail' => 'E-mail',
'columnContactEmail' => 'Contact E-mail',
'columnSubject' => 'Subject',
'columnCompanyName' => 'Company name',
'columnGpsLat' => 'GPS Latitude',
'columnGpsLng' => 'Gps Longitude',
];
@@ -1,5 +0,0 @@
<?php
return [
'recaptchaSiteKey' => 'reCAPTCHA site key',
'recaptchaSecret' => 'reCAPTCHA application secret key',
];
@@ -1,16 +0,0 @@
<?php
return [
'address' => [
'name' => 'Address block',
'description' => 'Small widget for displaying address saved in selected contact form.',
'new' => 'New address block',
'edit' => 'Editing address block'
],
'form' => [
'name' => 'Contact form',
'description' => 'Display small contact form anywhere on website.',
'new' => 'New contact form widget'
],
'noContactForms' => 'You have not created any contact form. Try to create one before creating this widget.',
'selectContactForm' => 'Select contact form'
];
@@ -1,8 +0,0 @@
<?php
return [
'name' => 'Contact form',
'description' => 'Simple contact form',
'allForms' => 'All contact forms',
'newForm' => 'Create new contact form',
'editForm' => 'Editing contact form'
];
@@ -1,8 +0,0 @@
<?php
return [
"contactForm" => "Kontaktný formulár",
"new" => "Nový",
"overview" => "Všetky formuláre",
"sentMessages" => "Správy",
"templatePath" => "Kontaktný formulár",
];
@@ -1,15 +0,0 @@
<?php
return [
"address" => "Adresa",
"compName" => "Názov zobrazený nad adresou",
"contactEmail" => "E-mail, kam budú doručované správy z tohoto formulára",
"contactInformation" => "Kontaktné informácie",
"content" => "Obsah kontaktného formulára",
"defaultSubject" => "Nová správa z kontaktného formulára",
"email" => "E-mail",
"emailList" => "Odosielať správy na tieto adresy",
"gpsLat" => "GPS šírka",
"gpsLng" => "GPS dĺžka",
"phone" => "Kontaktný telefón",
"subject" => "Predmet správy",
];
@@ -1,11 +0,0 @@
<?php
return [
"columnAddress" => "Adresa",
"columnCompanyName" => "Názov spoločnosti",
"columnContactEmail" => "Kontaktný e-mail",
"columnEmail" => "E-mail",
"columnGpsLat" => "GPS šírka",
"columnGpsLng" => "GPS dĺžka",
"columnPhone" => "Telefón",
"columnSubject" => "Predmet",
];
@@ -1,5 +0,0 @@
<?php
return [
"recaptchaSecret" => "Application secret key pre reCaptcha",
"recaptchaSiteKey" => "Site key pre reCaptcha",
];

Some files were not shown because too many files have changed in this diff Show More