Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Models/User/Searchs/Searchs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Searchs extends Model
'frame_select',
'target_frame_ids',
'recieve_keyword',
'narrow_down_label',
'page_select',
];

/**
Expand Down
24 changes: 22 additions & 2 deletions app/Plugins/User/Searchs/SearchsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private function searchContents($request, $searchs_frame, $method = null, $narro

// 各プラグインのSQL をUNION
// 公開されているページ、フレームを検索対象とする
$searchable_page_ids = $this->fetchSearchablePageIds($request);
$searchable_page_ids = $this->fetchSearchablePageIds($request, $searchs_frame);
$searchable_frame_ids = Frame::visible()->get()->pluck('id');

foreach ($union_sqls as $union_sql) {
Expand Down Expand Up @@ -427,6 +427,7 @@ public function saveBuckets($request, $page_id, $frame_id, $id = null)
$searchs->frame_select = intval($request->frame_select);
$searchs->target_frame_ids = empty($request->target_frame_ids) ? "": implode(',', $request->target_frame_ids);
$searchs->recieve_keyword = intval($request->recieve_keyword);
$searchs->page_select = intval($request->page_select);

// データ保存
$searchs->save();
Expand Down Expand Up @@ -474,9 +475,28 @@ public function changeBuckets($request, $page_id = null, $frame_id = null, $id =
/**
* 検索対象のページIDを取得する
*/
private function fetchSearchablePageIds($request)
private function fetchSearchablePageIds($request, $searchs_frame)
{
$pages = Page::get();

// ページの選択「ページ管理のメニュー表示条件に従う」
if ($searchs_frame->page_select == 1) {

// 表示ページのみに絞る
$pages = $pages->filter(function ($page) {
return $page->base_display_flag == 1;
});

// フレームの選択「選択したものだけ表示する」
if ($searchs_frame->frame_select == 1) {
// 選択したフレームに紐づくページ を追加取得してマージ
$frame_page_ids = Frame::whereIn('frames.id', explode(',', $searchs_frame->target_frame_ids))->get()->pluck('page_id')->toArray();
$pages_frame = Page::whereIn('pages.id', $frame_page_ids)->get();

$pages = $pages->merge($pages_frame)->unique('id');
}
}

// 見れないページ除外
$visible_page_ids = [];
foreach ($pages as $page) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddSelectPageFromSearchs extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('searchs', function (Blueprint $table) {
$table->integer('page_select')->default(0)->comment('ページの選択フラグ')->after('recieve_keyword');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('searchs', function (Blueprint $table) {
$table->dropColumn('page_select');
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@
</div>
</div>

<div class="form-group row">
<label class="{{$frame->getSettingLabelClass()}}">ページの選択</label><br />
<div class="{{$frame->getSettingInputClass(true)}}">
<div class="custom-control custom-radio custom-control-inline">
@if(old('page_select', $searchs->page_select) == 0)
<input type="radio" value="0" id="page_select_0" name="page_select" class="custom-control-input" checked="checked">
@else
<input type="radio" value="0" id="page_select_0" name="page_select" class="custom-control-input">
@endif
<label class="custom-control-label" for="page_select_0">全て表示する</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
@if(old('page_select', $searchs->page_select) == 1)
<input type="radio" value="1" id="page_select_1" name="page_select" class="custom-control-input" checked="checked">
@else
<input type="radio" value="1" id="page_select_1" name="page_select" class="custom-control-input">
@endif
<label class="custom-control-label" for="page_select_1">ページ管理のメニュー表示条件に従う</label>
</div>
</div>
</div>

<div class="form-group row mb-0">
<label class="{{$frame->getSettingLabelClass()}}">フレームの選択</label>
<div class="{{$frame->getSettingInputClass(true)}}">
Expand All @@ -172,7 +194,10 @@
<div class="form-group row">
<div class="{{$frame->getSettingLabelClass()}}"></div>
<div class="{{$frame->getSettingInputClass()}}">
<small class="text-muted">※ 「選択したものだけ表示する」を選択した場合、「固定記事」は検索対象外になります。</small><br>
<small class="text-muted">
※ 「選択したものだけ表示する」を選択した場合、「固定記事」は検索対象外になります。<br>
  また、メニュー非表示ページでも、選択したフレームは検索対象になります。<br>
</small>
</div>
</div>

Expand Down
Loading