From b5ec6d9f284c1a7e826437dbd446ee6e7e34a283 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Wed, 18 Mar 2026 09:42:55 +0900 Subject: [PATCH] =?UTF-8?q?add:=20=E3=82=B5=E3=82=A4=E3=83=88=E5=86=85?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2,=20=E9=9A=A0=E3=81=97=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=EF=BC=88=E3=83=9A=E3=83=BC=E3=82=B8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9E=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E9=9D=9E=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=AE=E3=83=9A=E3=83=BC=E3=82=B8=EF=BC=89=E3=81=AF?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=81=AB=E5=90=AB=E3=82=81=E3=81=AA=E3=81=84?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/User/Searchs/Searchs.php | 2 +- app/Plugins/User/Searchs/SearchsPlugin.php | 24 ++++++++++++-- ...16_164135_add_select_page_from_searchs.php | 32 +++++++++++++++++++ .../default/searchs_edit_search.blade.php | 27 +++++++++++++++- 4 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 database/migrations/2026_03_16_164135_add_select_page_from_searchs.php diff --git a/app/Models/User/Searchs/Searchs.php b/app/Models/User/Searchs/Searchs.php index 653311487..a662b3ba8 100644 --- a/app/Models/User/Searchs/Searchs.php +++ b/app/Models/User/Searchs/Searchs.php @@ -21,7 +21,7 @@ class Searchs extends Model 'frame_select', 'target_frame_ids', 'recieve_keyword', - 'narrow_down_label', + 'page_select', ]; /** diff --git a/app/Plugins/User/Searchs/SearchsPlugin.php b/app/Plugins/User/Searchs/SearchsPlugin.php index 28c83a0d3..ab25d7ae0 100644 --- a/app/Plugins/User/Searchs/SearchsPlugin.php +++ b/app/Plugins/User/Searchs/SearchsPlugin.php @@ -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) { @@ -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(); @@ -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) { diff --git a/database/migrations/2026_03_16_164135_add_select_page_from_searchs.php b/database/migrations/2026_03_16_164135_add_select_page_from_searchs.php new file mode 100644 index 000000000..cd23af26e --- /dev/null +++ b/database/migrations/2026_03_16_164135_add_select_page_from_searchs.php @@ -0,0 +1,32 @@ +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'); + }); + } +} diff --git a/resources/views/plugins/user/searchs/default/searchs_edit_search.blade.php b/resources/views/plugins/user/searchs/default/searchs_edit_search.blade.php index 9ac2c4be8..cb8707028 100644 --- a/resources/views/plugins/user/searchs/default/searchs_edit_search.blade.php +++ b/resources/views/plugins/user/searchs/default/searchs_edit_search.blade.php @@ -147,6 +147,28 @@ +
+
+
+
+ @if(old('page_select', $searchs->page_select) == 0) + + @else + + @endif + +
+
+ @if(old('page_select', $searchs->page_select) == 1) + + @else + + @endif + +
+
+
+
@@ -172,7 +194,10 @@
- ※ 「選択したものだけ表示する」を選択した場合、「固定記事」は検索対象外になります。
+ + ※ 「選択したものだけ表示する」を選択した場合、「固定記事」は検索対象外になります。
+   また、メニュー非表示ページでも、選択したフレームは検索対象になります。
+