FEATURE: add searching in content pages
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
namespace App\Handlers\Search;
|
namespace App\Handlers\Search;
|
||||||
|
|
||||||
use App\Handlers\Contracts\SearchHandler;
|
use App\Handlers\Contracts\SearchHandler;
|
||||||
|
use App\Models\Content as ContentModel;
|
||||||
|
|
||||||
class Content implements SearchHandler
|
class Content implements SearchHandler
|
||||||
{
|
{
|
||||||
@@ -16,9 +17,9 @@ class Content implements SearchHandler
|
|||||||
{
|
{
|
||||||
$token = '%' . $term . '%';
|
$token = '%' . $term . '%';
|
||||||
|
|
||||||
return Content::where('content', 'LIKE', $token)
|
return ContentModel::where('content', 'LIKE', $token)
|
||||||
->orWhere('description', 'LIKE', $token)
|
->orWhere('meta_description', 'LIKE', $token)
|
||||||
->orWhere('keywords', 'LIKE', $token)
|
->orWhere('meta_keywords', 'LIKE', $token)
|
||||||
->orWhere('title', 'LIKE', $token)
|
->orWhere('title', 'LIKE', $token)
|
||||||
->orWhere('url', 'LIKE', $token)
|
->orWhere('url', 'LIKE', $token)
|
||||||
->get();
|
->get();
|
||||||
@@ -31,6 +32,6 @@ class Content implements SearchHandler
|
|||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return trans('...');
|
return trans('search.content');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Handlers\Search\Presenters;
|
||||||
|
|
||||||
|
use App\Handlers\Contracts\SearchPresenterHandler;
|
||||||
|
|
||||||
|
class AdminContent implements SearchPresenterHandler
|
||||||
|
{
|
||||||
|
public function render($foundItems)
|
||||||
|
{
|
||||||
|
return view('admin.content.overviewTiles', ['pages' => $foundItems, 'tileClass' => 'large-4']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Handlers\Search\Presenters;
|
|
||||||
|
|
||||||
use App\Handlers\Contracts\SearchPresenterHandler;
|
|
||||||
|
|
||||||
class Content implements SearchPresenterHandler
|
|
||||||
{
|
|
||||||
public function render($foundItems)
|
|
||||||
{
|
|
||||||
var_dump($foundItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ use App\Handlers\Registrators\SettingsExtensionRegistrator;
|
|||||||
use App\Handlers\Registrators\TemplateRegistrator;
|
use App\Handlers\Registrators\TemplateRegistrator;
|
||||||
use App\Handlers\Registrators\WidgetRegistrator;
|
use App\Handlers\Registrators\WidgetRegistrator;
|
||||||
use App\Handlers\Search\Content;
|
use App\Handlers\Search\Content;
|
||||||
use App\Handlers\Search\Presenters\Content as ContentPresenter;
|
use App\Handlers\Search\Presenters\AdminContent as AdminContentPresenter;
|
||||||
use App\Widgets\HtmlCode\HtmlCode;
|
use App\Widgets\HtmlCode\HtmlCode;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
@@ -107,6 +107,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
$registrator = $this->app->make('registerSearchEngine');
|
$registrator = $this->app->make('registerSearchEngine');
|
||||||
|
|
||||||
$registrator->register(new Content(), new ContentPresenter());
|
$registrator->register(new Content(), new AdminContentPresenter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'content' => 'Content',
|
||||||
|
'term' => 'Search',
|
||||||
|
'results' => 'Found results',
|
||||||
|
'pageTitle' => 'Search'
|
||||||
|
];
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<div class="row" id="static-page-overview" data-equalizer>
|
||||||
|
@forelse($pages as $page)
|
||||||
|
<div class="columns @if(!isset($tileClass)) large-3 @else {{$tileClass}} @endif">
|
||||||
|
<div class="page callout" data-equalizer-watch>
|
||||||
|
<h4>{{$page->title}}</h4>
|
||||||
|
<span class="date">{{date('d.m.Y', strtotime($page->created_at))}}</span>
|
||||||
|
<span class="author">{{$page->author_name}}</span>
|
||||||
|
<br />
|
||||||
|
<span class="moduleName">@lang($page->module_name)</span>
|
||||||
|
|
||||||
|
<p class="perex">
|
||||||
|
@if (trim($page->meta_description))
|
||||||
|
{{str_limit($page->meta_description)}}
|
||||||
|
@else
|
||||||
|
{{str_limit(strip_tags($page->content))}}
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
|
||||||
|
@if ($page->meta_keywords)
|
||||||
|
<p class="keywords">{{$page->meta_keywords}}</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<p class="controls row text-center">
|
||||||
|
@if($page->is_homepage)
|
||||||
|
<a class="button tiny disabled"><i class="fa fa-home"></i></a>
|
||||||
|
@else
|
||||||
|
<a href="{{route('content.setHomepage', ['id' => $page->id])}}" class="button tiny success has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.setHomepage', ['name' => $page->title])"><i class="fa fa-home"></i></a>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<a href="{{route('content.edit', ['id' => $page->id])}}" class="button tiny success has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.edit', ['name' => $page->title])"><i class="fa fa-edit"></i></a>
|
||||||
|
|
||||||
|
@if($page->status == \App\Models\Content::STATUS_DRAFT)
|
||||||
|
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PUBLIC])}}" class="button tiny success confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.makePublic')"><i class="fa fa-eye"></i></a>
|
||||||
|
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_PROTECTED])}}" class="button tiny warning confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.makeProtected')"><i class="fa fa-lock"></i></a>
|
||||||
|
@else
|
||||||
|
<a href="{{route('page.content', ['url' => $page->url])}}" target="_blank" class="button tiny secondary has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.viewPage')"><i class="fa fa-desktop"></i></a>
|
||||||
|
<a href="{{route('content.changeStatus', ['id' => $page->id, 'status' => \App\Models\Content::STATUS_DRAFT])}}" class="button tiny warning confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.makeDraft')"><i class="fa fa-eye-slash"></i></a>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<a href="{{route('content.delete', ['id' => $page->id])}}" class="button tiny alert confirm has-tip" data-tooltip aria-haspopup="true" title="@lang('admin/contents.deletePage')"><i class="fa fa-remove"></i></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<em>@lang('admin/contents.noPagesAvailable')</em>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user